Vous souhaitez forcer les joueurs à sélectionner un nouveau métier lorsqu'ils meurent ? Ce tutoriel va vous intéresser ;)

Configuration du serveur

Pour commencer, nous allons créer un metier autre que le Maire, si cela n'est pas déjà fait.

Prenons par exemple le métier Policier :

TEAM_POLICE = DarkRP.createJob("Policier", {
color = Color(25, 25, 170, 255),
model = {"models/player/nypd/male_02.mdl",
"models/player/nypd/male_04.mdl",
"models/player/nypd/male_05.mdl",
"models/player/nypd/male_07.mdl",
"models/player/nypd/male_09.mdl"},
description = [[Tu est un policier]],
weapons = {"weapon_cuff_police","arrest_stick", "unarrest_stick", "stunstick", "door_ram", "weaponchecker", "weapon_fists", "m9k_sig_p229r", "weapon_arc_atmcard", "policebadge", "weapon_stungun"},
command = "police",
max = 5,
salary = 75,
admin = 0,
vote = true,
hasLicense = true,
category = "Civil Protection"
})

Apres avoir fait cela vous allez ajouter une fonction permettant de retomber Citoyen à votre mort ou la mort de votre joueur.

TEAM_POLICE = DarkRP.createJob("Police Nationale", {
color = Color(25, 25, 170, 255),
model = {"models/player/nypd/male_02.mdl",
"models/player/nypd/male_04.mdl",
"models/player/nypd/male_05.mdl",
"models/player/nypd/male_07.mdl",
"models/player/nypd/male_09.mdl"},
description = [[Tu est un policier]],
weapons = {"weapon_cuff_police","arrest_stick", "unarrest_stick", "stunstick", "door_ram", "weaponchecker", "weapon_fists", "m9k_sig_p229r", "weapon_arc_atmcard", "policebadge", "weapon_stungun"},
command = "police",
max = 5,
salary = 75,
admin = 0,
vote = true,
hasLicense = true,
category = "Civil Protection",
PlayerDeath = function(ply, weapon, killer)
ply:teamBan()
ply:changeTeam(GAMEMODE.DefaultTeam, true)
end
})
Passons maintenant à la fonction du Maire, apres avoir créé votre métier Maire comme cela :

TEAM_MAYOR = DarkRP.createJob("Maire", {
color = Color(150, 20, 20, 255),
model = {"models/obama/obama.mdl",
"models/hitler.mdl"},
description = [[]],
weapons = {"weapon_fists","weapon_arc_atmcard"},
command = "mayor",
max = 1,
salary = 150,
admin = 0,
vote = true,
hasLicense = true,
mayor = true,
category = "Civil Protection",
})

Ensuite, vous allez ajouter une autre fonction très proche de celle donnée au dessus. Pour avoir en resultat un metier de ce model:

TEAM_MAYOR = DarkRP.createJob("Maire", {
color = Color(150, 20, 20, 255),
model = {"models/obama/obama.mdl",
"models/hitler.mdl"},
description = [[]],
weapons = {"weapon_fists","weapon_arc_atmcard"},
command = "mayor",
max = 1,
salary = 150,
admin = 0,
vote = true,
hasLicense = true,
mayor = true,
category = "Civil Protection",
PlayerDeath = function(ply)
if ply:Team() == TEAM_MAYOR then
ply:changeTeam( TEAM_CITIZEN, true )
for k,v in pairs( player.GetAll() ) do
DarkRP.notify(v, 1, 4, "Le Maire est Deceder")
end
end
end,
})

Bonus: ajouter l'armure

Utilisez la fonction ply:SetArmor() pour paramétrer la valeur de l'armure :

PlayerLoadout = function(ply) ply:SetArmor(150) end,