Get Server Stats
#1

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

Reply
#2

****** 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)
Reply
#3

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

GetServerRuleAs* dont even need a plugin
Reply
#5

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....
Reply
#6

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.
Reply
#7

okay...can you give me the code? would help me...
Reply
#8

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");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)