Garry's Mod Wiki

GM:VariableEdited

  GM:VariableEdited( Entity ent, Player ply, string key, string val, table editor )

Description

Called when a variable is edited on an Entity (called by Edit Properties... menu). See Editable Entities for more information.

Arguments

1 Entity ent
The entity being edited
2 Player ply
The player doing the editing
3 string key
The name of the variable
4 string val
The new value, as a string which will later be converted to its appropriate type
5 table editor
The edit table defined in Entity:NetworkVar

Example

From base/gamemode/variable_edit.lua

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