Adding Servers - noobscode/Game-Server-Website GitHub Wiki

Adding servers to the list

Important!

  • Some Servers does not support uptime and will then show 0/sec
  • If you plan to only show your RUST servers we recommend using Rust-Servers.Net API

Using Rust-Servers.Net API

  1. Open up includes/api-rust-servers-net.php
  2. Copy paste your server API keys from rust-servers.net

Example:

$json = file_get_contents("https://rust-servers.net/api/?object=servers&element=detail&key=3lor1poi3hr1pp2irh13rh");

Repeat the process for each server block

Using Battlemetrics.com API

  1. Open up includes/api-battlemetrics-com.php
  2. Copy paste the Server ID this can be found in the URL when you're on a server page at battlemetrics.com
  • NB: You have to use the api url and not the server url itself
    The base URL should look like this https://api.battlemetrics.com/servers/SERVERID Replace the SERVERID with the ID of the server you want displayed in the list.

Example:

$json = file_get_contents("https://api.battlemetrics.com/servers/4962512");

Repeat the process for each server block

Adding additional servers

The template is "shipped" with support for up to three servers, if you want to add additional read how to bellow:

The process for adding additional servers for rust-servers.net API is identical but we'll be using battlemetrics as an example.

  1. Copy paste the entire server block for either API, each block is commented so you should be able to identify the block with ease.
  2. Rename all the variables for the new server block incrementing by 1.

Example of server an additional server block for Battlemetrics API (Can be used with copy paste)

// START SERVER BLOCK #4
$json = file_get_contents("https://api.battlemetrics.com/servers/3339541");
$data = json_decode($json, true);

// Some servers have a prefix for uptime like rust. If your server do, add it "INSIDE" bellow
$prefix = "";
$data4 = $data["data"]["attributes"];

$bm_name4 = $data4["name"];
$bm_status4 = $data4["status"];
$bm_uptime4 = isset($data4["details"][$prefix."_uptime"])?$data4["details"][$prefix."_uptime"]:0;
$bm_location4 = ( ( is_array( $data4["country"] ) ? implode(", ", $data4["country"]) : $data4["country"] ) );
$bm_activeplayers4 = $data4["players"];
$bm_maxplayers4 = $data4["maxPlayers"];
$bm_address4 = $data4["ip"];
$bm_port4 = $data4["port"];
$bm_country4 = $data4["country"];
// END SERVER BLOCK #4
  1. Open up modules/battlemetrics-table.php or modules/rust-servers-net-table.php if you are using rust-servers.net API
  2. Copy paste the last table and insert it right above the closing tags

Example:

    <th scope="row"><?php echo $bm_name3?></th>
      <td><button type="button" class="btn btn-dark btn-sm" data-toggle="modal" data-target="#Server3"><i class="fab fa-steam-symbol"></i> Steam Connect</button></td>
      <td><img src="" width="20" height="20" title="Arma3" alt="Arma3" /><?php echo " Arma 3"?></td>
      <td><?php echo $bm_status3?></td>
      <td><?php echo $bm_activeplayers3?>/<?php echo $bm_maxplayers3?></td>
      <td><?php echo $bm_uptime3?>/sec</td>
      <td><?php echo $bm_location3?></td>
    </tr>
    <th scope="row"><?php echo $bm_name4?></th>
      <td><button type="button" class="btn btn-dark btn-sm" data-toggle="modal" data-target="#Server4"><i class="fab fa-steam-symbol"></i> Steam Connect</button></td>
      <td><img src="IMAGEURL" width="20" height="20" title="Arma3" alt="Arma3" /><?php echo " Arma 3"?></td>
      <td><?php echo $bm_status4?></td>
      <td><?php echo $bm_activeplayers4?>/<?php echo $bm_maxplayers3?></td>
      <td><?php echo $bm_uptime4?>/sec</td>
      <td><?php echo $bm_location4?></td>
    </tr>
  </tbody>
</table>

Optional: GSW dosent support getting the game name automatically at this time so you need to manually specify the name and provide a link to the game icon.

  1. Copy paste the modal for server #3 and rename the variables incrementing by 1 again

Example:

<!-- Modal Server #4 -->
<div class="modal fade" id="Server4" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="Server4">Steam Connect</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>In order to connect <strong><?php echo $bm_name4; ?></strong> server you can use direct Steam connection link, or copy console command and paste it in Rust console.</p>
        <p class="text-center"><a href="steam://connect/<?php echo $bm_address4; ?>:<?php echo $bm_port4; ?>" role="button" class="btn btn-success"><i class="fab fa-steam-symbol"></i> Connect via Steam</a></p>
        <p>Once you press button above, Rust will be launched and try to connect server. This method doesn't work properly in some browsers.</p>
        <hr>
      </div>
  <div class="modal-body">
    <label for="consolecommand">Connect via Rust in-game console</label></p>
    <textarea class="form-control" id="consolecommand" rows="1">client.connect <?php echo $bm_address4; ?>:<?php echo $bm_port4; ?></textarea></p>
    <p>In order to connect via in-game console, while you are in Rust main menu press <kbd>F1</kbd> and paste code above.</p>
  </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

Done!

⚠️ **GitHub.com Fallback** ⚠️