PHP/JS Minecraft TPS

Status
This thread has been locked.

nick

Supreme
Feedback score
24
Posts
435
Reactions
386
Resources
0
Looking to put a player counter on my servers website, But after like about a hour looking I can't find one. If a website developer can help me and give me the code to a player counter, that will be amazing. Javascript or PHP is okay.

Example: Look on either Badlions, Zonixs, or Vexirs website.

No I am not paying lol
 
Type
Requesting
Last edited:
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

MCTrollers

Xenforo Designer
Supreme
Feedback score
33
Posts
786
Reactions
736
Resources
0
Looking to put a player counter on my servers website, But after like about a hour looking I can't find one. If a website developer can help me and give me the code to a player counter, that will be amazing. Javascript or PHP is okay.

Example: Look on either Badlions, Zonixs, or Vexirs website.

I can do this :) PM me
 

/usr/bin/

Linux Warrior & Software Developer
Supreme
Feedback score
14
Posts
358
Reactions
291
Resources
0

Micah_

Feedback score
6
Posts
86
Reactions
50
Resources
0
Id recommend McAPI. I can give you the code snippit for it if you'd like.
 

Mahan

Premium
Feedback score
13
Posts
243
Reactions
74
Resources
0
This should do the job.

HTML:
<div id="playersonline"></div>

<script>
$(document).ready(function () {
    var interval = 5000;   //number of milliseconds between each call
    var refresh = function() {
    $.getJSON("https://mcapi.ca/query/play.ip.com/info",function(json){
          if (json.status !== true) {
            // if server is offline display 0
            $("#playersonline").html('0');
        } else {
            // If server is online show the number of players online inside #playersonline
            $("#playersonline").html(json.players.online);
        }
    });
    setTimeout(function() {
        refresh();
            },
        interval);
            }
        refresh();
});
</script>
 

nick

Supreme
Feedback score
24
Posts
435
Reactions
386
Resources
0
MCTrollers gave me a Code Skript. I am now looking for a PHP/JS TPS Code
 

MTG

Supreme
Feedback score
78
Posts
2,455
Reactions
2,600
Resources
0
MCTrollers gave me a Code Skript. I am now looking for a PHP/JS TPS Code
This should do the job.

HTML:
<div id="playersonline"></div>

<script>
$(document).ready(function () {
    var interval = 5000;   //number of milliseconds between each call
    var refresh = function() {
    $.getJSON("https://mcapi.ca/query/play.ip.com/info",function(json){
          if (json.status !== true) {
            // if server is offline display 0
            $("#playersonline").html('0');
        } else {
            // If server is online show the number of players online inside #playersonline
            $("#playersonline").html(json.players.online);
        }
    });
    setTimeout(function() {
        refresh();
            },
        interval);
            }
        refresh();
});
</script>
 

MTG

Supreme
Feedback score
78
Posts
2,455
Reactions
2,600
Resources
0

Mahan

Premium
Feedback score
13
Posts
243
Reactions
74
Resources
0
and the one you quoted didn't work at all for some reason (Didnt even show a message)
Do you have jQuery included in your HTML?

If you don't, add this to your page.

HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 
Last edited:

SystemUpdate

Freelance Developer
Premium
Feedback score
4
Posts
119
Reactions
128
Resources
0
For TPS you'll need a plugin to make this information available over some sort of database
 

nick

Supreme
Feedback score
24
Posts
435
Reactions
386
Resources
0
For TPS you'll need a plugin to make this information available over some sort of database
Thanks, I'll look into that :tup:[DOUBLEPOST=1486302266][/DOUBLEPOST]
Do you have jQuery included in your HTML?

If you don't, add this to your page.

HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
Workd perfectly bro, I have given you a vouch :)[DOUBLEPOST=1486302646][/DOUBLEPOST]Locked as I got what I want, I would like to thank Mahan <3
 
Last edited:
Status
This thread has been locked.
Top