Skip to content

GetPlayerEnergy

How rested the player’s character is.

The character’s energy (the Rest) in the game’s own scale and the most it can hold, as the player’s game last reported them - and, under [audit] mode = "enforce", never above the game’s own maximum of 100, since a value over it is put back. The game runs it down as the character stays awake and up as they sleep. After a SetPlayerEnergy made before the player’s game has reported, the value is the one set and the maximum is 0 until the first report - check max before you divide by it.

GetPlayerEnergy(pid)
Parameter Type
pid number the player

number | nil, number | nil - value, max - the energy and its maximum, which is 0 while only the mode’s own set is known; nil until the player’s game has reported or the mode has set it, or for a player not connected

local rest, max = GetPlayerEnergy(pid)
if rest and max > 0 and rest < max * 0.1 then SendClientMessage(pid, COLOR_YELLOW, "You can barely keep your eyes open.") end

SetPlayerEnergy · GetPlayerNourishment · GetPlayerProgress · the Stats, skills, XP and perks group of the index