Jump to content

Script to check if a Game Server is online


Whoo

Recommended Posts

I've been looking for a simple script that would connect to a game server to see if it is still online. I've found many, but not one of them work. They will permanently send back the text "Online", or "Offline". This is the simplest code I have found:

 

<?php
$ip = "66.79.190.40"; 
$port = "27960"; 
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) 
echo '<B><FONT COLOR=red>Offline</b></FONT>'; 
else{ 
echo '<B><FONT COLOR=lime>Online</b></FONT>'; 
fclose($sock); 
} 
?>

 

I'm also looking into getting it to pull the map name and player-list, but I should be able to figure that out on my own once I get this working. If it helps, this script is supposed to connect to the original Quake games(One, two, and three).

What is the error?

 

<?php
$ip = "66.79.190.40"; 
$port = "27960"; 
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) 
echo '<B><FONT COLOR=red>Offline</b></FONT>'; 
echo '<br />'.$num.'<br />'.$error;
else{ 
echo '<B><FONT COLOR=lime>Online</b></FONT>'; 
fclose($sock); 
} 
?>

 

-cb-

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.