Garry's Mod Wiki

GM:CanEditVariable

  boolean GM:CanEditVariable( 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), to determine if the edit should be permitted.

See Editable entities for more details about the system.

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.

Returns

1 boolean
Return true to allow editing.

Example

From base/gamemode/variable_edit.lua.

Makes Edit Properties... right click property admin only.

hook.Add( "CanEditVariable", "AdminEditVar", function( ent, ply, key, val, editor ) return ply:IsAdmin() end )