Entity/SetNWVarProxy

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Added source code reference)
(Undo revision 32399 by Robotboy655 (talk))
(One intermediate revision by one user not shown)
Line 15: Line 15:
 
|type=function
 
|type=function
 
|name=callback
 
|name=callback
|desc=The function to be called when the NWVar changes. It has 3 arguments:
+
|desc=The function to be called when the NWVar changes. It has 4 arguments:
 
* {{FuncArg|Entity|ent|The entity}}
 
* {{FuncArg|Entity|ent|The entity}}
 
* {{FuncArg|string|name|Name of the NWVar that has changed}}
 
* {{FuncArg|string|name|Name of the NWVar that has changed}}

Revision as of 16:18, 11 June 2019

 Entity:SetNWVarProxy( )

Contents

Description

Sets a function to be called when the NWVar changes.

NOTE

Currently this function 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

Arguments

any key

The key of the NWVar to add callback for.

Arguments

function callback

The function to be called when the NWVar changes. It has 4 arguments:

  • Entity ent - The entity
  • string name - Name of the NWVar that has changed
  • any oldval - The old value
  • any newval - The new value

Examples

Example

Prints all changes to a NWVar called "Key" of Player 1.

Entity( 1 ):SetNWVarProxy( "Key", print )
Entity( 1 ):SetNWString( "Key", "Value" )
Entity( 1 ):SetNWString( "Key", "Table" )

Output:

Player [1][Player1]	Key	nil	Value
Player [1][Player1]	Key	Value	Table
Personal tools
Navigation