OnPlayerPrivateMessage: Difference between revisions
Jump to navigation
Jump to search
m (Add content argument) |
|||
(7 intermediate revisions by 6 users not shown) | |||
Line 5: | Line 5: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string | string fullMessage, player recipient, string content | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*''' | *'''fullMessage''': a [[string]] representing the message along with the nickname | ||
*'''recipient''': | *'''recipient''': the [[player]] to whom the message is being sent. | ||
*'''content''': a [[string]] representing the message content only. This parameter is available since '''1.6.0-9.22430''' version. | |||
==Source== | ==Source== | ||
Line 19: | Line 20: | ||
This example blocks players sending a PM to a player named "Bob". | This example blocks players sending a PM to a player named "Bob". | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function blockPM( | function blockPM(fullMsg,r,msg) | ||
if (getPlayerName(r) == "Bob") then -- If they sent a PM to "Bob" | if (getPlayerName(r) == "Bob") then -- If they sent a PM to "Bob" | ||
cancelEvent() -- Then cancel it | cancelEvent() -- Then cancel it | ||
Line 25: | Line 26: | ||
end | end | ||
end | end | ||
addEventHandler("onPlayerPrivateMessage", | addEventHandler("onPlayerPrivateMessage",root,blockPM) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Player events}} | {{See also/Server event|Player events}} | ||
[[ru:onPlayerPrivateMessage]] |
Latest revision as of 21:37, 23 May 2024
This event is triggered when a player sends a private message with msg command.
Parameters
string fullMessage, player recipient, string content
- fullMessage: a string representing the message along with the nickname
- recipient: the player to whom the message is being sent.
- content: a string representing the message content only. This parameter is available since 1.6.0-9.22430 version.
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(fullMsg,r,msg) 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",root,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