net.Receive

From GMod Wiki

Jump to: navigation, search
Function
Syntax net.Receive( String message_name, Function message_callback )
Where is this used?
Description:
Allows you to receive custom net messages.
Returns: nil
Part of Library: net
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Net.Receive]Net.Receive [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionAllows you to receive the server message "my message"
Used onNewerClient.png
Code
local function receive_message(len)
	print("Bits:", len)
	print(net.ReadString())
end
net.Receive("my message". receive_message)
 
OutputN/A

DescriptionAllows you to receive a client's message "my message"
Used onNewerServer.png
Code
local function receive_message(len, ply)
	print("Bits:", len)
	ply:PrintMessage(net.ReadString())
end
net.Receive("my message", receive_message)
 
OutputN/A


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox