Garry's Mod Wiki

Revision Difference

GM:CanEditVariable#518653

<function name="CanEditVariable" parent="GM" type="hook"> <ishook>yes</ishook> <description> Called when a variable is edited on an Entity (called by Edit Properties... menu), to determine if the edit should be permitted. See <page text="Editable entities">Editable_Entities</page> for more details about the system. </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>⤶ <arg name="editor" type="table">The edit table defined in <page>Entity:NetworkVar</page></arg>⤶ </args> <rets> <ret name="" type="boolean">Return true to allow editing</ret> </rets> </function> <example> <description> From base/gamemode/variable_edit.lua Makes "Edit Properties..." right click property admin only </description> <code> function GM:CanEditVariable( ent, ply, key, val, editor ) return ply:IsAdmin() end </code> </example>