fivem-cfg
v0.1.2
Published
TypeScript config generator for FiveM server.cfg files
Maintainers
Readme
fivem-cfg
Write your FiveM server.cfg in TypeScript. Get type-checking, autocomplete and a generated configuration file through a CLI or programmatically.
CLI
// server.config.ts
import { defineServer } from "fivem-cfg";
export default defineServer({
hostname: "My RP Server",
maxClients: 64,
});pnpx fivem-cfg --input server.config.ts --output server.cfg
Add `--verbose` / `-v` to see a confirmation message on stderr (default is silent).This generates a server.cfg file with the following content:
# autogenerated by fivem-cfg
set sv_hostname "My RP Server"
set sv_maxClients "64"Programmatic
import { defineServer } from "fivem-cfg";
const cfg = defineServer({
hostname: "My RP Server",
maxClients: 64,
oneSync: "on",
enforceGameBuild: 3751,
endpoints: { tcp: ["0.0.0.0:30120"], udp: ["0.0.0.0:30120"] },
});
console.log(cfg.generate()); // prints server.cfg contentInstall
pnpm add fivem-cfgConfiguration Options
All configuration options and their descriptions are documented as JSDoc annotations in src/schema.ts.
The schema covers all officially documented server-commands. Use the set/sets/setr (see "Convars") escape hatches for any convars not in the schema:
defineServer({
set: { sv_scriptHookAllowed: "1" },
sets: { tags: "roleplay, english", locale: "en-US" },
});