Garry's Mod Wiki

Revision Difference

GM:VariableEdited#527453

<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> <description>Called when a variable is edited on an Entity (called by Edit Properties... menu). See <page>Editable Entities</page> for more information.</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 <page>Entity:NetworkVar</page></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>