Serverstatus script

From Nitradopedia EN
Revision as of 10:35, 22 May 2015 by Cranken (talk | contribs) (Created page with "This article will shwo you how to create a serverstatus script.<br> What is needed?: 1. A Gameserver(this article will use a Minecraftserver as an example) 2. A Webspace whi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article will shwo you how to create a serverstatus script.
What is needed?:

1. A Gameserver(this article will use a Minecraftserver as an example)
2. A Webspace which lets you use PHP.
3. The following code

Code

<?php
 $server = "85.131.146.70";
 $port = "25565";
 $timeout = "10";
 if ($server and $port and $timeout) 
 {
 $minecraft = @fsockopen("$server", $port, $timeout);
 }
 if($minecraft) 
 {
 echo "The Minecraft-Server is Online";
 }
 else 
 {
 echo "The Minecraft-Server is Offline";
 }
 ?>

This code can now be used on your website.

Explanation

<?php   - Anfang des Scripts
    $server = "85.131.146.70";     - IP of the server, in this case 85.131.146.70
    $port = "25565";  - Port of the server, in this case 25565
    $timeout = "10";  - Validation of your online status(in seconds).
    if ($server and $port and $timeout)
    {
    $minecraft= @fsockopen("$server",$port,$timeout);      - Define $minecraft from $server, $port und $timeout
    }
    if($minecraft)  - "Wenn $minecraft erreichbar ist, dann..."
    { 
    echo "The Minecraft-Server is Online";   - ...shows "The Minecraft-Server is Online"
    }
    else        - andernfalls...
    {
    echo "The Minecraft-Server is Offline";   -...shows "The Minecraft-Server is Offline"
    }
    ?>       - End of the script