SA-MP Forums Archive
Get Server Stats - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Get Server Stats (/showthread.php?tid=73654)



Get Server Stats - [dp]Janson - 16.04.2009

Sry Guys,

but is it possible to get the current Gamemode of the Server with any plugin or something (ingame not php or something and not socket because of timeout!!!)

thx =D




Re: Get Server Stats - DMSOrg - 16.04.2009

****** released a command called GetServerRule I believe (include, btw) which probably can retrieve the gamemode name. SEARCH BUTTON, AHOY!

(also, this might be more suitable in the scripting discussion forum)


Re: Get Server Stats - d0 - 16.04.2009

you can use php and then use the pwncurl plugin to download the serverinfo


Re: Get Server Stats - boylett - 16.04.2009

GetServerRuleAs* dont even need a plugin


Re: Get Server Stats - [dp]Janson - 16.04.2009

but php works with sockets...sockets=>timeouts(sometimes) and i can't stand them xD

And i can't find any GetServerRule in the search here there is just a setserverrule in YSF....


Re: Get Server Stats - tom_jonez - 17.04.2009

Quote:
Originally Posted by [dp
Janson ]
but php works with sockets...sockets=>timeouts(sometimes) and i can't stand them xD

And i can't find any GetServerRule in the search here there is just a setserverrule in YSF....
Yeah, the website im making has a command GetGTAServerStatus($ip,$port) and i set the timeout to 1, it still takes like 5 seconds to load the simple page when the gameserver is down.


Re: Get Server Stats - [dp]Janson - 17.04.2009

okay...can you give me the code? would help me...


Re: Get Server Stats - tom_jonez - 17.04.2009

Quote:
Originally Posted by [dp
Janson ]
okay...can you give me the code? would help me...
Код:
function GetGTAServerStatus($image,$hostname=game_server_host,$port=game_server_port)
{
	$realtimeout = ini_get("default_socket_timeout");
	ini_set("default_socket_timeout","1");
	if(!isset($image)) $image = 1;
	if(!isset($hostname)) $fp = fsockopen("udp://".game_server_host, game_server_port, $errno, $errstr);
	else if(isset($hostname) && !isset($port)) $fp = fsockopen("udp://".$hostname, 7777, $errno, $errstr);
  else if(isset($hostname) && isset($port)) $fp = fsockopen("udp://".$hostname, $port, $errno, $errstr);
	ini_set("default_socket_timeout",$realtimeout);
	if($fp)
	{
		$packet = 'SAMP';
		$packet .= chr(strtok($hostname, '.')).chr(strtok('.')).chr(strtok('.')).chr(strtok('.'));
		$packet .= chr($port & 0xFF);
		$packet .= chr($port >> 8 & 0xFF);

		fwrite($fp, $packet.'i');
		fread($fp, 11);
		$is_passworded = ord(fread($fp, 1));
		$plr_count   = ord(fread($fp, 2));
		$max_plrs   = ord(fread($fp, 2));
		$strlen    = ord(fread($fp, 4));
		$hostname   = fread($fp, $strlen);
		fclose($fp);
		if(strlen($hostname) > 0)
		{
			if($image) echo("<center><a href=\"status.php\"><img src=\"./images/serverup.png\" alt=\"The Game Server Is Up!\" border=\"0\"></a></center>");
			return 1;
		}
		if(strlen($hostname) == 0)
		{
			if($image) echo("<center><img src=\"./images/serverdown.png\" alt=\"The Game Server Is Down!\"></center>");
			return 0;
		}
	}
	if($image) echo("<center><img src=\"./images/serverdown.png\" alt=\"The Game Server Is Down!\"></center>");
	return 0;
}
just use:
Код:
define("game_server_host","Host");
define("game_server_port","Port");