OnBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fixed incorrect onBan parameters)
m (Improving)
Line 17: Line 17:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example outputs a simple message to the server when a player added a ban.
This example does...
<!-- 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">
root = getRootElement()
function announceBan( theBan )
function announceBan( theBan )
if getElementType( source ) then --Check if a player banned the IP/Serial
if getElementType( source ) then --Check if a player banned the IP/Serial
Line 29: Line 25:
end
end


addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan'
addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan' and must be bound to root
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Server events}}
{{See also/Server event|Server events}}

Revision as of 16:56, 28 September 2011

This event is triggered when an IP address or serial is banned from the server.

Parameters

ban theBan
  • theBan : The ban which was added.

Source

The 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.

Cancel effect

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

Example

This example outputs a simple message to the server when a player added a ban.

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

addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan' and must be bound to root

See Also

Server events


Event functions

Shared