datastream.Hook

From GMod Wiki

Revision as of 21:21, 2 February 2011 by Donkie (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax datastream.Hook( String handler, Function func )
Where is this used?
Description:
Creates a datastream hook
Returns: nil
Part of Library: datastream
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Datastream.Hook]Datastream.Hook [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates a hook for the server (Take note, the first argument on a serverside hook is pl)
Used onNewerServer.png
Code
function IncomingHook( pl, handler, id, encoded, decoded )
 
	print( "Received data on server" );
	print( "Player: " .. pl:Name() );
	print( "Handler: " .. handler );
	print( "ID: " .. id );
	print( "GLON Encoded: " .. encoded );
	print( "Original:" );
	PrintTable( decoded );
 
end
datastream.Hook( "IncomingHook", IncomingHook );
 
OutputN/A
DescriptionCreates a hook for the client (Take note, the first argument on a clientside hook is NOT a player)
Used onNewerClient.png
Code
function IncomingHook( handler, id, encoded, decoded )
 
	print( "Received data on client!" );
	print( "Handler: " .. handler );
	print( "ID: " .. id );
	print( "GLON Encoded: " .. encoded );
	print( "Original:" );
	PrintTable( decoded );
 
end
datastream.Hook( "IncomingHook", IncomingHook );
 
OutputN/A


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox