DarkRP 2.5 Armour

**How do I add armour to certain jobs in DarkRP 2.5? So many posts I have tried do not work.

And if you do tell me the code please include where to put it please.

Thanks in advance.**

My guess:

gamemode/modules/base/sv_gamemode_functions.lua
PlayerSpawn at 604

then, maybe at line 674, put:
[lua]
if ( ply:Team() == TEAM_POLICE ) then
ply:SetArmor( 50 );
if ( ply:Team() == TEAM_POLICESERGEANT ) then
ply:SetArmor( 100 );
elseif ( ply:Team() == TEAM_PRESIDENT ) then
ply:SetArmor( 100 );
else
ply:SetArmor( 0 );
end
[/lua]

or, above the function (line 604) put this:
[lua]
local _armor = {};
_armor[ TEAM_POLICE ] = 50;
_armor[ TEAM_CITIZEN ] = 100;
[/lua]

and at the bottom (line 674) put this:
[lua]
if ( _armor[ ply:Team() ] ) then
ply:SetArmor( _armor[ ply:Team() ] );
end
[/lua]

All didn’t work, I may of done something wrong?

change TEAM_POLICE to whatever your teams are called. Check your job file.

Yes, they are called POLICE, I checked before.

if you don’t get any errors, try put: Msg( ply:Nick() … " team: " … ply:Team() … ", police: " … TEAM_POLICE … “.” );
should print 2 numbers, see if they’re the same

Try this:
[lua]
if ( ply:Team() == TEAM_POLICE ) then
ply:SetArmor( 50 );
elseif ( ply:Team() == TEAM_POLICESERGEANT ) then
ply:SetArmor( 100 );
elseif ( ply:Team() == TEAM_PRESIDENT ) then
ply:SetArmor( 100 );
else
ply:SetArmor( 0 );
end[/lua]

Nope this didn’t work either, thanks for trying though.

[editline]15th December 2013[/editline]

Bump

Don’t edit core files.
http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields
You could just give it in PlayerLoadout
[lua]
PlayerLoadout = function(ply) ply:SetArmor(100) end
[/lua]

In the job file for the jobs you want to have it.

Did not work.


TEAM_POLICE = AddExtraTeam("Police", {
	color = Color(25, 25, 170, 255),
	model = {"models/player/police.mdl"},
	description = [[The protector of every citizen that lives in the city .
		You have the power to arrest criminals and protect innocents.
		Hit them with your arrest baton to put them in jail
		Bash them with a stunstick and they might learn better than to disobey
		the law.
		The Battering Ram can break down the door of a criminal with a warrant
		for his/her arrest.
		Type /wanted <name> to alert the public to this criminal
		OR go to tab and warrant someone by clicking the warrant button]],
	weapons = {"arrest_stick", "unarrest_stick", "m9k_glock", "stunstick", "door_ram", "weaponchecker", "Stungun"},
	command = "police",
	max = 8,
	salary = 75,
	admin = 0,
	vote = true,
	hasLicense = true,
	chief = true,
	PlayerLoadout = function(ply) ply:SetArmor(100) end
})

[editline]15th December 2013[/editline]

bump

bump

[editline]15th December 2013[/editline]

Does anyone know?

[editline]15th December 2013[/editline]

??

[editline]15th December 2013[/editline]

Really need to fix this.


(User was banned for this post ("Don't bump your own thread" - Craptasket))

:frowning:

Make a module and just add an sv_ lua file and put the following inside;


function TeamArmor( ply )
	if ply:Team() == TEAM_POLICE then
		ply:SetArmor( 100 )
	elseif ply:Team() == TEAM_CHIEF then
		ply:SetArmor( 100 )
	end
end
hook.Add( "PlayerLoadout", "TeamArmor", TeamArmor )

Ok so I went in to gamemode/darkrp/gamemode/modules and created a folder called armor then added a lua file called sv_armor with this in:


function TeamArmor( ply )
	if ply:Team() == TEAM_POLICE then
		ply:SetArmor( 100 )
	elseif ply:Team() == TEAM_CHIEF then
		ply:SetArmor( 100 )
	end
end
hook.Add( "PlayerLoadout", "TeamArmor", TeamArmor )

But it didn’t work?

  • Snip -

The code works fine. You need to kill yourself to get that loadout.

You might just be changing jobs and not respawning to allow the new loadout.

Ok so I set it so when you change job you respawn and you still do not spawn with armor as TEAM_POLICE?

[editline]22nd December 2013[/editline]

Ok sorry it does work, but only for cheif not for normal police? And the team name is correct?

[editline]22nd December 2013[/editline]

Ok fixed it, I had two police classes, thanks so much!