How to create a DarkRP server

How to create a DarkRP server

In this guide, we'll see how to make a DarkRP server (installation and configuration).

DarkRP is the most played gamemode of GMod. It allows you to experience ever more original RolePlay adventures

How to install DarkRP

The installation of the DarkRP gamemode is done in a few clicks thanks to the management panel of your GMod server.

  1. Go to the control panel.
  2. Go to Plugins.
  3. Install DarkRP and DarkRP Modification.
  4. Restart your GMod server.

We will now configure DarkRP. To do this, go to the server files in the srcds/garrysmod/addons/darkrpmodification/lua/ directory.

Configuring darkrp_config

Configure disabled_default.lua

It is in this file that you can disable features, as well as objects and other basic settings of DarkRP (e.g.: disable default jobs).

To disable features, simply change false to true.

Configure licenseweapons.lua

This file is used to specify which weapons do not require a weapon license.

To add a weapon, add a row, where class is the ID of the weapon (available by right clicking on the weapon at stake, then puis Copy to Clipboard .

GM.NoLicense["class"] = true

Configure mysql.lua

This file allows you to save data related to the gamemode to an external database like MySQL.

Do not touch the file if you do not want to use an external database.

If you wish to enable enable the database:

RP_MySQLConfig.EnableMySQL = true
RP_MySQLConfig.Host = "sql.mtxserv.com"
RP_MySQLConfig.Username = "w_XXXXX"
RP_MySQLConfig.Password = "your sql password"
RP_MySQLConfig.Database_name = "XXXXX_sql"
RP_MySQLConfig.Database_port = 3306
RP_MySQLConfig.Preferred_module = "mysqloo"
RP_MySQLConfig.MultiStatements = false
  1. Replace the database settings with your SQL settings.
  2. Go to the control panel.
  3. Click Plugins.
  4. Install MySQLOO.
  5. Restart your server.

Configure settings.lua

This file allows you to change all settings in the DarkRP gamemode, for example, remove default laws, enable spawn of vehicles, npcs, etc.

Configuring darkrp_customthings

Configure agendas.lua

This file allows you to add the possibility to have a calendar at the top left of the screen, for the desired jobs. In the example below, only the TEAM_CHIEF job can edit the calendar, while the TEAM_POLICE job cannot edit it.

You can also allow access to the police agenda for a different TEAM than the TEAM_POLICE:

  1. Add a comma after TEAM_POLICE.
  2. Finally, the TEAM you want to put on.
AddAgenda("Police Calendar", TEAM_CHIEF, {TEAM_POLICE})

You can use this website to generate your agenda.

Configure ammo.lua

This file allows you to add ammos for weapons. You just have to copy the code below, paste it in the ammo.lua.

  1. You will need to change the type of ammunition available by going to the weapon file that needs the ammos.
  2. Search SWEP.Primary.Ammo and retrieve the type of ammo in quotation marks.
  3. Change the price as you like.
  4. Change the number of ammos given.
DarkRP.createAmmoType("m9k_ammo_357", { -- Ammo name
   name = "M9K 357 ammo", -- Name of the weapon in F4 menu
   model = "models/Items/357ammobox.mdl", -- Model of the weapon, display in F4 menu
   price = 100, -- Price of the weapon
   amountGiven = 20 -- Number of ammos
})

You can use this website to generate your ammos.

Configure categories.lua

This file allows you to add categories for jobs, weapons, ammunition, entities and vehicles.

  1. Copy the code below.
  2. Paste it into categories.lua.
  3. Change the category name.
  4. Edit Category Type.
  5. Change color.
  6. Change the order of the category.
DarkRP.createCategory{
   name = "Citizens", -- Category name
   categorises = "jobs", -- Category Type: "jobs", "entities", "shipments", "weapons", "vehicles", "ammo".
   startExpanded = true, -- Specifies whether the category is expanded when you open the F4.
   color = Color(0, 107, 0, 255), -- The color of the category.
   canSee = function(ply) return true end, -- Optional: if the player can see this category.
   sortOrder = 100, -- Optional: with that, you can decide where the category is displayed. A low value to put it at the top, a high value to put it at the bottom.
}

You can this this generator to avoir errors.

Configure demotegroups.lua

This file ensures that when a member of a group is demoted, it will be banned from every job in the group.

For example, if a person is banned from TEAM_1, he will also be banned from TEAM_2.

You can also add a TEAM other than TEAM_1 or TEAM_2.

  1. Copy the code below.
  2. Paste it into demotegroups.lua.
  3. Edit the name.
  4. Edit TEAM.
DarkRP.createDemoteGroup("Test", {TEAM_1, TEAM_2})

You can use this generator to avoid errors.

Configure doorgroups.lua

Are you tired of adding one to one door access for jobs? This file is for you!

It allows you to group all the jobs you want, into a single group for the doors!

  1. Copy the code below.
  2. Paste it to doorgroups.lua.
  3. Edit the name.
  4. Edit TEAM.
AddDoorGroup("Police", TEAM_CHIEF, TEAM_POLICE)

You can use this generator to avoid errors.

Configure entities.lua

This file allows you to add entities to the F4. You can add any entity by following the code and instructions below.

  1. Change the entity ID, available by right-clicking the entity in question and then "Copy to Clipboard".
  2. Edit the template, which you can find in your addon contents.
  3. Change the price as you like.
  4. Change the maximum number of entities that the player can purchase (applicable only on the specified entity).
  5. Edit the entity command, it must be different from another entity command.
DarkRP.createEntity("Cigarette machine", { -- Entity name
   ent = "cf_cigarette_machine", -- Entity ID
   model = "models/props_wasteland/laundry_washer003.mdl", -- Entity model (F4 menu)
   price = 596, -- The price of the entity, visible in the F4
   max = 1, -- The maximum number of entities that the player can purchase
   cmd = "buymachineciga", -- The command to be executed when a person buys the entity. It must unique.
   allowed = {TEAM_1} -- optional: allows the purchase of an entity for a single TEAM
})

See the DarkRP wiki to use advanced functions, and this generator to avoid errors.

Configure food.lua

This file allows you to add food for the cook.

ATTENTION ! Le job cuisinier doit contenir le code cook = true. Sinon, le job cuisinier ne pourra pas voir la catégorie food dans votre menu F4.

  1. Change the name of the food.
  2. Edit the model.
  3. Change the energy: the hunger points given by the food.
  4. Change the price as you like.
  5. Allow access to this food only for a certain TEAM.
DarkRP.createFood("Pizza", { -- Food name
        model = "models/foodnhouseholditems/pizzabox.mdl", -- The food model, visible in the F4
        energy = 52, -- The food points given by the food
        price = 3200, -- Price
        allowed = {TEAM_COOK} -- Optional: allows only specified teams to use this food.
})

You can use this food generator to avoid errors.

Configure groupchats.lua

Don’t have a radio for police jobs? You want only the specified jobs to be able to communicate with each other through chat?

This file is made for you! It allows you to group all the jobs you want into one group, for chat communication.

  1. Copy the code below.
  2. Paste it into groupchats.lua.
  3. Edit teams.
GAMEMODE:AddGroupChat(TEAM_1, TEAM_2)

In this example, TEAM_1 can communicate with TEAM_2.

You can use this generator to avoid errors.

Configure jobs.lua

This file allows you to create jobs other than the default DarkRP jobs.

The jobs you are going to add must be below line 17 (strict requirement)

  1. Your job must have a TEAM and a UNIQUE name.
  2. The color of the job.
  3. Optional: a category, if you have created one before.
  4. A playermodel, (which can be found here). Playermodels are enclosed in quotation marks followed by a comma.
  5. You will also need a description.
  6. Weapons, to be enclosed in quotation marks and separated with a comma, if you want to put more than one.
  7. A command which must ABSOLUTELY be unique, it will later be used to for job spawns.
  8. Maximum number of people who can join this job.
  9. A salary (by default, every 2 minutes).
  10. Whether he needs a vote when taking the job.
  11. Whether the job has a weapon license.
 TEAM_POMPIER = DarkRP.createJob ("Fireman", {--TEAM (must always be unique) + Job name
       color = Color (255, 165, 51, 255), -- Job color
       category = "Other", - Job category
       model = {"models/player/portal/male_02_fireman.mdl", -- Model available for the job
       "models/player/portal/male_04_fireman.mdl",
       "models/player/portal/male_05_fireman.mdl",
       "models/player/portal/male_05_fireman.mdl",
       "models/player/portal/male_06_fireman.mdl",
       "models/player/portal/male_08_fireman.mdl",
       "models/player/portal/male_09_fireman.mdl"},
       description = [[You have to turn off fires.]], --Job description
       weapons = {"fire_extinguisher", "fire_axe"}, - Weapon for the job
       command = "firefighter", - Job command (must always be unique)
       max = 3, - Maximum number of players in the job (0 = no limit)
       salary = 45, - Job salary
       admin = 0, - Job admin? (0 = no, 1 = admin and +, 2 = superadmin)
       vote = false, - Need a vote to take the job?
       hasLicense = false, - Have a basic weapon license?
}) 

You can use the DarkRP wiki in order to use advanced functions but also this site to generate your jobs.

If you are using another TEAM than TEAM_CITIZEN, change the TEAM in the code below (present at the end of the file) by the new TEAM.

GAMEMODE.DefaultTeam = TEAM_CITIZEN

The following code (present at the end of the file) allows you to indicate which jobs are part of the policy.

GAMEMODE.CivilProtection = { [TEAM_POLICE] = true, [TEAM_CHIEF] = true, [TEAM_MAYOR] = true, }

Now that you know how to add trades to your DarkRP server, maybe you want to remove basic jobs from the game?

  1. Edit file srcds/garrysmod/addons/darkrpmodification/lua/darkrp_config/disabled_defaults.lua.
  2. Search line DarkRP.disabledDefaults["jobs"] = { in the file.
  3. Just below this line you will find the list of default jobs. To disable jobs, change false to true.
    DarkRP.disabledDefaults["jobs"] = {
        ["chief"]     = true,
        ["citizen"]   = true,
        ["cook"]      = true, --Hungermod only--
        ["cp"]        = true,
        ["gangster"]  = true,
        ["gundealer"] = true,
        ["hobo"]      = true,
        ["mayor"]     = true,
        ["medic"]     = true,
        ["mobboss"]   = true,
    }
  4. Save the file and restart your server.
  5. Log into your server, you should no longer see the default DarkRP jobs.

Configure shipments.lua

This file allows you to add weapons purchasable via F4.

The weapon ID is available by right clicking on the weapon and then "Copy to clipboard".

  1. Edit the name of the weapon.
  2. Modify the model, which you can find in your content addons (the model must be present on the server and when you do spawn it must have physics).
  3. Change the weapon id.
  4. Optional: Add a category.
  5. Change the price.
  6. Modify the number of weapons with shipments.
  7. Find out if the weapon is sold separately.
  8. Change the price of the weapon sold separately.
  9. Don't spawn a crate containing the weapon?
  10. Optional: Add a TEAM that can only buy a weapon.
  11. Optional: Change the model of the weapon case.
DarkRP.createShipment("Grenade Aveuglante", { -- Weapon name
   model = "models/shenesis/w_flashbang.mdl", -- Modèle de l’arme
   entity = "weapon_sh_flashbang", -- Weapon ID
   category = "Other", -- Weapon category
   price = 9000, -- The price of the weapon (if noship = false and separate = false)
   amount = 1, -- Number of weapons with the shipment (if noship = false and separate = false)
   separate = false, -- The weapon is sold separately? (no cash register)
   pricesep = 1200, -- The price of the weapon sold separately
   noship = false, -- No weapon case?
   allowed = {TEAM_GUN}, -- teams than can buy the weapon
   shipmodel = "models/items/item_item_crate.mdl", -- Model of the weapon case
})

You can use the DarkRP wiki in order to use advanced functions but also this site to avoid errors.

GMod Server Hosting