在游戏服务器上花费的时间
Time spent on the game server
我正在尝试计算玩家在服务器上花费的总时间。
我每 5 分钟有一个 PHP cron 作业,它将从服务器查询详细信息 https://developer.valvesoftware.com/wiki/Server_queries
array (
'id' => '1',
'name' => 'Player',
'score' => '3',
'time' => '1234',
),
array (
'id' => '2',
'name' => 'Player 2',
'score' => '12',
'time' => '2453',
) + other 100k players.
// The 'time' is starting from 0 seconds when the player join the server, if she leave and then join again the time is starting from 0 seconds
只需将 PHP 查询中的实时数据添加到数据库
| id | name | last_score | total_score | last_time | total_time |
| -- | -------- | ---------- | ----------- | --------- | ---------- |
| 1 | Player | 3 | 0 | 1234 | 0 |
| 2 | Player 2 | 12 | 0 | 2453 | 0 |
我不是玩家在线服务器的所有者,所以当玩家离开时我无法立即登录。
我正在尝试做这样的事情https://www.gametracker.com/server_info/109.120.135.78:2302/top_players/
已解决!
$time = $query['Time'];
$last = $db_players['last_time'];
$total = $db_players['total_time'];
if ($time < $last) {
$total += $time;
} else {
$total += ($time - $last);
}
我正在尝试计算玩家在服务器上花费的总时间。
我每 5 分钟有一个 PHP cron 作业,它将从服务器查询详细信息 https://developer.valvesoftware.com/wiki/Server_queries
array (
'id' => '1',
'name' => 'Player',
'score' => '3',
'time' => '1234',
),
array (
'id' => '2',
'name' => 'Player 2',
'score' => '12',
'time' => '2453',
) + other 100k players.
// The 'time' is starting from 0 seconds when the player join the server, if she leave and then join again the time is starting from 0 seconds
只需将 PHP 查询中的实时数据添加到数据库
| id | name | last_score | total_score | last_time | total_time |
| -- | -------- | ---------- | ----------- | --------- | ---------- |
| 1 | Player | 3 | 0 | 1234 | 0 |
| 2 | Player 2 | 12 | 0 | 2453 | 0 |
我不是玩家在线服务器的所有者,所以当玩家离开时我无法立即登录。
我正在尝试做这样的事情https://www.gametracker.com/server_info/109.120.135.78:2302/top_players/
已解决!
$time = $query['Time'];
$last = $db_players['last_time'];
$total = $db_players['total_time'];
if ($time < $last) {
$total += $time;
} else {
$total += ($time - $last);
}