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.
Syntax
Section titled “Syntax”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 |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnStateChange(scope, id, key, value) if scope == "player" and key == "team" then teamOf[id] = tonumber(value) endendSee also
Section titled “See also”GetGlobalState · GetPlayerState · GetEntityState · the State bags group of the index
