// 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++; } } mysql_query("UPDATE Games SET players={$plcount} WHERE id = {$battle_id}"); // player count excludes spectators calculateBattleElo($battle_id); break; }
} else { admin(); } break; case "saveplayer": // if ($pcat == 3 || $pcat == 4) { savePlayer(); } else { admin(); } break; case "updateplayer": // if ($pcat == 4) { updatePlayer(); } else { admin(); } break; case "deleteplayer": // if ($pcat == 4) { deletePlayer(); } else { admin(); } break; case "playerbynumber": // if ($pcat == 3 || $pcat == 4) {
$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; } if (!validate()) { exit("FAILED 2 auth failed - delete do_not_delete_me.xml in springie folder and restart!"); } $id = updatePlayer($l, "", 0); if ($p == "" || $p == "help") { echo "RESPOND\n* !stats games, !stats maps, !stats player <name> *\n"; } $args = explode(" ", $p); switch ($args[0]) { case "games": $res = mysql_query("SELECT sum(duration) AS totalTime,count(*) AS cnt,avg(players) AS avgplayers FROM Games WHERE playerId = {$id}"); @($row = mysql_fetch_array($res)); echo "== This Springie - {$l} ==\n"; echo "Total games: {$row['cnt']}\n"; echo "Total in-game time: " . timeDiff($row[totalTime]) . "\n"; echo "Average player count in game: " . round($row[avgplayers]) . "\n"; $res = mysql_query("SELECT sum(duration) AS totalTime,count(*) AS cnt,avg(players) AS avgplayers FROM Games"); @($row = mysql_fetch_array($res)); echo "== Global ==\n";