Skip to content

Commit

Permalink
Reworked some commands to disable them when in standalone mode (refs …
Browse files Browse the repository at this point in the history
…#61, #62)
  • Loading branch information
Timo Smit committed Jan 21, 2017
1 parent 7e5c009 commit 9fdd36e
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 42 deletions.
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/admintest.lua
Expand Up @@ -31,4 +31,4 @@ function commandAdminTest(clientId, cmdArguments)

return true
end
commands.addadmin("admintest", commandAdminTest, auth.PERM_ADMINTEST, "display your current admin level", nil, (settings.get("g_standalone") == 0))
commands.addadmin("admintest", commandAdminTest, auth.PERM_ADMINTEST, "display your current admin level", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/ban.lua
Expand Up @@ -78,4 +78,4 @@ function commandBan(clientId, cmdArguments)

return true
end
commands.addadmin("ban", commandBan, auth.PERM_BAN, "ban a player with an optional duration and reason", "^9[^3name|slot#^9] ^9(^3duration^9) ^9(^3reason^9)", (settings.get("g_standalone") == 0))
commands.addadmin("ban", commandBan, auth.PERM_BAN, "ban a player with an optional duration and reason", "^9[^3name|slot#^9] ^9(^3duration^9) ^9(^3reason^9)", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/finger.lua
Expand Up @@ -60,4 +60,4 @@ function commandFinger(clientId, cmdArguments)

return true
end
commands.addadmin("finger", commandFinger, auth.PERM_FINGER, "gives specific information about a player", "^9[^3name|slot#^9]", (settings.get("g_standalone") == 0))
commands.addadmin("finger", commandFinger, auth.PERM_FINGER, "gives specific information about a player", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/gib.lua
Expand Up @@ -63,4 +63,4 @@ function commandGib(clientId, cmdArguments)

return true
end
commands.addadmin("gib", commandGib, auth.PERM_GIB, "insantly gibs a player", "^9(^3name|slot#^9) (^hreason^9)", (settings.get("g_standalone") == 0))
commands.addadmin("gib", commandGib, auth.PERM_GIB, "insantly gibs a player", "^9(^3name|slot#^9) (^hreason^9)", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/help.lua
Expand Up @@ -26,7 +26,7 @@ function commandHelp(clientId, cmdArguments)
local availableCommands = {}

for command, data in pairs(cmds) do
if data["function"] and data["flag"] and auth.isPlayerAllowed(clientId, data["flag"]) and (not data["hidden"] or (type(data["hidden"]) == "function" and not data["hidden"]())) then
if data["function"] and data["flag"] and auth.isPlayerAllowed(clientId, data["flag"]) and not data["hidden"] then
table.insert(availableCommands, command)
end
end
Expand Down
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/kick.lua
Expand Up @@ -62,4 +62,4 @@ function commandKick(clientId, cmdArguments)

return true
end
commands.addadmin("kick", commandKick, auth.PERM_KICK, "kick a player with an optional reason", "^9[^3name|slot#^9] ^9(^3reason^9)", (settings.get("g_standalone") == 0))
commands.addadmin("kick", commandKick, auth.PERM_KICK, "kick a player with an optional reason", "^9[^3name|slot#^9] ^9(^3reason^9)", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/listaliases.lua
Expand Up @@ -81,4 +81,4 @@ function commandListAliases(clientId, cmdArguments)

return true
end
commands.addadmin("listaliases", commandListAliases, auth.PERM_FINGER, "display all known aliases for a player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (not db.isconnected()) end)
commands.addadmin("listaliases", commandListAliases, auth.PERM_LISTALIASES, "display all known aliases for a player", "^9[^3name|slot#^9] ^9(^hoffset^9)")
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/listplayers.lua
Expand Up @@ -85,4 +85,4 @@ function commandListPlayers(clientId, cmdArguments)

return true
end
commands.addadmin("listplayers", commandListPlayers, auth.PERM_LISTPLAYERS, "display a list of connected players, their slot numbers as well as their admin levels", nil, (settings.get("g_standalone") == 0))
commands.addadmin("listplayers", commandListPlayers, auth.PERM_LISTPLAYERS, "display a list of connected players, their slot numbers as well as their admin levels", nil, nil, (settings.get("g_standalone") == 0))
4 changes: 2 additions & 2 deletions luamods/wolfadmin/commands/admin/lock.lua
Expand Up @@ -42,7 +42,7 @@ function commandLock(clientId, cmdArguments)

return false
end
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true)
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") == 1))

function commandLock(clientId, cmdArguments)
if cmdArguments[1] == nil or (cmdArguments[1] ~= constants.TEAM_AXIS_SC and cmdArguments[1] ~= constants.TEAM_ALLIES_SC and cmdArguments[1] ~= constants.TEAM_SPECTATORS_SC and cmdArguments[1] ~= "all") then
Expand All @@ -68,4 +68,4 @@ function commandLock(clientId, cmdArguments)

return false
end
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", (settings.get("g_standalone") == 0))
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/mute.lua
Expand Up @@ -85,4 +85,4 @@ function commandMute(clientId, cmdArguments)

return true
end
commands.addadmin("mute", commandMute, auth.PERM_MUTE, "voicemutes a player", "^9[^3name|slot#^9]", (settings.get("g_standalone") == 0))
commands.addadmin("mute", commandMute, auth.PERM_MUTE, "voicemutes a player", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/nextmap.lua
Expand Up @@ -26,4 +26,4 @@ function commandNextMap(clientId, cmdArguments)

return true
end
commands.addadmin("nextmap", commandNextMap, auth.PERM_NEXTMAP, "loads the next map", nil, (settings.get("g_standalone") == 0))
commands.addadmin("nextmap", commandNextMap, auth.PERM_NEXTMAP, "loads the next map", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/pause.lua
Expand Up @@ -27,4 +27,4 @@ function commandPause(clientId, cmdArguments)

return true
end
commands.addadmin("pause", commandPause, auth.PERM_RESTART, "pauses the game for all players", nil, (settings.get("g_standalone") == 0))
commands.addadmin("pause", commandPause, auth.PERM_RESTART, "pauses the game for all players", nil, nil, (settings.get("g_standalone") == 0))
8 changes: 6 additions & 2 deletions luamods/wolfadmin/commands/admin/put.lua
Expand Up @@ -16,10 +16,14 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

local admin = require (wolfa_getLuaPath()..".admin.admin")

local auth = require (wolfa_getLuaPath()..".auth.auth")

local commands = require (wolfa_getLuaPath()..".commands.commands")
local constants = require (wolfa_getLuaPath()..".util.constants")

local util = require (wolfa_getLuaPath()..".util.util")
local constants = require (wolfa_getLuaPath()..".util.constants")
local settings = require (wolfa_getLuaPath()..".util.settings")

function commandPlayerLock(clientId, cmdArguments)
if cmdArguments[2] == nil or (cmdArguments[2] ~= constants.TEAM_AXIS_SC and cmdArguments[2] ~= constants.TEAM_ALLIES_SC and cmdArguments[2] ~= constants.TEAM_SPECTATORS_SC) then
Expand Down Expand Up @@ -70,4 +74,4 @@ function commandPlayerLock(clientId, cmdArguments)

return true
end
commands.addadmin("put", commandPlayerLock, auth.PERM_LOCKPLAYER, "locks a player to a specific team", "^9[^3name|slot#^9]")
commands.addadmin("put", commandPlayerLock, auth.PERM_PUT, "locks a player to a specific team", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/readconfig.lua
Expand Up @@ -30,4 +30,4 @@ function commandReadconfig(clientId, cmdArguments)

return false
end
commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true)
commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true, (settings.get("g_standalone") == 1))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/reset.lua
Expand Up @@ -26,4 +26,4 @@ function commandReset(clientId, cmdArguments)

return true
end
commands.addadmin("reset", commandReset, auth.PERM_RESTART, "resets the current match", nil, (settings.get("g_standalone") == 0))
commands.addadmin("reset", commandReset, auth.PERM_RESTART, "resets the current match", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/restart.lua
Expand Up @@ -34,4 +34,4 @@ function commandRestart(clientId, cmdArguments)

return true
end
commands.addadmin("restart", commandRestart, auth.PERM_RESTART, "restarts the current map", nil, (settings.get("g_standalone") == 0))
commands.addadmin("restart", commandRestart, auth.PERM_RESTART, "restarts the current map", nil, nil, (settings.get("g_standalone") == 0))
4 changes: 2 additions & 2 deletions luamods/wolfadmin/commands/admin/setlevel.lua
Expand Up @@ -42,7 +42,7 @@ function commandSetLevel(clientId, cmdArguments)

return false
end
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", (settings.get("g_standalone") == 0 and db.isconnected()))
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true, (settings.get("g_standalone") == 1))

function commandSetLevel(clientId, cmdArguments)
if cmdArguments[1] == nil then
Expand Down Expand Up @@ -83,4 +83,4 @@ function commandSetLevel(clientId, cmdArguments)

return false
end
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", (settings.get("g_standalone") == 0 and db.isconnected()))
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/showbans.lua
Expand Up @@ -52,4 +52,4 @@ function commandShowBans(clientId, cmdArguments)

return true
end
commands.addadmin("showbans", commandShowBans, auth.PERM_LISTBANS, "display a (partial) list of active bans", "(^hstart at ban#^9) ((^hbanner^9) (^3banner's name^9)) ((^3find^9) (^hbanned player^9)) ((^3reason^9) (^hreason for ban^9))", function() return (not db.isconnected()) end)
commands.addadmin("showbans", commandShowBans, auth.PERM_LISTBANS, "display a (partial) list of active bans", "(^hstart at ban#^9) ((^hbanner^9) (^3banner's name^9)) ((^3find^9) (^hbanned player^9)) ((^3reason^9) (^hreason for ban^9))", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/showhistory.lua
Expand Up @@ -70,4 +70,4 @@ function commandListHistory(clientId, cmdArguments)

return true
end
commands.addadmin("showhistory", commandListHistory, auth.PERM_LISTHISTORY, "display history for a specific player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (settings.get("g_standalone") == 0 or not db.isconnected()) end)
commands.addadmin("showhistory", commandListHistory, auth.PERM_LISTHISTORY, "display history for a specific player", "^9[^3name|slot#^9] ^9(^hoffset^9)", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/shuffle.lua
Expand Up @@ -26,4 +26,4 @@ function commandShuffle(clientId, cmdArguments)

return true
end
commands.addadmin("shuffle", commandShuffle, auth.PERM_SHUFFLE, "shuffle the teams to try and even them", nil, (settings.get("g_standalone") == 0))
commands.addadmin("shuffle", commandShuffle, auth.PERM_SHUFFLE, "shuffle the teams to try and even them", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/slap.lua
Expand Up @@ -66,4 +66,4 @@ function commandSlap(clientId, cmdArguments)

return true
end
commands.addadmin("slap", commandSlap, auth.PERM_SLAP, "give a player a specified amount of damage for a specified reason", "^9[^3name|slot#^9] (^hdamage^9) (^hreason^9)", (settings.get("g_standalone") == 0))
commands.addadmin("slap", commandSlap, auth.PERM_SLAP, "give a player a specified amount of damage for a specified reason", "^9[^3name|slot#^9] (^hdamage^9) (^hreason^9)", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/swap.lua
Expand Up @@ -26,4 +26,4 @@ function commandSwap(clientId, cmdArguments)

return true
end
commands.addadmin("swap", commandSwap, auth.PERM_SWAP, "swap teams", nil, (settings.get("g_standalone") == 0))
commands.addadmin("swap", commandSwap, auth.PERM_SWAP, "swap teams", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/time.lua
Expand Up @@ -24,4 +24,4 @@ function commandTime(clientId, cmdArguments)

return true
end
commands.addadmin("time", commandTime, auth.PERM_TIME, "displays the local time", nil, (settings.get("g_standalone") == 0))
commands.addadmin("time", commandTime, auth.PERM_TIME, "displays the local time", nil, nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/unban.lua
Expand Up @@ -48,4 +48,4 @@ function commandRemoveBan(clientId, cmdArguments)

return true
end
commands.addadmin("unban", commandRemoveBan, auth.PERM_BAN, "unbans a player specified ban number as seen in ^2!showbans^9", "^9[^3ban#^9]", function() return (settings.get("g_standalone") == 0 or not db.isconnected()) end)
commands.addadmin("unban", commandRemoveBan, auth.PERM_BAN, "unbans a player specified ban number as seen in ^2!showbans^9", "^9[^3ban#^9]", nil, (settings.get("g_standalone") == 0))
4 changes: 2 additions & 2 deletions luamods/wolfadmin/commands/admin/unlock.lua
Expand Up @@ -42,7 +42,7 @@ function commandUnlock(clientId, cmdArguments)

return false
end
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true)
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") == 1))

function commandUnlock(clientId, cmdArguments)
if cmdArguments[1] == nil or (cmdArguments[1] ~= constants.TEAM_AXIS_SC and cmdArguments[1] ~= constants.TEAM_ALLIES_SC and cmdArguments[1] ~= constants.TEAM_SPECTATORS_SC and cmdArguments[1] ~= "all") then
Expand All @@ -68,4 +68,4 @@ function commandUnlock(clientId, cmdArguments)

return false
end
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", (settings.get("g_standalone") == 0))
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/unmute.lua
Expand Up @@ -58,4 +58,4 @@ function commandUnmute(clientId, cmdArguments)

return true
end
commands.addadmin("unmute", commandUnmute, auth.PERM_MUTE, "unvoicemutes a player", "^9[^3name|slot#^9]", (settings.get("g_standalone") == 0))
commands.addadmin("unmute", commandUnmute, auth.PERM_MUTE, "unvoicemutes a player", "^9[^3name|slot#^9]", nil, (settings.get("g_standalone") == 0))
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/admin/unpause.lua
Expand Up @@ -27,4 +27,4 @@ function commandUnpause(clientId, cmdArguments)

return true
end
commands.addadmin("unpause", commandUnpause, auth.PERM_PAUSE, "pauses the game for all players", nil, (settings.get("g_standalone") == 0))
commands.addadmin("unpause", commandUnpause, auth.PERM_PAUSE, "pauses the game for all players", nil, nil, (settings.get("g_standalone") == 0))
4 changes: 2 additions & 2 deletions luamods/wolfadmin/commands/admin/warn.lua
Expand Up @@ -49,7 +49,7 @@ function commandWarn(clientId, cmdArguments)

return false
end
commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true)
commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true, (settings.get("g_standalone") == 1))

function commandWarn(clientId, cmdArguments)
if #cmdArguments < 2 then
Expand Down Expand Up @@ -87,4 +87,4 @@ function commandWarn(clientId, cmdArguments)

return true
end
commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", (settings.get("g_standalone") == 0 and db.isconnected()))
commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", nil, (settings.get("g_standalone") == 0))
8 changes: 4 additions & 4 deletions luamods/wolfadmin/commands/client/say.lua
Expand Up @@ -26,10 +26,10 @@ function commandSay(clientId, cmdArguments)
return true
end
end
commands.addclient("say", commandSay, "", "", false)
commands.addclient("say_team", commandSay, "", "", false)
commands.addclient("say_teamnl", commandSay, "", "", false)
commands.addclient("say_buddy", commandSay, "", "", false)
commands.addclient("say", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_team", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_teamnl", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_buddy", commandSay, "", "", false, (settings.get("g_standalone") == 0))

function commandVoiceSay(clientId, cmdArguments)
if players.isMuted(clientId, players.MUTE_VOICE) then
Expand Down
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/client/team.lua
Expand Up @@ -31,7 +31,7 @@ function commandTeam(clientId, cmdArguments)
end

local team = util.getTeamFromCode(et.trap_Argv(1))
if teams.isLocked(team) then
if settings.get("g_standalone") == 1 and teams.isLocked(team) then
local teamName = util.getTeamName(team)
local teamColor = util.getTeamColor(team)

Expand Down
18 changes: 15 additions & 3 deletions luamods/wolfadmin/commands/commands.lua
Expand Up @@ -58,7 +58,11 @@ function commands.getadmin(command)
return admincmds
end

function commands.addclient(command, func, flag, syntax, chat)
function commands.addclient(command, func, flag, syntax, chat, disabled)
if disabled then
return
end

clientcmds[command] = {
["function"] = func,
["flag"] = flag,
Expand All @@ -67,13 +71,21 @@ function commands.addclient(command, func, flag, syntax, chat)
}
end

function commands.addserver(command, func)
function commands.addserver(command, func, disabled)
if disabled then
return
end

servercmds[command] = {
["function"] = func,
}
end

function commands.addadmin(command, func, flag, help, syntax, hidden)
function commands.addadmin(command, func, flag, help, syntax, hidden, disabled)
if disabled then
return
end

admincmds[command] = {
["function"] = func,
["flag"] = flag,
Expand Down
2 changes: 1 addition & 1 deletion luamods/wolfadmin/commands/server/acl.lua
Expand Up @@ -199,4 +199,4 @@ function commandAcl(cmdArguments)

return true
end
commands.addserver("acl", commandAcl)
commands.addserver("acl", commandAcl, (settings.get("g_standalone") == 0))

0 comments on commit 9fdd36e

Please sign in to comment.