For a few days I'v been trying to add armor to DarkRP jobs/classes with no luck at all. I'd appreciate it if someone could tell me what lua code to add and where to put it.
Show us your code.
[QUOTE=Chessnut;32417308]Show us your code.[/QUOTE]
What do you mean by code the class?
The code in general that shows how you did the armor crap?
[QUOTE=Chessnut;32418093]The code in general that shows how you did the armor crap?[/QUOTE]
Well I have a few codes I'v found I'm not sure if they work and If they do I don't know where to put them.
Lua Codes:
hook.Add("PlayerLoadout", "armortheCPs", function( ply )
if
ply:Team() == "TEAM_POLICE" or
ply:Team() == "TEAM_SWAT"
then
ply:SetArmor( 100 )
end
end)
hook.Add("PlayerSpawn", "SomeUniqueName", function(ply)
if ply:Team() == TEAM_CP then
ply:SetArmor( 15 )
elseif ply:Team() == TEAM_CHIEF then
ply:SetArmor( 25 )
elseif ply:Team() == TEAM_MAYOR then
ply:SetArmor( 50 )
else
ply:SetArmor( 0 )
end
end)
function SpawnArmor(ply)
----- Edit Below This Line -----
local tarmor = {}
tarmor[1]={"Police",TEAM_POLICE,15} -- Syntax is Name,TeamName,ArmorAmmt
tarmor[2]={"Police Chief",TEAM_CHIEF,25} -- You can add and edit <span class="highlight">armor</span> easily
tarmor[3]={"Mayor",TEAM_MAYOR,50}
----- Edit Above This Line -----
local t == ply:Team()
for a,b in pairs(tarmor) do
if t == b[2] then
ply:SetArmor(b[3])
Notify(ply,1,4,"As a "..b[1].." you got "..b[3].." <span class="highlight">armor</span>.")
end
end
end
hook.Add("PlayerSpawn","SpawnArmor",SpawnArmor)
Briefly looking over the code I don't see any missing variables, so you can put all of it inside of a lua file, and put the file in garrysmod/lua/autorun/server/ and it should work. It looks like each chunk of code is from a different place, so if you were to put all 3 of them in the file some would overwrite each other.
It didn't work ): .
Which block of code did you use, and were there any errors in console mentioning the file? You need to be more specific than saying "It didn't work".
[QUOTE=Shatter;32429178]Which block of code did you use, and were there any errors in console mentioning the file? You need to be more specific than saying "It didn't work".[/QUOTE]
I tried all 3 of them. I didn't see any errors either.
On the first one, teams aren't to be in quotes.
Are you including it ON the server?
rcon lua_openscript lolarmorscript.lua
Sorry, you need to Log In to post a reply to this thread.