General > Developers Corner

Trying to learn lua a little

(1/4) > >>

Desimay:
So I am trying to learn lua a little and I wrote this for my server.


--- Code: ---function AddHpToLevel(ply)
if ( ply:getLevel() <= 60 ) then
ply:SetHealth(700)
end
if ( ply:getLevel() <= 50 ) then
ply:SetHealth(600)
end
if ( ply:getLevel() <= 40 ) then
ply:SetHealth(500)
end
if ( ply:getLevel() <= 30 ) then
ply:SetHealth(400)
end
if ( ply:getLevel() <= 20 ) then
ply:SetHealth(300)
end
if ( ply:getLevel() <= 10 ) then
ply:SetHealth(200)
end
end
hook.Add("PlayerSpawn", "test", AddHpToLevel)

--- End code ---

But it doesn't seem to work. Is there something I am doing wrong?

JamminR:
Where do you have the file this code is in?
Tried adding print messages for debugging, both within the function, and outside of it (to see that it's even loading?)
Do you have a function called getLevel somewhere?

Desimay:
Ok it does run but doesn't set my HP. The getLevel is this function.

--- Code: ---function meta:getLevel()
return self:getDarkRPVar('level')
end

--- End code ---

Neku:
Okay...

Does getDarkRPVar exist?

Desimay:

--- Quote from: Neku on February 12, 2014, 09:07:06 PM ---Okay...

Does getDarkRPVar exist?

--- End quote ---

Yes, the level mod works fine.

Navigation

[0] Message Index

[#] Next page

Go to full version