01
Where jobs are created: the darkrpmodification addon
DarkRP installs into garrysmod/gamemodes/darkrp. Do not edit any file in that folder: the next gamemode update would wipe your changes. All customisation goes through the darkrpmodification addon, published by the DarkRP author on GitHub (github.com/FPtje/darkrpmodification). DarkRP reads it at startup and its updates never touch it.
- Download the repository's ZIP archive from GitHub.
- Extract it into
garrysmod/addons, then rename the folder darkrpmodification, in lower case with no spaces.
- Check the path: you should end up with
garrysmod/addons/darkrpmodification/lua/darkrp_customthings/jobs.lua. With one folder level too many, the addon is not loaded.
The files that matter for this guide:
lua/darkrp_customthings/jobs.lua: your jobs;
lua/darkrp_customthings/categories.lua: the F4 menu categories;
lua/darkrp_customthings/shipments.lua and entities.lua: weapons and items for sale;
lua/darkrp_config/disabled_defaults.lua: to disable the jobs, weapons and entities that ship with DarkRP.
If your DarkRP server is not set up yet, start with creating a DarkRP server. Keep a copy of each file before editing it: one missing comma is enough to stop it from loading.
02
Writing a job with DarkRP.createJob
Open jobs.lua. The file shows where to add your jobs: below the line that says so, and above the GAMEMODE.DefaultTeam and GAMEMODE.CivilProtection lines that end the file. Here is a complete job:
TEAM_GARDE = DarkRP.createJob("Agent de sécurité", {
color = Color(40, 120, 200, 255),
model = {
"models/player/Group03/Male_04.mdl",
"models/player/Group03/Female_02.mdl"
},
description = [[Vous protégez les commerces et les habitants qui vous engagent.]],
weapons = {"stunstick"},
command = "garde",
max = 4,
salary = 60,
admin = 0,
vote = false,
hasLicense = true,
category = "Citizens",
})
TEAM_GARDE: the variable that refers to the job elsewhere in your files. Each job has its own.
color: the job's colour in the player list (Tab key) and elsewhere, as red, green, blue and opacity.
model: one model, or a list from which DarkRP picks one at random. A model from the Workshop must also be downloaded by players (see Workshop addons).
description: the text shown in the F4 menu. Double brackets [[ ]] let you write over several lines.
weapons: the weapons given on spawn, on top of the default ones. You write the weapon's class name, not its display name.
command: the chat command, without the slash. Here, players type /garde.
max: the number of slots. A whole number sets a limit, a number between 0 and 1 a share of the players (0.3 for 30%), and 0 removes the limit.
salary: the salary paid on each payday.
admin: 0 for everyone, 1 for admins, 2 for superadmins.
vote: with true, the player must win a vote, started with /votegarde.
hasLicense: true grants the gun licence automatically, useful for the police.
category: the F4 menu category. It must exist, otherwise DarkRP shows an error.
A job restricted to a group. The optional customCheck field adds a condition. For a VIP job, with a vip group created in ULX (see ULX and ULib):
customCheck = function(ply) return ply:GetUserGroup() == "vip" end,
CustomCheckFailMsg = "Ce métier est réservé aux VIP.",
Put these two lines inside the job block, before the closing brace. The NeedToChangeFrom = TEAM_POLICE field only opens the job to players who already have the given job.
03
Categories, default jobs and police
Creating a category. DarkRP ships with four job categories: Citizens, Civil Protection, Gangsters and Other. To add one, write in categories.lua:
DarkRP.createCategory{
name = "Services",
categorises = "jobs",
startExpanded = true,
color = Color(40, 120, 200, 255),
canSee = function(ply) return true end,
sortOrder = 50,
}
categorises says what the category holds: jobs, entities, shipments, weapons, vehicles or ammo.
sortOrder positions the category in the menu: the smaller the number, the higher it sits. The default is 100.
canSee is optional: if it returns false, the player sees neither the category nor its contents.
The job joins it with category = "Services", written exactly like the category name.
Changing a job that ships with DarkRP. Do not just copy it: first disable the original in disabled_defaults.lua by setting its line to true (for example ["medic"] = true,). Then copy its block from the gamemode/config/jobrelated.lua file of the DarkRP repository into your jobs.lua, and edit it. Anything that pointed to the old job (restricted weapons, door groups) must be redone for the new one.
Giving police powers. At the end of jobs.lua, the GAMEMODE.CivilProtection table lists the jobs that can issue warrants and mark people as wanted. Add yours:
GAMEMODE.CivilProtection = {
[TEAM_POLICE] = true,
[TEAM_CHIEF] = true,
[TEAM_MAYOR] = true,
[TEAM_GARDE] = true,
}
The GAMEMODE.DefaultTeam line just above sets the job of players who join the server or get demoted.
04
Selling weapons and entities
Weapons are sold in shipments.lua, by the crate or individually. This example replaces the pump shotgun that ships with DarkRP: first disable ["Pump shotgun"] in disabled_defaults.lua.
DarkRP.createShipment("Fusil à pompe", {
model = "models/weapons/w_shot_m3super90.mdl",
entity = "weapon_pumpshotgun2",
price = 2000,
amount = 10,
separate = false,
pricesep = nil,
noship = false,
allowed = {TEAM_GUN},
category = "Shotguns",
})
entity: the weapon's class name; model: the model shown above the crate.
price and amount: the price of one crate and the number of weapons inside.
separate = true and pricesep: the weapon is also sold individually, at that price. noship = true removes the crate.
allowed: the jobs that can buy it. TEAM_GUN is DarkRP's gun dealer.
category: a shipments category; if the weapon is also sold individually, you also need a weapons category with the same name.
Entities (money printers, labs, items from an addon) are sold in entities.lua:
DarkRP.createEntity("Imprimante améliorée", {
ent = "nom_de_classe_de_l_entite",
model = "models/props_c17/consolebox01a.mdl",
price = 2500,
max = 1,
cmd = "buyimprimante",
allowed = {TEAM_GANG, TEAM_MOB},
category = "Other",
})
ent is the entity's class name, given by its addon (the name of its folder in lua/entities). max limits how many copies each player can have, 0 for no limit, and cmd is the chat command to buy it. Weapons and entities from addons must be installed on the server, for example in your Workshop collection.
05
Syntax errors and reading the console
After each change, restart the server and read the console from startup. When a darkrpmodification file contains an error, DarkRP explains it in the server console: a message starting with [ERROR] Lua is unable to understand file, followed by the file name, the line number, an explanation and some Hints. Admins who are connected also see an in-game message, There is 1 Lua problem!, pointing them to the console.
The most common errors:
- A missing comma at the end of a field. Lua then reports a brace that is never closed (
'}' expected), with the line number where the block starts, and names the word that follows the missing comma. Look at the end of the line just before that word.
- An incomplete block ending: a job ends with
}), the brace that closes the fields and then the parenthesis of DarkRP.createJob.
- An unclosed quote or brackets:
unfinished string or unfinished long string.
- Curly quotes, pasted from a word processor or Discord:
unexpected symbol near. Lua only accepts straight quotes ".
- An unknown category:
The category of "…" ("…") does not exist!. The name matches no category of the right type, often because of a capital letter or a typo.
- A misspelled
TEAM_ name: Lua does not report an unknown variable, it is simply nil. In GAMEMODE.CivilProtection, this gives the table index is nil error.
- A model replaced by a big red
ERROR: the path is wrong, or players have not downloaded the content.
Fix the first error shown, then restart: the following ones often stem from it. An editor with Lua syntax colouring helps spot badly closed braces and quotes. For the rest of administration (permissions, sanctions), see ULX and ULib, and for server basics, creating a Garry's Mod server.
06
On a CloudFive server
On our Garry's Mod hosting plans, from €2 per month, everything is done from the customer area at manager.cloudfive.fr:
- DarkRP, Workshop collection and ULX in one click, from the server page;
- files: add or edit
jobs.lua and the other darkrpmodification files with the file manager or over SFTP;
- the console: it shows Lua errors live on restart;
- backups: take one before changing your jobs, so you can roll back if needed.
Servers run in France on AMD Ryzen 9 9950X, DDR5 memory and NVMe storage, on our own network, with Anti-DDoS Premium included and a game-specific profile. Monthly, with no commitment, and support in French 7 days a week. If you would rather administer everything yourself, a gaming VPS works too: see a Garry's Mod server on a VPS.
07
Frequently asked questions
How do I create a job in DarkRP?
Add a DarkRP.createJob block to the lua/darkrp_customthings/jobs.lua file of the darkrpmodification addon, with at least color, model, description, weapons, command, max, salary and admin. Then restart the server and read the console to catch any error.
Why should I not edit DarkRP files directly?
Because the next gamemode update replaces its files and wipes your changes. The darkrpmodification addon exists for this: DarkRP reads it at startup and its updates never touch it.
How do I restrict a DarkRP job to VIPs?
Add a customCheck field to the job that checks the player's group, for example ply:GetUserGroup() == "vip", and a CustomCheckFailMsg message for everyone else. The vip group is created in your admin tool, such as ULX.
What does the "The category does not exist" error mean?
The category field of the job, weapon or entity points to a category that does not exist for that type of item. Create it in categories.lua with DarkRP.createCategory, or fix the name, matching capital letters exactly.
How do I change a job that ships with DarkRP?
Disable it in lua/darkrp_config/disabled_defaults.lua by setting its line to true, then copy its block from DarkRP's jobrelated.lua file into your jobs.lua and edit it. Also redo anything that depended on the old job, such as restricted weapons.