Thread: EverythingRS Players Online [ANY BASE]

Page 1 of 6 123 ... LastLast
Results 1 to 10 of 54
  1. #1 EverythingRS Players Online [ANY BASE] 
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    3,928
    Thanks given
    1,492
    Thanks received
    1,944
    Rep Power
    4870
    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 [Only registered and activated users can see links. ] and include it into your project.
    • Also register an account at [Only registered and activated users can see links. ]
    • Remember your secret key as you will be using it in the next section





    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

    Code:
    public static void main(
    Add this and change your secret key to the one on your account

    Code:
    			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.

    Code:
    <?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

    Code:
    com.everythingrs.playersonline.PlayersOnline.get();
    To set the count to whatever you wish use this code

    Code:
    com.everythingrs.playersonline.PlayersOnline.set(value);
    To add to the playercount use this

    Code:
    com.everythingrs.playersonline.PlayersOnline.increment(value);
    To subtract from the playercount use this

    Code:
    com.everythingrs.playersonline.PlayersOnline.decrement(value);

    Support - Below are some snippets on how to convert the code to other bases


    Converting to Ruse

    Quote Originally Posted by Prestigious View Post
    For Ruse all you have to do is change
    Code:
    PlayerHandler.Players
    to
    Code:
    World.getPlayers()
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]
    2. [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Aug 2017
    Posts
    72
    Thanks given
    29
    Thanks received
    12
    Rep Power
    0
    gj as always, looking for more stuff to be released
    Reply With Quote  
     

  4. Thankful user:


  5. #3  
    Registered Member

    Join Date
    Nov 2010
    Posts
    1,527
    Thanks given
    1,016
    Thanks received
    349
    Rep Power
    241
    Thanksss alot mate your churning out so much good help for the community and for people like me it is really helpful i will be using when i start new project all your stuff!
    Reply With Quote  
     

  6. Thankful user:


  7. #4  
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    3,928
    Thanks given
    1,492
    Thanks received
    1,944
    Rep Power
    4870
    For Vencillio. In Server.java under

    Code:
    public static void main(String[] args) {
    Add this (and remember to change the secret_key)

    Code:
    com.everythingrs.playersonline.PlayersOnline.init("change_this_to_secret_key", 5, false);
    Then in PlayerUpdating.java

    In

    Code:
    public static void update(Player player, PlayerUpdateFlags[] pFlags) {
    Look for this

    Code:
    if (block.getBuffer().writerIndex() > 0) {
    Above that add

    Code:
    com.everythingrs.playersonline.PlayersOnline.set(added);
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]
    2. [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. Thankful users:


  9. #5  
    GravityScape & SimpliCity Developer.

    RSWSkiller's Avatar
    Join Date
    Dec 2013
    Age
    23
    Posts
    754
    Thanks given
    175
    Thanks received
    65
    Rep Power
    147
    like always good work from you genesis
    will defo use it :]
    Reply With Quote  
     

  10. Thankful user:


  11. #6  
    Officially Retired


    Join Date
    Oct 2007
    Age
    26
    Posts
    5,460
    Thanks given
    558
    Thanks received
    122
    Rep Power
    1364
    Code:
    <?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";
    
    ?>

    how do i make it into html?
    Reply With Quote  
     

  12. #7  
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    3,928
    Thanks given
    1,492
    Thanks received
    1,944
    Rep Power
    4870
    Quote Originally Posted by Zotic View Post
    Code:
    <?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";
    
    ?>

    how do i make it into html?
    At the moment PHP is required. Creating a JavaScript version is definitely a priority though.
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]
    2. [Only registered and activated users can see links. ]
    Reply With Quote  
     

  13. Thankful user:


  14. #8  
    Officially Retired


    Join Date
    Oct 2007
    Age
    26
    Posts
    5,460
    Thanks given
    558
    Thanks received
    122
    Rep Power
    1364
    Quote Originally Posted by Genesis View Post
    At the moment PHP is required. Creating a JavaScript version is definitely a priority though.
    Aww. cuz im using html on my page
    Reply With Quote  
     

  15. #9  
    PHP :heart_eyes:

    Project's Avatar
    Join Date
    Dec 2010
    Posts
    2,522
    Thanks given
    1,009
    Thanks received
    785
    Discord
    Project#6365
    Rep Power
    1283
    Quote Originally Posted by Zotic View Post
    Aww. cuz im using html on my page
    Change your file name to .php

    html is processed in a php file.

    just make sure when calling / utilizing php in the middle of html code you close up your statements

    i.e <?php ?>
    i.e <?php if($statement){?> <?php } ?>
    Reply With Quote  
     

  16. #10  
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    3,928
    Thanks given
    1,492
    Thanks received
    1,944
    Rep Power
    4870
    Quote Originally Posted by Zotic View Post
    how do i make it into html?
    Non-PHP version. Working with HTML. Be sure to change "accountName" to the username you use to sign into ERS.

    Code:
    <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.
    Quote Originally Posted by Project View Post
    Change your file name to .php

    html is processed in a php file.

    just make sure when calling / utilizing php in the middle of html code you close up your statements
    Not everyone uses paid webhosting, so that wouldn't have been an option for them unfortunately.
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]
    2. [Only registered and activated users can see links. ]
    Reply With Quote  
     

  17. Thankful users:


Page 1 of 6 123 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. EverythingRS Voting Installation [ANY BASE]
    By Genesis in forum Tutorials
    Replies: 340
    Last Post: Yesterday, 06:50 PM
  2. EverythingRS Hiscores Installation [ANY BASE]
    By Genesis in forum Tutorials
    Replies: 220
    Last Post: 11-24-2019, 02:11 AM
  3. EverythingRS Commands Installation [ANY BASE]
    By Genesis in forum Tutorials
    Replies: 33
    Last Post: 07-30-2019, 04:55 AM
  4. [ANY REVISION] Players Online
    By Ownster in forum Tutorials
    Replies: 13
    Last Post: 07-01-2013, 02:37 AM
  5. Replies: 17
    Last Post: 06-06-2012, 11:39 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •