OnBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: Category:Private __NOTOC__<!-- Remove all comments from this page when you're done!--> {{Server event}} <!-- Change this to Client event if it's clientside --> <!-- Describe in plai...)
 
m (Reverted edits by Violence (talk) to last revision by Botder)
Tag: Rollback
 
(21 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
{{Server event}}
 
This event is triggered when an IP address or serial is banned from the server.
[[Category:Private]]
__NOTOC__<!-- Remove all comments from this page when you're done!-->
{{Server event}} <!-- Change this to Client event if it's clientside -->
<!-- Describe in plain english when does this event trigger. Don't go into details, just give an overview -->
This event is triggered when...


==Parameters==
==Parameters==
<!-- NOTE: don't use datatype names for parameter names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd. Don't use Lua library functions / keywords either. -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string parameter1, int parameter2
ban theBan
</syntaxhighlight>  
</syntaxhighlight>  


*'''parameter1''': A string representing...
*'''theBan''': the [[ban]] which was added.
*'''parameter2''': An integer representing...


<!-- Add the event's source in the section below -->
==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[element]] that...
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.


<!-- Only include this section below if cancelling the event has any effect. If you don't know if it does, ask a dev! -->
==Cancel effect==
==Cancel effect==
If this event is [[Event system#Canceling|canceled]], ...
This event cannot be canceled.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example outputs a simple message to all players 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">
--This line does...
function announceBan( theBan )
blah()
  if ( isElement( source ) ) and ( getElementType( source ) == "player" ) then -- Check if the element responsible for the ban is a player element
--This line does this...
outputChatBox( getPlayerName( source ) .. " banned " .. ( getBanSerial( theBan ) or getBanIP( theBan ) ) ) -- Output to the chatbox saying the player has banned the IP/Serial
mooo
  end
end
addEventHandler( "onBan", root, announceBan ) -- Adds the event handler for "onBan" and must be bound to root
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Server events}}
{{Event_functions}}
<!-- leave this until syntax is available. Cannot document the function or event without syntax.-->
[[Category:Need_Syntax]]
<!-- leave this unless you complete the event -->
[[Category:Incomplete Event]]
<!-- leave this unless you provide a good example -->
[[Category:Needs Example]]

Latest revision as of 14:11, 22 August 2020

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

This event cannot be canceled.

Example

This example outputs a simple message to all players when a player added a ban.

function announceBan( theBan )
   if ( isElement( source ) ) and ( getElementType( source ) == "player" ) then -- Check if the element responsible for the ban is a player element
	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