Squirrel/Server/Functions/Messages/SendPlayerMessage
From Liberty Unleashed Wiki
(Difference between revisions)
Line 14: | Line 14: | ||
== Example == | == Example == | ||
− | + | This will send a fake message to the player who typed '/fakemessage', it will be shown as coming from 'Bob' if they are on the server. | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( pPlayer, szCommand, szText ) | |
+ | { | ||
+ | if ( szCommand == "fakemessage" ) | ||
+ | { | ||
+ | local pPlayer2 = FindPlayer( "Bob" ); | ||
+ | if ( pPlayer2 ) SendPlayerMessage( pPlayer2, pPlayer, "BOOBIES!" ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Server/Functions/Players/FindPlayer|FindPlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Messages}} | {{Squirrel/Server/Functions/Messages}} |
Latest revision as of 23:53, 19 October 2010
Sends a message faking another players message
[edit] Syntax
bool SendPlayerMessage( player playerToFake, player playerToSendTo, string message )
[edit] Arguments
- playerToFake - The pointer of the player to fake
- playerToSendTo - The pointer of the player to send the fake message to
- message - The message to send
[edit] Example
This will send a fake message to the player who typed '/fakemessage', it will be shown as coming from 'Bob' if they are on the server.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "fakemessage" ) { local pPlayer2 = FindPlayer( "Bob" ); if ( pPlayer2 ) SendPlayerMessage( pPlayer2, pPlayer, "BOOBIES!" ); } return 1; }
[edit] Notes
The function FindPlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
[edit] Related Functions
- BigMessage
- ClearMessages
- Message
- MessageAllExcept
- MessagePlayer
- PagerMessage
- SendPlayerMessage
- SmallMessage