Garry's Mod Wiki

Revision Difference

Player:SetPData#512431

<function name="SetPData" parent="Player" type="classfunc">⤶ <description>⤶ Writes a **P**layer **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>.⤶ ⤶ <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>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>player.GetByID( 1 ):SetPData( "money", 100 )</code>⤶ ⤶ </example>