Squirrel/Server/Events/Player/onPlayerChat
From Liberty Unleashed Wiki
(Difference between revisions)
(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: | ||
− | + | {{Squirrel/Title|onPlayerChat}} | |
− | This is called when a player sends a | + | 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> |
− | == | + | === Arguments === |
− | * '''player''' - The player | + | * '''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| | + | 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
This is called when a player sends a chat message. This event is called even if the player is muted.
[edit] Syntax
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.
function onPlayerChat( player, text ) { if ( player.Muted ) { MessagePlayer( "You are currently muted.", player ); } return 1; }
[edit] Notes
The functions MessagePlayer and Player.Muted were used in this example. More info about them in the corresponding pages.
[edit] Related Events
- onPlayerAction
- onPlayerArmourChange
- onPlayerCashChange
- onPlayerChat
- onPlayerCommand
- onPlayerConnect
- onPlayerDeath
- onPlayerFall
- onPlayerHealthChange
- onPlayerIslandChange
- onPlayerJoin
- onPlayerKeyStateChange
- onPlayerKill
- onPlayerPart
- onPlayerScoreChange
- onPlayerSkinChange
- onPlayerSpawn
- onPlayerUpdate
- onPlayerTeamChange
- onPlayerUseDetonator
- onPlayerVirtualWorldChange
- onPlayerWeaponChange