(darkrp) reset job armor?

I added armor to the police job but it only takes affect on respawn. But if i were to change to another job, the armor would stay there until respawn. I was wondering if theres a way to fix this. I have tried

function TeamArmor( ply )
if ply:Team() == TEAM_Citizen then
ply:SetArmor( 0 )
hook.Add( “PlayerLoadout”, “TeamArmor”, TeamArmor )

But then i realize that it will only work when you respawn again.

DarkRP has a job field for this;


PlayerLoadout = function( ply ) return ply:SetArmor( 100 ) end

Where would i put that?

…its a job field. You put it in your job code for the job you want to spawn with the armor.

I put it in jobs.lua

TEAM_MOB = DarkRP.createJob(“Hitman”, {
color = Color(166, 83, 41),
model = “models/player/phoenix.mdl”,
description = [[To become hitman you must play for at least 2 hours.
You are the hitman of the town. You will get paid for
whoever buys a hit from you.]],
weapons = {},
command = “hitman”,
max = 2,
salary = 60,
admin = 0,
vote = false,
hasLicense = false,
PlayerLoadout = function( ply ) return ply:SetArmor( 25 ) end
})

But it doesnt work. And also is this suppose to remove the armor when they switch jobs too?

You’re setting the armor to 25, if you haven’t noticed:


PlayerLoadout = function( ply ) return ply:SetArmor( 25 ) end

To set the armor to zero, it would basically just be
[LUA]PlayerLoadout = function( ply ) return ply:SetArmor( 0 ) end[/LUA]

It’s just stating, that whenever a person switches job to that job you’ve placed the code in, it will set his armor to what you told it to.

Yes i know. The problem is that if i put it into a job, it gives me lua errors and ends up not working.

TEAM_MOB = DarkRP.createJob(“Hitman”, {
color = Color(166, 83, 41),
model = “models/player/phoenix.mdl”,
description = [[To become hitman you must play for at least 2 hours.
You are the hitman of the town. You will get paid for
whoever buys a hit from you.]],
weapons = {},
command = “hitman”,
max = 2,
salary = 60,
admin = 0,
vote = false,
hasLicense = false,
PlayerLoadout = function( ply ) return ply:SetArmor( 25 ) end
})

And…the errors its giving you are?



hook.Add( "PlayerSpawn", "player_spawn", function( ply )
	if(ply.Team() == "TEAM_POLICE") then
		ply:SetArmor( 100 );
	end
end )


Should work, not tested

Since you have to respawn anyway it would be easier to just do ply:Kill() instead of ply:SetArmor(0).

it works now thanks. I used PlayerLoadout = function( ply ) return ply:SetArmor( 0 ) end to other jobs so that when they change from a police force, their armor will be removed