Squirrel/Server/Functions/Messages/SendPlayerMessage

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 14: Line 14:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
+
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.
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- Todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "fakemessage" )
 +
{
 +
local pPlayer2 = FindPlayer( "Bob" );
 +
if ( pPlayer2 ) SendPlayerMessage( pPlayer2, pPlayer, "BOOBIES!" );
 +
}
 +
 +
return 1;
 +
}
 
</code>
 
</code>
  
 
=== Notes ===
 
=== Notes ===
  
-- List of used functions and other notes here.  
+
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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

Sends a message faking another players message

[edit] Syntax

  1. 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.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "fakemessage" )
  5. {
  6. local pPlayer2 = FindPlayer( "Bob" );
  7. if ( pPlayer2 ) SendPlayerMessage( pPlayer2, pPlayer, "BOOBIES!" );
  8. }
  9. return 1;
  10. }
  11.  

[edit] Notes

The function FindPlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox