DarkRP Job Health, Armor, Speed

I was wondering how you set a DarkRP jobs health, armor, walk speed, and run speed.

SetHealth(), SetArmor(), SetWalkSpeed(), SetRunSpeed()

PlayerSpawn = function(ply) ply:SetArmor(number)

PlayerSpawn = function(ply) ply:SetHealth(number)

1 - Late.

2 - The function is GM:PlayerSpawn()

The point is where do I put all of this. I tried putting it into the jobs and it didn’t want to work.

??
If you want it to do on spawn:

[lua]
hook.Add( “PlayerSpawn”, “TheNeuraProject”, function( ply )
ply:SetHealth( number )
ply:SetArmor( number )
ply:SetWalkSpeed( number )
ply:SetRunSpeed( number )
end)
[/lua]

He probably doesn’t want to do it for all jobs but rather for specific jobs, which is where the stuff Mikey posted is correct. There’s a PlayerSpawn property in darkrp jobs which gets called when you spawn, just like the hook (http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields)
I have always used the PlayerLoadout property for this, so in a specific job you do something like this:

[lua]
TEAM_GUN = DarkRP.createJob(“Gun Dealer”, {
color = Color(255, 140, 0, 255),
model = “models/player/monk.mdl”,
description = [[A Gun Dealer is the only person who can sell guns to other people.
Make sure you aren’t caught selling illegal firearms to the public! You might get arrested!]],
weapons = {},
command = “gundealer”,
max = 2,
salary = GAMEMODE.Config.normalsalary,
admin = 0,
vote = false,
hasLicense = false,
category = “Citizens”,
PlayerLoadout = function(ply) – this line is added. Remember a comma at the end of above line if it is not there.
ply:SetHealth(100)
ply:SetArmor(100)
ply:SetWalkSpeed(30)
ply:SetRunSpeed(80)
end,
})
[/lua]

Oh shit… I didn’t notice you said DarkRP. Sorry man :frowning:

Yeah that’s ms333 that was exactly what I needed. I couldn’t figure out how to set exact jobs. Thanks a ton!

**Hi there,

I tried doing it like this,**

TEAM_CR = DarkRP.createJob(“Clone Recruit”, {
color = Color(145, 145, 145, 255),
model = {“models/player/sgg/starwars/clonetrooper_clean.mdl”},
description = [[You are a Clone Recruit waiting to be trained on the Venator]],
weapons = {“weapon_752_dc15satrainingnodmg”, “weapon_752_dc15atrainingnodmg”},
command = “recruit”,
max = 0,
salary = 0,
admin = 0,
vote = false,
hasLicense = false,
candemote = false,
– CustomCheck
medic = false,
chief = false,
mayor = false,
hobo = false,
cook = false,
category = “Clone Troopers”,
PlayerLoadout = function(ply)
ply:SetHealth(500)
ply:SetArmor(0)
ply:SetWalkSpeed(0)
ply:SetRunSpeed(0)
})

But I am getting this error:

[ERROR] Lua is unable to understand file “darkrp_customthings/jobs.lua” because its author made a mistake around line number 26.
The best help I can give you is this:

Right before the ‘}’, Lua encountered something it could not make sense of.

Hints:

  • Did you forget something here? (Perhaps a closing bracket)
  • Is it a typo?

Line 26 is the bottom line the "})"

Thanks, Prior.

You forgot to copy the end for the PlayerLoadout function


    PlayerSpawn = function(ply) ply:SetHealth(2000) ply:SetMaxHealth(2000) end,
}) 

I added this to a job, max health so that they can still be healed using a medkit. But now when I change my job, I have 2000 then when I suicide it goes to 100.

I don’t know much about darkrp I believe playerspawn is only called once the player is given his weapon on initial job change.
Use the hook OnPlayerSpawn to change the health?
I presume there’s an easier way about this though

Could always try the PlayerLoadout function as that is called when you get a set of weapons; everytime you die.

---------------Theres an edit at bottom---------------------

I know how this is REALLY late but I’m pretty sure its cause u didn’t put a [tab] before the ply:SetHealth ect. ect.

you put:

PlayerLoadout = function(ply)
ply:SetHealth(500)
ply:SetArmor(0)
ply:SetWalkSpeed(0)
ply:SetRunSpeed(0)
})

when I think it should be:

PlayerLoadout = function(ply)

  • ply:SetHealth(500)
    
  • ply:SetArmor(0)
    
  • ply:SetWalkSpeed(0)
    
  • ply:SetRunSpeed(0)
    

})

EDIT: I don’t know if you had a tab because the forums don’t like them even if u put them in a post…

  • a tab goes here

Spaces like those mean absolutely nothing to Lua, the only error was that he forgot to add an “end” at the ending of the function to signify it’s over.