OnPlayerPrivateMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
addEventHandler("onPlayerPrivateMessage",getRootElement(),blockPM)
addEventHandler("onPlayerPrivateMessage",getRootElement(),blockPM)
</syntaxhighlight>
</syntaxhighlight>
{{See also/Server event|Player events}}
 
==See Also==
===Player events===
{{Player_events}}
===Event functions===
{{Event functions}}


[[ru:onPlayerPrivateMessage]]
[[ru:onPlayerPrivateMessage]]

Revision as of 02:16, 27 September 2018

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 to be sent.
  • 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


Event functions