Garry's Mod Wiki


  boolean Player:SetPData( string key, any value )


Writes a Persistent Data key-value pair to the SQL database. (sv.db when called on server, cl.db when called on client)

Internally uses the sql library. See util.SetPData for cases when the player is not currently on the server.

This function internally uses Player:SteamID64, it previously utilized Player:UniqueID which can cause collisions (two or more players sharing the same PData entry). Player:SetPData now replaces all instances of Player:UniqueID with Player:SteamID64 when running Player:SetPData
PData is not networked from servers to clients!


1 string key
Name of the PData key
2 any value
Value to write to the key (must be an SQL valid data type, such as a string or integer)


1 boolean
Whether the operation was successful or not


Sets the key "money" from player 1's PData to 100

Entity( 1 ):SetPData( "money", 100 )