Garry's Mod Wiki

GM:EntityNetworkedVarChanged

  GM:EntityNetworkedVarChanged( Entity ent, string name, any oldval, any newval )

Description

Called when an NW2Var is changed.

If a NW2Var is set on an entity that is based on a Lua Entity could result in the NW2Var being mixed up with other ones and being updated multiple times.

Issue Tracker: 5455
This hook is fired before the client value is actually changed. Calling the GetNW2 function for the specified variable name within this hook will return the old value, not the current/updated one.

Arguments

1 Entity ent
The owner entity of changed NW2Var
2 string name
The name if changed NW2Var
3 any oldval
The old value of the NW2Var
4 any newval
The new value of the NW2Var

Example

Example usage of the hook. Prints out all NWVar changes.

hook.Add("EntityNetworkedVarChanged","printchange", print ) -- Trigger a change! Entity(1):SetNW2String( "UserGroup", "owner" )
Output:
Player [1][Player1] UserGroup superadmin owner