Install and Configure DarkRP on Garry's Mod
Install DarkRP on your Linux Garry's Mod server: gamemode, darkrpmodification addon, settings, custom jobs, updates, rollback and troubleshooting.
On this page
This guide explains how to turn your Garry's Mod server into a roleplay server with DarkRP: installing the gamemode, customizing it without touching its code, adding a job, updating and rolling back.
HostMyServers does not offer managed game hosting: you administer this server yourself on your VPS or dedicated server.
Prerequisites
- A server installed with the Create a Garry's Mod Server guide. This guide builds on its
gmoduser, the/home/gmod/gmod-serverfolder, thestart.shscript and thegmod.serviceservice - The
/home/gmod/backup.shscript, described in the Automatic Backup section of that same guide - SSH access with
sudo - Garry's Mod on your computer, to check the result in game
File Layout
DarkRP separates its code from your settings. All paths below start from /home/gmod/gmod-server/garrysmod.
| Item | Location | Role |
|---|---|---|
| Gamemode | gamemodes/darkrp |
DarkRP code, never to be modified |
| Customization addon | addons/darkrpmodification |
Your settings, jobs and entities |
| Database | sv.db |
The server's SQLite database, including player data |
| DarkRP logs | data/darkrp_logs |
History of actions on the server |
Step 1: Back Up the Server
Stop the server, run the backup and keep a copy of the launch script:
sudo systemctl stop gmod.service
sudo -u gmod /home/gmod/backup.sh
sudo -u gmod cp -p /home/gmod/gmod-server/start.sh /home/gmod/start.sh.before-darkrpCheck that the archive and the copy exist:
sudo -u gmod ls -lh /home/gmod/backups /home/gmod/start.sh.before-darkrpStep 2: Install DarkRP and Its Addon
Open a session as the gmod user, then fetch the two official repositories. If you already cloned DarkRP with the installation guide, it is not downloaded a second time.
sudo -iu gmod
cd ~/gmod-server/garrysmod
[ -d gamemodes/darkrp ] || git clone https://github.com/FPtje/DarkRP.git gamemodes/darkrp
git clone https://github.com/FPtje/darkrpmodification.git addons/darkrpmodificationCheck that the expected files are present:
ls gamemodes/darkrp/darkrp.txt addons/darkrpmodification/lua/darkrp_config/settings.luaBoth paths must be displayed without error. Keep these folder names in lowercase: Linux is case-sensitive.
Step 3: Enable the Gamemode
Still as the gmod user, replace the gamemode in the launch script and check the result:
sed -i 's/+gamemode sandbox/+gamemode darkrp/' ~/gmod-server/start.sh
grep -n '+gamemode' ~/gmod-server/start.shThe line displayed must contain +gamemode darkrp. If another gamemode appears there, fix it with nano ~/gmod-server/start.sh.
Exit the session and start the server:
exit
sudo systemctl start gmod.serviceKeep the gm_construct map for this first test. You can install a roleplay map once the gamemode is validated.
Step 4: Check That It Works
Check the service, then look for errors in its logs:
sudo systemctl is-active gmod.service
sudo journalctl -u gmod.service -n 300 --no-pager | grep -iE 'corrupt team|does not exist|lua error|\[error\]'The first command must answer active. The second must display nothing.
Then connect to the server from the game:
- Press F4: the DarkRP menu opens with the list of jobs
- In the chat, type
/rpname John Smith: your character's name changes - Choose a job in the F4 menu: your character takes on its appearance
DarkRP's content is published on the Workshop, and the gamemode is linked to it by its ID: the game offers it to players when they connect.
Step 5: Change the Settings
Open the configuration file:
sudo -u gmod nano /home/gmod/gmod-server/garrysmod/addons/darkrpmodification/lua/darkrp_config/settings.luaHere are some common settings, with their default value:
| Setting | Default value | Effect |
|---|---|---|
GM.Config.startingmoney |
500 |
Money received on first connection |
GM.Config.normalsalary |
45 |
Starting salary of new players |
GM.Config.paydelay |
160 |
Delay between two salaries, in seconds |
GM.Config.currency |
"$" |
Currency symbol |
GM.Config.currencyLeft |
true |
Symbol on the left (true) or right (false) of the amount |
GM.Config.allowrpnames |
true |
Allows the /rpname command |
GM.Config.respawntime |
1 |
Minimum wait before respawning, in seconds |
GM.Config.maxdoors |
20 |
Maximum number of doors per player |
GM.Config.logging |
true |
Enables DarkRP logs |
For example, to display amounts in euros:
GM.Config.currency = "€"
GM.Config.currencyLeft = falseEdit the existing lines instead of duplicating them, then restart the server:
sudo systemctl restart gmod.serviceCheck the change in game: the amount displayed on screen must use the new symbol. startingmoney only applies to players connecting for the first time.
Step 6: Add a Job
Open the jobs file:
sudo -u gmod nano /home/gmod/gmod-server/garrysmod/addons/darkrpmodification/lua/darkrp_customthings/jobs.luaAdd this block right after the header comment, before the GAMEMODE.DefaultTeam line:
TEAM_GUARD = DarkRP.createJob("Guard", {
color = Color(45, 110, 170, 255),
model = {"models/player/police.mdl", "models/player/police_fem.mdl"},
description = [[You protect the city's shops.]],
weapons = {"stunstick"},
command = "guard",
max = 3,
salary = 60,
admin = 0,
vote = false,
hasLicense = false,
category = "Citizens",
})| Field | Description |
|---|---|
color |
Job color in the scoreboard and menus |
model |
Character model, or list of models |
description |
Text displayed in the F4 menu |
weapons |
Weapons received in addition to the default equipment |
command |
The job's chat command, without /, unique on the server |
max |
Maximum number of players, or share of players if the value is between 0 and 1 |
salary |
Salary paid to the player |
admin |
0 for everyone, 1 for admins, 2 for superadmins |
vote |
Requires a vote to get the job |
hasLicense |
Grants a weapon license |
category |
F4 menu category, which must already exist. Citizens is provided by DarkRP |
Restart the server, then check in game that Guard appears in the F4 menu and that the /guard command works:
sudo systemctl restart gmod.serviceThe addon's Git repository keeps track of your changes. To review them, or to undo those of a file:
sudo -iu gmod
cd ~/gmod-server/garrysmod/addons/darkrpmodification
git diff
git checkout -- lua/darkrp_customthings/jobs.lua
exitThe git checkout command erases your changes to that file: only run it to go back to its original version.
Disabling or Modifying a Default Job
The built-in jobs are disabled in addons/darkrpmodification/lua/darkrp_config/disabled_defaults.lua. For example, ["gangster"] = true, in the DarkRP.disabledDefaults["jobs"] list removes the Gangster job.
To modify a default job, disable it, then copy its definition from gamemodes/darkrp/gamemode/config/jobrelated.lua to jobs.lua. Do not disable citizen without adapting GAMEMODE.DefaultTeam, because it is the job assigned to players when they arrive.
Useful In-Game Commands
| Command | Effect | Access |
|---|---|---|
/rpname <name> |
Changes the character's name | Everyone |
/job <title> |
Changes the displayed job title | Everyone |
/setspawn <job command> |
Replaces the job's spawn point with your position | Administrators |
/addspawn <job command> |
Adds a spawn point to the job | Administrators |
/setmoney <player> <amount> |
Sets a player's money | Depending on the DarkRP_SetMoney privilege |
DarkRP includes the FAdmin administration tool and the FPP prop protection. To manage your teams with detailed groups, see Install ULX and ULib on Garry's Mod.
Switching to a Roleplay Map
Add the map to your Workshop collection, as described in the server installation guide, then change the starting map in start.sh:
sudo -u gmod nano /home/gmod/gmod-server/start.sh +map rp_map_name \The name is that of the .bsp file, without the extension. Then restart the service. If the server no longer starts on this map, put gm_construct back.
For content that is not on the Workshop, see Serve Garry's Mod Content with FastDL and Nginx.
Database
DarkRP uses the SQLite sv.db database by default, already covered by backup.sh, and no configuration is needed. An external MySQL database is configured in addons/darkrpmodification/lua/darkrp_config/mysql.lua and requires the MySQLOO module. Back up your data before any change.
Updating DarkRP
Stop the server, back up, note the current version, then update:
sudo systemctl stop gmod.service
sudo -u gmod /home/gmod/backup.sh
sudo -iu gmod
git -C ~/gmod-server/garrysmod/gamemodes/darkrp rev-parse HEAD > ~/darkrp-before-update.txt
git -C ~/gmod-server/garrysmod/gamemodes/darkrp pull --ff-only
exit
sudo systemctl start gmod.serviceThen repeat the checks from step 4. There is no need to update darkrpmodification every time: if a setting is missing from settings.lua, DarkRP uses its default value.
Rolling Back
Go Back to the Previous DarkRP Version
sudo systemctl stop gmod.service
sudo -iu gmod
git -C ~/gmod-server/garrysmod/gamemodes/darkrp reset --hard "$(cat ~/darkrp-before-update.txt)"
exit
sudo systemctl start gmod.serviceGo Back to Sandbox Mode
sudo systemctl stop gmod.service
sudo -u gmod cp -p /home/gmod/start.sh.before-darkrp /home/gmod/gmod-server/start.sh
sudo systemctl start gmod.serviceThe DarkRP folders stay in place and are no longer used.
Restore the Data
List the backups, then restore the one of your choice. Everything that changed since that backup, such as player money, is lost.
sudo systemctl stop gmod.service
sudo -iu gmod
ls -1t ~/backups | head -n 5
tar -xzf ~/backups/gmod_YYYY-MM-DD_HH-MM-SS.tar.gz -C ~/gmod-server/garrysmod
exit
sudo systemctl start gmod.serviceTroubleshooting
The F4 Menu Doesn't Open and the Server Stays in Sandbox
- Check the
+gamemode darkrpline instart.sh - Check that the
gamemodes/darkrp/darkrp.txtfile exists, with this exact lowercase name - Check the logs:
sudo journalctl -u gmod.service -n 300 --no-pager
fatal: destination path ... already exists and is not an empty directory
The folder already exists. For darkrpmodification, check its contents: if it contains your settings, do not delete it.
fatal: detected dubious ownership in repository
The Git command was run as a user other than gmod. Open a session with sudo -iu gmod and run it again.
Corrupt team: Guard!
A field of the job is invalid. The message that follows says which one, for example The salary must be a number and it must be greater than zero.. If you read This job does not have a unique command., choose another value for command.
The category of "Guard" ("...") does not exist!
The specified category does not exist. Its name is case-sensitive. Use an existing category or create it in addons/darkrpmodification/lua/darkrp_customthings/categories.lua.
Lua Error Mentioning darkrp_customthings/jobs.lua
A brace, comma or quote is missing near the indicated line. Fix the file, or go back to its original version with git checkout, then restart the server.
Addon detected in the darkrp_modules folder.
A full addon was placed in lua/darkrp_modules. Move it to garrysmod/addons/.
There is a player with an invalid team!
This error usually follows a previous error. Look for the first error in the server logs, often in jobs.lua.
error: Your local changes to the following files would be overwritten by merge
This message appears if you run git pull in darkrpmodification after modifying its files. This update is not needed: leave the addon as is. If the message concerns gamemodes/darkrp, a gamemode file was modified: git -C ~/gmod-server/garrysmod/gamemodes/darkrp status tells you which one.
Purple Textures or ERROR Models
The player did not receive the content. Check that their in-game content download option is not disabled, then check the addons in your Workshop collection.
FAQ
Can I install DarkRP from the Workshop?
Yes, the project publishes it under ID 248302805. Use only one method: this guide uses Git, which makes it easy to go back to a specific version.
Is DarkRP available in other languages?
The gamemode ships in English. Translations can be added in lua/darkrp_language within darkrpmodification.
Where can I find more examples?
See the DarkRP wiki, especially the Custom job fields page.