Garry's Mod Wiki

Revision Difference

GM:EntityNetworkedVarChanged#511351

<function name="EntityNetworkedVarChanged" parent="GM" type="hook"> <ishook>yes</ishook> <description> Called when an NWVar is changed. <note>Currently this hook only works for the NW2Var system (accessed by adding a 2 in between NW and Var for most NWVar functions), which will replace the original one at some point in the future</note> <note>This hook is fired before the client value is actually changed. Calling the GetNW function for the specified variable name within this hook will return the old value, not the current/updated one.</note> </description> <realm>Shared</realm> <predicted>No</predicted> <args> <arg name="ent" type="Entity">The owner entity of changed NWVar</arg> <arg name="name" type="string">The name if changed NWVar</arg> <arg name="oldval" type="any">The old value of the NWVar</arg> <arg name="newval" type="any">The new value of the NWVar</arg> </args> </function> <example> <description>Example usage of the hook. Prints out all NWVar changes.</description> <code> hook.Add("EntityNetworkedVarChanged","printchange", print ) -- Trigger a change! Entity(1):SetNW2String( "UserGroup", "owner" ) </code> <outputfixedwidth>Fixed width</outputfixedwidth> <output>Player [1][Player1] UserGroup superadmin owner</output> </example>