GetBans: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 65: Line 65:
local banTime = getBanTime( ban )
local banTime = getBanTime( ban )
local banReason = getBanReason ( ban )  
local banReason = getBanReason ( ban )  
--
if not nick then -- if ' nick ' doesn't exist, we will use "N/A"
if not nick then -- if ' nick ' doesn't exist, we will use "N/A"
nick = "N/A"
nick = "N/A"
end
end
--
if not ip then -- if ' ip ' doesn't exist, we will use "N/A"
if not ip then -- if ' ip ' doesn't exist, we will use "N/A"
ip = "N/A"
ip = "N/A"
end
end
--
if not serial then -- if ' serial ' doesn't exist, we will use "N/A"
if not serial then -- if ' serial ' doesn't exist, we will use "N/A"
serial = "N/A"
serial = "N/A"
end
end
--
if not banReason then -- if ' banReason ' doesn't exist, we will use "N/A"
if not banReason then -- if ' banReason ' doesn't exist, we will use "N/A"
banReason = "N/A"
banReason = "N/A"
end
end
--
if nick == iNick or ip == iIp or serial == iSerial then -- If any of our input arguments match any bans.
if nick == iNick or ip == iIp or serial == iSerial then -- If any of our input arguments match any bans.
if tonumber(showOutput) == 1 then -- If we use ' 1 ' in the forth argument, all the data will be output on ONE line.
--
outputChatBox ( "Ban #" .. banID .. " | Nick: " .. nick .. " | IP: " .. ip .. " | Serial: " .. serial .. " | BanTime: " .. banTime .. " | BanReason: " .. banReason, playerSource, 0, 153, 0, true )  
if tonumber(showOutput) == 1 then -- If we use ' 1 ' in the forth argument, all the data will be output on ONE line.
else -- If nothing or anything other than ' 1 ' is used in the forth argument, all the data will be output on seperate lines.
outputChatBox ( "Ban #" .. banID .. " | Nick: " .. nick .. " | IP: " .. ip .. " | Serial: " .. serial .. " | BanTime: " .. banTime .. " | BanReason: " .. banReason, playerSource, 0, 153, 0, true )  
outputChatBox ( "Ban #" .. banID, playerSource, 0, 153, 0, true )
else -- If nothing or anything other than ' 1 ' is used in the forth argument, all the data will be output on seperate lines.
outputChatBox ( "Nick: " .. nick, playerSource, 0, 153, 0, true )
outputChatBox ( "Ban #" .. banID, playerSource, 0, 153, 0, true )
outputChatBox ( "IP: " .. ip, playerSource, 0, 153, 0, true )
outputChatBox ( "Nick: " .. nick, playerSource, 0, 153, 0, true )
outputChatBox ( "Serial: " .. serial, playerSource, 0, 153, 0, true )
outputChatBox ( "IP: " .. ip, playerSource, 0, 153, 0, true )
outputChatBox ( "BanTime: " .. banTime, playerSource, 0, 153, 0, true )
outputChatBox ( "Serial: " .. serial, playerSource, 0, 153, 0, true )
outputChatBox ( "BanReason: " .. banReason, playerSource, 0, 153, 0, true )
outputChatBox ( "BanTime: " .. banTime, playerSource, 0, 153, 0, true )
end
outputChatBox ( "BanReason: " .. banReason, playerSource, 0, 153, 0, true )
end
--
break -- Break the loop when we have found our target.
break -- Break the loop when we have found our target.
--
end
end
--
end
end
--
end
end
addCommandHandler ( "bans", listBans )  
addCommandHandler ( "bans", listBans )  

Revision as of 15:01, 3 December 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

Click to collapse [-]
Server

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.

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 ) -- Output the ban.
		end
		--
	end
	--
end
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.
Click to expand [+]
Server

See Also