Revision Difference
Player:SetPData#560049
<function name="SetPData" parent="Player" type="classfunc">
<description>
Writes a **P**ersistent **Data** key-value pair to the SQL database. (`sv.db` when called on server, `cl.db` when called on client)
Internally uses the <page>sql</page> library. See <page>util.SetPData</page> for cases when the player is not currently on the server.
⤶
<warning>This function internally uses <page>Player:UniqueID</page>, which can cause collisions (two or more players sharing the same PData entry). It's recommended that you don't use it. See the related wiki page for more information.</warning>⤶
⤶
<note>This function internally uses <page>Player:SteamID64</page>, it previously utilized <page>Player:UniqueID</page> which can cause collisions (two or more players sharing the same PData entry). <page>Player:SetPData</page> now replaces all instances of <page>Player:UniqueID</page> with <page>Player:SteamID64</page> when running <page>Player:SetPData</page></note>⤶
⤶
<validate>Need to update source link?⤶
https://github.com/Facepunch/garrysmod/blob/45ff9bdf7da8d661200dc20540f970212571aef8/garrysmod/lua/includes/extensions/player.lua#L133-L147</validate>⤶
<note>PData is not networked from servers to clients!</note>
</description>
<realm>Shared</realm>
<file line="173-L182">lua/includes/extensions/player.lua</file>
<args>
<arg name="key" type="string">Name of the PData key</arg>
<arg name="value" type="any">Value to write to the key (**must** be an SQL valid data type, such as a string or integer)</arg>
</args>
<rets>
<ret name="" type="boolean">Whether the operation was successful or not</ret>
</rets>
</function>
<example>
<description>Sets the key "money" from player 1's PData to 100</description>
<code>Entity( 1 ):SetPData( "money", 100 )</code>
</example>