[lua]
function BuyHealthNPC( user )
local user = user
local pos = user:GetPos()
local distance = user:GetPos():Distance(Vector(-1753, -1542, -131.97))
if distance < 400 then
if user:CanAfford("250") then
if user:Health <= 99 then
user:AddMoney("-200")
user:SetHealth(100)
Notify(user, 1, 4, string.format(LANGUAGE.you_bought_x, "Health", "$200"))
else
Notify(user, 1, 4, "Your already in great condition.")
end
end
else
Notify(user, 1, 4, "You are not near the NPC!")
end
end
concommand.Add("GiveHealthNPC", BuyHealthNPC)
[/lua]
This code is suppost to give the player health when they activate something.. but it is giving me this error when I start up my game.
[code][gamemodes\darkrpsvn3\gamemode\init.lua:224] function arguments expected near '<='
[/code]
And line 224 is:
[code] if user:Health <= 99 then[/code]
Can anyone explain why this is happening? Thanks :D
It should be user:Health( ). Health is a function and needs to be called.
Thanks! I got it working. Also, how could I add 3d2d over an NPC's head? I tried playing around with this code I found:
[lua] cam.Start3D2D(Pos + Ang:Right() * 11.5, Ang, 0.11)
draw.WordBox(2, -TextWidth*0.5, -30, "Elite Printer", "HUDNumber5", Color(0, 0, 140, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber5", Color(0, 0, 140, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth3*0.5, 66, "Level "..tostring(self.dt.level), "HUDNumber5", Color(0, 0, 140, 100), Color(255,255,255,255))
cam.End3D2D()
[/lua]
Sorry, you need to Log In to post a reply to this thread.