1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, If you'd like to instant message with many other users, then join our
    Official Rune-Status Discord Server!
    Dismiss Notice
  3. Got your own Server? Looking for a Server to play right now??
    Make sure you check out the Public Server Directory!
    Dismiss Notice
  4. If you're new to the Rsps Scene and want to jump straight into learning how to Set-up and Customise your own RuneScape Private Sever then check out the Guides and Tutorials for RS2 here.
    Dismiss Notice
Dismiss Notice
Hey Guest,
Are you sure your posting in the Right Sections?
If your unsure which RuneTek version you are working with visit this page to find out.

EverythingRS Players Online [ANY BASE]

Discussion in 'Guides & Tutorials' started by Genesis, Feb 11, 2018.

  1. EverythingRS - Players Online Tutorial

    EverythingRS is a free API system. Here's a quick tutorial on how to get started with adding Players Online.

    Getting started

    • First off download our everythingrs-api.jar from Sorry you must be logged in to read this.
      Click here to log in.
      and include it into your project.
    • Also register an account at Sorry you must be logged in to read this.
      Click here to log in.
    • Remember your secret key as you will be using it in the next section

    [​IMG]


    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);
    

    Displaying your player count on your website

    In your index.php place this where ever you wish to display your player count. Remember to change the secret key.

    <?php
    
    $secret = "change_this_to_your_secret_key";
    $playersOnline = @file_get_contents("https://everythingrs.com/api/playersonline/get/".$secret);
    echo "There are currently ".$playersOnline." 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);
     
    Tags:
Loading...
Loading...