GetBans: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (fix oop) |
||
(One intermediate revision by one other user not shown) | |||
Line 7: | Line 7: | ||
table getBans ( ) | table getBans ( ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[Ban]].getList}} | |||
===Returns=== | ===Returns=== |
Latest revision as of 14:39, 7 August 2016
This function will return a table containing all the bans present in the server's banlist.xml.
Syntax
table getBans ( )
OOP Syntax Help! I don't understand this!
- Method: Ban.getList(...)
Returns
Returns a table containing all the bans.
Example
Click to collapse [-]
Example 1: ServerThis 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.