Jump to content
php.lv forumi

samp


ashais13

Recommended Posts

kaa lai palaiz so samp monitoru man vinjs uzraadas saadi ko es daru nepareizi seit monis kaa man vinjs izskatas

<html>
 <head>
<title>SA:MP Server Query Script</title>
<style type="text/css">
  body { font-family: verdana; font-size: 11px; }
  td { font-family: verdana; font-size: 11px; }
</style>
 </head>
 <body bgcolor="#1B304B" text="#EEEEEE">
<br><center><b><font color="#ffffff">SA:MP Server Query Script</font></b></center><br><br>
<table width="350" bgcolor="#000000" cellpadding="4" cellspacing="1" align="center">
<?
//	if ($_GET['ip']) $ip = $_GET['ip'];
//	if ($_GET['port']) $port = $_GET['port'];

if (!isset($ip))
	$ip = '83.149.98.25';
if (!isset($port))
	$port = 7777;

$fp = fsockopen('udp://' . $ip, $port, $errno, $errstr);
if (!$fp)
{
	echo "<tr><td bgcolor=\"#2B5486\">Socket Error: $errno - $errstr</td></tr>\n";
}
else
{
	$packet = 'SAMP';
	$packet .= chr(strtok($ip, '.'));
	$packet .= chr(strtok('.'));
	$packet .= chr(strtok('.'));
	$packet .= 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);
	$strlen		= ord(fread($fp, 4));
	$gamemode	  = fread($fp, $strlen);
	$strlen		= ord(fread($fp, 4));
	$mapname	   = fread($fp, $strlen);

	echo '	  <tr><td bgcolor="#2B5486" colspan="2" align="center"><b>' . $hostname . '</b></td></tr>'."\n";
	echo '	  <tr><td bgcolor="#2B5486" width="100">Players: </td><td bgcolor="#2B5486" width="250">' . $plr_count . ' / ' . $max_plrs . '</td></tr>'."\n";
	echo '	  <tr><td bgcolor="#2B5486">GameMode: </td><td bgcolor="#2B5486">' . $gamemode . '</td></tr>'."\n";
	echo '	  <tr><td bgcolor="#2B5486">MapName: </td><td bgcolor="#2B5486">' . $mapname . '</td></tr>'."\n";
	if ($is_passworded)
	{
		echo '	  <tr><td bgcolor="#2B5486">Passworded: </td><td bgcolor="#2B5486">Yes</td></tr>'."\n";
	} else {
		echo '	  <tr><td bgcolor="#2B5486">Passworded: </td><td bgcolor="#2B5486">No</td></tr>'."\n";
	}

	fwrite($fp, $packet.'c');
	fread($fp, 11);
	$plr_count = ord(fread($fp, 2));
	if ($plr_count > 0)
	{
		echo '	</table><br>'."\n";
		echo '	<table width="350" bgcolor="#000000" cellpadding="4" cellspacing="1" align="center">'."\n";
		echo '	  <tr><td bgcolor="#2B5486" colspan="2" align="center"><b>Players:</b></td></tr>'."\n";
		echo '	  <tr><td bgcolor="#2B5486" align="center" width="250"><b>Player</b></td><td bgcolor="#2B5486" align="center" width="100"><b>Score</b></td></tr>'."\n";
		for ($i=0; $i<$plr_count; $i++)
		{
			$strlen = ord(fread($fp, 1));
			$plrname = fread($fp, $strlen);
			$score = samp_getLong(fread($fp, 4));

			echo '	  <tr><td bgcolor="#2B5486">' . $plrname . '</td><td bgcolor="#2B5486">' . 
$score  . '</td></tr>'."\n";
		}
	}
	fclose($fp);
}
?>
</table><br>
<center><small>© 2006 SA:MP Team. All rights reserved.</small></center>
 </body>
</html>

<?

function samp_getLong($dat) {
$num=0;
if ((ord(substr($dat,3,1)) & 128) > 0) {
	for ($i=0; $i<strlen($dat); $i++) {
		$num-=((255-ord(substr($dat,$i,1))) << 8*$i);
	}
	$num--;
} else {
	for ($i=0; $i<strlen($dat); $i++) {
		$num+=(ord(substr($dat,$i,1)) << 8*$i);
	}
}
return $num;
}

Link to comment
Share on other sites

  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Pateica, ka ja izlaboji to vietu, tad nevajag neko labot tajā ini failā...

 

P.S. Kad agrāk ķēpājos ar php-fusion, man viņš nestrādāja pilnībā =/ Viņam kkas tur čakarējās...

Pārinstalēju serveri uz appserv (es iesaku appserv-win32-2.5.6 vai jaunāku ) :)

Bet es negalvoju, ka vaina ir serverī... Atceros ka esmu izmēģinājis visus serverus...Gan xapm, wapm, appserv un t.t.

Appserv, ja nokonfigurē viņš ir labs :)

Edited by hackerman
Link to comment
Share on other sites

ashais13, tu ar galvu draudzējaties ? Tev problēma ir skriptā. Liec to php.ini mierā.

 

PS. Par Start -> Search neesi dzirdējis ?

PS2. e107 ir būvēts uz PHP bāzes. Tas nav kaut kas neatkarīgs no PHP. Tātad php.ini tev ir jābūt.

PS3. hackerman, visi tie "serveri" ir viens un tas pats - apache + php + vēl kaut kas. Atšķirība ir tikai konfigurācijās un kā tas viss ir sakabināts kopā.

Edited by andrisp
Link to comment
Share on other sites


×
×
  • Create New...