GetBans: Difference between revisions
Jump to navigation
Jump to search
Enterprise (talk | contribs) No edit summary |
(Added an example.) |
||
Line 12: | Line 12: | ||
==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. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function listBans () | ||
local bansList = getBans() -- Return a table of all the bans. | |||
local banID = 0 -- Set "banID" to 0. | |||
for k, ban in ipairs ( banList ) do -- For every ban do the following... | |||
banID = banID + 1 -- Each ban has a uniuqe ID. | |||
outputChatBox ( "Ban #" .. banID .. ": " .. ban .. "", source, 255, 0, 0 ) -- Output the ban. | |||
end | |||
end | |||
addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Admin functions}} | {{Admin functions}} | ||
[[ru:getBans]] | [[ru:getBans]] |
Revision as of 19:52, 24 February 2010
This function will return a table over all the ban values in the server.
Syntax
table getBans ()
Returns
Returns a table over all the ban pointers.
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. local banID = 0 -- Set "banID" to 0. for k, ban in ipairs ( banList ) do -- For every ban do the following... banID = banID + 1 -- Each ban has a uniuqe ID. outputChatBox ( "Ban #" .. banID .. ": " .. ban .. "", source, 255, 0, 0 ) -- Output the ban. end end addCommandHandler ( "bans", listBans ) -- Add "/bans" as the trigger for the function.