Exemplo n.º 1
0
function displayStats($pid)
{
    if ($pid == 0) {
        return;
    }
    $ret = "";
    $mod = getModId($_GET[mod]);
    $map = getMapId($_GET[map]);
    $total = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0"), 0, 0);
    $wins = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0 AND victoryTeam=1 AND aliveTillEnd=1"), 0, 0);
    $quit = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0 AND (dropTime<>0 OR leaveTime<>0) AND (dropTime < loseTime OR leaveTime < loseTime)"), 0, 0);
    $maptime = mysql_result(mysql_query("SELECT sum(duration) FROM Games WHERE mapId = {$map} AND id IN (SELECT distinct gameId FROM Games2players WHERE playerId={$pid})"), 0, 0);
    $modtime = mysql_result(mysql_query("SELECT sum(duration) FROM Games WHERE modId = {$mod} AND id IN (SELECT distinct gameId FROM Games2players WHERE playerId={$pid})"), 0, 0);
    $side = @mysql_result(mysql_query("SELECT side,count(*) AS cnt FROM Games2players WHERE playerId={$pid} AND spectator=0 GROUP BY side ORDER BY cnt DESC LIMIT 0,1"), 0, 0);
    @($ret = "total:{$total} games, skill rating:" . eloToText($pid) . " (" . round(getPlayerElo($pid)) . "), won:" . round(100 * $wins / $total) . "%, left:" . round(100 * $quit / $total) . "%, maptime:" . timeDiff($maptime) . ", modtime:" . timeDiff($modtime) . ", side:{$side}\n");
    return $ret;
}
Exemplo n.º 2
0
 // param1 = ip
 // param2 = spectator
 // param3 = onVictoryTeam
 // param4 = aliveTillEnd
 // param5 = dropTime
 // param6 = leaveTime
 // param7 = side
 // param8 = loseTime (time when player lost)
 // param9 = allyNumber
 // param10 = rank
 case "battle":
     if (!validate()) {
         exit("FAILED 2 auth failed");
     }
     $id = updatePlayer($_GET['login'], -1, 0);
     $map = getMapId($_GET['map']);
     $mod = getModId($_GET['mod']);
     mysql_query("INSERT INTO Games (playerId, title, mapId, modId, start, duration, players) VALUES ({$id}, '{$_GET['title']}', {$map}, {$mod}, {$_GET['start']}, {$_GET['duration']}, " . count($_GET[player]) . ")");
     $battle_id = mysql_insert_id();
     $plcount = 0;
     for ($i = 0; $i < count($_GET[player]); ++$i) {
         $s = explode("|", $_GET['player'][$i]);
         $pid = updatePlayer($s[0], $s[1], $s[10]);
         if ($s[10] == 0 || $s[10] == "") {
             // doesnt have rank set in data, check database for latest rank
             $s[10] = mysql_result(mysql_query("SELECT rank FROM Players WHERE id = {$pid}"), 0, 0);
         }
         mysql_query("REPLACE INTO Games2players (gameId, playerId, spectator, victoryTeam, aliveTillEnd, dropTime, leaveTime, side, loseTime, allyNumber, rank) VALUES ({$battle_id}, {$pid}, {$s['2']}, {$s['3']}, {$s['4']}, {$s['5']}, {$s['6']}, '{$s['7']}', {$s['8']}, {$s['9']}, {$s['10']})");
         if ($s[2] == 0) {
             $plcount++;
         }