[insert_php]
function getAPI($url)
{
$encoded_json = wp_remote_get( esc_url_raw($url) );
$uncoded_json = json_decode( wp_remote_retrieve_body( $encoded_json ), true );

return $uncoded_json;
}
function timeConvert($value)
{
$minutes = $value / 60;
$hours = $minutes / 60;
$days = $hours / 24;

return $days;
}
function dayTimeConvert($value)
{
$value = $value * 24;
$value = intval($value);

return $value;
}
[/insert_php]

[insert_php]
print_r(“”);
$socket = fsockopen(‘81.149.209.24′,’28017’);
if($socket == true) {
$status = getAPI(“http://81.149.209.24:28017/status.json?apiKey=YWZZCqoydAwmhBXgORjeoOBBRavKAyhL”);
$performance = getAPI(“http://81.149.209.24:28017/performance.json?apiKey=YWZZCqoydAwmhBXgORjeoOBBRavKAyhL”);
$uptime = timeConvert($performance[‘unity’][‘uptime’]);
$uptimehour = $uptime – intval($uptime);

print_r(”

” . $status[‘hostname’] .”

Connect to this server in-game: Press F1 & type: connect 81.149.209.24:28017

Online Server Online           81.149.209.24:28017

 

Online Players

Sleeping Players

Server Uptime

 
 

” . $status[‘players’] . ” / ” . $status[‘maxplayers’] . “

” . $status[‘sleepers’] . “

” . intval($uptime) . ” Days ” . dayTimeConvert($uptimehour) . ” Hours

 
 

Map Size

Map Seed

Map Type

 
 

” . $status[‘world’][‘size’] . “

” . $status[‘world’][‘seed’] . “

” . $status[‘level’] . “

 

” . $status[‘hostname’] .” Live Map

Live Rust Server Map

“);
} elseif ($socket == false) {
echo “We are very sorry this server is off-line right now. Please try again in a few minutes.”;
}
[/insert_php]

Click here to visit playrust.io and see live player, cave and monument locations.