Skip to content
Nayruden edited this page Sep 14, 2010 · 6 revisions

Server.Broadcast(player, message)
Specify nil instead of a player to broadcast to everyone. Echoes the message to the server too. The message on the client appears in the lower left like a chat message.

Server.ForAllPlayers( fn )
The function specified is called for every player in the server, passing the player in as the first argument. IE, Server.ForAllPlayers( function( ply ) Server.Broadcast( ply, “foobar” ) end ) will send foobar to each player. (Note you’d actually want to just call Server.Broadcast once with nil to send to all players, but you get the idea.)

Console commands
Event.Hook( “Console_mycommand”, my_function )

  • Replace mycommand with the name of your command
  • my_function receives a userdata as the first argument followed by a list of parameters, one for each argument (separate by a space).

IE, Event.Hook(“Console_blah”, function(a,b,c) Shared.Message( tostring( c ) ) end) prints “two” when “blah one two” is input into console.

Clone this wiki locally