Home / Forum / Discussion and Help for Gmod-Glua-Lua / How to create a DarkRP server? ๐Ÿ“Œ Pinned

How to create a DarkRP server?

Thread
profile avatar Jenny Fer
โš—๏ธ Support
๐Ÿ“– Posts: 31
โ†ฉ๏ธ Replies: 42
โค๏ธ Reactions: 18
Jenny Fer Posted 1622951322 (Edited) (1151 views)

In this guide, we will look at how to create a DarkRP server and more specifically the installation & configuration. DarkRP is one of the best known and most played gamemodes of GMod. It allows you to live adventures in a RolePlay way while playing the character you want.



Installation of the DarkRP gamemode



We will see how to install the gamemode on your server.
Go to your management panel.
Go to Plugins.
Install DarkRP and DarkRP Modification.
Restart your server.

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

Configuration of darkrp_config



Configuring the disabled_default.lua
This is where you can disable certain features as well as objects and other basic settings in the gamemode. (e.g. disable default jobs)
To disable some things by default you just have to replace false with true.

Configure the licenseweapons.lua
This file allows you to tell the gamemode which weapons do not need a weapon license.

To add a weapon, add a line of this style, where class is the ID of the available weapon by right clicking on the weapon in game and then "Copy to clipboard":

GM.NoLicense["class"]   = true


Setting up the mysql.lua
This file allows you to save the data related to the gamemode directly to an external database. If you don't have your own database yet: Web hosting + SQL.
Do not touch the file if you do not want to use an external database.

RP_MySQLConfig.EnableMySQL = true

RP_MySQLConfig.Host = "YOURHOST.com"
RP_MySQLConfig.Username = "w_XXXXX"
RP_MySQLConfig.Password = "your password"
RP_MySQLConfig.Database_name = "XXXXX_sql"
RP_MySQLConfig.Database_port = 3306
RP_MySQLConfig.Preferred_module = "mysqloo"
RP_MySQLConfig.MultiStatements = false
.

  1. Replace the XXXXX with the numbers on your website dashboard.
  2. Go to the management panel of your server.
  3. Go to Plugins.
  4. Install MySQLOO.
  5. Restart your server.


Configure the settings.lua

Ce fichier vous permet de modifier tous les paramรจtres du mode de jeu. Par exemple, supprimer les lois par dรฉfaut, activer le spawn des vรฉhicules, les npcs, etc.

Configuration of darkrp_customthings


This file allows you to change all the gamemode settings. For example, remove default laws, enable vehicle spawn, npcs, etc.

Configuring darkrp_customthings
Configure the agendas.lua
This file allows you to add for some jobs the possibility to have a calendar on the top left of the screen. In the example below TEAM_CHIEF is the only one who can edit the agenda and TEAM_POLICE can see the agenda.

You can also allow access to the police diary for another TEAM than TEAM_POLICE:

Add a comma after the TEAM_POLICE.
And finally, the TEAM you want to put.

AddAgenda("Agenda de la police", TEAM_CHIEF, {TEAM_POLICE})


You can use this site to avoid errors.

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

You will need to change the type of ammunition, available by going to the file for the weapon that needs the ammunition.
Search for SWEP.Primary.Ammo and get the ammo type in quotes.
Change the price to your liking.
Change the number of rounds given.

DarkRP.createAmmoType("m9k_ammo_357", { -- Type of ammunition

name = "M9K 357 ammo", -- The name given in the F4
model = "models/Items/357ammobox.mdl", -- The model visible in the F4
price = 100, -- Price
amountGiven = 20 -- The number of ammunition
})


You can use this site to avoid errors.

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

Copy the code below.
Paste it into categories.lua.
Change the category name.
Change the category type.
Change the colour.
Change the order of the category.

DarkRP.createCategory{

name = "Citizens", -- The name of the category.
categorises = "jobs", -- What it categorises must be one of its words: "jobs", "entities", "shipments", "weapons", "vehicles", "ammo".
startExpanded = true, -- Indicates if 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 this you can decide where your category is. Low numbers to put it on top, high numbers to put it on the bottom.
}


You can use this site to avoid errors.
Setting up the demotegroups.lua
This file allows you to make sure that when a member of a group is demoted, he 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.

Copy the code below.
Paste it in demotegroups.lua.
Change the name.
Modify the TEAM.

DarkRP.createDemoteGroup("Test", {TEAM_1, TEAM_2})


You can use this site to avoid errors.
Configuring doorgroups.lua
Tired of adding one by one the access to the doors for the jobs?

This file is for you!

It simply allows you to group all the jobs you want into a single door group!

Copy the code below.
Paste it in doorgroups.lua.
Change the name.
Modify the TEAM.

AddDoorGroup("Police", TEAM_CHIEF, TEAM_POLICE)


You can use this site to avoid errors.
Configuring the entities.lua
This file allows you to add entities to the F4. You can add any entity by following the code and instructions below.

Modify the ID of the entity, available by right-clicking on the entity in question and then "Copy to clipboard".
Modify the model, which you can find in your addon contents.
Modify the price as you wish.
Modify the maximum number of entities that the person can buy (applicable only on this entity).
Modify the order of the entity, it must be different from another order of another entity.

DarkRP.createEntity("Cigarette Machine", { -- The name of the entity

ent = "cf_cigarette_machine", -- The ID of the entity
model = "models/props_wasteland/laundry_washer003.mdl", -- The model of the entity, visible in the F4
price = 596, -- The price of the entity, visible in the F4
max = 1, -- The maximum number of entities the person can buy
cmd = "buymachineciga", -- The command executed when a person buys the entity, it must be different from another entity command
allowed = {TEAM_1} -- optional: allows the purchase of an entity for only one TEAM
})


You can use the DarkRP wiki to use advanced features, but also this site to avoid errors.
Setting up the food.lua
This file allows to add food for the cook.

ATTENTION ! the cook job must contain the code piece cook = true. Otherwise, the cook job will not be able to see the food category in your F4 menu.

Modify the name of the food.
Modify the model, which you can find in your addons content.
Change the energy, i.e. the hunger points given by the food.
Modify the price as you wish.
Modify the access of this food to a certain TEAM.

DarkRP.createFood("Pizza", { -- The name of the food

model = "models/foodnhouseholditems/pizzabox.mdl", -- The model of the food, visible in the F4
energy = 52, -- The food points given by the food
price = 3200, -- The price
allowed = {TEAM_COOK} -- Optional: allows the purchase of an entity for only one TEAM
})


You can use this site to avoid errors.
Configuring groupchats.lua
You don't have a radio for police jobs and you want some jobs to be able to communicate with each other via chat?

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

Copy the code below.
Paste it in the file groupchats.lua.
Modify the TEAM.

GAMEMODE:AddGroupChat(TEAM_1, TEAM_2)


As you can see, TEAM_1 can communicate with TEAM_2, via the chat.

You can use this site to avoid errors.

Configuring the jobs.lua
This file allows you to implement jobs other than the basic DarkRP jobs.

The jobs you will add must be below line 17 (strictly)

Your job must have a TEAM and a UNIQUE name.
A colour for the job.
Optional: a category if you have created one before.
A playermodel, which can be found here, by decompiling a playermodel addon with this site, or simply, In Game, in your content list. Playermodels are to be put between inverted commas followed by a comma.
You will also need a description.
A few weapons, to be enclosed in inverted commas and separated by a comma, if you wish to include more than one.
A command, which must ABSOLUTELY be unique, it will be used later to set up job spawns.
A maximum number of people who can join this job.
A salary, which is by default every 2 minutes.
Whether the job needs a vote when it is taken.
Whether the job has a weapon license.

TEAM_FIREFIGHTER = DarkRP.createJob("Firefighter", { --TEAM (must always be unique) + Job name

color = Color(255, 165, 51, 255), --Color of the job
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", -- Command of the job (must always be unique)
max = 3, -- Maximum number of players in the job (0 = no limit)
salary = 45, -- Salary of the job
admin = 0, -- Job admin ? (0 = no, 1 = admin and +, 2 = superadmin)
vote = false, -- Need a vote to take the job?
hasLicense = false, -- Has a basic weapon license?
})


You can use the DarkRP wiki to use advanced features but also this site to avoid errors.
If you use another TEAM than TEAM_CITIZEN then change the TEAM in the code below (at the end of the file) to the new TEAM.

GAMEMODE.DefaultTeam = TEAM_CITIZEN


The following code (at the end of the file) indicates 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 jobs on your DarkRP server, maybe you want to remove the basic jobs from the game?
Edit the file srcds/garrysmod/addons/darkrpmodification/lua/darkrp_config/disabled_defaults.lua.
Look in the file for the line DarkRP.disabledDefaults["jobs"] = {.
Just below this line, you will find the list of basic jobs.
To disable jobs, change the value from 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,
}


Save the file and restart your server.
Log in to your server, you should no longer see the DarkRP core trades.
Configure the shipments.lua
This file allows you to add weapons that can be purchased via the F4.

The ID of the weapon is available by right-clicking on the weapon in game then "Copy to clipboard".

Change the name of the weapon.
Modify the model, which you can find in your addon content (the model must be present on the server and when you spawn it must have physics).
Change the weapon id.
Optional: Add a category.
Change the price.
Change the number of weapons with shipment.
Know if the weapon is sold separately.
Change the price of the weapon sold separately.
Do not show a crate containing the weapon?
Optional: Add a TEAM that can only buy a weapon.
Optional: Change the model of the weapon crate.

DarkRP.createShipment("Grenade Aveuglante", { -- Nom de lโ€™arme

model = "models/shenesis/w_flashbang.mdl", -- Model of the weapon
entity = "weapon_sh_flashbang", --ID of the weapon
category = "Other", -- Weapon category
price = 9000, -- The price of the weapon (if noship = false and separate = false)
amount = 1, -- Number of weapon with the shipment (if noship = false and separate = false)
separate = false, -- Is the weapon sold separately? (no case)
pricesep = 1200, -- The price of the weapon sold separately
noship = false, -- No gun case?
allowed = {TEAM_GUN}, -- TEAM can buy it
shipmodel = "models/items/item_item_crate.mdl", --Model of the weapon case
})


You can use the DarkRP wiki to use advanced features but also this site to avoid errors.
Darkrp_language configuration
Basically, the darkrpmodification is not translated. That's why we propose you a translation, this one will be replaced in the darkrp_language. You will have to delete the english.lua file, and replace it by the attached file.

Translating the DarkRP weapons (keys, arrest, ...)
Let's see how to translate the names of the DarkRP weapons. For that nothing is simpler:

Connect to the FTP.
Go to srcds/garrysmod/gamemode/darkrp/entities/weapons/.
Go to one of the weapons and open the file shared.lua.
Change the SWEP.PrintName line.
Now change what is in quotes to the name you want.
One of the weapons is translated, now you just have to do the same for the others!
โ›”๏ธ Sorry, you are not connected, join to leave a reaction

Replies


Sign in or register to reply