GetBans: Difference between revisions
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 ' nick ' doesn't exist, we will use "N/A" | |||
if not nick then | |||
nick = "N/A" | nick = "N/A" | ||
end | end | ||
-- | -- If ' ip ' doesn't exist, we will use "N/A" | ||
if not ip then -- | |||
ip = "N/A" | ip = "N/A" | ||
end | end | ||
-- | -- If ' serial ' doesn't exist, we will use "N/A" | ||
if not serial then -- | |||
serial = "N/A" | serial = "N/A" | ||
end | end | ||
-- | -- If ' banReason ' doesn't exist, we will use "N/A" | ||
if not banReason then | |||
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. | ||
-- | -- |
Revision as of 15:06, 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 [-]
ServerExample 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