From 1c94169182814b6c86d01fb606e68540f08e6beb Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Wed, 3 Jan 2018 01:07:26 +0100 Subject: [PATCH] * fixed bug on TFS 1.x when online_afk is enabled --- system/status.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/system/status.php b/system/status.php index 29f3a948..5d060d08 100644 --- a/system/status.php +++ b/system/status.php @@ -75,8 +75,13 @@ if(isset($config['lua']['statustimeout'])) // get status timeout from server config $status_timeout = eval('return ' . $config['lua']['statusTimeout'] . ';') / 1000 + 1; -if($status['lastCheck'] + $status_timeout < time()) -{ +if($status['lastCheck'] + $status_timeout < time()) { + updateStatus(); +} + +function updateStatus() { + global $db, $cache, $config, $status, $status_ip, $status_port; + // get server status and save it to database $serverInfo = new OTS_ServerInfo($status_ip, $status_port); $serverStatus = $serverInfo->status(); @@ -98,9 +103,14 @@ if($status['lastCheck'] + $status_timeout < time()) if($config['online_afk']) { // get amount of players that are currently logged in-game, including disconnected clients (exited) - $query = $db->query('SELECT COUNT(' . $db->fieldName('id') . ') AS playersTotal FROM ' . $db->tableName('players') . - ' WHERE ' . $db->fieldName('online') . ' > 0'); - + if(tableExist('players_online')) { // tfs 1.x + $query = $db->query('SELECT COUNT(`player_id`) AS `playersTotal` FROM `players`;'); + } + else { + $query = $db->query('SELECT COUNT(`id`) AS `playersTotal` FROM `players` WHERE `online` > 0'); + } + + $status['playersTotal'] = 0; if($query->rowCount() > 0) { $query = $query->fetch(); @@ -132,5 +142,4 @@ if($status['lastCheck'] + $status_timeout < time()) foreach($status as $key => $value) { updateDatabaseConfig('status_' . $key, $value); } -} -?> +} \ No newline at end of file