Jump to content
Sign in to follow this  
V3ct0r

[PHP] Online HD & GM

Recommended Posts

With this script you can show to players who is online from HD and GM.

 

<?php

$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = 'GameDB';
$hd_level = 30;

if (mssql_connect($db_host, $db_user, $db_pass) == false) {
	die ('<b>Error: </b> Can not connect to MSSQL server!');
}

if (mssql_select_db($db_name) == false) {
	die ('<b>Error: </b> Can not select game database!');
}

$sql = 'SELECT c.cha_name, a.gm  FROM character AS c LEFT JOIN account AS a ON (c.act_id = a.act_id) WHERE c.mem_addr > 0 AND a.gm > 0';
$query = mssql_query($sql);
if ($query == false) {
	die ('<b>Error: </b> Can not get list of online HD and GM!');
}

$stuff = array();
while ($cha = mssql_fetch_object($query))
{
	$stuff[] = $cha;
}

mssql_close();

?>

<html>
	
	<head>
		<title>Список HD и GM в игре</title>
	</head>
	
	<body>
		<h1>Список HD и GM в игре</h1>
		<?php
			
			$stuff_online = '';
			$n =  count($stuff);
			
			if ($n > 0)
			{
				for ($i = 0; $i < $n; $i++)
				{
					if ($stuff[$i]->gm > $hd_level) {
						$stuff_online .= '[GM] ' . $stuff[$i]->cha_name;
					}
					else {
						$stuff_online .= '[HD] ' . $stuff[$i]->cha_name;
					}
					
					if ($i != ($n - 1)) {
						$stuff_online .= ', ';
					}
					else {
						$stuff_online .= '.';
					}
				}
			}
			else
			{
				$stuff_online = 'All HD and GM are offline.';
			}
			
			print $stuff_online;

		?>
		
	</body>
	
</html>

 

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×