EverythingRS - Players Online Tutorial

Join Our Support Discord If you need more help or for some reason cannot understand the tutorial please join our support Discord. We're always available to help!

Getting Started

Registration and secret key

  • After adding the everything-rs.jar into your project the next step is to create an account, once the account is created you must register onto the toplist as we use the toplist data in many of our api's.
  • Now go to your dashboard and you should see your secret key

Making the Players Online work with your server

  • This part of the tutorial is for PI, but can easily be changed to work with any server. If you want me to add a snippet on the thread so it can work with your framework leave a comment with the server base you want the snippet for.
In your server startup (Server.java) under
public static void main(
Add this and change your secret key to the one on your account
com.everythingrs.playersonline.PlayersOnline.service.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
        int online = 0;
        for (Player player: PlayerHandler.players) {
            if (player != null) {
                online += 1;
            }
        }
        com.everythingrs.playersonline.PlayersOnline.insert("secret_key", online, false);
    }
}, 0, 30, TimeUnit.SECONDS);
In your server startup add
com.everythingrs.playersonline.PlayersOnline.service.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
        int online = 0;
        for (Player player: World.getPlayers()) {
            if (player != null) {
                online += 1;
            }
        }
        com.everythingrs.playersonline.PlayersOnline.insert("secret_key", online, false);
    }
}, 0, 30, TimeUnit.SECONDS);

Displaying your player count on your website

  • In your index.php or index.html place this where ever you wish to display your player count. Remember to change the secret key. Be sure to change "accountName" to the username you use to sign into ERS.
  • <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript">
        var accountName = "REPLACE_THIS_WITH_YOUR_ACCOUNT_NAME";
        $.get("https://everythingrs.com/api/players-online/get/" + accountName, function (response) {
            $("#players").html(response);
        });
    
    </script>
    There are currently <span id="players"></span> players online.

Fin

  • You are finished with the tutorial and can now view your player count on your site!

Info and some documentation

  • Player count will update every 30 seconds. If you wish to make calls every 30 minutes just change the 5 to 30 (or to whichever number you wish) and TimeUnit.SECONDS to TimeUnit.MINUTES in the startup code. If you wish to make direct changes to the way the code works, this section will help out. To fetch the current players online you can use this code
    com.everythingrs.playersonline.PlayersOnline.get();
    To set the count to whatever you wish use this code
    com.everythingrs.playersonline.PlayersOnline.set(value);
    To add to the playercount use this
    com.everythingrs.playersonline.PlayersOnline.increment(value);
    To subtract from the playercount use this
    com.everythingrs.playersonline.PlayersOnline.decrement(value);