OnBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added a small example announcing the ban)
Line 21: Line 21:
<!-- 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 announceBan( sz )
mooo
if getElementType( source ) then --Check if a player banned the IP/Serial
outputChatBox( getClientName( source ) .. " banned " .. sz ) --Output to the chatbox saying the player has banned the IP/Serial
end
end
 
addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan'
</syntaxhighlight>
</syntaxhighlight>



Revision as of 00:28, 7 January 2008

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

Parameters

string theIPOrSerial
  • theIPOrSerial: The IP address or serial that was banned from the server.

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

root = getRootElement()

function announceBan( sz )
	if getElementType( source ) then --Check if a player banned the IP/Serial
		outputChatBox( getClientName( source ) .. " banned " .. sz ) --Output to the chatbox saying the player has banned the IP/Serial
	end
end

addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan'

See Also