No, HTML isn’t a server language.
how about palyers.json print each player name and ping …e.tc
I think they want to know how to post it within an HTML’/PHP format so it displays on a webpage? Just someone not too fluent in using html/php combined.
No way this exists, I’ve been checking the length of the players.json array this entire time
Sorry to revive this old thread, I’m trying to display the player count on my website as well but because the data is sent over HTTP instead of HTTPS, I can’t seem to grab the JSON from dynamic.json file. Is it possible for a server owner to put a certificate on these files or is there possibly a new way to get this data?
I tried using both php and JS referenced above with no luck. This is a link to a test page and my code. Rando
<script type="text/javascript">
async function getStuff() {
let response = await fetch('https://ip:port/dynamic.json', {
method: 'GET',
mode: 'no-cors'
})
//let json = await response.text();
//console.log(json);
.then(response => response.json())
.then(data => doStuff(data));
}
function doStuff(data)
{
let clients = data.clients;
let maxclients = data.sv_maxclients;
document.getElementById("clients").innerHTML(clients);
document.getElementById("maxclients").innerHTML(maxclients);
}
</script>
Thanks!
I did this for my website, working fine
index.php
<?php
include('./config.php');
?>
<html lang="en">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<body>
<main>
<section id="b-s">
</section>
</main>
</body>
</html>
<script>
$(document).ready(function() {
$("#b-s").load("./server-info.php");
var intervalId = window.setInterval(function() {
$("#b-s").load("./server-info.php");
}, <?php echo $updateFrequency;?>);
});
</script>
server-info
<?php
require_once('./config.php');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $serverIP . "/players.json");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$json;
$serverStatus = 0;
$output = curl_exec($curl);
if (curl_exec($curl) === false){
$serverStatus = 1;
} elseif (!empty(curl_exec($curl)) && !empty($output)) {
$serverStatus = 2;
$json = json_decode($output, TRUE, 512, JSON_BIGINT_AS_STRING);
} else {
$serverStatus = 0;
}
curl_close($curl);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="server">
<?php if ($serverStatus === 2){ echo '<div class="server-stat">' . count($json) . '/69</div>'; } else { echo '<div class="server-stat ellipse-grey">0</div>'; } ?>
</div>
</body>
</html>
config
<?php
$serverIP = 'xxxxx:xxxxx';
$updateFrequency = 10
?>
None Of this works it shows a / or a o on page for results
i am trying to make a github pages website that uses html so how would i display that info using html on my site?