KcdMp.on_state
Registers a handler for one key, whatever bag it changes in.
One handler per key. The handler gets the new value (nil when removed), the scope ("global", "player", "entity")
and the id. Runs before KcdMp.on_state_change for the same change.
Syntax
Section titled “Syntax”KcdMp.on_state(key, fn)| Parameter | Type | |
|---|---|---|
key |
string | the key to watch |
fn |
function | function(value, scope, id) end |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”-- remember every player's team as the mode puts it in their bagsKcdMp.on_state("team", function(value, scope, pid) if scope == "player" then teamOf[pid] = tonumber(value) endend)See also
Section titled “See also”KcdMp.on_state_change · KcdMp.state · the State bags group of the index
