Jump to content

Server Stats Script?


Recommended Posts

Aftar any round the dedicated server save xml stat files in the "log" folder.

This is an exemple of that files:


<?xml version="1.0" encoding="ISO-8859-1"?>

<xml>

	<statistics version="1.0" date="2006-05-05 22:54">

		<marksman>

			<player name="GhostFalco" side="USA" team="Charlie" leader="false" score="1495" kills="7" deaths="3" zone_score="700" lethal_shots="7" grenade_kill="0"/>

		</marksman>

		<demolition>

			<player name="Rsf_Leprechauh" side="USA" team="Alpha" leader="true" score="1785" kills="1" deaths="3" zone_score="1250" lethal_shots="1" grenade_kill="0"/>

		</demolition>

		<tactician>

			<player name="=3dS=_MaxCap" side="USA" team="Charlie" leader="false" score="2395" kills="6" deaths="3" zone_score="2000" lethal_shots="6" grenade_kill="0"/>

		</tactician>

		<ranking>

			<player name="=3dS=_MaxCap" side="USA" team="Charlie" leader="false" score="2395" kills="6" deaths="3" zone_score="2000" lethal_shots="6" grenade_kill="0"/>

			<player name="=CCI=Carlos" side="USA" team="Alpha" leader="false" score="2135" kills="4" deaths="2" zone_score="1650" lethal_shots="4" grenade_kill="0"/>

			<player name="Rsf_Leprechauh" side="USA" team="Alpha" leader="true" score="1785" kills="1" deaths="3" zone_score="1250" lethal_shots="1" grenade_kill="0"/>

			<player name="CCIBIGGY" side="USA" team="Non assegnato" leader="false" score="1625" kills="3" deaths="3" zone_score="1000" lethal_shots="3" grenade_kill="0"/>

			<player name="GhostFalco" side="USA" team="Charlie" leader="false" score="1495" kills="7" deaths="3" zone_score="700" lethal_shots="7" grenade_kill="0"/>

			<player name="dimsum" side="USA" team="Non assegnato" leader="false" score="1365" kills="4" deaths="1" zone_score="600" lethal_shots="4" grenade_kill="0"/>

			<player name="=CCI=Andy" side="USA" team="Non assegnato" leader="false" score="915" kills="2" deaths="2" zone_score="350" lethal_shots="3" grenade_kill="0"/>

			<player name="Countsuckula" side="USA" team="Non assegnato" leader="false" score="795" kills="1" deaths="1" zone_score="350" lethal_shots="1" grenade_kill="0"/>

			<player name="COVERTRANGER" side="USA" team="Non assegnato" leader="false" score="735" kills="1" deaths="1" zone_score="0" lethal_shots="1" grenade_kill="0"/>

			<player name="_3dS_Patriota" side="USA" team="Charlie" leader="true" score="635" kills="1" deaths="3" zone_score="0" lethal_shots="1" grenade_kill="0"/>

			<player name="=3dS=OMBRA" side="USA" team="Charlie" leader="false" score="585" kills="2" deaths="1" zone_score="0" lethal_shots="2" grenade_kill="0"/>

			<player name="Lawn_Mower_Man" side="USA" team="Non assegnato" leader="false" score="500" kills="0" deaths="1" zone_score="0" lethal_shots="0" grenade_kill="0"/>

			<player name="JimJim" side="MEX" team="Bravo" leader="false" score="465" kills="2" deaths="3" zone_score="300" lethal_shots="0" grenade_kill="0"/>

			<player name="=CdO=Giox" side="MEX" team="Alpha" leader="false" score="435" kills="2" deaths="2" zone_score="600" lethal_shots="0" grenade_kill="0"/>

			<player name="shadow19763464" side="MEX" team="Bravo" leader="true" score="405" kills="3" deaths="2" zone_score="300" lethal_shots="0" grenade_kill="0"/>

			<player name="Starbucks" side="MEX" team="Bravo" leader="false" score="405" kills="1" deaths="1" zone_score="300" lethal_shots="0" grenade_kill="0"/>

			<player name="cl3rik" side="MEX" team="Alpha" leader="false" score="300" kills="0" deaths="0" zone_score="300" lethal_shots="0" grenade_kill="0"/>

			<player name="[SPQR]Ginevra" side="MEX" team="Alpha" leader="true" score="300" kills="0" deaths="1" zone_score="300" lethal_shots="0" grenade_kill="0"/>

			<player name="LoOsEr" side="MEX" team="Alpha" leader="false" score="235" kills="1" deaths="3" zone_score="0" lethal_shots="1" grenade_kill="0"/>

			<player name="SandraFranke" side="MEX" team="Bravo" leader="false" score="165" kills="2" deaths="0" zone_score="0" lethal_shots="0" grenade_kill="0"/>

			<player name="=TanAtoS=Anti" side="MEX" team="Non assegnato" leader="false" score="115" kills="4" deaths="3" zone_score="0" lethal_shots="0" grenade_kill="0"/>

			<player name="NP21" side="MEX" team="Non assegnato" leader="false" score="0" kills="0" deaths="0" zone_score="0" lethal_shots="0" grenade_kill="0"/>

			<player name="Tm4_Mushroomslap" side="MEX" team="Alpha" leader="false" score="0" kills="0" deaths="0" zone_score="0" lethal_shots="0" grenade_kill="0"/>

			<player name="AlwaysDead" side="MEX" team="Bravo" leader="false" score="0" kills="0" deaths="0" zone_score="0" lethal_shots="0" grenade_kill="0"/>

		</ranking>

	</statistics>

</xml>

It is possibile to collect all stats in a php or html page to made a sort of ranking of server players?

Link to comment
Share on other sites

  • Replies 140
  • Created
  • Last Reply

Top Posters In This Topic

Did a bunch of work on a PHP script here tonight. Had a tough time with the XML until I found simpleXML for PHP that parses the whole thing, it's pretty sweet. I might need some help with some simple graphics/images later. Should have some kind of beta here by the end of the week or early this weekend. :)

Link to comment
Share on other sites

So I could use some help with graphics if anyone is interested. I think they should be pretty easy. I tried doing it myself but the results were not pretty, I'm not much of a graphics person. :P

First I need three images of the same size, pretty small, like 50x50 pixels or so, for the awards:

-Marksman (scope?)

-Demolition (explosion?)

-Tactician

Second, I need two images, again, pretty small, rectangular maybe.

-USA (flag)

-Mexico (flag)

And finally, I need some sort of checkmark image, again small, to designate if the person was a leader or not

-Leader (checkmark)

If anyone wants to help out with one or more of these that would be great! Thanks. :D

Link to comment
Share on other sites

Clanbase.com, Gotfrag.com (i believe) and MANY MANY other sites use those flags. vwar probably didn't make those flags themself, i have no idea who actually made those flags :)

Link to comment
Share on other sites

Nice images! The only thing that I can recommend is to make them transparent gifs so people who download your stats program can change the colors of the page without having to edit the images.

Thanx :)

I know that but with trasparent images you can't use shadow. I think these images are only an "exemple" becouse I think all webmasters will personalize these images with thier website theme/template.

I'm going to make some trasparent gifs ;)

Leader

ghostleader.jpg

Link to comment
Share on other sites

if ($deaths == 0)

{

$deathpercentage="0%";

$killpercentage ="100%";

echo "$killpercentage / $deathpercentage";

}

elseif ($kills == 0)

{

$deathpercentage="100%";

$killpercentage ="0%";

echo "$killpercentage / $deathpercentage";

}

else

{

your code here

}

My suggestion

else

{

// add total kills and deaths for easy percentage calcs

$totalkds = $kills + $deaths;

$killpercentage = $kills / $totalkds;

$deathpercentage = $deaths / $totalkds;

echo "$killpercentage % / $deathpercentage %";

}

or something like that, whats your funtion to calc now and I can help you. Whatever you do I would check for 0 deaths and 0 kills first before you try to do any calculations that way you dont have to try and do a calculation and get an cant divide operand by 0 error

Edited by RuTHlezz1
Link to comment
Share on other sites

Here's what I came up with, basically, if you have kills but no deaths, I assume that you died once... think that's ok?


<?php

if ($xml_data->statistics->ranking->player[$i-12]['deaths'] >= 0 && $xml_data->statistics->ranking->player[$i-12]['kills'] == 0) //deaths/no deaths but no kills

	echo "0";

elseif ($xml_data->statistics->ranking->player[$i-12]['deaths'] == 0 && $xml_data->statistics->ranking->player[$i-12]['kills'] > 0) //kills but no deaths

{

	//assume one death, that ok?

	echo $xml_data->statistics->ranking->player[$i-12]['kills'] / 1;

}

else

{	

	$k_d_ratio = $xml_data->statistics->ranking->player[$i-12]['kills'] / $xml_data->statistics->ranking->player[$i-12]['deaths'];

	echo number_format($k_d_ratio, 2);

}

?>

Thanks for the help! :)

Link to comment
Share on other sites

Well that would probably be ok then only problem is if they didnt really die one time your statistics are flawed from the go. For example over 1000 game if you only died one time in 25% of those games your death rate would still show 1000 total deaths instead of 250.

Honestly I dont think that many people or any at all will make it through one game without a death, however if they are a sniper and dont move alot and dont get many kills would it be fair to give them an auto death?

Let me look at your code a little bit more and think about it and I will post.

Are you wanting to show percentage of Kills to Deaths like

75% kills / 25% Deaths?

I think I got something worked out. Their is no real reason to add 1 death, if you havnt died then your 100% so no need to divide just output the kills to the screen.


<?php

//no deaths and no kills

if ($xml_data->statistics->ranking->player[$i-12]['deaths'] >= 0 && $xml_data->statistics->ranking->player[$i-12]['kills'] == 0) 

	{

		echo "0/0";

	}

	//kills but no deaths

	elseif ($xml_data->statistics->ranking->player[$i-12]['deaths'] == 0 && $xml_data->statistics->ranking->player[$i-12]['kills'] > 0) 

		{

			echo "100 / 0";

		}

		else

			{ 

			  $kills = $xml_data->statistics->ranking->player[$i-12]['kills'];  

			  $deaths = $xml_data->statistics->ranking->player[$i-12]['deaths'];

			  // Total Kill and Death 

			  $k_d_ratio =  $kills + $deaths;

			  // Killed Percentage

			  $killpercent = $kills / $deaths;

			  // Died Percent

			  $deathpercent = $deaths / $kills;

			  echo "$killpercent / $deathpercent";

			  // If you just want to show number of kills and deaths uncomment line below

			  // echo "$kills / $deaths";


			}

?>

I got a question. Does this game append the logs of each game to the same file or is it making a new file for each game?

If it is doing that latter you will need to add in database support to check for players name, if name is not there create it with tables for stats and enter data from game. If the name is there pull previous stats from database and recalculate with new stats and then write them back.

Edited by RuTHlezz1
Link to comment
Share on other sites

Nice work man!!!!!!!!!

Here is a code snippet if you want alt color tables. you will need to place it your do while loop.

		// Set Color for alt table

		// If $color==1 table row color = #FFC600

		if($color==1)

		  {

			 $altcolor = "$bgcolor4"; #Slate Grey

						 // Set $color==2, for switching to other color

			$color="2"; 

		  }

		  // When $color not equal 1, use this table row color

		  else

			{				   

			   $altcolor="#6D7B8D"; 

			   $color="1";

			}

Edited by RuTHlezz1
Link to comment
Share on other sites

I got a question. Does this game append the logs of each game to the same file or is it making a new file for each game?

It's make a new file for every round:

domination_0.xml

domination_1.xml

domination_2.xml

domination_3.xml

domination_4.xml

domination_5.xml

domination_6.xml

domination_7.xml

domination_8.xml

...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...