RSPS Players Online Tutorial

Getting Started 3 steps

First download our everythingrs-api.jar from here and include it into your project.

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.

EverythingRS API
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);
  • 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.
  • 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);
How helpful was this post?