From 4fb14bca049dfc75d99f9376e8c00a154c2cf04d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 21 Jul 2018 16:38:40 +0100 Subject: [PATCH 1/2] Added afk times to sync --- modules/ExpGamingCore/Sync/control.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/ExpGamingCore/Sync/control.lua b/modules/ExpGamingCore/Sync/control.lua index 5db9acb6..7837c913 100644 --- a/modules/ExpGamingCore/Sync/control.lua +++ b/modules/ExpGamingCore/Sync/control.lua @@ -32,13 +32,14 @@ local global = global{ time_set={0,'0.00M'}, last_update={0,'0.00M'}, time_period={18000,'5.00M'}, + game_speed=1.0, players={ online={'Offline'}, n_online=0, all={'Offline'}, n_all=0, admins_online=0, - afk_players=0, + afk_players={}, times={'Offline'} }, ranks={'Offline'}, @@ -168,11 +169,11 @@ end function Sync.count_afk(time) if not game then return 0 end local time = time or 7200 - local _count = 0 + local rtn = {} for _,player in pairs(game.connected_players) do - if player.afk_time > time then _count=_count+1 end + if player.afk_time > time then rtn[player.name] = player.afk_time end end - return _count + return rtn end --- Used to get the number of players in each rank and currently online; if ExpGamingCore/Ranking is present then it will give more than admin and user @@ -243,13 +244,14 @@ function Sync.update() info.time_period[2] = tick_to_display_format(info.time_period[1]) info.last_update[1] = game.tick info.last_update[2] = tick_to_display_format(game.tick) + info.game_speed = game.speed info.players={ online=Sync.count_players(true), n_online=#game.connected_players, all=Sync.count_players(), n_all=#game.players, admins_online=Sync.count_admins(), - afk_players=Sync.count_afk(), + afk_players=Sync.count_afk_times(), times=Sync.count_player_times() } info.ranks = Sync.count_ranks() From b911b14bf8701f65aa4aec8e5d7a4cbdea5b257f Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 21 Jul 2018 17:07:29 +0100 Subject: [PATCH 2/2] Forgot to maintain tick formating --- modules/ExpGamingCore/Sync/control.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ExpGamingCore/Sync/control.lua b/modules/ExpGamingCore/Sync/control.lua index 7837c913..c13d4024 100644 --- a/modules/ExpGamingCore/Sync/control.lua +++ b/modules/ExpGamingCore/Sync/control.lua @@ -163,15 +163,15 @@ function Sync.count_admins() end --- Used to get the number of afk players defined by 2 min by default --- @usage Sync.count_afk() +-- @usage Sync.count_afk_times() -- @tparam[opt=7200] int time in ticks that a player is called afk -- @treturn number the number of afk players -function Sync.count_afk(time) +function Sync.count_afk_times(time) if not game then return 0 end local time = time or 7200 local rtn = {} for _,player in pairs(game.connected_players) do - if player.afk_time > time then rtn[player.name] = player.afk_time end + if player.afk_time > time then rtn[player.name] = Sync.tick_format(player.afk_time) end end return rtn end