Fixed possibility to setlevel higher than current level

This commit is contained in:
Timo Smit 2017-02-01 14:33:33 +01:00
parent 7ddde82e8d
commit 329eb3afc7

View file

@ -15,12 +15,16 @@
-- 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 auth = require (wolfa_getLuaPath()..".auth.auth")
local settings = require (wolfa_getLuaPath()..".util.settings")
local db = require (wolfa_getLuaPath()..".db.db")
local commands = require (wolfa_getLuaPath()..".commands.commands")
local admin = require (wolfa_getLuaPath()..".admin.admin") local admin = require (wolfa_getLuaPath()..".admin.admin")
local auth = require (wolfa_getLuaPath()..".auth.auth")
local db = require (wolfa_getLuaPath()..".db.db")
local commands = require (wolfa_getLuaPath()..".commands.commands")
local settings = require (wolfa_getLuaPath()..".util.settings")
function commandSetLevel(clientId, command, victim, level) function commandSetLevel(clientId, command, victim, level)
if not victim or not level then if not victim or not level then
return false return false
@ -36,9 +40,15 @@ function commandSetLevel(clientId, command, victim, level)
return false return false
end end
if auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
return false
elseif level > auth.getPlayerLevel(clientId) then
return false
end
level = tonumber(level) or 0 level = tonumber(level) or 0
admin.setPlayerLevel(cmdClient, tonumber(level), clientId) admin.setPlayerLevel(cmdClient, level, clientId)
return false return false
end end
@ -54,7 +64,7 @@ function commandSetLevel(clientId, command, victim, level)
else else
cmdClient = tonumber(victim) cmdClient = tonumber(victim)
end end
if cmdClient == -1 or cmdClient == nil then if cmdClient == -1 or cmdClient == nil then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9no or multiple matches for '^7"..victim.."^9'.\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9no or multiple matches for '^7"..victim.."^9'.\";")
@ -64,22 +74,26 @@ function commandSetLevel(clientId, command, victim, level)
return true return true
end end
level = tonumber(level) or 0
if auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then if auth.getPlayerLevel(cmdClient) > auth.getPlayerLevel(clientId) then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9sorry, but your intended victim has a higher admin level than you do.\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9sorry, but your intended victim has a higher admin level than you do.\";")
return true return true
elseif not db.getLevel(tonumber(level)) then elseif not db.getLevel(level) then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9this admin level does not exist.\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9this admin level does not exist.\";")
return true
elseif level > auth.getPlayerLevel(clientId) then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dsetlevel: ^9you may not setlevel higher than your current level.\";")
return true return true
end end
level = tonumber(level) or 0
admin.setPlayerLevel(cmdClient, tonumber(level), clientId) admin.setPlayerLevel(cmdClient, tonumber(level), clientId)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay -1 \"^dsetlevel: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is now a level ^7"..level.." ^9player.\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dsetlevel: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is now a level ^7"..level.." ^9player.\";")
return false return false
end end