RemoveBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} This function will remove a ban specified by the ban element. ==Syntax== <syntaxhighlight lang="lua"> bool removeBan ( ban theBan, [ player responsibleElement ] ) </c...)
 
(Admin rights required.)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
This function will remove a ban specified by the [[ban]] element.
This function will remove a specific [[ban]].
{{note| Don't forget to give admin rights to the resource, in which you are using removeBan function or it won't work.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool removeBan ( ban theBan, [ player responsibleElement ] )
bool removeBan ( ban theBan [, player responsibleElement = nil ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[ban]]:remove}}


===Required Arguments===  
===Required Arguments===  
*'''theBan:''' The [[ban]] element to be removed.
*'''theBan:''' The [[ban]] to be removed.


===Optional Arguments===  
===Optional Arguments===  
Line 19: Line 22:


==Example==
==Example==
This example removes all the bans when the resource is started and outputs to everyone the players.
<syntaxhighlight lang="lua">addEventHandler("onResourceStart",resourceRoot,function()
bans = getBans()
for i,d in ipairs(bans)do
nick = getBanNick(d)
if(removeBan(d))then
outputChatBox(nick.."has been removed from ban",root)
end
end
end)
</syntaxhighlight>
This example removes the ban for IP 1.2.3.4
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
for _,ban in ipairs(getBans())do
    if getBanIP(ban) == "1.2.3.4" then
        removeBan(ban)
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Admin functions}}
{{Admin functions}}
[[ru:removeBan]]

Latest revision as of 17:09, 6 December 2023

This function will remove a specific ban.

[[{{{image}}}|link=|]] Note: Don't forget to give admin rights to the resource, in which you are using removeBan function or it won't work.

Syntax

bool removeBan ( ban theBan [, player responsibleElement = nil ] )


OOP Syntax Help! I don't understand this!

Method: ban:remove(...)


Required Arguments

  • theBan: The ban to be removed.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • responsibleElement: The element that is responsible for removing the ban element. This can be a player or the root (getRootElement()).

Returns

Returns true if the ban was removed succesfully, false if invalid arguments are specified.

Example

This example removes all the bans when the resource is started and outputs to everyone the players.

addEventHandler("onResourceStart",resourceRoot,function()
	bans = getBans()
	for i,d in ipairs(bans)do
		nick = getBanNick(d)
		if(removeBan(d))then
			outputChatBox(nick.."has been removed from ban",root)
		end
	end
end)

This example removes the ban for IP 1.2.3.4

for _,ban in ipairs(getBans())do
    if getBanIP(ban) == "1.2.3.4" then
        removeBan(ban)
    end
end

See Also