Hi, im new to Fivem server development and im trying to self teach. im going through the fivem documentation and in my attempt to learn im wanted to make a simple script on giving myself infinite stamina. Here is what i have so far, but it is not working. The command is registering but i am not getting max stamina. what am i doing wrong?
RegisterCommand('maxstam', function ()
local player = PlayerId()
local stamina = GetPlayerStamina(player)
if stamina < 100 then stamina = 100
end
print(json.encode(stamina))
end)
With FiveM you will be using a Lua environment, not a C environment. The simplest way I can describe the issue you had is, you expected the value returned from the Get function to be the actual value or a reference directly to the value you want to change, when it is actually just a new value that is equal to the value you want to change. Your “stamina” variable is just a local reading of the memory value, not the acutal memory value, so you can not change it by setting it equal to something else, there is a function you will call to make that memory value change. I hope I explained that well…