Server Status

From VbGORE Visual Basic Online RPG Engine

link title== Server Status == This is a tutorial to check if the specified IP is online or not.

[edit] For websites

This is a very simple way to determinate if your server is online or not.

<?php 
$ip = 83.235.181.217; 
$port = 2106; 
 
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) 
  echo "<B><FONT COLOR=red>The server is current offline.</b></FONT>"; 
else{ 
  echo "<B><FONT COLOR=green>Yay! The server is online!</b></FONT>"; 
  fclose($sock); 
} 
?>

That is the most basic way to check if your game is online or not, you can use it in most of websites. Adding the @ in front of the fsockopen() keeps an error message from displaying for those who need it. Note: Don't forget to replace "Your game's ip here" and "Your game's port here" for the respective IP and port.

[edit] For signatures to use on forum, etc

In this Example we'll use the Article Dynamic Signature. First of all make sure you did the Workshop correct and the resulting Image loads correct and shows you all data.

So then let's go to add the server Status..

First of all be sure to add before

$dbhost = 'localhost';

this

error_reporting(0);

This will turn the error off when php can't connect to the server (=offline). When the error would be displayed, the image wouldn't be given out by php ;)

Next add under

if ($online == '0')
	{
		$reallyonline = 'Offline';	
	} else {
		$reallyonline = 'Online';	
	}

the Following:

$ip = 83.235.181.217; 
$port = 7777; 
 
if (! $sock = fsockopen($ip, $port, $num, $error, 5)) 
  $server_online = 'Offline';
else{ 
  $server_online = 'Online';
  fclose($sock); 
}

Replace "Your game's ip here" with the IP of your server and "Your game's port here" with the corresponding port to your server.

At last you'll have to replace

ImageString ($img_handle, 2, 25, 7,  "$serverdesc", $color);

with

ImageString ($img_handle, 2, 25, 7,  "$serverdesc ($server_online)", $color);

That's it! The final result should look like this.

If there are further questions, just send Christoph680 a PM in the forums.

Personal tools