Fixed checks for punishments without reason and/or time

This commit is contained in:
Timo Smit 2019-01-17 19:16:45 +01:00
parent 14ebac44d9
commit b2b3fae5ce
5 changed files with 31 additions and 17 deletions

View file

@ -32,7 +32,7 @@ function admin.putPlayer(clientId, teamId)
end end
function admin.kickPlayer(victimId, invokerId, reason) function admin.kickPlayer(victimId, invokerId, reason)
et.trap_DropClient(victimId, "You have been kicked, Reason: "..(reason and reason or "kicked by admin"), 0) et.trap_DropClient(victimId, "You have been kicked, Reason: "..reason, 0)
end end
function admin.setPlayerLevel(clientId, level) function admin.setPlayerLevel(clientId, level)

View file

@ -54,14 +54,13 @@ function commandBan(clientId, command, victim, ...)
if args[1] and util.getTimeFromString(args[1]) and args[2] then if args[1] and util.getTimeFromString(args[1]) and args[2] then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = table.concat(args, " ", 2) reason = table.concat(args, " ", 2)
elseif args[1] and util.getTimeFromString(args[1]) then elseif args[1] and util.getTimeFromString(args[1]) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = "banned by admin" reason = "banned by admin"
elseif args[1] then elseif args[1] and not util.getTimeFromString(args[1]) then
duration = 600 duration = 600
reason = table.concat(args, " ") reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) then elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = -1
reason = "banned by admin" reason = "banned by admin"
else else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban usage: "..commands.getadmin("ban")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dban usage: "..commands.getadmin("ban")["syntax"].."\";")
@ -85,7 +84,11 @@ function commandBan(clientId, command, victim, ...)
history.add(cmdClient, clientId, "ban", reason) history.add(cmdClient, clientId, "ban", reason)
end end
if duration then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned for "..duration.." seconds\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned for "..duration.." seconds\";")
else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned permanently\";")
end
return true return true
end end

View file

@ -57,7 +57,18 @@ function commandKick(clientId, command, victim, ...)
return true return true
end end
local reason = table.concat({...}, " ") local args = {...}
local reason
if args[1] then
reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
reason = "kicked by admin"
else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick usage: "..commands.getadmin("kick")["syntax"].."\";")
return true
end
admin.kickPlayer(cmdClient, clientId, reason) admin.kickPlayer(cmdClient, clientId, reason)

View file

@ -56,14 +56,14 @@ function commandMute(clientId, command, victim, ...)
if args[1] and util.getTimeFromString(args[1]) and args[2] then if args[1] and util.getTimeFromString(args[1]) and args[2] then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = table.concat(args, " ", 2) reason = table.concat(args, " ", 2)
elseif args[1] and util.getTimeFromString(args[1]) then elseif args[1] and util.getTimeFromString(args[1]) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = "muted by admin" reason = "muted by admin"
elseif args[1] then elseif args[1] and not util.getTimeFromString(args[1]) then
duration = 600 duration = 600
reason = table.concat(args, " ") reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) then elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = -1 duration = 600
reason = "muted by admin" reason = "muted by admin"
else else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute usage: "..commands.getadmin("mute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dmute usage: "..commands.getadmin("mute")["syntax"].."\";")

View file

@ -56,14 +56,14 @@ function commandVoiceMute(clientId, command, victim, ...)
if args[1] and util.getTimeFromString(args[1]) and args[2] then if args[1] and util.getTimeFromString(args[1]) and args[2] then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = table.concat(args, " ", 2) reason = table.concat(args, " ", 2)
elseif args[1] and util.getTimeFromString(args[1]) then elseif args[1] and util.getTimeFromString(args[1]) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = util.getTimeFromString(args[1]) duration = util.getTimeFromString(args[1])
reason = "muted by admin" reason = "muted by admin"
elseif args[1] then elseif args[1] and not util.getTimeFromString(args[1]) then
duration = 600 duration = 600
reason = table.concat(args, " ") reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) then elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = -1 duration = 600
reason = "muted by admin" reason = "muted by admin"
else else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")