General > Developers Corner
Trying to learn lua a little
Neku:
Perhaps you could try removing the quotes from
--- Code: ---self:getDarkRPVar('level')
--- End code ---
Desimay:
--- Quote from: Neku on February 12, 2014, 09:28:39 PM ---Perhaps you could try removing the quotes from
--- Code: ---self:getDarkRPVar('level')
--- End code ---
--- End quote ---
The level mod works fine, it is just that I want it to set a users health depending on what level, aka level 60 gets 600 health. I am running a Gang Wars RP so the more health the better
Neku:
How about instead of end...
Start using elseif, right now if you have it so any level below 60 gets 700 HP.
Desimay:
Ok I did that but it is still not setting HP. It does run the script though.
--- Code: ---function AddHpToLevel(ply)
if ( ply:getDarkRPVar('level') >= 60 ) then
ply:SetHealth(700)
elseif ( ply:getDarkRPVar('level') >= 50 ) then
ply:SetHealth(600)
elseif ( ply:getDarkRPVar('level') >= 40 ) then
ply:SetHealth(500)
elseif ( ply:getDarkRPVar('level') >= 30 ) then
ply:SetHealth(400)
elseif ( ply:getDarkRPVar('level') >= 20 ) then
ply:SetHealth(300)
elseif ( ply:getDarkRPVar('level') >= 10 ) then
ply:SetHealth(200)
end
end
hook.Add("PlayerSpawn", "test", AddHpToLevel)
print( "Loaded HP Gen2222");
--- End code ---
I have tried that with no luck.
JamminR:
1) As I originally asked, where are you putting this code?
It's possible, depending on where it is, that it's loading before the functions it uses are created by the gamemode or addon.
2) Try a print command inside the function too, to see if it's working right when it runs, if the hook is even running.
--- Code: ---function AddHpToLevel(ply)
print ( ply:Nick() .. " level is ".. ply:getDarkRPVar('level') )
if ( ply:getDarkRPVar('level') >= 60 ) then
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version