Why my script doesn't work?
[CODE]function GM:StaminaTick(ply)
ply:SetDarkRPVar("Stamina", 100)
local velocity = ply:GetVelocity():Length2D();
local stam = ply:GetDarkRPVar("Stamina")or 100;
local value;
if ( ply:KeyDown(IN_SPEED) and velocity >= (ply:GetRunSpeed() - 5) ) then
value = math.Clamp(stam - 1, 0, 100);
ply:SetDarkRPVar("Stamina", value);
else
if ( ply:KeyDown(IN_DUCK) ) then
value = math.Clamp(stam + 2, 0, 100);
else
value = math.Clamp(stam + 1, 0, 100);
end;
ply:SetDarkRPVar("Stamina", value)
end
local walkSpeed = ply:GetWalkSpeed();
if (stam < 1) then
ply:SetRunSpeed(walkSpeed);
end
end[/CODE]
[CODE]draw.SimpleText(LocalPlayer().DarkRPVars.Stamina, "TargetID", 25 + 550, ScrH() - 10, color_rp_yellow, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)[/CODE]
[ERROR] lua/includes/modules/draw.lua:86: bad argument #1 to 'GetTextSize' (string expected, got nil)
1. GetTextSize - [C]:-1
2. SimpleText - lua/includes/modules/draw.lua:86
3. DoActualHUD - gamemodes/darkrp/gamemode/client/hud.lua:320
4. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:335
5. unknown - gamemodes/darkrp/gamemode/client/hud.lua:447
P.S.
Sorry if written incorrectly.
Please, answer!
The code you included doesn't contain the offending line.
I noticed that you copied my code from Pistachio, and for some reason you are setting the stamina to 100 every time. It also might be that the function isn't being called.
[editline]1st March 2013[/editline]
Did you call that function in the PlayerTick hook?
Sorry, you need to Log In to post a reply to this thread.