RE:NODE
Обзор хостинга

Руководства11 мин чтения

Garry's Mod DarkRP server: install, jobs and admin

How to set up a DarkRP server: installing the gamemode, darkrpmodification, custom jobs, ULX or SAM admin, the database and the settings that matter.

Эта статья пока на английском. Мы её переводим.

0 прочтений

DarkRP is a Garry's Mod gamemode, which means installing it is two folders and a launch parameter: the gamemode itself in garrysmod/gamemodes/darkrp/, and the darkrpmodification addon where all your changes live. Everything after that - jobs, shipments, salaries, who can ban whom - is Lua you edit in the addon and never in the gamemode. A server that follows that one rule survives DarkRP updates. A server that edits the gamemode directly loses every customisation the first time it updates, which is how most people learn the rule.

What DarkRP needs before you start#

DarkRP runs on the standard Garry's Mod dedicated server, installed with SteamCMD as app 4020 under an anonymous login. The Garry's Mod server setup guide covers the base install; this post assumes you have a server that starts in sandbox and accepts connections.

Two things DarkRP needs that sandbox does not:

  • Counter-Strike: Source content. The classic DarkRP maps - rp_downtown_v4c_v2 and most of its descendants - use CS:S textures and models. Without them your city is purple and black checkerboard. On a dedicated server you install the CS:S dedicated server content with SteamCMD (app 232330) and point Garry's Mod at it in garrysmod/cfg/mount.cfg.
  • A plan with room for addons. DarkRP itself is small. The workshop collection is not. A typical public DarkRP server carries a few gigabytes of addons before it has a single custom job.
garrysmod/cfg/mount.cfg
"mountcfg"{    "cstrike"   "/home/container/cstrike/cstrike"}

The path is to the folder that contains cstrike's own content directories. Get it wrong and nothing complains at startup; you find out when you load the map.

PlayersRAMNotes
Up to 16, small addon list2 GBComfortable for a private server
24-32, normal DarkRP3-4 GBThe common public server
40-64, large collection6 GBAddon list is now the limiting factor

One hard limit to know before you buy anything: the default Garry's Mod dedicated server is a 32-bit process, and a 32-bit process falls over somewhere around 3 GB of resident memory no matter what the plan allows. Garry's Mod also publishes an x86-64 branch which lifts that ceiling. If your server crashes at a consistent player count with no error, memory address space is the first suspect, not the plan.

Installing DarkRP and darkrpmodification#

DarkRP and its modification addon are both published by FPtje on GitHub. Download the current release of each, or clone them.

  1. Unpack DarkRP into garrysmod/gamemodes/darkrp/. The folder name must be exactly darkrp, lowercase, and it must contain darkrp.txt and a gamemode/ folder. A zip from GitHub unpacks as DarkRP-master, so rename it.
  2. Unpack the modification addon into garrysmod/addons/darkrpmodification/. Same rule: rename it from darkrpmodification-master.
  3. Start the server with +gamemode darkrp and a DarkRP map.
  4. Watch the console through the whole first start. Lua errors at load are the only warning you get that something did not install.
bash
$ ./srcds_run -game garrysmod -console -port 27015 \    +gamemode darkrp +map rp_downtown_v4c_v2 +maxplayers 40

On a panel the same values are fields on the Startup tab rather than a command you type, but they are the same values. Add sv_defaultgamemode "darkrp" to garrysmod/cfg/server.cfg as well, so a map change does not silently drop you back into sandbox.

Lowercase everything. Garry's Mod on Linux is case sensitive, and an addon folder named MyAddon with materials under Materials/ produces missing textures that work perfectly on a Windows test server. This is the most common single cause of "it worked at home".

The structure you will actually be editing:

code
garrysmod/addons/darkrpmodification/lua/    darkrp_config/        settings.lua           # every DarkRP setting        disabled_defaults.lua  # switch off built-in jobs, entities, modules        mysql.lua              # database connection    darkrp_customthings/        jobs.lua        entities.lua        shipments.lua        food.lua        ammo.lua        doorgroups.lua        agendas.lua        categories.lua

Nothing in gamemodes/darkrp/ should ever be touched. If a guide tells you to edit a file in there, it is out of date by about a decade.

Settings#

darkrp_config/settings.lua arrives with every setting already present, each with a comment explaining it and its default. You change values in place; you do not add keys that are not already in the file.

darkrp_config/settings.lua
GM.Config.startingmoney = 500GM.Config.normalsalary  = 45GM.Config.propertytax   = falseGM.Config.adminsents    = trueGM.Config.voiceradius   = true

The four decisions that shape a server more than any others:

  • Starting money and salary together set the economy's pace. A high salary with cheap shipments means everyone has everything within an hour and the roleplay collapses into deathmatch. It is easier to start stingy and raise it than the other way round, because you cannot take money back from people who already have it.
  • Property tax charges players for owned doors on each paycheck. It stops a handful of players owning the whole map and going inactive. It also drives new players away if they cannot afford a house at all.
  • Admin-only spawnable entities (adminsents) keeps sandbox props and SENTs away from ordinary players. On a roleplay server, leave it on.
  • Voice radius makes voice chat local rather than global, which is the single change that makes a server feel like roleplay instead of a lobby.

Changes to settings.lua are read when the gamemode loads, so they need a map change or a server restart. Testing them one at a time is slower and far quicker overall than changing fifteen and wondering which one broke jobs.

Jobs#

Jobs live in darkrp_customthings/jobs.lua and are created with one function call. This is the whole API:

jobs.lua
TEAM_MECHANIC = DarkRP.createJob("Mechanic", {    color = Color(50, 100, 180, 255),    model = {        "models/player/gasmask.mdl",        "models/player/riot.mdl",    },    description = [[Repair vehicles. Charge too much for it.]],    weapons = {"weapon_physgun"},    command = "mechanic",    max = 3,    salary = 60,    admin = 0,    vote = false,    hasLicense = false,    candemote = true,    category = "Citizens",})

The fields that matter and are routinely got wrong:

  • command is what players type, so /mechanic here. It must be unique across every job.
  • max is how many players can hold the job. 0 is unlimited. A decimal below 1 is read as a fraction of the current player count, so max = 0.1 means ten per cent of the server - much better than a fixed number for police on a server whose population swings.
  • admin is 0 for everyone, 1 for admins, 2 for superadmins.
  • TEAM_MECHANIC is a global. Two jobs sharing a name means one silently replaces the other.
  • category must match a category created with DarkRP.createCategory, or the job does not appear in the F4 menu even though it loaded fine.

For jobs restricted to donators or a staff rank, DarkRP has customCheck:

lua
customCheck = function(ply)    return CLIENT or table.HasValue({"superadmin", "vip"}, ply:GetUserGroup())end,CustomCheckFailMsg = "This job is for VIP members.",

The same file's neighbours work the same way. DarkRP.createEntity adds a buyable entity such as a printer, DarkRP.createShipment adds a weapon shipment with an allowed list of jobs that may buy it, DarkRP.createFood adds an item that restores health, and DarkRP.createDoorGroup lets you mark doors in the map as ownable only by certain jobs. Built-in jobs and entities you do not want are removed in disabled_defaults.lua rather than deleted from the gamemode.

Admin: FAdmin, ULX and SAM#

DarkRP ships with its own admin mod, FAdmin. It is adequate for a small private server and it knows about DarkRP concepts like jobs and doors. It is also the reason most ULX installs behave oddly on DarkRP, because two admin mods fighting over the same commands is exactly as much fun as it sounds. If you install another one, turn FAdmin off first:

darkrp_config/disabled_defaults.lua
DarkRP.disabledDefaults["modules"]["fadmin"] = true

ULX with ULib is the free standard. Install both addons, restart, then create the first superadmin from the server console - not from in-game, because nobody has permission yet:

code
ulx adduser "YourName" superadminulx addgroup vip userulx groupallow vip ulx kick

ULX stores its groups in garrysmod/data/ulib/groups.txt and its users in garrysmod/data/ulib/users.txt. Both are plain text, both are worth backing up, and both are easier to fix by hand than through the menu when you lock yourself out. ulx menu opens XGUI in game for everything else.

SAM is the paid admin mod most large DarkRP servers moved to. It keeps ranks and bans in MySQL rather than text files, which matters once you run more than one server, and it is noticeably lighter in the client menu. Whether that is worth paying for depends entirely on whether your staff team is three friends or fifteen people you have never met.

Whichever you pick, keep the superadmin list short. A superadmin in any GMod admin mod can run arbitrary Lua on your server, which is the same thing as having your panel password. Panel access is a separate question with a better answer: subusers and least privilege lets a moderator use the console without being able to delete the server or see your billing.

The database#

DarkRP stores money, owned doors and a few other things through MySQLite, which defaults to SQLite: a single file at garrysmod/sv.db. For one server that is genuinely fine. It is fast, it needs no configuration, and it has exactly one failure mode - the file. Back it up with everything else.

You want a real database when you run more than one server and want shared money, when you want to query or fix data without shutting the server down, or when you install an addon that expects MySQL anyway. The connection goes in darkrp_config/mysql.lua:

darkrp_config/mysql.lua
DarkRP.registerDatabaseConfig{    EnableMySQL      = true,    Host             = "db.example.net",    Username         = "s7_user",    Password         = "generated-password",    Database_name    = "s7_gmod",    Database_port    = 3306,    Preferred_module = "mysqloo",    MultiStatements  = false,}

That needs the mysqloo binary module in garrysmod/lua/bin/, and the file has to match the server's platform and architecture. Garry's Mod names these with a .dll extension even on Linux, which surprises everybody: gmsv_mysqloo_linux.dll for a 32-bit server and gmsv_mysqloo_linux64.dll for the x86-64 branch. The wrong one loads as nothing at all and DarkRP quietly falls back, so if money keeps resetting after you switched to MySQL, that file is why.

Every RE:NODE game plan includes one database slot created from the panel, with the host, user and password generated for you and an Open in phpMyAdmin button that signs you in with a single-use token. That covers the credentials above without you administering anything.

Keeping the server yours#

DarkRP servers are targeted more than any other Garry's Mod gamemode, because there is an entire cottage industry of exploit menus aimed at them. Three settings and one habit deal with most of it.

garrysmod/cfg/server.cfg
hostname "Northside RP"rcon_password ""sv_password ""sv_lan 0sv_allowcslua 0sv_allowupload 0sv_allowdownload 1sbox_godmode 0sbox_noclip 0

sv_allowcslua 0 is the important one. It blocks clients from running their own clientside Lua, which is the mechanism behind most of the free "DarkRP exploit" menus people download. sv_allowupload 0 stops clients pushing files to your server. Leaving rcon_password empty disables RCON, which you do not need because you have a panel console - the reasoning is in RCON, safely.

The habit is not installing leaked paid addons. A leaked script is the most reliable way to get a backdoor onto a Garry's Mod server, and the person who uploaded it to a forum is not the author. Keeping a modded server clean covers how to audit what you already have.

Performance and troubleshooting#

Jobs did not appear. A Lua error in jobs.lua. Read the console from the top of the startup, not the bottom.

Purple and black textures, or ERROR signs. Missing content. Textures are CS:S or a map's own material pack; ERROR models are an addon the client did not download. Client downloads are a separate system covered in Workshop addons and FastDL.

Money resets every restart. The database is not writing. Either sv.db is not writable, or MySQL is enabled with a missing or mismatched mysqloo module.

Everything broke after a DarkRP update. Something was edited inside gamemodes/darkrp/. Reinstall the gamemode clean and move the change into darkrpmodification.

The server drags only when it fills. Almost always an addon with a loop that runs per player. A hundred printers each on their own timer costs the same whether four people are online or forty, but the per-player loops scale with the room. Remove half your addons, measure, then remove half of what is left.

Consistent crash at the same player count. Memory, and probably the 32-bit ceiling described earlier rather than the plan's limit.

Raising -tickrate costs CPU in direct proportion to players and buys less than people expect on a gamemode that is mostly standing still and talking - what tick rate actually means has the honest version. Spend the CPU on the addon list instead.

On RE:NODE, a Garry's Mod plan comes with one port allocation, which covers the game and query port on 27015; add another on the Network tab if you want SourceTV. The console is unfiltered, which is where a broken addon announces itself, the file manager edits jobs.lua in the browser with syntax highlighting, and backup slots are included on every plan - worth using before every addon change, because a backup nobody has restored is a hypothesis.

FAQ#

Do I need Counter-Strike: Source for a DarkRP server?

For the usual maps, yes. rp_downtown_v4c_v2 and most classic RP maps use CS:S textures. Install the CS:S dedicated server content with SteamCMD and mount it in cfg/mount.cfg, or pick a map that ships all its own content.

Where do I add custom jobs?

In addons/darkrpmodification/lua/darkrp_customthings/jobs.lua, using DarkRP.createJob. Never inside gamemodes/darkrp/. The modification addon exists precisely so DarkRP updates do not overwrite your work.

Should I use ULX or SAM?

ULX is free, well documented and fine for most servers. SAM is paid, stores ranks in MySQL and is lighter in game. Either way, disable DarkRP's built-in FAdmin first, or the two will argue over the same commands.

How much RAM does a DarkRP server need?

Two gigabytes for a private server with a short addon list, three to four for a normal public one at 32 players. Above that the addon list is usually the constraint, and the 32-bit server binary will stop you somewhere near 3 GB regardless.

Can I change jobs without restarting?

Not reliably. Jobs are registered when the gamemode loads, so a map change or a restart is the honest way to apply edits. Get into the habit of batching config changes and restarting once.

Why does my server show no addons for players who join?

Because mounting an addon on the server and telling clients to download it are two different systems. The server runs what is in addons/; clients only get what the workshop collection or resource.AddWorkshop tells them to fetch.


Комментарии

Полностью анонимно: без аккаунта, без почты, без cookie. Мы храним имя, которое вы ввели, текст и время - больше ничего. Количество ссылок ограничено, разметка не отображается.

0/2000