Gamemode.CompletedIncomingStream

From GMod Wiki

Revision as of 21:20, 2 February 2011 by Donkie (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameCompletedIncomingStream
SyntaxGM:CompletedIncomingStream( Player pl , String handler, Number id, String rawdata, procdata )
DescriptionCalled when the client or server has completed receiving a stream. Use this to block unwanted data. Procdata can be a number of different types of data. pl is serverside only.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.CompletedIncomingStream]Gamemode.CompletedIncomingStream [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionBlock any streams that contain certain keywords.
Used onNewerServer.png
Code
 
function GM:CompletedIncomingStream( pl, handler, id, rawdata, procdata )
 
	if string.find( rawdata, "exploit code" ) != nil then return false end
	return true
 
end
 
OutputThe stream is blocked if the raw data contains "exploit code" anywhere in it..

DescriptionCheck to see if a stream finished sending to the client.
Used onNewerClient.png
Code
 
if SERVER then
 
  function SendStream()
 
     datastream.StreamToClients( player.GetAll(), "TestHook", { "TestString", 44 } )
 
  end
 
end
 
if CLIENT then
 
  function CheckFinished( handler, id, rawdata, procdata )
 
	if handler == "TestHook" then print( "Test Hook Stream Received" ) end
 
  end
  hook.Add( "CompletedIncomingStream", "CheckFinished", CheckFinished )
 
end
 
OutputPrints "Test Hook Stream Received" to console once the client receives the stream. Something will have to call the function on the server, of course. Make sure to remove the pl argument from the hook when using this on the client.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox