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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...