CymraegDraig / DrillUKWebsite.github.io

Official DrillUK Website
1 stars 0 forks source link

DayZ Server Count #2

Open CymraegDraig opened 5 months ago

CymraegDraig commented 5 months ago

We need to convert the dayz.html page's server tracker from the FiveM server count, to the DayZ server count.

PENDING: WAITING FOR CONFIRMED IP ADDRESS

t4by commented 5 months ago
<script>
    // Function to fetch player count from Steam Web API
    function getPlayerCount() {
        // Replace 'YOUR_SERVER_IP' and 'YOUR_SERVER_PORT' with your DayZ server IP and port
        const serverIP = 'YOUR_SERVER_IP';
        const serverPort = 'YOUR_SERVER_PORT';

        // Steam Web API URL to get server info
        const steamAPIURL = `https://api.steampowered.com/IGameServersService/GetServerDetails/v1/?format=json&appid=221100&addr=${serverIP}:${serverPort}`;

        fetch(steamAPIURL)
            .then(response => response.json())
            .then(data => {
                const playerCount = data.response.players;
                document.getElementById('playerCount').textContent = playerCount;
            })
            .catch(error => {
                console.error('Error fetching player count:', error);
                document.getElementById('playerCount').textContent = 'Error';
            });
    }

    // Fetch player count when the page loads
    window.onload = getPlayerCount;
</script>
t4by commented 5 months ago
<h1>DayZ Server Player Count</h1>
<p>Current player count: <span id="playerCount">Loading...</span></p>