Jobs

Ajout et configuration des jobs.

Schéma

TEAM_PIRATE = DarkRP.createJob("Pirate", { -- Ce TEAM_PIRATE est utilisé pour les AddDoorGroup ou ajouter une porte à uniquement cette Team. Donc, ne jamais utiliser le même TEAM_
color = Color(80, 5, 255, 0), -- Couleur du job dans le Chat / Tableau de bord
model = "models/player/swat.mdl", -- Model; pour en ajouter plusieurs utilisez {"models/../model1.mdl","models/../model2.mld}, NOTEZ la virgule après l'accolade.
description = [[Description.]], --Description pour le job.
weapons = {"med_kit"}, -- Les armes du job. Séparez les avec une virgule ex: "med_kid", "armor_kit" et toujours finir le dernier sans une virgule.
command = "pirate", --Commande de chat pour devenir de ce job. N'utilisez jamais le même sur d'autres TEAM_.
max = 5, -- Nombre maximum de joueurs pouvant être dans le job.
salary = 200, -- Salaire payé.
admin = 0, -- Faut-il être admin? 1 pour oui, 0 pour non.
vote = true, -- Ont-ils besoin de voter pour devenir de ce job ? true pour oui, false pour non.
hasLicense = true, -- Ont-ils une licence pour les armes ?
})

Schéma SWAT

TEAM_SWAT = DarkRP.createJob("S.W.A.T", {
color = Color(80, 45, 0, 255),
model = "models/player/swat.mdl",
description = [[C'est un job special donateur,
votre devoir est de soigner durant les operations.
Vous devez rester dans le departement.
Sauf si on vous dit le contraire.
Faites tout ce que vous pouvez pour garder la ville en securite.
Vous pouvez soigner votre equipe mais c'est optionnel si un medecin est present.
S'il n'y a pas de maires, vous etes le chef.]],
weapons = {"arrest_stick", "unarrest_stick", "weapon_glock2", "weapon_ak472", "ls_sniper", "weapon_m42", "weapon_mp52", "stunstick", "door_ram", "weaponchecker"},
command = "swat",
max = 1,
salary = 200,
admin = 0,
vote = true,
hasLicense = true,
})

Explications

TEAM_SWAT = Variable Lua de l'équipe. C'est utilisé pour certaines choses comme choisir qui peut acheter telles armes (autorisé uniquement la TEAM_SWAT par exemple).

DarkRP.createJob("S.W.A.T", = S.W.A.T est le nom du job affiché dans le tableau de bord.

color = Color(0,0,153,255), = C'est la couleur du job affiché dans le tableau de bord, en format RGB. Vous pouvez chercher la couleur parfaite en utilisant l'outil de couleur du jeu.

model = "models/player/barney.mdl", = Le model du joueur que vous avez une fois que vous apparaissez. Si le client n'a pas le model, il aura un model ERROR à la place.

Depuis la révision 529, vous pouvez ajouter plusieurs models pour chaque job, quand un joueur choisit le job dans le menu F4, un menu GUI apparaît avec tous les models possibles. Pour ajouter plus de 1 model, vous devez les lister entre les accolades {}, séparés par des virgules, ex : {"models/player/barney.mdl","models/player/alyx.mdl"}.

description = [[Tuer et proteger des terroristes]], = La description de ce métier qui peut être vu dans le menu F4. Cette fonctionnalité est rarement utilisée, mais peut aidée.

weapons = {"weapon_deagle2", "weapon_mp52", "weapon_pumpshotgun2"}, = Les armes avec lesquelles on apparaît une fois dans le métier. Vous devez utiliser les noms d'entités d'armes ou ça ne marchera pas.

"swat", = La commande pour devenir ce métier. (Assurez vous 'exclure le slash / car DarkRP le fait automatiquement).

max = 3, = Combien de joueurs peuvent devenir de ce job en même temps ?

salary = 300, = Salaire gagné durant le jour de paie.

admin = 0, = Qui peut être de ce job ? (0 = tout le monde, 1 = admin, 2 = superadmin uniquement)

vote = true, = Avez-vous besoin de voter pour être dans cette team ? (false = non et true = oui)

hasLicense = true, = Est-ce que cette team nécessite une licence d'arme ? (false = non et true = oui)

Exemples

TEAM_DRUG = DarkRP.createJob("Vendeur de drogue", {
color = Color(80, 45, 0, 255),
model = "models/Eli.mdl",
description = [[Vous etes un vendeur de drogue. Vous vendez des drogues anonymes. Faites des /advert.]],
weapons = {},
command = "drug",
max = 3,
salary = 15,
admin = 0,
vote = false,
hasLicense = false
})
TEAM_SWAT = DarkRP.createJob("S.W.A.T", {
color = Color(80, 45, 0, 255),
model = "models/player/swat.mdl",
description = [[C'est un job special donateur,
votre devoir est de soigner durant les operations.
Vous devez rester dans le departement.
Sauf si on vous dit le contraire.
Faites tout ce que vous pouvez pour garder la ville en securite.
Vous pouvez soigner votre equipe mais c'est optionnel si un medecin est present.]],
weapons = {"arrest_stick", "unarrest_stick", "weapon_glock2", "weapon_ak472", "ls_sniper", "weapon_m42", "weapon_mp52", "stunstick", "door_ram", "weaponchecker"},
command = "swat",
max = 3,
salary = 100,
admin = 0,
vote = true,
hasLicense = true,
})
TEAM_SWATM = DarkRP.createJob("Medecin S.W.A.T", {
color = Color(80, 45, 0, 255),
model = "models/player/swat.mdl",
description = [[C'est un job special donateur,
votre devoir est de soigner durant les operations.
Vous devez rester dans le departement.
Sauf si on vous dit le contraire.
Faites tout ce que vous pouvez pour garder la ville en securite.
Vous devez garder votre team vivante en les soignant.]],
weapons = {"arrest_stick", "unarrest_stick", "weapon_glock2", "weapon_ak472", "ls_sniper", "weapon_m42", "weapon_mp52", "stunstick", "door_ram", "weaponchecker", "med_kit"},
command = "swatm",
max = 3,
salary = 100,
admin = 0,
vote = true,
hasLicense = true,
})
TEAM_SWATC = DarkRP.createJob("Chef S.W.A.T", {
color = Color(80, 45, 0, 255),
model = "models/player/swat.mdl",
description = [[C'est un job special donateur,
votre devoir est de soigner durant les operations.
Vous devez rester dans le departement.
Sauf si on vous dit le contraire.
Faites tout ce que vous pouvez pour garder la ville en securite.
Vous pouvez soigner votre equipe mais c'est optionnel si un medecin est present.
S'il n'y a pas de maires, vous etes le chef.]],
weapons = {"arrest_stick", "unarrest_stick", "weapon_glock2", "weapon_ak472", "ls_sniper", "weapon_m42", "weapon_mp52", "stunstick", "door_ram", "weaponchecker", "med_kit"},
command = "swat",
max = 1,
salary = 200,
admin = 0,
vote = true,
hasLicense = true,
})

Champs Avancés

Vous pouvez créer des travaux personnalisés dans DarkRP. Cependant, il y a beaucoup de choses à tripoter. Cette page explique chaque "champ". Vous pouvez créer des emplois personnalisés dans DarkRP. Sinon, il y a beaucoup de choses.

Exemple avec toutes les fonctions

Voici un exemple avec toutes les fonctions disponibles

TEAM_EXEMPLE = DarkRP.createJob("Team exemple", {
color = Color(255, 255, 255, 255),
model = {
"models/player/Group03/Female_01.mdl",
"models/player/Group03/Female_02.mdl"
},
description = [[Ce texte sert en description de la team.]],
weapons = {"weapon_p2282"},
command = "example",
max = 0.7, -- 70% des joueurs peuvent avoir le job. Mettez un nombre entier pour fixer une limite absolue.
salary = 45,
admin = 0,
vote = false,
hasLicense = false,
-- Les fonctions suivantes sont OPTIONNELS. Si vous ne les utilisez pas, ou vous ne changez pas les valeurs par défaut, RETIREZ les.
NeedToChangeFrom = TEAM_CITIZEN,
customCheck = function(ply) return ply:getDarkRPVar("money") > 10000 end,
CustomCheckFailMsg = "Vous n'avez pas assez d'argent!", -- alternative: CustomCheckFailMsg = function(ply, jobTable) return ply:getDarkRPVar("money") < 5000 and "Vous etes pauvre" or "Vous n'avez pas assez d'argent!" end,
modelScale = 1.2,
maxpocket = 20,
maps = {"rp_downtown_v2", "gm_construct"},
candemote = false,
mayor = false,
chief = false,
medic = false,
cook = false,
hobo = false,
ammo = {
["pistol"] = 60,
},
category = "Other", -- Le nom de la catégorie. Note : La catégorie doit être crée !
sortOrder = 100, -- La position de cette chose dans sa catégorie. Nombre inférieur signifie qu'il sera plus haut.
playerClass = "player_darkrp",
CanPlayerSuicide = function(ply) return false end,
PlayerCanPickupWeapon = function(ply, weapon) return true end,
PlayerDeath = function(ply, weapon, killer) end,
PlayerLoadout = function(ply) return true end,
PlayerSelectSpawn = function(ply, spawn) end,
PlayerSetModel = function(ply) return "models/player/Group03/Female_02.mdl" end,
PlayerSpawn = function(ply) end,
PlayerSpawnProp = function(ply, model) end,
RequiresVote = function(ply, job) for k,v in pairs(player.GetAll()) do if IsValid(v) and v:IsAdmin() then return false end end return true end, -- Les gens ont besoin de faire un vote lorsqu'il n'y a pas d'administrateur autour
ShowSpare1 = function(ply) end,
ShowSpare2 = function(ply) end,
OnPlayerChangedTeam = function(ply, oldTeam, newTeam) end,
canStartVote = function(ply) return ply:Distance(SomeNPC) < 200 end,
canStartVoteReason = "Vous devez etre a proximite de certains PNJ", -- alternative: canStartVoteReason = function(ply, jobTable) return ply:Distance(SomeNPC) > 5000 and "Vous etes trop loin de cerrtains PNJ" or "Vous devez etre a proimite de certains PNJ" end,
buttonColor = Color(255, 255, 255, 255), -- Le couleur de le bouton dans le menu F4
label = "Super job", -- Optionnel: Le texte sur le bouton dans le menu F4
})

Explications

color (Color) (required) : La couleur de la team.

model (string/table) (required) : Le model de la team. Cela peut être une chaîne de caractères ou une table de caractères. Deux exemples :

A string, players who have this job have ONE model, namely the one given in the string:

model = "models/player/Group03/Female_01.mdl"

A table, the model of the player holding this job is randomly chosen from the list of given models:

model = {
"models/player/Group03/Female_01.mdl",
"models/player/Group03/Female_02.mdl"
}

description (string) (required)

  • The description of a job shows up in the F4 menu when selecting the job. Describe what your job does and what the use of it is.

weapons (table) (required)

  • The list of weapons people with this job spawn with (besides the default weapons).

  • The following example means that the job spawns with the weapons in the list:

weapons = {"arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weaponchecker"}

command (string) (required)

  • What do you have to enter in chat to get this job?

  • Example: type /example in chat to get the example job

command = "example"
  • If the job requires voting, a command "/voteexample" is added.

The "/" at the start of the command should be omitted.

max (number) (required)

  • How many people can have this job at any given time.

  • Set to a number between 0 and 1 to make it a percentage. E.g. max = 0.3 means at most 30% of the players can have this job.

  • Set to a whole number to set an absolute limit.

salary (number) (required)

  • The salary this job gets.

admin (number) (required)

  • What (admin) access you need to get this job.

admin = 0 -- anyone can get this job
admin = 1 -- only admins can get this job
admin = 2 -- only superadmins can get this job
  • If you want to customize this further (with donators, moderators and whatnot), look at customCheck (scroll down).

vote (boolean)

  • Do players need to create a vote to get this job? true for yes, false for no.

hasLicense (boolean)

  • Does this job get a gun license for free? true for yes, false for no.

  • It's useful to give the cops gun licenses.

NeedToChangeFrom (number/table)

  • You can only get this job if you had a specific other job first.

  • Example: You can only become a chief of police when you're already a CP:

NeedToChangeFrom = TEAM_POLICE
  • Example 2: You can only become a mayor if you're either a CP or a chief:

NeedToChangeFrom = {TEAM_CHIEF, TEAM_POLICE}

customCheck (function)

  • See here for an example with donator jobs.

  • Function arguments are: Player ply

CustomCheckFailMsg (string/function)

  • Custom message when someone tries and fails to get the job.

  • See here for an example with donator jobs.

If using this as a function, the arguments are:

modelScale (number)

  • How big are the players that have this job?

modelScale = 1 -- the default size
modelScale = 1.2 -- 120% of the default size
modelScale = 0.9 -- 90% of the default size.
  • Don't make it too big or too small, people will get trouble with jumping and crouching.

maxpocket (number)

  • The amount of items that can fit in the pocket of people having this job. If not set, it will revert to the setting in settings.lua, which is set to 10 by default.

maps (table)

In what maps this job will be available. This is just a list of maps.

candemote (boolean)

Can people who have this job be demoted? By default hobo's and citizens cannot be demoted because it has no use to demote them.

mayor (boolean)

People with this job can do things the mayor can do (create a lottery, accept warrants etc.).

chief (boolean)

People with this job can do things the chief can do.

medic (boolean)

People with this job can do things the medic can do.

cook (boolean)

People with this job can do things the cook can do.

hobo (boolean)

People with this job can do things the hobo can do.

ammo (table)

The ammo people spawn with.

The keys in the table are the ammo names and the values are how much of each ammo is given.

category (string)

The category it belongs to in the F4 menu.

This will throw an error if the category doesn't exist! Please see the categories page.

category (number)

Location in the category. Lower number means more on top of the list. By default this is set 100.

More advanced fields

playerClass (string)

The GMod player class to assign to the player when they change to this job.

CanPlayerSuicide (function)

A function that decides whether players with this job can commit suicide.

Arguments are:

CanPlayerSuicide (function)

A function that decides whether players with this job can commit suicide.

Arguments are:

PlayerCanPickupWeapon (function)

A function that decides whether players with this job can pick up a certain weapon.

Arguments are:

PlayerDeath (function)

Called when a player dies.

Arguments are:

PlayerLoadout (function)

Called when a player gets his weapons. Return true to prevent him from getting his default weapons!

Arguments are:

PlayerSelectSpawn (function)

Called when a spawn is selected for this player.

Arguments are:

PlayerSetModel (function)

A function that decides what the model should be. Return a string to override the default model.

Arguments are:

PlayerSpawn (function)

Called when a player spawns.

Arguments are:

PlayerSpawnProp (function)

Called when a player attempts to spawn a prop.

Arguments are:

RequiresVote (function)

Decides whether the player needs to make a vote to get the job.

Overrides the vote field! (the vote field will have no effect when this is set)

Arguments are:

Example :

People need to make a vote if there are three or more people who have this job. People DON'T need to make a vote if there are fewer than three people with this job.

Autre :

VIPS can skip the vote

ShowSpare1 (function)

Called when a player presses the F1 key.

Arguments are:

ShowSpare2 (function)

Called when a player presses the F2 key.

Arguments are:

OnPlayerChangedTeam (function)

Called when a player switches to this job.

Arguments are: