Skip to content

OnStateChange

A key of a state bag changed.

scope is "global", "player" or "entity"; id the pid or entity id (0 for the global bag); value the new string, nil when the key was removed. An error inside is logged, never fatal.

function OnStateChange(scope, id, key, value)
-- ...
end
Parameter Type
scope string "global", "player" or "entity"
id number the pid or the entity id; 0 for the global bag
key string the key
value string | nil the new value; nil = removed

nothing

function OnStateChange(scope, id, key, value)
if scope == "player" and key == "team" then teamOf[id] = tonumber(value) end
end

GetGlobalState · GetPlayerState · GetEntityState · the State bags group of the index