Skip to content

SetPlayerData

Stores a value on the player, private to the server, for the session.

Any Lua value - a string, a number, a boolean, a table. Cleared when the player disconnects and on a reload. Never replicated: for a value the clients read use SetPlayerState; for one that should survive the visit, the mode’s database. The natural cache for a player’s row: load it here on the connect, answer every callback from here, write it back on the disconnect.

SetPlayerData(pid, key, value)
Parameter Type
pid number the player
key string the key
value any the value; nil removes the key

boolean - false when not connected

SetPlayerData(pid, "team", "red")
SetPlayerData(pid, "kills", (GetPlayerData(pid, "kills") or 0) + 1)

GetPlayerData · GetDatabase · SetPlayerState · the Storage and persistence group of the index