DarkRP Armor

I know there are alot of threads, but they don’t seem to work for me. I may just be being retarded, but I would appreciate some help. What codes do I have to add and where? If I want TEAM_POLICE to have 50 armour when they spawn?

http://forum.facepunch.com/showthread.php?t=1250283

Add spawn hook, check for player:IsCP() and then player:SetArmor(50)

Also, easiest but kinda dumb way is adding item_battery to weapon list

Sorry, i know nothign about LUA, would you/someone be able to help me with the code? I’ve tried numerous things any help is appreciated

[lua]
local function SpawnArmorForCPs(ply)
if ply:IsCP() then
ply:SetArmor(50)
end
end
hook.Add(“PlayerSpawn”, “CPArmor”, SpawnArmorForCPs)
[/lua]
Place in autorun/server/cparmor.lua.

That worked for police chief, but how would I apply this for swat?

Make SWAT part of CP

Yes but I wanted to have SWAT as a different hp but that works fine thanks! It worked, changed nothing restarted server, now it doesn’t work? Would this be a dodgy addon?

-snip-

[LUA]
local function PoliceSpawn( _p )

if ( _p:IsCP() ) then

	_p:SetArmor( 50 );

	if ( _p:Team() == TEAM_SWAT ) then

		_p:SetHealth( 150 );
                    _p:SetArmor( 75 );

	elseif ( _p:Team() == TEAM_SPIDERMANSWAT ) then

		_p:SetHealth( 300 );
                    _p:SetArmor( 100 );

	end		
	
end

end

hook.Add( “PlayerSpawn”, “PoliceSpawnExtras”, PoliceSpawn );
[/LUA]

like that you can have different health for different police jobs.

This didn’t work for me :confused: but thanks for trying :slight_smile:



local function PoliceSpawn( _p ) 
	if ( _p:IsCP() ) then
		_p:SetArmor( 50 );
	elseif ( _p:Team() == TEAM_SWAT ) then
			_p:SetHealth( 150 );
            _p:SetArmor( 75 );
	elseif ( _p:Team() == TEAM_SPIDERMANSWAT ) then
			_p:SetHealth( 300 );
            _p:SetArmor( 100 );
	end
end
hook.Add( "PlayerSpawn", "PoliceSpawnExtras", PoliceSpawn );

then SWAT won’t get armor

Sence this has not been put as solved, I’ll try to post something that works for my DarkRP Server.

Go here. garrysmod/gamemodes/darkrp/gamemode/modules

Create a file named “classhealth.lua” (Or anything you want)

Put this inside.



function ArmorSpawn( ply )
	if ply:Team() == TEAM_POLICE then
		ply:SetArmor(150)
		ply:SetHealth(150)
		ply:SetRunSpeed(265)
		ply:SetWalkSpeed(200)
	end
	if ply:Team() == TEAM_CHIEF then
		ply:SetArmor(200)
		ply:SetHealth(200)
		ply:SetRunSpeed(265)
		ply:SetWalkSpeed(200)
	end
end
hook.Add( "PlayerLoadout", "ArmorSpawn", ArmorSpawn )

You can use anything that has ply: before it in these settings. Basically you just need to copy/paste the repeating parts and rename the TEAM_.

Good luck!