Revision Difference
GM:CanEditVariable#560607
<function name="CanEditVariable" parent="GM" type="hook">
<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>
<file line="28">gamemodes/base/gamemode/variable_edit.lua</file>⤶
<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>
<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>
hook.Add( "CanEditVariable", "AdminEditVar", function( ent, ply, key, val, editor )
return ply:IsAdmin()
end )
</code>
</example>