Jump to content

MTA Sever Stat Fetcher 1.0 by 404


404

Recommended Posts

Posted (edited)

I am new to the GTA PC world, I got the game about 2 weeks ago and started playing it then started moding it and found MTA and was like, "oh cool". So I played it for a few days then I started to browse the forums and got an idea to make a php script to fetch server stats. As I was browsing the forum I noticed that someone made on a while back and I saw another topic that said he didn't update it anymore. So that brings me to this, my first post and a php script to fetch stats.

I am pretty much done with the coding part (I used the existing code and modified it pretty good). Though as I started to test it out on different servers it did not work so I will have to make like a config file for it. You can look at it now right here: http://ninezeronine.net/404/gtaserver.php. Please post any questions/comments you have.

////Edit////

11/20/04 - 6:07 EST

I made a lot of progress and the release that I had hoped for today just isn't going to happen, while the script works great on some servers it looks horrible on others. I am trying to resolve a salution to fix this, check back for updates. Also any request you want please post them.

////Edit////

11/21/04 - 6:50 EST

Okay, I think I fixed the bugs but am not totally sure, tested it on the top 10 servers and a few others and it worked okay. One thing is that it does not work on any MTA Server < 0.4.1 or with GTA3 servers. If I get enough request I can make compatible version. Anyway here is the link and have fun, questions, comments and suggestions welcome.

http://www.ninezeronine.net/404/mta.php

Edited by Guest
Posted

Finally somebody decided to work on stat for mta servers. Everybody knows that statistic that dusty made for mta0.2.2 is too old for mta 0.4, so I thing you should continue your work and good luck with coding it :wink:

Posted

Good Job, but the score seems to be off..or it looks like the ping am not sure :? . Maybe add a cool design and zip it, i bet lots of people would use it, Good Luck.

  • 2 weeks later...
Posted

this is my config file:

<?php
/////////////////////////////////////////////////////////////////
//           MTA Sever Stat Fetcher 1.0         //
//        http://www.ninezeronine.net/404      //
//              [email protected]           //
//                      gtaconfig.php                   //
//         Copyright (C) 2004 Justin Court      //
////////////////////////////////////////////////////////////////

//////////----Start Config----//////////
$ServerIP = "24.132.106.135";
$ServerPort = "2003";
$serverArr = 2;
$mapArr = 4;
$verArr = 5;
$curUserArr = 7;
$maxUserArr = 8;
$displayPlayers = 1; //1=yes, 0=no
$displayScore = 1; //1=yes, 0=no
$displayPing = 1; //1=yes, 0=no
$displayMap = 1; //1=yes, 0=no
$displayMTAVersion = 1; //1=yes, 0=no
$displayServerAndPort = 1; //1=yes, 0=no
$useMTAHandler = 1; //1=yes, 0=no
$numStart = 1; //1=start at one, 0 start at zero
$displayLeadingZero = 1; //1=yes, 0=no
$table1color = "#C0C0C0";
$table2color = "#FFFFFF";
$tableBorderColor = "#000000";
///////////----End Config----///////////

//////////--Do Not Edit Below This Unless You Know What You Are Doing--//////////
$fp = fsockopen("udp://" . $ServerIP, $ServerPort + 123, $errno, $errstr);

if (!$fp) {
echo "$errstr ($errno)
\n";
exit;
} else {   
fputs ($fp, "s");   
$c = '';
do {
	$c .= fread ($fp,1);
	$fpstatus = socket_get_status($fp); 
} while ($fpstatus["unread_bytes"] );
	fclose ($fp);

	$playerquery = strchr($c,"?");
	$serverquery = substr($c,0, strlen($c) - strlen($playerquery));

	$players = explode("?",$playerquery);
	unset($players[0]);    // Remove Array number 0 because nothing is entered by explode.

	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("%","",$serverquery);

		for($i=0;$i<(count($serverquery));$i++){
			$explodedata = explode("<=>",$serverquery);
		}
}

$server_name = str_replace($ServerPort,"",$explodedata[$serverArr]);

?>

and it's not working i have port 123 free on the server pc

Posted (edited)

This may be of help to some people:

<?php
/////////////////////////////////////////////////////////////////
//           MTA Sever Stat Fetcher 1.0                          //
//        http://www.ninezeronine.net/404                     //
//                      gtaconfig.php                                   //
//         Copyright (C) 2004 Justin Court                     //
////////////////////////////////////////////////////////////////

//////////----Start Config----//////////
$ServerIP = "217.170.21.65";
$ServerPort = "2004";
$serverArr = 2;
$mapArr = 4;
$verArr = 3;
$curUserArr = 5;
$maxUserArr = 6;
$displayPlayers = 1; //1=yes, 0=no
$displayScore = 1; //1=yes, 0=no
$displayPing = 1; //1=yes, 0=no
$displayMap = 1; //1=yes, 0=no
$displayMTAVersion = 1; //1=yes, 0=no
$displayServerAndPort = 1; //1=yes, 0=no
$useMTAHandler = 1; //1=yes, 0=no
$numStart = 1; //1=start at one, 0 start at zero
$displayLeadingZero = 1; //1=yes, 0=no
$table1color = "#C0C0C0";
$table2color = "#FFFFFF";
$tableBorderColor = "#000000";
///////////----End Config----///////////

//////////--Do Not Edit Below This Unless You Know What You Are Doing--//////////
$fp = fsockopen("udp://" . $ServerIP, $ServerPort + 123, $errno, $errstr);

if (!$fp) {
echo "$errstr ($errno)
\n";
exit;
} else {   
fputs ($fp, "s");   
$c = '';
do {
	$c .= fread ($fp,1);
	$fpstatus = socket_get_status($fp); 
} while ($fpstatus["unread_bytes"] );
	fclose ($fp);

	$playerquery = strchr($c,"?");
	$serverquery = substr($c,0, strlen($c) - strlen($playerquery));

	$players = explode("?",$playerquery);
	unset($players[0]);    // Remove Array number 0 because nothing is entered by explode.

	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("%","",$serverquery);

		for($i=0;$i<(count($serverquery));$i++){
			$explodedata = explode("<=>",$serverquery);
		}
}

$server_name = str_replace($ServerPort,"",$explodedata[$serverArr]);

?>

BTW I got it working for the stats for my GTA3 Server - the only prob is that it says Vice City Stunt for map instead of Portland, everything else seems to work fine :D

Edit: Here's My Stats Page

Edit2: Here's My Stats Setup Page

Edited by Guest
Posted

Could I request you pull my email addy out of the config.php scripts you posted? I don't want any spam bots :P

Posted
this is my config file:

<?php
/////////////////////////////////////////////////////////////////
//           MTA Sever Stat Fetcher 1.0         //
//        http://www.ninezeronine.net/404      //
//                      gtaconfig.php                   //
//         Copyright (C) 2004 Justin Court      //
////////////////////////////////////////////////////////////////

//////////----Start Config----//////////
$ServerIP = "24.132.106.135";
$ServerPort = "2003";
$serverArr = 2;
$mapArr = 4;
$verArr = 5;
$curUserArr = 7;
$maxUserArr = 8;
$displayPlayers = 1; //1=yes, 0=no
$displayScore = 1; //1=yes, 0=no
$displayPing = 1; //1=yes, 0=no
$displayMap = 1; //1=yes, 0=no
$displayMTAVersion = 1; //1=yes, 0=no
$displayServerAndPort = 1; //1=yes, 0=no
$useMTAHandler = 1; //1=yes, 0=no
$numStart = 1; //1=start at one, 0 start at zero
$displayLeadingZero = 1; //1=yes, 0=no
$table1color = "#C0C0C0";
$table2color = "#FFFFFF";
$tableBorderColor = "#000000";
///////////----End Config----///////////

//////////--Do Not Edit Below This Unless You Know What You Are Doing--//////////
$fp = fsockopen("udp://" . $ServerIP, $ServerPort + 123, $errno, $errstr);

if (!$fp) {
echo "$errstr ($errno)
\n";
exit;
} else {   
fputs ($fp, "s");   
$c = '';
do {
	$c .= fread ($fp,1);
	$fpstatus = socket_get_status($fp); 
} while ($fpstatus["unread_bytes"] );
	fclose ($fp);

	$playerquery = strchr($c,"?");
	$serverquery = substr($c,0, strlen($c) - strlen($playerquery));

	$players = explode("?",$playerquery);
	unset($players[0]);    // Remove Array number 0 because nothing is entered by explode.

	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery); 
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("","<=>",$serverquery);
	$serverquery = str_replace("%","",$serverquery);

		for($i=0;$i<(count($serverquery));$i++){
			$explodedata = explode("<=>",$serverquery);
		}
}

$server_name = str_replace($ServerPort,"",$explodedata[$serverArr]);

?>

and it's not working i have port 123 free on the server pc

What OS are you running and do you have PHP installed?

Posted

I would try and do kills like that, I know I could in PHP if the server outputted it, if not maybe one of the MTAmA people could make it output then you could display it with php and even log it into SQL, I am very new to the whole GTA: MTA scene so I am not too fond of the server and such yet.

Posted

For some odd enough reason, It sometimes displays a character before the server name, still working on this issue.

  • 2 weeks later...
Posted

Well Bob, the story behind my lack of updates for my stats script is pretty much being swamped at work.. I just didn't have time to do it anymore, I didn't have time to maintain my server anymore and I could think of better things to do with $200+ a month instead of paying for a server I didn't use much.

I wouldn't mind tinkering with the script some to get it running again in the latest version whenever I get a chance if someone would like to donate some web space. I have a domain for the script that I planned on using (I believe it was mtastats.com, but I'd have to double check).

I'd prefer a unix system that can run a mta server for testing purposes. Needs MySQL and PHP of course.

If anyone is interested my e-mail address is dusty at cox dot net.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...