Commands now work if allow

This commit is contained in:
Cooldude2606
2017-09-14 19:23:52 +01:00
parent af82181886
commit d30dfe059d
4 changed files with 14 additions and 11 deletions

View File

@@ -66,7 +66,7 @@ function load_command(command)
for _,command_d in pairs(Exp_commands) do if event.name == command_d[1] then command_data = command_d break end end for _,command_d in pairs(Exp_commands) do if event.name == command_d[1] then command_data = command_d break end end
if event.player_index then if event.player_index then
local player = game.players[event.player_index] local player = game.players[event.player_index]
if rank_allowed(get_rank(player),command.name) then if not rank_allowed(get_rank(player),command.name) then
player.print('401 - Unauthorized: Access is denied due to invalid credentials') player.print('401 - Unauthorized: Access is denied due to invalid credentials')
game.write_file('commands.log','\n'..game.tick..' Player: '..player.name..' Failed to use command (Unauthorized): '..command.name..' With args of: '..table.to_string(get_command_args(event,command,true)), true, 0) game.write_file('commands.log','\n'..game.tick..' Player: '..player.name..' Failed to use command (Unauthorized): '..command.name..' With args of: '..table.to_string(get_command_args(event,command,true)), true, 0)
return return

View File

@@ -40,7 +40,7 @@ function string_to_rank(string)
end end
-- surches the rank for a certain allow command -- surches the rank for a certain allow command
function rank_allowed(rank,is_allowed) function rank_allowed(rank,is_allowed)
for _,allow in rank.allow do for _,allow in pairs(rank.allow) do
if allow == is_allowed then return true end if allow == is_allowed then return true end
end end
return false return false

View File

@@ -161,22 +161,25 @@ local ranks = {
} }
-- rank table setup -- rank table setup
for n,rank in pairs(ranks.ranks) do for n,rank in pairs(ranks.ranks) do
local ranks_list = ranks.ranks
rank.power = n rank.power = n
if ranks_list[n-1] then if ranks.ranks[n-1] then
for _,disallow in pairs(ranks_list[n-1].disallow) do for _,disallow in pairs(ranks.ranks[n-1].disallow) do
table.insert(rank.disallow,disallow) table.insert(rank.disallow,disallow)
end end
end end
if ranks_list[n+1] then
for _,allow in pairs(ranks_list[n+1].allow) do
table.insert(rank.allow,allow)
end
end
if rank.time and not ranks.highest_timed_rank then ranks.highest_timed_rank=rank end if rank.time and not ranks.highest_timed_rank then ranks.highest_timed_rank=rank end
if rank.time then ranks.lowest_timed_rank=rank end if rank.time then ranks.lowest_timed_rank=rank end
ranks.number_of_ranks=ranks.number_of_ranks+1 ranks.number_of_ranks=ranks.number_of_ranks+1
end end
for n = #ranks.ranks, 1, -1 do
rank = ranks.ranks[n]
if ranks.ranks[n+1] then
for _,allow in pairs(ranks.ranks[n+1].allow) do
table.insert(rank.allow,allow)
end
end
end
-- returns a list off all the ranks, return only one part if given -- returns a list off all the ranks, return only one part if given
function get_ranks(part) function get_ranks(part)
local to_return = {} local to_return = {}

View File

@@ -19,7 +19,7 @@ local credits = {{
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
--Please Only Edit Below This Line----------------------------------------------------------- --Please Only Edit Below This Line-----------------------------------------------------------
--this command is just a way or using loadstring from in game while keeping achievements --this command is just a way or using loadstring from in game while keeping achievements
define_command('server-interface','For use of the highest staff only',{'command',true},'admin',function(player,event,args) define_command('server-interface','For use of the highest staff only',{'command',true},function(player,event,args)
if player == '<server>' then if player == '<server>' then
local returned,value = pcall(loadstring(event.parameter)) local returned,value = pcall(loadstring(event.parameter))
if type(value) == 'table' then game.write_file('server-interface.log', '\n'..game.tick..' Ran by: <server> Code: '..event.parameter..'\n Returned: '..table.to_string(value), true, 0) print(table.to_string(value)) if type(value) == 'table' then game.write_file('server-interface.log', '\n'..game.tick..' Ran by: <server> Code: '..event.parameter..'\n Returned: '..table.to_string(value), true, 0) print(table.to_string(value))