break; case "showChat": echo displayChat($lid); break; case "newMessage": if ($message) { echo newMessage($uid, $lid, $message); } break; } } if ($lid) { switch ($request) { case "lobbyinfo": $lobbyinfo = $lobby->lobbyinfo(); $lobbyplayers = $lobby->lobbyData(); $count = countPlayers($lid); updateLobbyReady($lid); if ($lobby->status == "ready") { removeOfflinePlayers(checkOfflinePlayers($lid)); } $array = array('id' => $uid, 'ready' => readystatus($id, true), 'inlobby' => isPlayerInLobby($uid), 'info' => $lobbyinfo, 'count' => $count, 'players' => $lobbyplayers); echo json_encode($array); break; case "lobbyplayers": echo json_encode($lobby->lobbyData()); break; case "distance": if ($lat && $lon) { $server = new Server($lobby->lobbyserver($lid)); echo GetDistance($lat, $lon, $server->latitude, $server->longitude);
function checkOfflinePlayers($id) { $lobby = new Lobby($id); $players = $lobby->lobbyData(); foreach ($players as $team) { if ($players['size'] == $team) { continue; } foreach ($team as $player) { if (getOnline($player['id']) == "Offline") { $array[] = $player['id']; } } } return $array; }