OnPlayerPrivateMessage: Difference between revisions
Jump to navigation
Jump to search
(Created page with '__NOTOC__ {{Server event}} This event is triggered when a player sends a private message with ''msg'' command. ==Parameters== <syntaxhighlight lang="lua"> string message, player recipient </co…') |
|||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
This example blocks players sending a PM to a player named "Bob". | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function blockPM(msg,r) | ||
if (getPlayerName(r) == "Bob") then -- If they sent a PM to "Bob" | |||
cancelEvent() -- Then cancel it | |||
outputChatBox("Bob is not accepting PM's at this time.",source,255,0,0) -- And output it was cancelled. | |||
end | |||
end | |||
addEventHandler("onPlayerPrivateMessage",getRootElement(),blockPM) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Player events}} | {{See also/Server event|Player events}} | ||
Revision as of 01:19, 16 August 2010
This event is triggered when a player sends a private message with msg command.
Parameters
string message, player recipient
- message: A string representing the private message typed.
- recipient: The player to whom the message is being sent.
Source
The source of this event is the player who sent the private message.
Cancel effect
If this event is canceled, the game's chat system won't deliver the message. You may use outputChatBox to send the messages then.
Example
This example blocks players sending a PM to a player named "Bob".
function blockPM(msg,r) if (getPlayerName(r) == "Bob") then -- If they sent a PM to "Bob" cancelEvent() -- Then cancel it outputChatBox("Bob is not accepting PM's at this time.",source,255,0,0) -- And output it was cancelled. end end addEventHandler("onPlayerPrivateMessage",getRootElement(),blockPM)
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled