Garry's Mod Wiki

Revision Difference

GM:VariableEdited#511203

<function name="VariableEdited" parent="GM" type="hook">⤶ <ishook>yes</ishook>⤶ <description>Called when a variable is edited on an Entity (called by Edit Properties... menu)</description>⤶ <realm>Server</realm>⤶ <predicted>No</predicted>⤶ <args>⤶ <arg name="ent" type="Entity">The entity being edited</arg>⤶ <arg name="ply" type="Player">The player doing the editing</arg>⤶ <arg name="key" type="string">The name of the variable</arg>⤶ <arg name="val" type="string">The new value, as a string which will later be converted to its appropriate type</arg>⤶ <arg name="editor" type="table">The edit table defined in &lt;page&gt;Entity:NetworkVar&lt;/page&gt;</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>From base/gamemode/variable_edit.lua</description>⤶ <code>⤶ function GM:VariableEdited( ent, ply, key, val, editor )⤶ if ( !IsValid( ent ) ) then return end⤶ if ( !IsValid( ply ) ) then return end⤶ local CanEdit = hook.Run( "CanEditVariable", ent, ply, key, val, editor )⤶ if ( !CanEdit ) then return end⤶ ent:EditValue( key, val )⤶ end⤶ </code>⤶ ⤶ </example>