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
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
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
duration = util.getTimeFromString(args[1])
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])
reason = "banned by admin"
elseif args[1] then
elseif args[1] and not util.getTimeFromString(args[1]) then
duration = 600
reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) then
duration = -1
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) and auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
reason = "banned by admin"
else
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)
end
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned for "..duration.." seconds\";")
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\";")
else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dban: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been banned permanently\";")
end
return true
end

View file

@ -57,7 +57,18 @@ function commandKick(clientId, command, victim, ...)
return true
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)

View file

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

View file

@ -52,22 +52,22 @@ function commandVoiceMute(clientId, command, victim, ...)
local args = {...}
local duration, reason
if args[1] and util.getTimeFromString(args[1]) and args[2] then
duration = util.getTimeFromString(args[1])
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])
reason = "muted by admin"
elseif args[1] then
elseif args[1] and not util.getTimeFromString(args[1]) then
duration = 600
reason = table.concat(args, " ")
elseif auth.isPlayerAllowed(clientId, auth.PERM_PERMA) then
duration = -1
elseif auth.isPlayerAllowed(clientId, auth.PERM_NOREASON) then
duration = 600
reason = "muted by admin"
else
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true
end