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.
Syntax
Section titled “Syntax”SetPlayerData(pid, key, value)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
key |
string | the key |
value |
any | the value; nil removes the key |
Returns
Section titled “Returns”boolean - false when not connected
Example
Section titled “Example”SetPlayerData(pid, "team", "red")SetPlayerData(pid, "kills", (GetPlayerData(pid, "kills") or 0) + 1)See also
Section titled “See also”GetPlayerData · GetDatabase · SetPlayerState · the Storage and persistence group of the index
