Skip to content

SetPlayerState

Sets a key of a player’s bag, read by every client.

Every client has every player’s bag from its join on - KcdMp.state.player[pid][key]; the client’s own pid is KcdMp.player_id. Gone with the player’s session.

SetPlayerState(pid, key, value)
Parameter Type
pid number the player
key string 1-48 characters
value string | number | boolean | nil kept as a string; nil removes the key

boolean - false when not connected or out of bounds

SetPlayerTeam(pid, 2)
SetPlayerState(pid, "team", 2) -- the client scripts colour the label by it

GetPlayerState · GetPlayerStates · SetGlobalState · SetPlayerData · the State bags group of the index