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); } break; case "balanceTeams": $players = getPlayersSkill($lid); balanceTeams($lid, $players); break;
function displayLobbyPlayers($lobbyID, $lobbytype, $team, $ready = false, $rate = false) { global $user; $uid = $user->id; global $lobby; $lobbyPlayers = grabLobbyPlayers($lobbyID, $lobbytype, $team); $display = ''; if ($team != 0) { foreach ($lobbyPlayers as $data) { if (!$ready && !$rate) { $display .= '<li><a href="profile.php?id=' . $data['id'] . '" target="_blank"> <img src="theme/images/class/' . $data['class'] . '.png" height="18">' . $data["nickname"] . ' <img class="avatar" src=' . $data['avatar'] . '></a></li>'; } if ($ready) { $id = getLPid($data['id'], $lobbyID); $readystatus = readystatus($id, true); if ($readystatus == 1 && $lobby->leader != $data['id']) { $class = '<li class="ready">'; } if ($readystatus == 0 && $lobby->leader != $data['id']) { $class = '<li class="not_ready">'; } if ($lobby->leader == $data['id']) { $class = '<li class="lobby_leader">'; } if ($data['id']) { $link = '<a href="profile.php?id=' . $data['id'] . '" target="_blank">'; $linkend = '</a>'; } else { $link = '<div onclick="joinGame(' . $lobby->ID . ')">'; $linkend = '</div>'; } $display .= $class . $link . ' <img src="theme/images/class/' . $data['class'] . '.png" height="18">' . $data["nickname"] . ' <img class="avatar" src=' . $data['avatar'] . '>' . $linkend . '</li>'; } if ($rate) { $display .= '<li><a href="profile.php?id=' . $data['id'] . '" target="_blank"> <img src="theme/images/class/' . $data['class'] . '.png" height="18">' . $data["nickname"] . ' <img class="avatar" src=' . $data['avatar'] . '></a>' . ($uid != $data['id'] ? '<span class="rate_switch"><a href="#rate_up:userid" class="rate_up" data-id="' . $data['id'] . '">+</a><a "#rate_down:userid" class="rate_down" data-id="' . $data['id'] . '">-</a></span>' : '') . '</li>'; } $n++; } for ($n; $n < teamplayers($lobbytype); $n++) { $display .= '<li class="empty"><img src="theme/images/class/noclass.png" height="18">empty</li>'; } } else { foreach ($lobbyPlayers as $data) { if ($display == "") { $display .= $data['nickname']; } else { $display .= ', ' . $data['nickname']; } } } return $display; }