Squirrel/Server/Functions/Messages/Message
From Liberty Unleashed Wiki
(Difference between revisions)
m (Squirrel/Functions/Misc/Message moved to Squirrel/Server/Functions/Messages/Message: Moved to Messages group) |
m (Updated the example) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | This function sends a message to all the players in the game. It can be customised to your own colour if needed. Defaults to Green | + | This function sends a chatbox message to all the players in the game. It can be customised to your own colour if needed. Defaults to Green. |
== Syntax == | == Syntax == | ||
− | ''Message'' can take 2 | + | ''Message'' can take 2 different lists of parameters. These are: |
− | <code>bool Message( string text, int r | + | <code>bool Message( string text, int r, int g, int b )</code> |
<code>bool Message( string text, Colour col )</code> | <code>bool Message( string text, Colour col )</code> | ||
== Arguments == | == Arguments == | ||
− | * '''text''' - This is the message to send to | + | * '''text''' - This is the message to send to players |
− | * '''r''' - The | + | * '''r''' - The amount of Red to be in the colour |
− | * '''g''' - The | + | * '''g''' - The amount of Green to be in the colour |
− | * '''b''' - The | + | * '''b''' - The amount of Blue to be in the colour |
− | * '''col''' - A colour | + | * '''col''' - A colour object. Good for defining your own colours at script start |
== Example == | == Example == | ||
Line 24: | Line 24: | ||
Col_Blue <- Colour( 0, 0, 255 ); | Col_Blue <- Colour( 0, 0, 255 ); | ||
− | function | + | function onPlayerCommand( plr, cmd, text ) |
{ | { | ||
if ( cmd == "test" ) | if ( cmd == "test" ) | ||
Line 38: | Line 38: | ||
=== Notes === | === Notes === | ||
− | The call [[Squirrel/Events/Player/ | + | The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page. |
== Related Functions == | == Related Functions == | ||
− | {{Squirrel/Functions/ | + | {{Squirrel/Server/Functions/Messages}} |
Revision as of 11:29, 9 September 2009
This function sends a chatbox message to all the players in the game. It can be customised to your own colour if needed. Defaults to Green.
Syntax
Message can take 2 different lists of parameters. These are:
bool Message( string text, int r, int g, int b )
bool Message( string text, Colour col )
Arguments
- text - This is the message to send to players
- r - The amount of Red to be in the colour
- g - The amount of Green to be in the colour
- b - The amount of Blue to be in the colour
- col - A colour object. Good for defining your own colours at script start
Example
This will send a message saying 'Testing... Red! Green! Blue!' when somebody types '/test'
Col_Blue <- Colour( 0, 0, 255 ); function onPlayerCommand( plr, cmd, text ) { if ( cmd == "test" ) { Message( "Testing..." ); Message( "Red!", 255, 0, 0 ); Message( "Green!", 0, 255, 0 ); Message( "Blue!", Col_Blue ); } }
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.