Squirrel/Server/Functions/Messages/Message
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __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 == Syntax == <code>bool Message( string text,...) |
|||
Line 3: | Line 3: | ||
== Syntax == | == Syntax == | ||
+ | |||
+ | ''Message'' can take 2 differant lists of parameters. These are: | ||
<code>bool Message( string text, int r = 50, int g = 205, b = 50 )</code> | <code>bool Message( string text, int r = 50, int g = 205, b = 50 )</code> | ||
+ | <code>bool Message( string text, Colour col )</code> | ||
== Arguments == | == Arguments == | ||
Line 12: | Line 15: | ||
* '''g''' - The ammount of Green to be in the colour | * '''g''' - The ammount of Green to be in the colour | ||
* '''b''' - The ammount of Blue to be in the colour | * '''b''' - The ammount of Blue to be in the colour | ||
+ | * '''col''' - A colour class. Good for defining your own colours at script start. | ||
== Example == | == Example == | ||
Line 18: | Line 22: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
+ | Col_Blue <- Colour( 0, 0, 255 ); | ||
+ | |||
function OnPlayerCommand( id, cmd, text ) | function OnPlayerCommand( id, cmd, text ) | ||
{ | { | ||
Line 25: | Line 31: | ||
Message( "Red!", 255, 0, 0 ); | Message( "Red!", 255, 0, 0 ); | ||
Message( "Green!", 0, 255, 0 ); | Message( "Green!", 0, 255, 0 ); | ||
− | Message( "Blue!", | + | Message( "Blue!", Col_Blue ); |
} | } | ||
} | } |
Revision as of 14:04, 8 March 2009
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
Syntax
Message can take 2 differant lists of parameters. These are:
bool Message( string text, int r = 50, int g = 205, b = 50 )
bool Message( string text, Colour col )
Arguments
- text - This is the message to send to the player
- r - The ammount of Red to be in the colour
- g - The ammount of Green to be in the colour
- b - The ammount of Blue to be in the colour
- col - A colour class. 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( id, 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.