OnUnban: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server event}} This event is triggered when an IP address or serial is unbanned from the server. ==Parameters== <syntaxhighlight lang="lua"> string theIPOrSerial </syntaxhighlight> *'''theIPOrSerial'...)
 
No edit summary
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
This event is triggered when an IP address or serial is unbanned from the server.
This event is triggered when a ban is removed from the server.
 
if the ban was removed using function [[removeBan]], and the responsibleElement was not specifying, the event will return nil.


==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string theIPOrSerial
ban theBan, player responsibleElement
</syntaxhighlight>  
</syntaxhighlight>  


*'''theIPOrSerial''': The IP address or serial that was unbanned from the server.
*'''theBan ''': the [[ban]] that will be removed.
*'''responsibleElement''': the [[player]] who removed the ban, otherwise returns ''nil''.


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[element]] that was responsible for the unbanning. If no responsible was specified, the source is the global root element.
The source is always the global root element.


==Cancel effect==
==Cancel effect==
Line 21: Line 24:
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
root = getRootElement()
blah()
 
--This line does this...
function announceUnban( theBan, responsibleElement )
mooo
if getElementType( responsibleElement ) then --Check if a player unbanned the IP/Serial
outputChatBox( getPlayerName( responsibleElement ) .. " unbanned " .. ( getBanSerial(theBan) or getBanIP(theBan) ) ) --Output to the chatbox saying the player has unbanned the IP/Serial
end
end
 
addEventHandler( "onUnban", root, announceUnban ) --Adds the event handler for 'onUnban'
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==Changelog==
{{Event_functions}}
{{ChangelogHeader}}
[[Category:Needs Example]]
{{ChangelogItem|1.3.0-9.03908|Fixed/added responsible element parameter}}
 
{{See also/Server event|Server events}}

Latest revision as of 03:05, 27 September 2018

This event is triggered when a ban is removed from the server.

if the ban was removed using function removeBan, and the responsibleElement was not specifying, the event will return nil.

Parameters

ban theBan, player responsibleElement
  • theBan : the ban that will be removed.
  • responsibleElement: the player who removed the ban, otherwise returns nil.

Source

The source is always the global root element.

Cancel effect

If this event is canceled, the requested unban is not performed.

Example

This example does...

root = getRootElement()

function announceUnban( theBan, responsibleElement )
	if getElementType( responsibleElement ) then --Check if a player unbanned the IP/Serial
		outputChatBox( getPlayerName( responsibleElement ) .. " unbanned " .. ( getBanSerial(theBan) or getBanIP(theBan) ) ) --Output to the chatbox saying the player has unbanned the IP/Serial
	end
end

addEventHandler( "onUnban", root, announceUnban ) --Adds the event handler for 'onUnban'

Changelog

Version Description
1.3.0-9.03908 Fixed/added responsible element parameter

See Also

Server events


Event functions