summaryrefslogtreecommitdiff
path: root/html/import/import_lms.php
blob: eb3ebd72dfeeb90ff888cffe26608b791c1a2230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// get the caps, captimes and store them in the events database
	$ttl = 0;
	if ($qc_deaths[col4] + $q_suicides[col4] == $qm_gameinfofl[col3]) {
		// echo " get out time ";
		$outtime = small_query("SELECT col0, col1, col2 FROM uts_temp_$uid WHERE (col1 = 'kill' AND col4 = $playerid) or (col1 = 'suicide' AND col2 = $playerid) ORDER BY CONVERT(col0, UNSIGNED INTEGER) DESC LIMIT 0,1");
		$col0 = $outtime[col0];
		$col1 = 'out';
		$col2 = intval($outtime[col0] - $gamestart); //time
		$col3 = $outtime[col2]; // killer
		$col4 = "";

		$sql_eventslms = "INSERT INTO uts_events 
			      (matchid, playerid, col0, col1, col2, col3, col4) VALUES
			      ($matchid, $playerid, '$col0', '$col1', '$col2', '$col3', '$col4')";
		mysql_query($sql_eventslms) or die (mysql_error());

		// Fix ttl
		$ttl = ($outtime[col0] - $gamestart) / ($qc_deaths[col4] + $q_suicides[col4]);

		mysql_query("UPDATE uts_player SET ttl = $ttl WHERE id = $playerecordid") or die(mysql_error());
	}
	else {
		$disconnect = small_query("SELECT col0 FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'Disconnect' AND col3 = $playerid");
		if ((!empty($disconnect[col0])) and (intval($disconnect[col0]) < intval($gameend))) {
			// echo " get out time ";
			$outtime = $player_left - $gamestart;
			$q_out = mysql_query($sql_out);
			$col0 = $disconnect[col0];
			$col1 = 'out';
			$col2 = intval($disconnect[col0] - $gamestart); //time
			$col3 = "Disconnect";
			$col4 = "";

			$sql_eventslms = "INSERT INTO uts_events 
				      (matchid, playerid, col0, col1, col2, col3, col4) VALUES
				      ($matchid, $playerid, '$col0', '$col1', '$col2', '$col3', '$col4')";
			mysql_query($sql_eventslms) or die (mysql_error());

			// Update ttl and set score to 0
			$ttl = ($disconnect[col0] - $gamestart) / ($qc_deaths[col4] + $q_suicides[col4]);

			mysql_query("UPDATE uts_player SET ttl = $ttl, gamescore = 0 WHERE id = $playerecordid") or die(mysql_error());
		}
	}
?>