GetBans: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 12: Line 12:


==Example==
==Example==
'''Example 1:''' This example lists every ban when somebody types "/bans". WARNING: This will spam chat (for the player that executed the command) if the server has a lot of bans.
<section name="Example 1: Server" class="server" show="true">
This example lists every ban when somebody types "/bans". WARNING: This will spam chat (for the player that executed the command) if the server has a lot of bans.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function listBans ( playerSource )
function listBans ( playerSource )
Line 30: Line 31:
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.
</syntaxhighlight>
</syntaxhighlight>
==See Also==
==See Also==
{{Admin functions}}
{{Admin functions}}
[[ru:getBans]]
[[ru:getBans]]

Revision as of 01:00, 6 January 2015

This function will return a table over all the ban values in the server.

Syntax

table getBans ()

Returns

Returns a table of all the bans.

Example

<section name="Example 1: Server" class="server" show="true"> This example lists every ban when somebody types "/bans". WARNING: This will spam chat (for the player that executed the command) if the server has a lot of bans.

function listBans ( playerSource )
local banList = getBans() -- Return a table of all the bans.
	--
	for banID, ban in ipairs ( banList ) do -- For every ban do the following...	
		--
		local nick = getBanNick ( ban ) -- Get the IP of the ban
		--
		if nick then
			outputChatBox ( "Ban #" .. banID .. ": " .. nick, playerSource , 255, 0, 0, true ) -- Output the ban.
		end
		--
	end
	--
end
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.

See Also