load client and server commands dynamically (issue #51)

This commit is contained in:
Timo Smit 2016-02-18 19:42:17 +01:00
parent f883b92292
commit ae8ae5a417
26 changed files with 123 additions and 80 deletions

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local balancer = require "luascripts.wolfadmin.admin.balancer" local balancer = require "luascripts.wolfadmin.admin.balancer"
function commandBalance(clientId, cmdArguments) function commandBalance(clientId, cmdArguments)
@ -23,4 +23,4 @@ function commandBalance(clientId, cmdArguments)
return true return true
end end
commands.register("balance", commandBalance, "p", "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^hforce^9)") commands.addadmin("balance", commandBalance, "p", "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^hforce^9)")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local warns = require "luascripts.wolfadmin.admin.warns" local warns = require "luascripts.wolfadmin.admin.warns"
function commandRemoveWarn(clientId, cmdArguments) function commandRemoveWarn(clientId, cmdArguments)
@ -25,7 +25,7 @@ function commandRemoveWarn(clientId, cmdArguments)
return true return true
elseif #cmdArguments < 2 or tonumber(cmdArguments[2]) == nil then elseif #cmdArguments < 2 or tonumber(cmdArguments[2]) == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn usage: "..commands.get("dewarn")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^ddewarn usage: "..commands.getadmin("dewarn")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -56,4 +56,4 @@ function commandRemoveWarn(clientId, cmdArguments)
return true return true
end end
commands.register("dewarn", commandRemoveWarn, "R", "remove a warning for a certain player", "^9[^3name|slot#^9] ^9[^3warn#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end) commands.addadmin("dewarn", commandRemoveWarn, "R", "remove a warning for a certain player", "^9[^3name|slot#^9] ^9[^3warn#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end)

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local voting = require "luascripts.wolfadmin.game.voting" local voting = require "luascripts.wolfadmin.game.voting"
function commandEnableVote(clientId, cmdArguments) function commandEnableVote(clientId, cmdArguments)
@ -25,4 +25,4 @@ function commandEnableVote(clientId, cmdArguments)
return true return true
end end
commands.register("enablevote", commandEnableVote, "c", "enables next map voting") commands.addadmin("enablevote", commandEnableVote, "c", "enables next map voting")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local greetings = require "luascripts.wolfadmin.players.greetings" local greetings = require "luascripts.wolfadmin.players.greetings"
@ -29,4 +29,4 @@ function commandGreeting(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgreeting: ^9you do not have a personal greeting.\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgreeting: ^9you do not have a personal greeting.\";")
end end
end end
commands.register("greeting", commandGreeting, "Q", "display your personal greeting, if you have one") commands.addadmin("greeting", commandGreeting, "Q", "display your personal greeting, if you have one")

View file

@ -15,10 +15,10 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
function commandHelp(clientId, cmdArguments) function commandHelp(clientId, cmdArguments)
local cmds = commands.get() local cmds = commands.getadmin()
if #cmdArguments == 0 then if #cmdArguments == 0 then
local availableCommands = {} local availableCommands = {}
@ -66,4 +66,4 @@ function commandHelp(clientId, cmdArguments)
return false return false
end end
commands.register("help", commandHelp, "h", "display commands available to you or help on a specific command", "^9(^hcommand^9)", true) commands.addadmin("help", commandHelp, "h", "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats" local stats = require "luascripts.wolfadmin.players.stats"
function commandIncognito(clientId, cmdArguments) function commandIncognito(clientId, cmdArguments)
@ -74,4 +74,4 @@ function commandIncognito(clientId, cmdArguments)
return true return true
end end
commands.register("incognito", commandIncognito, "s", "fakes your level to guest (no aka)") commands.addadmin("incognito", commandIncognito, "s", "fakes your level to guest (no aka)")

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local bots = require "luascripts.wolfadmin.game.bots" local bots = require "luascripts.wolfadmin.game.bots"
function commandBotsOff(clientId, cmdArguments) function commandBotsOff(clientId, cmdArguments)
@ -25,4 +25,4 @@ function commandBotsOff(clientId, cmdArguments)
return true return true
end end
commands.register("kickbots", commandBotsOff, "O", "kicks all bots from the game") commands.addadmin("kickbots", commandBotsOff, "O", "kicks all bots from the game")

View file

@ -18,7 +18,7 @@
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local db = require "luascripts.wolfadmin.db.db" local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats" local stats = require "luascripts.wolfadmin.players.stats"
function commandListAliases(clientId, cmdArguments) function commandListAliases(clientId, cmdArguments)
@ -27,7 +27,7 @@ function commandListAliases(clientId, cmdArguments)
return true return true
elseif cmdArguments[1] == nil then elseif cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases usage: "..commands.get("listaliases")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases usage: "..commands.getadmin("listaliases")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -71,4 +71,4 @@ function commandListAliases(clientId, cmdArguments)
return true return true
end end
commands.register("listaliases", commandListAliases, "f", "display all known aliases for a player", "^9[^3name|slot#^9]", function() return (settings.get("db_type") == "cfg") end) commands.addadmin("listaliases", commandListAliases, "f", "display all known aliases for a player", "^9[^3name|slot#^9]", function() return (settings.get("db_type") == "cfg") end)

View file

@ -18,7 +18,7 @@
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local db = require "luascripts.wolfadmin.db.db" local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats" local stats = require "luascripts.wolfadmin.players.stats"
function commandListLevels(clientId, cmdArguments) function commandListLevels(clientId, cmdArguments)
@ -88,4 +88,4 @@ function commandListLevels(clientId, cmdArguments)
return true return true
end end
commands.register("listlevels", commandListLevels, "s", "display all levels on the server") commands.addadmin("listlevels", commandListLevels, "s", "display all levels on the server")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local game = require "luascripts.wolfadmin.game.game" local game = require "luascripts.wolfadmin.game.game"
function commandListMaps(clientId, cmdArguments) function commandListMaps(clientId, cmdArguments)
@ -35,4 +35,4 @@ function commandListMaps(clientId, cmdArguments)
return true return true
end end
commands.register("listmaps", commandListMaps, "C", "display the maps in the rotation") commands.addadmin("listmaps", commandListMaps, "C", "display the maps in the rotation")

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local bots = require "luascripts.wolfadmin.game.bots" local bots = require "luascripts.wolfadmin.game.bots"
function commandBotsOn(clientId, cmdArguments) function commandBotsOn(clientId, cmdArguments)
@ -25,4 +25,4 @@ function commandBotsOn(clientId, cmdArguments)
return true return true
end end
commands.register("needbots", commandBotsOn, "O", "adds bots to the game") commands.addadmin("needbots", commandBotsOn, "O", "adds bots to the game")

View file

@ -16,13 +16,13 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin" local admin = require "luascripts.wolfadmin.admin.admin"
local stats = require "luascripts.wolfadmin.players.stats" local stats = require "luascripts.wolfadmin.players.stats"
function commandPlayerLock(clientId, cmdArguments) function commandPlayerLock(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock usage: "..commands.get("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -61,4 +61,4 @@ function commandPlayerLock(clientId, cmdArguments)
return true return true
end end
commands.register("plock", commandPlayerLock, "K", "locks a player to a specific team", "^9[^3name|slot#^9]") commands.addadmin("plock", commandPlayerLock, "K", "locks a player to a specific team", "^9[^3name|slot#^9]")

View file

@ -16,13 +16,13 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin" local admin = require "luascripts.wolfadmin.admin.admin"
local stats = require "luascripts.wolfadmin.players.stats" local stats = require "luascripts.wolfadmin.players.stats"
function commandPlayerUnlock(clientId, cmdArguments) function commandPlayerUnlock(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock usage: "..commands.get("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpunlock usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -53,4 +53,4 @@ function commandPlayerUnlock(clientId, cmdArguments)
return true return true
end end
commands.register("punlock", commandPlayerUnlock, "K", "unlocks a player", "^9[^3name|slot#^9]") commands.addadmin("punlock", commandPlayerUnlock, "K", "unlocks a player", "^9[^3name|slot#^9]")

View file

@ -17,12 +17,12 @@
local constants = require "luascripts.wolfadmin.util.constants" local constants = require "luascripts.wolfadmin.util.constants"
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local bots = require "luascripts.wolfadmin.game.bots" local bots = require "luascripts.wolfadmin.game.bots"
function commandPutBots(clientId, cmdArguments) function commandPutBots(clientId, cmdArguments)
if cmdArguments[1] == nil and cmdArguments[1] ~= constants.TEAM_AXIS_SC and cmdArguments[1] ~= constants.TEAM_ALLIES_SC and cmdArguments[1] ~= constants.TEAM_SPECTATORS_SC then if cmdArguments[1] == nil and cmdArguments[1] ~= constants.TEAM_AXIS_SC and cmdArguments[1] ~= constants.TEAM_ALLIES_SC and cmdArguments[1] ~= constants.TEAM_SPECTATORS_SC then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dputbots usage: "..commands.get("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dputbots usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true return true
end end
@ -44,4 +44,4 @@ function commandPutBots(clientId, cmdArguments)
return true return true
end end
commands.register("putbots", commandPutBots, "p", "puts all bots into a specific team", "^9[r|b|s]") commands.addadmin("putbots", commandPutBots, "p", "puts all bots into a specific team", "^9[r|b|s]")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local rules = require "luascripts.wolfadmin.admin.rules" local rules = require "luascripts.wolfadmin.admin.rules"
local greetings = require "luascripts.wolfadmin.players.greetings" local greetings = require "luascripts.wolfadmin.players.greetings"
@ -29,4 +29,4 @@ function commandReadconfig(clientId, cmdArguments)
return false return false
end end
commands.register("readconfig", commandReadconfig, "G", "reloads the shrubbot config file and refreshes user flags", nil, true) commands.addadmin("readconfig", commandReadconfig, "G", "reloads the shrubbot config file and refreshes user flags", nil, true)

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local game = require "luascripts.wolfadmin.game.game" local game = require "luascripts.wolfadmin.game.game"
local sprees = require "luascripts.wolfadmin.game.sprees" local sprees = require "luascripts.wolfadmin.game.sprees"
@ -32,4 +32,4 @@ function commandResetSprees(clientId, cmdArguments)
return true return true
end end
commands.register("resetsprees", commandResetSprees, "G", "resets the spree records") commands.addadmin("resetsprees", commandResetSprees, "G", "resets the spree records")

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local rules = require "luascripts.wolfadmin.admin.rules" local rules = require "luascripts.wolfadmin.admin.rules"
function commandRules(clientId, cmdArguments) function commandRules(clientId, cmdArguments)
@ -42,4 +42,4 @@ function commandRules(clientId, cmdArguments)
return true return true
end end
commands.register("rules", commandRules, "C", "display the rules on the server", "^9(^hrule^9)") commands.addadmin("rules", commandRules, "C", "display the rules on the server", "^9(^hrule^9)")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin" local admin = require "luascripts.wolfadmin.admin.admin"
function commandSetLevel(clientId, cmdArguments) function commandSetLevel(clientId, cmdArguments)
@ -45,4 +45,4 @@ function commandSetLevel(clientId, cmdArguments)
return false return false
end end
commands.register("setlevel", commandSetLevel, "s", "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true) commands.addadmin("setlevel", commandSetLevel, "s", "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true)

View file

@ -19,7 +19,7 @@ local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local db = require "luascripts.wolfadmin.db.db" local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local warns = require "luascripts.wolfadmin.admin.warns" local warns = require "luascripts.wolfadmin.admin.warns"
function commandShowWarns(clientId, cmdArguments) function commandShowWarns(clientId, cmdArguments)
@ -28,7 +28,7 @@ function commandShowWarns(clientId, cmdArguments)
return true return true
elseif cmdArguments[1] == nil then elseif cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns usage: "..commands.get("showwarns")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshowwarns usage: "..commands.getadmin("showwarns")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -62,4 +62,4 @@ function commandShowWarns(clientId, cmdArguments)
return true return true
end end
commands.register("showwarns", commandShowWarns, "R", "display warnings for a specific player", "^9[^3name|slot#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end) commands.addadmin("showwarns", commandShowWarns, "R", "display warnings for a specific player", "^9[^3name|slot#^9]", function() return (settings.get("g_warnHistory") == 0 or settings.get("db_type") == "cfg") end)

View file

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local sprees = require "luascripts.wolfadmin.game.sprees" local sprees = require "luascripts.wolfadmin.game.sprees"
function commandShowSprees(clientId, cmdArguments) function commandShowSprees(clientId, cmdArguments)
@ -37,4 +37,4 @@ function commandShowSprees(clientId, cmdArguments)
return true return true
end end
commands.register("sprees", commandShowSprees, "I", "display the current spree records") commands.addadmin("sprees", commandShowSprees, "I", "display the current spree records")

View file

@ -16,11 +16,11 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
function commandShowStats(clientId, cmdArguments) function commandShowStats(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.get("stats")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.getadmin("stats")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -94,4 +94,4 @@ function commandShowStats(clientId, cmdArguments)
return true return true
end end
commands.register("stats", commandShowStats, "I", "display the statistics for a specific player", "^9[^3name|slot#^9]") commands.addadmin("stats", commandShowStats, "I", "display the statistics for a specific player", "^9[^3name|slot#^9]")

View file

@ -16,12 +16,12 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util" local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin" local admin = require "luascripts.wolfadmin.admin.admin"
function commandVoiceMute(clientId, cmdArguments) function commandVoiceMute(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.get("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -50,7 +50,7 @@ function commandVoiceMute(clientId, cmdArguments)
elseif cmdArguments[2] then elseif cmdArguments[2] then
vmuteReason = table.concat(cmdArguments, " ", 2) vmuteReason = table.concat(cmdArguments, " ", 2)
elseif et.G_shrubbot_permission(clientId, "8") ~= 1 then elseif et.G_shrubbot_permission(clientId, "8") ~= 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.get("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true return true
end end
@ -75,4 +75,4 @@ function commandVoiceMute(clientId, cmdArguments)
return true return true
end end
commands.register("vmute", commandVoiceMute, "m", "voicemutes a player", "^9[^3name|slot#^9]") commands.addadmin("vmute", commandVoiceMute, "m", "voicemutes a player", "^9[^3name|slot#^9]")

View file

@ -15,12 +15,12 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin" local admin = require "luascripts.wolfadmin.admin.admin"
function commandVoiceUnmute(clientId, cmdArguments) function commandVoiceUnmute(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvunmute usage: "..commands.get("vunmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvunmute usage: "..commands.getadmin("vunmute")["syntax"].."\";")
return true return true
elseif tonumber(cmdArguments[1]) == nil then elseif tonumber(cmdArguments[1]) == nil then
@ -51,4 +51,4 @@ function commandVoiceUnmute(clientId, cmdArguments)
return true return true
end end
commands.register("vunmute", commandVoiceUnmute, "m", "unvoicemutes a player", "^9[^3name|slot#^9]") commands.addadmin("vunmute", commandVoiceUnmute, "m", "unvoicemutes a player", "^9[^3name|slot#^9]")

View file

@ -16,7 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local settings = require "luascripts.wolfadmin.util.settings" local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local warns = require "luascripts.wolfadmin.admin.warns" local warns = require "luascripts.wolfadmin.admin.warns"
function commandAddWarn(clientId, cmdArguments) function commandAddWarn(clientId, cmdArguments)
@ -40,4 +40,4 @@ function commandAddWarn(clientId, cmdArguments)
return false return false
end end
commands.register("warn", commandAddWarn, "R", "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true) commands.addadmin("warn", commandAddWarn, "R", "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true)

View file

@ -26,18 +26,50 @@ local stats = require "luascripts.wolfadmin.players.stats"
local commands = {} local commands = {}
-- available shrubflags: lqyFHY -- available shrubflags: lqyFHY
local data = {} local clientcmds = {}
local servercmds = {}
local admincmds = {}
function commands.get(command) function commands.getclient(command)
if command then if command then
return data[command] return clientcmds[command]
end end
return data return clientcmds
end end
function commands.register(command, func, flag, help, syntax, hidden) function commands.getserver(command)
data[command] = { if command then
return servercmds[command]
end
return servercmds
end
function commands.getadmin(command)
if command then
return admincmds[command]
end
return admincmds
end
function commands.addclient(command, func, flag, syntax)
clientcmds[command] = {
["function"] = func,
["flag"] = flag,
["syntax"] = "^2!"..command..(syntax and " "..syntax or ""),
}
end
function commands.addserver(command, func)
servercmds[command] = {
["function"] = func,
}
end
function commands.addadmin(command, func, flag, help, syntax, hidden)
admincmds[command] = {
["function"] = func, ["function"] = func,
["flag"] = flag, ["flag"] = flag,
["help"] = help or "N/A", ["help"] = help or "N/A",
@ -46,24 +78,35 @@ function commands.register(command, func, flag, help, syntax, hidden)
} }
end end
function commands.load() function commands.loadfiles(dir)
local functionStart = et.trap_Milliseconds()
local files = files.ls("commands/")
local amount = 0 local amount = 0
local files = files.ls("commands/"..dir.."/")
for _, file in pairs(files) do for _, file in pairs(files) do
if string.match(string.lower(file), "^[a-z]+%.lua$") then if string.match(string.lower(file), "^[a-z]+%.lua$") then
require("luascripts/wolfadmin/commands/"..string.sub(file, 1, string.len(file) - 4)) require("luascripts/wolfadmin/commands/"..dir.."/"..string.sub(file, 1, string.len(file) - 4))
amount = amount + 1 amount = amount + 1
end end
end end
outputDebug("commands.load(): "..amount.." entries loaded in "..et.trap_Milliseconds() - functionStart.." ms")
return amount return amount
end end
function commands.load()
local functionStart = et.trap_Milliseconds()
local clientAmount = commands.loadfiles("client")
local serverAmount = commands.loadfiles("server")
local adminAmount = commands.loadfiles("admin")
local totalAmount = clientAmount + serverAmount + adminAmount
outputDebug("commands.load(): "..totalAmount.." entries loaded in "..et.trap_Milliseconds() - functionStart.." ms")
return totalAmount
end
function commands.log(clientId, command, cmdArguments) function commands.log(clientId, command, cmdArguments)
local functionStart = et.trap_Milliseconds() local functionStart = et.trap_Milliseconds()
local fileDescriptor = files.open(et.trap_Cvar_Get("g_logAdmin"), et.FS_APPEND) local fileDescriptor = files.open(et.trap_Cvar_Get("g_logAdmin"), et.FS_APPEND)
@ -168,14 +211,14 @@ function commands.onservercommand(cmdText)
shrubCmd = string.lower(string.sub(cmdText, 2, string.len(cmdText))) shrubCmd = string.lower(string.sub(cmdText, 2, string.len(cmdText)))
end end
if data[shrubCmd] and data[shrubCmd]["function"] and data[shrubCmd]["flag"] then if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then
for i = 1, et.trap_Argc() - shrubArgumentsOffset do for i = 1, et.trap_Argc() - shrubArgumentsOffset do
shrubArguments[i] = et.trap_Argv(i + shrubArgumentsOffset - 1) shrubArguments[i] = et.trap_Argv(i + shrubArgumentsOffset - 1)
end end
data[shrubCmd]["function"](-1337, shrubArguments) admincmds[shrubCmd]["function"](-1337, shrubArguments)
if not data[shrubCmd]["hidden"] then if not admincmds[shrubCmd]["hidden"] then
commands.log(-1, shrubCmd, shrubArguments) commands.log(-1, shrubCmd, shrubArguments)
end end
end end
@ -326,12 +369,12 @@ function commands.onclientcommand(clientId, cmdText)
if shrubCmd then if shrubCmd then
shrubCmd = string.lower(shrubCmd) shrubCmd = string.lower(shrubCmd)
if data[shrubCmd] and data[shrubCmd]["function"] and data[shrubCmd]["flag"] then if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then
if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and et.G_shrubbot_permission(clientId, "9") == 1) or (wolfCmd == "!"..shrubCmd and et.G_shrubbot_permission(clientId, "3") == 1) then if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and et.G_shrubbot_permission(clientId, "9") == 1) or (wolfCmd == "!"..shrubCmd and et.G_shrubbot_permission(clientId, "3") == 1) then
if data[shrubCmd]["flag"] ~= "" and et.G_shrubbot_permission(clientId, data[shrubCmd]["flag"]) == 1 then if admincmds[shrubCmd]["flag"] ~= "" and et.G_shrubbot_permission(clientId, admincmds[shrubCmd]["flag"]) == 1 then
local isFinished = data[shrubCmd]["function"](clientId, shrubArguments) local isFinished = admincmds[shrubCmd]["function"](clientId, shrubArguments)
if not data[shrubCmd]["hidden"] then if not admincmds[shrubCmd]["hidden"] then
commands.log(clientId, shrubCmd, shrubArguments) commands.log(clientId, shrubCmd, shrubArguments)
end end

View file

@ -30,7 +30,7 @@ local balancer = require "luascripts.wolfadmin.admin.balancer"
local rules = require "luascripts.wolfadmin.admin.rules" local rules = require "luascripts.wolfadmin.admin.rules"
local warns = require "luascripts.wolfadmin.admin.warns" local warns = require "luascripts.wolfadmin.admin.warns"
local commands = require "luascripts.wolfadmin.commands" local commands = require "luascripts.wolfadmin.commands.commands"
local game = require "luascripts.wolfadmin.game.game" local game = require "luascripts.wolfadmin.game.game"
local bots = require "luascripts.wolfadmin.game.bots" local bots = require "luascripts.wolfadmin.game.bots"