DarkRP 2.5 Question

Hey guys I’m a complete noob with Lua Coding, but interested into learning it but I want to understand why this code isn’t working

function GM:PlayerSpawn( ply )
if ply:Team() == TEAM_POLICE then
ply:SetArmor( 50 )
end
end

I’ve put this code in; lua/autorun/server, than darkrp/gamemode/init.lua but it’s not working.

I’m not getting any errors or anything. I’m also using a custom HUD.

-Thanks in advance


(User was banned for this post ("Read the stickies before posting (again)" - Asaratha))

You’re overriding the function that DarkRP uses to setup players when they spawn. Use hooks instead:



local function setPoliceArmor( ply )
   if ply:Team() == TEAM_POLICE then
      ply:SetArmor( 50 )
   end
end
hook.Add("PlayerSpawn", "YourUniqueNameHere12460348256078", setPoliceArmor)


It still isn’t working, where should I place this code at? (Sorry, I’m very rubbish at placing codes in correct paths.)