[SPQR]The JAckal Posted May 9, 2006 Share Posted May 9, 2006 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? Quote Link to comment Share on other sites More sharing options...
EasyCo Posted May 9, 2006 Share Posted May 9, 2006 That would be awesome. I'm sure that information could be harvested and placed in a webpage. Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 9, 2006 Share Posted May 9, 2006 If anyone has a larger version of this file or files, could you email it to me? firefly2442 [at] gmail.com Thanks! Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 9, 2006 Author Share Posted May 9, 2006 Any1 able to write a script to do that? Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 9, 2006 Share Posted May 9, 2006 I know PHP, I can get on it if I have some time here.... Is grenade_kill part of "kills" or is it separate? Quote Link to comment Share on other sites More sharing options...
MajorPlayer Posted May 9, 2006 Share Posted May 9, 2006 Looks like grenade kills is already included in the kills so its seperate. Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 11, 2006 Author Share Posted May 11, 2006 I might need some help with some simple graphics/images later. I don't know nothing about php, but i will very happy to help you about graphic. Send me a PM if you need help Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 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. 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. Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 11, 2006 Author Share Posted May 11, 2006 USA Flag Mexico Flag (Flags from VWar) Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 Does their license allow others to use their images? Quote Link to comment Share on other sites More sharing options...
Ben Posted May 11, 2006 Share Posted May 11, 2006 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 Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 11, 2006 Author Share Posted May 11, 2006 (edited) Marksman Demolition Tactician Edited May 11, 2006 by [SPQR]The JAckal Quote Link to comment Share on other sites More sharing options...
RuTHlezz1 Posted May 11, 2006 Share Posted May 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 11, 2006 Author Share Posted May 11, 2006 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 Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 So for the Kill to Death Ratio (K:D), how do you think I should calculate it if they don't have any deaths? I can't divide by zero obviously... Quote Link to comment Share on other sites More sharing options...
RuTHlezz1 Posted May 11, 2006 Share Posted May 11, 2006 (edited) 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 May 11, 2006 by RuTHlezz1 Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 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! Quote Link to comment Share on other sites More sharing options...
RuTHlezz1 Posted May 11, 2006 Share Posted May 11, 2006 (edited) 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 May 11, 2006 by RuTHlezz1 Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 (edited) Not sure about that. Does anyone know if the server rewrites over the file each time? Yeah, good call there... Here's an early screenshot, I need to add CSS stylesheet support here in a minute.... Edited May 11, 2006 by firefly2442 Quote Link to comment Share on other sites More sharing options...
RuTHlezz1 Posted May 11, 2006 Share Posted May 11, 2006 (edited) 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 May 11, 2006 by RuTHlezz1 Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 How can you have more lethal shots than kills? RuTHlezz1- Thanks! I'll work on incorporating that.... Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 Well, I guess I can release beta v0.1 Screenshots: I still want the HTML code to be valid: http://validator.w3.org/ I'll work on this later.... Here's the download link: http://www.rivetcode.com/files/phpgrawstat...awstats_0-1.zip Enjoy! Quote Link to comment Share on other sites More sharing options...
[SPQR]The JAckal Posted May 11, 2006 Author Share Posted May 11, 2006 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 ... Quote Link to comment Share on other sites More sharing options...
firefly2442 Posted May 11, 2006 Share Posted May 11, 2006 Does it make stats for other game modes too, like Coop? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.