All pastes #915705 Raw Edit

-z-

public php v1 · immutable
#915705 ·published 2008-02-24 00:02 UTC
rendered paste body
<?// Eventlog Parser by -z- of www.nexuizninjaz.com | Last Updated 02/23/08// -----------------------------------------------------------------------------------//// This Class Parses all possible outputs as denoted by eventlog.txt//// team colors:	// 1 = No Team (Domination)	// 5 = Red Team	// 14 = Blue Team	// 10 = Pink Team	// 13 = Yellow Team// Weapon Itemstring:	// <weaponid><flags>	// or	// <weaponid><flags>|<runes>// where flags can contain:	// F = player carries the flag	// S = player has strength	// I = player has the shield	// T = player is typing (console, menu or chat)   // and weapon IDs are:	// 1 = Shotgun	// 2 = Uzi	// 4 = Mortar	// 8 = Electro	// 16 = Crylink	// 32 = Nex	// 64 = Hagar	// 128 = Rocket Launcher	// 4096 = Laser// runes/curses are stored as a bit mask with the following values:	// 1 = Strength	// 2 = Defense	// 4 = Regeneration	// 8 = Speed	// 16 = Vampire	// 8192 = Weakness	// 16384 = Vulnerability	// 32768 = Venom	// 65536 = Slow	// 131072 = Empathy// death type:// either a weapon ID (see above), or one of:	// 10000 = fallen to death	// 10001 = telefragged	// 10002 = drowned	// 10003 = killed by a trap / fallen into the void	// 10004 = lava	// 10005 = slime	// 10006 = console kill	// 10007 = (MinstaGib) out of ammo	// 10008 = swamp	// 10009 = team change	// 10010 = auto team change	// 10011 = camping protection	// 10012 = player became too fast (should never happen)				// Set some test strings$s_join_player = ":join:10:player:-z-";$s_join_bot = ":join:5:bot:[BOT]Acidic";$s_part = ":part:5";$s_team = ":team:3:14";$s_kill_frag = ":kill:frag:1:2:type=4:items=4:victimitems=128F";$s_kill_tk = ":kill:tk:2:4:type=4:items=2:victimitems=S";$s_kill_suicide = ":kill:suicide:2:4:type=4:items=1:victimitems=14S";$s_kill_accident = ":kill:accident:2:4:type=4:items=4096:victimitems=32S";$s_ctf_steal = ":ctf:steal:14:1";$s_ctf_dropped = ":ctf:dropped:5:2";$s_ctf_pickup = ":ctf:pickup:14:4";$s_ctf_capture = ":ctf:capture:14:4";$s_ctf_return = ":ctf:return:5:2";$s_ctf_returned = ":ctf:returned:5:4";?><h3>Joins</h3><h4>Player</h4><pre><?var_dump(isJoin($s_join_player));?></pre><h4>Bot</h4><pre><?var_dump(isJoin($s_join_bot));?></pre><h4>False</h4><pre><?var_dump(isJoin($s_part));?></pre><h3>Part</h3><h4>True</h4><pre><?var_dump(isPart($s_part));?></pre><h4>False</h4><pre><?var_dump(isPart($s_join_player));?></pre><h3>Team</h3><h4>True</h4><pre><?var_dump(isTeam($s_team));?></pre><h4>False</h4><pre><?var_dump(isTeam($s_join_player));?></pre><h3>Kill</h3><h4>Frag</h4><pre><?var_dump(isKill($s_kill_frag));?></pre><h4>TK</h4><pre><?var_dump(isKill($s_kill_tk));?></pre><h4>Suicide</h4><pre><?var_dump(isKill($s_kill_suicide));?></pre><h4>Accident</h4><pre><?var_dump(isKill($s_kill_accident));?></pre><h4>False</h4><pre><?var_dump(isKill($s_join_player));?></pre><h3>CTF</h3><h4>Steal</h4><pre><?var_dump(isCTF($s_ctf_steal));?></pre><h4>Dropped</h4><pre><?var_dump(isCTF($s_ctf_dropped));?></pre><h4>Pickup</h4><pre><?var_dump(isCTF($s_ctf_pickup));?></pre><h4>Capture</h4><pre><?var_dump(isCTF($s_ctf_capture));?></pre><h4>Return</h4><pre><?var_dump(isCTF($s_ctf_return));?></pre><h4>Returned</h4><pre><?var_dump(isCTF($s_ctf_returned));?></pre><h4>False</h4><pre><?var_dump(isCTF($s_join_player));?></pre><?// True returns - array(id,type,nick)function isJoin($string) {	// Is it a join?	$isJoin = (substr($string,1,4) == "join") ? TRUE : FALSE;	// Yes, parse the ID, Type and Nickname	if ($isJoin) {		$joinData = explode(":",substr($string,6));	}	return ($isJoin) ? $joinData : FALSE;}// True returns - $idfunction isPart($string) {	// Is it a part?	$isPart = (substr($string,1,4) == "part") ? TRUE : FALSE;	// Yes, parse the ID	if ($isPart) {		$partData = substr($string,6);	}	return ($isPart) ? $partData : FALSE;}// True returns - aray(id,team)function isTeam($string) {	// Is it a team?	$isTeam = (substr($string,1,4) == "team") ? TRUE : FALSE;	// Yes, parse the ID, Team ID	if ($isTeam) {		$teamData = explode(":",substr($string,6));	}	return ($isTeam) ? $teamData : FALSE;}// True returns - array(type, killer id, victim id, type, items of killer, items of victim)function isKill($string) {	// Is it a kill?	$isKill = (substr($string,1,4) == "kill") ? TRUE : FALSE;	// Yes, parse the type, killer id, victim id, type, items of killer, items of victim	if ($isKill) {		$killData = explode(":",substr($string,6));		// it parses with type=#, items=#, vicitimitems=# for some reason I don't understand, I fix that here.		$killData[3] = substr($killData[3],5);		$killData[4] = substr($killData[4],6);		$killData[5] = substr($killData[5],12);	}	return ($isKill) ? $killData : FALSE;}// True returns - array(type, killer id, victim id, type, items of killer, items of victim)function isCTF($string) {	// Is it a ctf?	$isCTF = (substr($string,1,3) == "ctf") ? TRUE : FALSE;	// Yes, parse the type, flag color, player id	if ($isCTF) {		$ctfData = explode(":",substr($string,5));	}	return ($isCTF) ? $ctfData : FALSE;}?>