Squirrel/Server/Functions/Messages/MessagePlayer
From Liberty Unleashed Wiki
(Difference between revisions)
m |
m (outdated example) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|MessagePlayer}} | |
This function sends a personal message to a player in the game. It can be customized to your own colour if needed. | This function sends a personal message to a player in the game. It can be customized to your own colour if needed. | ||
== Syntax == | == Syntax == | ||
− | + | <code>bool MessagePlayer( string text, Player plr, [ int r, int g, int b ] )</code> | |
− | + | <code>bool MessagePlayer( string text, Player plr, [ Colour col ] )</code> | |
− | <code>bool MessagePlayer( string text, | + | |
− | <code>bool | + | |
== Arguments == | == Arguments == | ||
Line 13: | Line 11: | ||
* '''text''' - This is the message to send to the player | * '''text''' - This is the message to send to the player | ||
* '''plr''' - This is the pointer of the player | * '''plr''' - This is the pointer of the player | ||
− | * '''r''' - The | + | * '''r''' - The amount of Red to be in the colour. This argument is optional |
− | * '''g''' - The | + | * '''g''' - The amount of Green to be in the colour. This argument is optional |
− | * '''b''' - The | + | * '''b''' - The amount of Blue to be in the colour. This argument is optional |
− | * '''col''' - A colour | + | * '''col''' - A colour object. Good for defining your own colours at script start. This argument is optional |
== Example == | == Example == | ||
Line 23: | Line 21: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerCommand( player, cmd, text ) |
{ | { | ||
if ( cmd == "testpm" ) | if ( cmd == "testpm" ) | ||
Line 29: | Line 27: | ||
MessagePlayer( "Testing PM...", player, 255, 0, 0 ); | MessagePlayer( "Testing PM...", player, 255, 0, 0 ); | ||
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 34: | Line 34: | ||
=== 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}} |
Latest revision as of 02:00, 16 October 2010
This function sends a personal message to a player in the game. It can be customized to your own colour if needed.
[edit] Syntax
bool MessagePlayer( string text, Player plr, [ int r, int g, int b ] )
bool MessagePlayer( string text, Player plr, [ Colour col ] )
[edit] Arguments
- text - This is the message to send to the player
- plr - This is the pointer of the player
- r - The amount of Red to be in the colour. This argument is optional
- g - The amount of Green to be in the colour. This argument is optional
- b - The amount of Blue to be in the colour. This argument is optional
- col - A colour object. Good for defining your own colours at script start. This argument is optional
[edit] Example
This will send a personal message saying 'Testing PM...' when a player types '/testpm'
function onPlayerCommand( player, cmd, text ) { if ( cmd == "testpm" ) { MessagePlayer( "Testing PM...", player, 255, 0, 0 ); } return 1; }
[edit] Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.