Squirrel/Server/Events/Player/onPlayerChat

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This is called when a player sends a message in the main chat. This event is also called even if the player is muted. == Syntax == <code>function onPlayerChat( player, message ...)
 
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|onPlayerChat}}
This is called when a player sends a message in the main chat. This event is also called even if the player is muted.
+
This is called when a player sends a chat message. This event is called even if the player is muted.
  
 
== Syntax ==
 
== Syntax ==
  
<code>function onPlayerChat( player, message )</code>
+
<code>function onPlayerChat( Player player, string message )</code>
  
== Parameters ==
+
=== Arguments ===
  
* '''player''' - The player pointer
+
* '''player''' - The player who spoke
 
* '''message''' - The message the player sent
 
* '''message''' - The message the player sent
 +
 +
=== Returns ===
 +
 +
* '''1''' - Send the message to other clients, unless they're muted
 +
* '''0''' - Returning 0 will cancel this message and effectively mute the player
  
 
== Example ==
 
== Example ==
Line 20: Line 25:
 
     if ( player.Muted )
 
     if ( player.Muted )
 
     {
 
     {
           MessagePlayer( "You are currently muted", player );
+
           MessagePlayer( "You are currently muted.", player );
 
     }
 
     }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 27: Line 34:
 
=== Notes ===
 
=== Notes ===
  
The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and [[Squirrel/Server/Functions/Players/Muted|player.Muted]] were used in in this example. More info about them in the corresponding pages.
+
The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and [[Squirrel/Server/Functions/Players/Muted|Player.Muted]] were used in this example. More info about them in the corresponding pages.
  
 
== Related Events ==
 
== Related Events ==
  
 
{{Squirrel/Server/Events/Player}}
 
{{Squirrel/Server/Events/Player}}

Latest revision as of 18:48, 22 December 2010

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

This is called when a player sends a chat message. This event is called even if the player is muted.

[edit] Syntax

  1. function onPlayerChat( Player player, string message )

[edit] Arguments

  • player - The player who spoke
  • message - The message the player sent

[edit] Returns

  • 1 - Send the message to other clients, unless they're muted
  • 0 - Returning 0 will cancel this message and effectively mute the player

[edit] Example

This example checks if the player has been muted, and if they are, sends a message to them stating they have been muted.

  1.  
  2. function onPlayerChat( player, text )
  3. {
  4. if ( player.Muted )
  5. {
  6. MessagePlayer( "You are currently muted.", player );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The functions MessagePlayer and Player.Muted were used in this example. More info about them in the corresponding pages.

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox