Thread: [RSPS-SCORES.COM] Create free highscores in minutes - how to

Page 6 of 8 FirstFirst ... 45678 LastLast
Results 51 to 60 of 74
  1. #51  
    RSPS SERVICES PROVIDER

    The Plateau's Avatar
    Join Date
    May 2015
    Posts
    999
    Thanks given
    592
    Thanks received
    191
    Rep Power
    129
    Quote Originally Posted by LukaFurlan View Post
    Hello, so I created website that offers free highscores hosting service.
    Creating highscores takes no more then 4 minutes!

    FREE INSTALLATION SERVICE


    So let me tell you what to do

    First go to Rsps-scores - free rsps highscores and click Create highscores button

    Then fill registration form and click Sign Up



    Website will then take you to your newly created dashboard. In dashboard you can add any URL to your highscore page
    or add different game modes by completing these forms



    You can also change your highscores theme (theme examples will be at the end of the thread)

    I have provided two examples on how to install highscores server sided, I will explain how to install on ruse based servers in this thread

    For first you have to create new class in com.ruse called HighscoresHandler with these contents:

    Code:
    package com.ruse;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import com.ruse.model.Skill;
    import com.ruse.world.entity.impl.player.Player;
    import com.mysql.jdbc.Statement;
    
    public class HighscoresHandler implements Runnable{
    
    	/**
    	 * Secret key
    	 */
    	final static String secret = "";
    	/**
    	 * Username that is used for mysql connection
    	 */
    	final static String user = "";
    
    
    	private Player player;
    
    	public HighscoresHandler(Player player) {
    		this.player = player;
    	}
    
    	/**
    	 * Function that handles everything, it inserts or updates
    	 * user data in database
    	 */
    	@Override
    	public void run() {
    		/**
    		 * Players username
    		 */
    		final String username = player.getUsername();
    		/**
    		 * Represents game mode
    		 * If you want to set game modes do this:
    		 */
    		final int gameMode = 0;
    		/**
    		 * Represents overall xp
    		 */
    		final long overallXp = player.getSkillManager().getTotalExp();
    		/**
    		 * Represents attack xp
    		 */
    		final long attackXp = player.getSkillManager().getExperience(Skill.ATTACK);
    		/**
    		 * Represents defence xp
    		 */
    		final long defenceXp = player.getSkillManager().getExperience(Skill.DEFENCE);
    		/**
    		 * Represents strength xp
    		 */
    		final long strengthXp = player.getSkillManager().getExperience(Skill.STRENGTH);
    		/**
    		 * Represents constitution xp
    		 */
    		final long constitutionXp = player.getSkillManager().getExperience(Skill.CONSTITUTION);
    		/**
    		 * Represents ranged xp
    		 */
    		final long rangedXp = player.getSkillManager().getExperience(Skill.RANGED);
    		/**
    		 * Represents prayer xp
    		 */
    		final long prayerXp = player.getSkillManager().getExperience(Skill.PRAYER);
    		/**
    		 * Represents magic xp
    		 */
    		final long magicXp = player.getSkillManager().getExperience(Skill.MAGIC);
    		/**
    		 * Represents cooking xp
    		 */
    		final long cookingXp = player.getSkillManager().getExperience(Skill.COOKING);
    		/**
    		 * Represents woodcutting xp
    		 */
    		final long woodcuttingXp = player.getSkillManager().getExperience(Skill.WOODCUTTING);
    		/**
    		 * Represents fletching xp
    		 */
    		final long fletchingXp = player.getSkillManager().getExperience(Skill.FLETCHING);
    		/**
    		 * Represents fishing xp
    		 */
    		final long fishingXp = player.getSkillManager().getExperience(Skill.FISHING);
    		/**
    		 * Represents firemaking xp
    		 */
    		final long firemakingXp = player.getSkillManager().getExperience(Skill.FIREMAKING);
    		/**
    		 * Represents crafting xp
    		 */
    		final long craftingXp = player.getSkillManager().getExperience(Skill.CRAFTING);
    		/**
    		 * Represents smithing xp
    		 */
    		final long smithingXp = player.getSkillManager().getExperience(Skill.SMITHING);
    		/**
    		 * Represents mining xp
    		 */
    		final long miningXp = player.getSkillManager().getExperience(Skill.MINING);
    		/**
    		 * Represents herblore xp
    		 */
    		final long herbloreXp = player.getSkillManager().getExperience(Skill.HERBLORE);
    		/**
    		 * Represents agility xp
    		 */
    		final long agilityXp = player.getSkillManager().getExperience(Skill.AGILITY);
    		/**
    		 * Represents thieving xp
    		 */
    		final long thievingXp = player.getSkillManager().getExperience(Skill.THIEVING);
    		/**
    		 * Represents slayer xp
    		 */
    		final long slayerXp = player.getSkillManager().getExperience(Skill.SLAYER);
    		/**
    		 * Represents farming xp
    		 */
    		final long farmingXp = player.getSkillManager().getExperience(Skill.FARMING);
    		/**
    		 * Represents runecrafting xp
    		 */
    		final long runecraftingXp = player.getSkillManager().getExperience(Skill.RUNECRAFTING);
    		/**
    		 * Represents hunter xp
    		 */
    		final long hunterXp = player.getSkillManager().getExperience(Skill.HUNTER);
    		/**
    		 * Represents construction xp
    		 */
    		final long constructionXp = player.getSkillManager().getExperience(Skill.CONSTRUCTION);
    		/**
    		 * Creates new instance of jdbc driver
    		 * if that driver exists
    		 */
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    		} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e1) {
    			e1.printStackTrace();
    		}
    		/**
    		 * Sets Connection variable to null
    		 */
    		Connection connection = null;
    		/**
    		 * Sets Statement variable to null
    		 */
    		Statement stmt = null;
    
    		/**
    		 * Attempts connecting to database
    		 */
    		try {
    			connection = DriverManager.getConnection("jdbc:mysql://198.211.123.88:3306/admin_scores_data", user, secret);
    		} catch (SQLException e) {
    			e.printStackTrace();
    			return;
    		}
    		/**
    		 * Checks if connection isnt null
    		 */
    		if (connection != null) {
    		    try {
    		    	stmt = (Statement) connection.createStatement();
    				ResultSet rs = stmt.executeQuery("SELECT COUNT(*) AS count FROM `"+user+"_scores` WHERE username='" +username+ "'");
    				if(rs.next()) {
    					if(rs.getInt("count") > 0)  {
    						stmt.executeUpdate("UPDATE `"+user+"_scores` SET overall_xp = '"+overallXp+"', attack_xp = '"+attackXp+"', defence_xp = '"+defenceXp+"', strength_xp = '"+strengthXp+"', constitution_xp = '"+constitutionXp+"', ranged_xp = '"+rangedXp+"', prayer_xp = '"+prayerXp+"', magic_xp = '"+magicXp+"', cooking_xp = '"+cookingXp+"', woodcutting_xp = '"+woodcuttingXp+"', fletching_xp = '"+fletchingXp+"', fishing_xp = '"+fishingXp+"', firemaking_xp = '"+firemakingXp+"', crafting_xp = '"+craftingXp+"', smithing_xp = '"+smithingXp+"', mining_xp = '"+miningXp+"', herblore_xp = '"+herbloreXp+"', agility_xp = '"+agilityXp+"', thieving_xp = '"+thievingXp+"', slayer_xp = '"+slayerXp+"', farming_xp = '"+farmingXp+"', runecrafting_xp = '"+runecraftingXp+"', hunter_xp = '"+hunterXp+"', construction_xp = '"+constructionXp+"' WHERE username = '"+username+"'");
    					} else {
    						stmt.executeUpdate("INSERT INTO `"+user+"_scores` (username, mode, overall_xp, attack_xp, defence_xp, strength_xp, constitution_xp, ranged_xp, prayer_xp, magic_xp, cooking_xp, woodcutting_xp, fletching_xp, fishing_xp, firemaking_xp, crafting_xp, smithing_xp, mining_xp, herblore_xp, agility_xp, thieving_xp, slayer_xp, farming_xp, runecrafting_xp, hunter_xp, construction_xp) VALUES ('"+username+"', '"+gameMode+"', '"+overallXp+"', '"+attackXp+"', '"+defenceXp+"', '"+strengthXp+"', '"+constitutionXp+"', '"+rangedXp+"', '"+prayerXp+"', '"+magicXp+"', '"+cookingXp+"', '"+woodcuttingXp+"', '"+fletchingXp+"', '"+fishingXp+"', '"+firemakingXp+"', '"+craftingXp+"', '"+smithingXp+"', '"+miningXp+"', '"+herbloreXp+"', '"+agilityXp+"', '"+thievingXp+"', '"+slayerXp+"', '"+farmingXp+"', '"+runecraftingXp+"', '"+hunterXp+"', '"+constructionXp+"')");
    					}
    				}
    				stmt.close();
    				connection.close();
    			} catch (SQLException e1) {
    				e1.printStackTrace();
    			}
    		} else {
    			System.out.println("Failed to make connection!");
    		}
    
    		return;
    	}
    }
    Please fill your secret and user with ones provided on dashboard



    After you have done that click save and close this class.

    Next open up PlayerHandler.java and search for

    Code:
    if(player.logout() || exception) {
    under that add

    Code:
    new Thread(new HighscoresHandler(player)).start();
    save and close PlayerHandler class and compile!
    You have now installed highscores server-sided too.

    Player data will be sent everytime you log out.

    Spoiler for Examples of theme images:










    If you have any questions, please ask!

    Rsps-scores - free rsps highscores
    can we add crowns for staff member and donors ?
    Reply With Quote  
     

  2. #52  
    Officially Running

    Mr Dream's Avatar
    Join Date
    Dec 2013
    Posts
    1,922
    Thanks given
    555
    Thanks received
    295
    Rep Power
    905
    Is this only for ruse? And thanks
    Attached image
    Attached image
    Reply With Quote  
     

  3. #53  
    Unfortunately we’re all human. Except me


    Join Date
    Aug 2011
    Posts
    926
    Thanks given
    539
    Thanks received
    439
    Rep Power
    601
    Quote Originally Posted by Frostydapure View Post
    Is this only for ruse? And thanks
    You can use it on any base
    Reply With Quote  
     

  4. #54  
    Registered Member
    Join Date
    Dec 2016
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Great release!
    Reply With Quote  
     

  5. #55  
    Registered Member
    Join Date
    Apr 2008
    Posts
    199
    Thanks given
    8
    Thanks received
    8
    Rep Power
    50
    great release luka! for anyone wanting to fix the ironman / other character gameMode's not switching, replace the final int gameMode with: final String gameMode = player.ironPlayer() ? "f58776" : "0";
    Reply With Quote  
     

  6. #56  
    Registered Member
    Join Date
    Dec 2016
    Posts
    87
    Thanks given
    1
    Thanks received
    4
    Rep Power
    59
    If you create a web api where you have an api key, the api will do the direct sql... so public don't see what's happening in the db side. You just passing the data to the api, but other than that... it looks good. Well done.
    Reply With Quote  
     

  7. #57  
    Unfortunately we’re all human. Except me


    Join Date
    Aug 2011
    Posts
    926
    Thanks given
    539
    Thanks received
    439
    Rep Power
    601
    Quote Originally Posted by Jmusic View Post
    If you create a web api where you have an api key, the api will do the direct sql... so public don't see what's happening in the db side. You just passing the data to the api, but other than that... it looks good. Well done.
    I did that at first but even if public has their own db account, they cant do anything with it.
    Reply With Quote  
     

  8. #58  
    Registered Member
    Join Date
    Dec 2016
    Posts
    87
    Thanks given
    1
    Thanks received
    4
    Rep Power
    59
    Yes, but an api is preferred for best practices. Any person with a decent amount of knowledge can telnet or ssh into the public ip, that db should only allow access from the api's ip for security. If you had an api, you could expose its endpoint and can accept json. So the highscores would be compatible with any language, could also possibly create an api client. Just some insight on my thoughts to further improve your system.
    Reply With Quote  
     

  9. #59  
    kierandevvs
    Guest
    A table per user? This is really inefficient and an incoming web hook / REST API would have done just fine. You don't even use SSL so stealing that password would be easy. Not only that but your SQL queries don't even use prepared statements so SQL injection is a possibility.
    All you would have to do is set your username to be "DROP TABLE table_name;".

    Also please learn about relational schemas instead of doing one massive query you could have had a table like so

    Code:
    ID    SkillId    SkillLevel    SkillExp    Player
    And then populated it like so
    Code:
    for(int i = 0; i < skills.length; i++) {
    PreparedStatement statement = new PreparedStatement ("INSERT INTO table (SkillID, SkillLevel, SkillExp, Player) VALUES (?,?,?,?)")
    statement .setInt(1, i);
    statement .setInt(2, player.getlevelfor(i));
    statement .setInt(3, player.getExpFor(i));
    statement .setString(4, player.getUsername());
    statement .execute();
    }
    Also don't use dynamic table names in queries as they cant be set via prepared statements and it leaves it open to injection. Hard code it. But again, a webhook would have been a much better choice here.
    Reply With Quote  
     

  10. #60  
    Unfortunately we’re all human. Except me


    Join Date
    Aug 2011
    Posts
    926
    Thanks given
    539
    Thanks received
    439
    Rep Power
    601
    well someone can inject it if he wants but all he will be injecting is his own table.. even with delete he will only damage his own highscores
    Reply With Quote  
     

Page 6 of 8 FirstFirst ... 45678 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. Replies: 3
    Last Post: 11-16-2015, 10:17 PM
  2. Replies: 10
    Last Post: 06-30-2011, 10:32 PM
  3. Replies: 11
    Last Post: 03-15-2011, 12:07 AM
  4. Replies: 14
    Last Post: 06-22-2008, 01:24 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
  •