Defent Posted April 10, 2014 Report Share Posted April 10, 2014 So I created a script that checks your .RPT and reports back the latest kill that happened. I am not that good at PHP scripting so excuse any stupid placements of blocks or whatnot. <?php //CONFIG $search = 'PKILL:'; $input = array_reverse(file("C:\Server\Steam\SteamApps\common\panthera\Configs\instance_16_panthera\arma2oaserver.RPT"),1); // the ,1) needs to be there.. for some reason. //CONFIG END $found = false; foreach ($input as $line) { if(strpos($line, $search) !== false) { $found = true; echo "<h7>[".$line."]</h7><br/>"; break; } } if(!$found) { echo "<h5>I see no dead, yet.</h5>"; } ?> The result ends up like this: http://numenadayz.com/stats.php What do you think? Any feedback on how to make it better or should I keep it away because it affects performance and yada yada? insertcoins 1 Link to comment Share on other sites More sharing options...
Flosstradamus Posted April 10, 2014 Report Share Posted April 10, 2014 Yeah this should of been posted under Epoch Resources forum. It seems pretty cool but I currently have no use for it. Link to comment Share on other sites More sharing options...
Defent Posted April 10, 2014 Author Report Share Posted April 10, 2014 Yea noticed that too. This doesn't really do anything practical other than, ya know.. looks cool. Link to comment Share on other sites More sharing options...
Sukkaed Posted April 10, 2014 Report Share Posted April 10, 2014 :unsure: :wacko: :blink: Warning: array_reverse() expects parameter 1 to be array, boolean given in *snip on line 4 Warning: Invalid argument supplied for foreach() in *snip on line 8 Link to comment Share on other sites More sharing options...
Defent Posted April 10, 2014 Author Report Share Posted April 10, 2014 I like it. Maybe make something like (Im not a PHP boss either a SQF boss nor C++ etc so..^^): If (weapon == "DMR_DZ") then {Image DMR}; Otherwise, I really, really like it, good job mate. xBowBii That would be possible, you can add another search word in the script and just make a if case and then add images based on that boolean etc :) - I guess atleast. And thanks! :unsure: :wacko: :blink: Warning: array_reverse() expects parameter 1 to be array, boolean given in *snip on line 4 Warning: Invalid argument supplied for foreach() in *snip on line 8 Try this instead: $input = array_reverse file("path\to\my.rpt"); I don't actually know what the 2nd error means. did you change any of my arrays and what not? Link to comment Share on other sites More sharing options...
MassAsster Posted April 10, 2014 Report Share Posted April 10, 2014 icons\dmr.png <---- currently icons/dmr.png <--- should be looks good man , neat idea! ;) Link to comment Share on other sites More sharing options...
Defent Posted April 10, 2014 Author Report Share Posted April 10, 2014 icons\dmr.png <---- currently icons/dmr.png <--- should be looks good man , neat idea! ;) Yea noticed that.. amongst other things. I've been trying to get the picture to show up but it just won't respond to the arrays. I guess the break; ruins the for loop and therefore the script only returns the first array. I have no idea how to make the loop only return one line though.. I kinda made a cheap move to break the loop after the first value had been returned :) Here's what I've done so far: <?php //CONFIG $search = 'PKILL:'; $search_array = array("DMR", "m8_carbine", "AK_74", "m8_compact"); $input = array_reverse(file("C:\Server\Steam\SteamApps\common\panthera\Configs\instance_16_panthera\arma2oaserver.RPT"),1); //CONFIG END $found = false; foreach ($input as $line ) { if(strpos($line, $search) !== false) { /* if (array_search("DMR", $search_array)) { $found = true; echo "<h7><img src='fuck/dmr.png'></img> ".$line."</h7><br/>"; break; } else if (array_search("AK_74", $search_array)) { $found = true; echo "<h7><img src='fuck/ak_74.png'></img> ".$line."</h7><br/>"; break; } else if (array_search("m8_compact", $search_array)) { $found = true; echo "<h7><img src='fuck/m8_carbine.png'></img> ".$line."</h7><br/>"; break; } $found = true; echo "<h7><img src='fuck/shitisfucked.png'></img> ".$line."</h7><br/>"; break; */ } /* else //bob the builder, if shit is not working well then its fucked. { $found = true; echo "<h7><img src='fuck\shitisfucked.png' heigh='30' width='30'></img> ".$line."</h7><br/>"; break; } */ } if(!$found) { echo "<h5>I see no dead, yet.</h5>"; } ?> Link to comment Share on other sites More sharing options...
MassAsster Posted April 11, 2014 Report Share Posted April 11, 2014 Just curious, why did you choose foreach rather than while ? http://www.php.net/manual/en/control-structures.while.php I find foreach annoying Link to comment Share on other sites More sharing options...
Sukkaed Posted April 11, 2014 Report Share Posted April 11, 2014 I don't actually know what the 2nd error means. did you change any of my arrays and what not? I didn't change anything but the path. I'll try that. Link to comment Share on other sites More sharing options...
Defent Posted April 11, 2014 Author Report Share Posted April 11, 2014 Just curious, why did you choose foreach rather than while ? http://www.php.net/manual/en/control-structures.while.php I find foreach annoying I found it easier to use, because I needed to reverse the file searching, otherwise I would get the oldest result instead of the newest result. Link to comment Share on other sites More sharing options...
Sukkaed Posted April 11, 2014 Report Share Posted April 11, 2014 This only shows the last kill? Can it be a list of all kills in that .RPT? ..and only way it worked for me is like this: $input = file('path\to\my.rpt'); $rev_input = array_reverse($input); EDIT: Never mind. I just removed "break;" and it shows all kills. Defent 1 Link to comment Share on other sites More sharing options...
zerew Posted April 17, 2014 Report Share Posted April 17, 2014 My code, all kills. <?php $file = 'C:\dayz\server\instance_11_Chernarus\arma2oaserver.RPT'; $searchfor = 'PKILL:'; header('Content-Type: text/plain'); $contents = file_get_contents($file); $pattern = preg_quote($searchfor, '/'); $pattern = "/^.*$pattern.*$/m"; if(preg_match_all($pattern, $contents, $matches)){ echo "Kill list: "; echo implode(" ", $matches[0]); } else { echo "Not Kills!"; } ?> Link to comment Share on other sites More sharing options...
zerew Posted April 19, 2014 Report Share Posted April 19, 2014 I modified the code for easier insertion into html page. <pre> <?php $file = 'C:\dayz\server\instance_11_Chernarus\arma2oaserver.RPT'; $searchfor = 'PKILL:'; $contents = file_get_contents($file); $pattern = preg_quote($searchfor, '/'); $pattern = "/^.*$pattern.*$/m"; if(preg_match_all($pattern, $contents, $matches)){ echo "Список убийств: <br> "; $result = implode(" ", $matches[0]); $patterns = array(); $patterns[0] = '/"PKILL:/'; $patterns[1] = '/was killed by/'; $patterns[2] = '/with weapon/'; $patterns[3] = '/from/'; $patterns[4] = '/m"/'; $replacements = array(); $replacements[4] = 'Игрок<b>'; $replacements[3] = '</b>был убит игроком<b>'; $replacements[2] = '</b>из оружия<b>'; $replacements[1] = '</b>с расстояния'; $replacements[0] = '</b> метров.'; echo preg_replace($patterns, $replacements, $result); } else { echo "Пока что убийств нету!"; } ?> </pre> </pre></pre> - required to correct lines line looks like this: "12:40:30 Игрок puhru был убит игроком Yilk из оружия AKS_74_U с расстояния 3.30967 метров." I used replacement, translated into Russian, and added html codes. result of the work here: http://kill.ggbb.ws/ Defent 1 Link to comment Share on other sites More sharing options...
Defent Posted April 19, 2014 Author Report Share Posted April 19, 2014 Oh, nice - I like what you did with it, thanks for fixing some stuff that I had problems with :) Link to comment Share on other sites More sharing options...
Triage Posted April 19, 2014 Report Share Posted April 19, 2014 Nice work defent. Going to be adding this to my website when I get home. Link to comment Share on other sites More sharing options...
Defent Posted April 19, 2014 Author Report Share Posted April 19, 2014 Thank you :) Link to comment Share on other sites More sharing options...
zerew Posted April 20, 2014 Report Share Posted April 20, 2014 If you want images of weapons. Edit the replacement code. And use images of weapons PrivateHiveTools $patterns = array(); $patterns[0] = '/"PKILL:/'; $patterns[1] = '/was killed by/'; $patterns[2] = '/with weapon /'; $patterns[3] = '/ from/'; $patterns[4] = '/m"/'; $replacements = array(); $replacements[4] = 'Игрок<b>'; $replacements[3] = '</b>был убит игроком<b>'; $replacements[2] = '</b>из оружия<b><img src=/images/'; $replacements[1] = '.png width=120 height=30></b>с расстояния'; $replacements[0] = '</b> метров.'; Specify your image sizes and a folder of images taken from PrivateHiveTools Note that in 4 and 5 string added spaces. Defent, thanks for the idea of this code! Defent 1 Link to comment Share on other sites More sharing options...
theballin7 Posted April 28, 2014 Report Share Posted April 28, 2014 this is how mine is done it dont show the gun image but its not needed i created an .dll that writes to a text file and then made a php script to read everything on that file i added this line into my server files/compile/serverPlayerDied.sqf under diag_log _loc_message; i added "Deathsz" callExtension (_loc_message) Deathsz being my .dll name php code <?php $file1 = "C:\Users\DayZ\Desktop\DayZ Servers\Epoch\Deathsz.txt"; $lines = file($file1); foreach($lines as $line_num => $line) { echo "<font color='red'>$line</font>"; echo "<br>"; } ?> and the output would look like this ( you would just have the kills not the menus ) Defent 1 Link to comment Share on other sites More sharing options...
cen Posted April 28, 2014 Report Share Posted April 28, 2014 any chance of sharing your .dll? Link to comment Share on other sites More sharing options...
theballin7 Posted April 29, 2014 Report Share Posted April 29, 2014 any chance of sharing your .dll? here you go place the dll and text file in your server root directory http://www.mediafire.com/download/idqnc5ecjljfim9/Deathsz.zip Link to comment Share on other sites More sharing options...
cen Posted April 29, 2014 Report Share Posted April 29, 2014 Thanks ballin! Link to comment Share on other sites More sharing options...
ludicrousgib Posted May 6, 2014 Report Share Posted May 6, 2014 I'd love to add this to my site, but im really confused. Running a couple of servers on a dedi, with the site hosted separately. Guessing this only works if the server and site are hosted off the same machine? Link to comment Share on other sites More sharing options...
RimBlock Posted May 21, 2014 Report Share Posted May 21, 2014 Setup a shared drive on the webserver where you would like the file to stay. Create a new limited access user account that can be used to login to that share. Make sure the account is not having any access to the game server. Mount the shared drive on you game server (using the restricted access account). Setup a batchfile to run robocopy to sync the gameserver rpt with the remote share location (push from game server to webserver for security reasons). Use Windows task schedular to run the batch file automatically every XXX minutes. Link to comment Share on other sites More sharing options...
Gr8 Posted May 26, 2014 Report Share Posted May 26, 2014 Is it possible to use this with non dedicated servers? I have access to RPT. I use survivalservers Link to comment Share on other sites More sharing options...
CommanderRetra Posted May 27, 2014 Report Share Posted May 27, 2014 Is it possible to use this with non dedicated servers? I have access to RPT. I use survivalserversif you cancel your service with them and buy a dedi it will work. Seriously. Just don't use Survival Servers. looter809 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now