OnPlayerBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ {{Server event}} This event is triggered when a player added a ban (like onBan). ==Parameters== <syntaxhighlight lang="lua"> ban banPointer, player responsibleElement </syntaxhighlight> *'''b…')
 
(Cancel Effect)
 
(17 intermediate revisions by 12 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
This event is triggered when a player added a ban (like onBan).
This event is triggered when a player added a [[ban]] (like [[onBan]]).


==Parameters==
==Parameters==
Line 8: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


*'''banPointer''': The ban pointer which was added.
*'''banPointer''': the [[ban]] pointer which was added.
*'''responsibleElement''': The player who added the ban
*'''responsibleElement''': the [[player]] who added the ban.


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[element]] that was responsible for the banning. If no responsible was specified, the source is the global root element.
The [[event system#Event source|source]] of this event is the [[player]] who was banned.
 
==Cancel effect==
This event cannot be canceled.


==Example==  
==Example==  
This example outputs the responsible element and the banned player's name when a ban takes place.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- TODO
function outputBan ( banPointer, responsibleElement ) -- Define the banner and the ban pointer in the function.
local banner = getPlayerName( responsibleElement ) or "Console" -- Get the banner's name.
outputChatBox ( banner .." has banned ".. getPlayerName( source ) ..".", root, 255, 0, 0 ) -- Output the ban.
end
addEventHandler ( "onPlayerBan", root, outputBan ) -- Trigger the function when there is a ban.
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Server events}}
==Changelog==
{{Needs_Example}}
{{ChangelogHeader}}
{{ChangelogItem|1.3.0-9.03908|Fixed responsible element parameter}}
 
{{See also/Server event|Player events}}
 
[[ru:onPlayerBan]]

Latest revision as of 17:11, 6 December 2023

This event is triggered when a player added a ban (like onBan).

Parameters

ban banPointer, player responsibleElement
  • banPointer: the ban pointer which was added.
  • responsibleElement: the player who added the ban.

Source

The source of this event is the player who was banned.

Cancel effect

This event cannot be canceled.

Example

This example outputs the responsible element and the banned player's name when a ban takes place.

function outputBan ( banPointer, responsibleElement ) -- Define the banner and the ban pointer in the function.
	local banner = getPlayerName( responsibleElement ) or "Console" -- Get the banner's name.
	
	outputChatBox ( banner .." has banned ".. getPlayerName( source ) ..".", root, 255, 0, 0 ) -- Output the ban.
end
addEventHandler ( "onPlayerBan", root, outputBan ) -- Trigger the function when there is a ban.

Changelog

Version Description
1.3.0-9.03908 Fixed responsible element parameter

See Also

Player events


Event functions