Entity.SetNetworkedVarProxy

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:SetNetworkedVarProxy( String name, Function proxy )
Description:
Calls the specified function when the variable is changed.
Returns: nil
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.SetNetworkedVarProxy]Entity.SetNetworkedVarProxy [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionCalls a function when the networked variable is changed.

This is from the Shuttle entity by Catdaemon and is used for drawing information text upon entering the vehicle.

The hook is used to add the proxy to the local player.
Used onNewerShared.png
Code
function ShuttleLocalDrivingChanged(entity, name, oldval, newval)
 
	if newval==true and LocalPlayerIsDrivingShuttle==false then
 
		EnterMessageAlpha=4
 
	end
 
	LocalPlayerIsDrivingShuttle=newval
 
end
 
hook.Add("InitPostEntity","ShuttleInitAddProxy",
	function()
 
		LocalPlayer():SetNetworkedVarProxy( "isDriveShuttle", ShuttleLocalDrivingChanged )
 
	end
)
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox