Garry's Mod Wiki


  Entity:SetNetworked2VarProxy( string name, function callback )


Sets a function to be called when the NW2Var changes. Internally uses GM:EntityNetworkedVarChanged to call the function.

Only one NW2VarProxy can be set per-var
Running this function clientside will only set it for the client it is called on.


1 string name
The name of the NW2Var to add callback for.
2 function callback
The function to be called when the NW2Var changes.
Function argument(s):
1 Entity ent - The entity
2 string name - Name of the NW2Var that has changed
3 any oldval - The old value
4 any newval - The new value


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

Entity( 1 ):SetNetworked2VarProxy( "Key", print ) Entity( 1 ):SetNW2String( "Key", "Value" ) Entity( 1 ):SetNW2String( "Key", "Table" )
Player [1][Player1] Key nil Value Player [1][Player1] Key Value Table