Garry's Mod Wiki

GM:EntityNetworkedVarChanged

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

Description

Called when an NWVar is changed.

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
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.

Arguments

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

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

Page Links


Special Pages


Wikis

?

Render Time: 32ms

DB GetPage 2
Generate Html 7
SaveChanges (1) 14
Render Body 0
Render Sidebar 6