From af821818867586941b8f24fd55e7b486870ef08f Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 14 Sep 2017 19:11:42 +0100 Subject: [PATCH] Command use now in rank table --- .../ExpGaming - Command Maker.lua | 16 ++++----------- .../ExpGaming-Core/ExpGaming - Rank Table.lua | 20 ++++++++++++++----- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/locale/ExpGaming-Core/ExpGaming - Command Maker.lua b/locale/ExpGaming-Core/ExpGaming - Command Maker.lua index 750871a0..ff3d5304 100644 --- a/locale/ExpGaming-Core/ExpGaming - Command Maker.lua +++ b/locale/ExpGaming-Core/ExpGaming - Command Maker.lua @@ -49,15 +49,13 @@ end --name is what is used in /command --help is the help info given --inputs is a list i.e. {'name','message',true} the last value being true opposed to a string allows a variable number of words for the last input i.e. message can be multiple words long ---restriction is the lowest rank that can use the command --event(player,event,args) if the function that will be ran on the command use -function define_command(name,help,inputs,restriction,event) +function define_command(name,help,inputs,event) if not name then error('Command requires a name') end local help = help or 'No Help Given' local inputs = inputs or {true} - local restriction = restriction or 0 if not event or type(event) ~= 'function' then error('Command requires a function') end - table.insert(Exp_commands,{name=name,help=help,inputs=inputs,restriction=restriction,event=event}) + table.insert(Exp_commands,{name=name,help=help,inputs=inputs,event=event}) end --The magic for the commands. It is a hard bit of code so GL; but it will call the command event have some sanitisaion of the input function load_command(command) @@ -68,10 +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 if event.player_index then local player = game.players[event.player_index] - local temp_restriction = nil - if type(command.restriction) == 'number' then temp_restriction = command.restriction end - local restriction = temp_restriction or string_to_rank(command.restriction).power or 0 - if get_rank(player).power > restriction then + if rank_allowed(get_rank(player),command.name) then 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) return @@ -98,10 +93,7 @@ function get_commands(rank) local rank = rank or 'Owner' local to_return = {} for _,command in pairs(global.commands) do - local temp_restriction = nil - if type(command.restriction) == 'number' then temp_restriction = command.restriction end - local restriction = temp_restriction or string_to_rank(command.restriction).power or 0 - if restriction > string_to_rank(rank).power then table.insert(to_return,command) end + if rank_allowed(string_to_rank(rank),command.name) then table.insert(to_return,command) end end return to_return end diff --git a/locale/ExpGaming-Core/ExpGaming - Rank Table.lua b/locale/ExpGaming-Core/ExpGaming - Rank Table.lua index f29dbf9b..8c13cce1 100644 --- a/locale/ExpGaming-Core/ExpGaming - Rank Table.lua +++ b/locale/ExpGaming-Core/ExpGaming - Rank Table.lua @@ -60,7 +60,8 @@ local ranks = { time=nil, colour={r=179,g=125,b=46}, disallow={}, - allow={}}, + allow={} + }, {name='Admin', short_hand='Admin', @@ -72,7 +73,9 @@ local ranks = { 'edit_permission_group', 'delete_permission_group', 'add_permission_group'}, - allow={} + allow={ + 'server-interface', + 'tp-all'} }, {name='Mod', @@ -82,7 +85,9 @@ local ranks = { colour={r=0,g=170,b=0}, disallow={ 'server_command'}, - allow={} + allow={ + 'temp-ban' + } }, {name='Donator', @@ -91,7 +96,10 @@ local ranks = { time=nil, colour={r=233,g=63,b=233}, disallow={}, - allow={}}, + allow={ + 'tp', + 'repair'} + }, {name='Veteran', short_hand='Vet', @@ -132,7 +140,9 @@ local ranks = { 'launch_rocket', 'reset_assembling_machine', 'cancel_research'}, - allow={} + allow={ + 'kill', + 'tag'} }, {name='Jail',