GetBans: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 13: | Line 13: | ||
==Example== | ==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. | 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="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function listBans () | 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... | for banID, ban in ipairs ( banList ) do -- For every ban do the following... | ||
-- | |||
local nick = getBanNick ( ban ) -- Get the IP of the ban | local nick = getBanNick ( ban ) -- Get the IP of the ban | ||
-- | |||
if nick then | if nick then | ||
outputChatBox ( "Ban #" .. banID .. ": " .. nick, | outputChatBox ( "Ban #" .. banID .. ": " .. nick, playerSource , 255, 0, 0 ) -- Output the ban. | ||
end | end | ||
-- | |||
end | end | ||
-- | |||
end | end | ||
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function. | addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Admin functions}} | {{Admin functions}} | ||
[[ru:getBans]] | [[ru:getBans]] |
Revision as of 06:35, 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
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.
Click to collapse [-]
Serverfunction 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.