From 16135e9189afe15a92762138df814b0c20eedd14 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 21 Feb 2019 22:17:09 +0000 Subject: [PATCH] Fixed auto promote while in jail --- modules/ExpGamingCore/Role/config.lua | 8 ++++++-- modules/ExpGamingCore/Role/control.lua | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ExpGamingCore/Role/config.lua b/modules/ExpGamingCore/Role/config.lua index 32e896ea..aadb38fb 100644 --- a/modules/ExpGamingCore/Role/config.lua +++ b/modules/ExpGamingCore/Role/config.lua @@ -1,10 +1,13 @@ +-- the two below are used internally by the role system and should not be REMOVED, name must be kept the same and used at least once Role.add_flag('is_default') -- this must be included in at least one role -Role.add_flag('is_root',function(player,state) +Role.add_flag('is_root',function(player,state) if state then game.print('--- !!!ALERT!!! --- '..player.name..' has been given a role with ROOT ACCESS --- !!!ALERT!!! ---') end if player.character then player.character.destructible = not state end end) -- the SERVER role will have root but you may assign this to other roles --- the two above and used internally and should NOT have their names changed and should NOT be removed but the state function MAY be changed +-- the two below are ised internally by the role system and should not be RENAMED, name must be kept the same but does not need to be used +Role.add_flag('block_auto_promote') -- is not required but name is used internally to block time based promotions Role.add_flag('is_antiroot',function(player,state) if player.character then player.character.destructible = not state end end) -- not required but setting true will disallow everything for that role +-- all below are not required and are not used internally Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recommenced but not required Role.add_flag('is_spectator',function(player,state) player.spectator = state end) Role.add_flag('is_jail',function(player,state) if player.character then player.character.active = not state end end) @@ -250,6 +253,7 @@ Role{ colour={r=50,g=50,b=50}, is_jail=true, is_antiroot=true, + block_auto_promote=true, allow={} } diff --git a/modules/ExpGamingCore/Role/control.lua b/modules/ExpGamingCore/Role/control.lua index 364bc995..77e9d204 100644 --- a/modules/ExpGamingCore/Role/control.lua +++ b/modules/ExpGamingCore/Role/control.lua @@ -516,10 +516,12 @@ end) script.on_event(defines.events.on_tick,function(event) if game.tick%(3600*5) ~= 0 then return end -- every 5 minutes - for role_name, time in pairs(Role.meta.times) do - for _,player in pairs(game.connected_players) do + for _,player in pairs(game.connected_players) do + if not Role.has_flag(player,'block_auto_promote') then local highest = Role.get_highest(player) - if highest.index > time[1] and (player.online_time) > time[2] then Role.assign(player,role_name) end + for role_name, time in pairs(Role.meta.times) do + if highest.index > time[1] and (player.online_time) > time[2] then Role.assign(player,role_name) end + end end end end)