I have a networked int that resets itself to 100 in GM:PlayerSpawn, and that works fine.
But, for some reason, if I decrease the networked int, about 8 seconds later it goes back up to 100.
[lua]
local meta = FindMetaTable("Player");
function GM:Think()
print(LocalPlayer():checkStamina())
LocalPlayer():setStamina()
end
function meta:checkStamina()
local stamina = LocalPlayer():GetNWInt("stamina")
return stamina
end
function meta:setStamina()
if self:KeyDown(IN_SPEED) then
local newStamina = LocalPlayer():checkStamina() - 0.05
LocalPlayer():SetNWInt("stamina", newStamina)
end
end
[/lua]
Not sure why... Disabling the line of code that resets it to 100 on spawn fixes it, but moving the line of code to another function does not. But why is that function being called if the player is not spawning?
Could you post your player spawn function?
[lua]
function GM:PlayerSpawn ( ply )
ply:SetNWInt("stamina", 100)
end
[/lua]
You can't set nw variables client-side.
sorry this isn't relevant but what's with the weird camel casing?
Sorry, you need to Log In to post a reply to this thread.