GM/EntityNetworkedVarChanged

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added note that the hook is called before the value is actually updated)
 
Line 32: Line 32:
  
 
-- Trigger a change!
 
-- Trigger a change!
Entity(1):SetNWString( "UserGroup", "owner" )
+
Entity(1):SetNW2String( "UserGroup", "owner" )
 
|OutputFixedWidth=Fixed width
 
|OutputFixedWidth=Fixed width
 
|Output=Player [1][Player1] UserGroup superadmin owner
 
|Output=Player [1][Player1] UserGroup superadmin owner
 
}}
 
}}

Latest revision as of 16:49, 9 July 2019

 GM:EntityNetworkedVarChanged( )

Contents

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

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

Entity ent

The owner entity of changed NWVar

Arguments

string name

The name if changed NWVar

Arguments

any oldval

The old value of the NWVar

Arguments

any newval

The new value of the NWVar

Examples

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
Personal tools
Navigation