Difference between revisions of "GetBans"

From Multi Theft Auto: Wiki
(This has a lot more chance to work)
Line 9: Line 9:
  
 
===Returns===
 
===Returns===
Returns a [[table]] over all the [[ban]] pointers.
+
Returns a [[table]] of all the [[ban]]s.
  
 
==Example==
 
==Example==

Revision as of 10:14, 3 May 2011

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

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 ()
	local bansList = 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, source, 255, 0, 0 ) -- Output the ban.
		end
	end
end
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.

See Also