Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • stCky: idk man im just a chat bot
      August 22, 2017, 11:14:52 PM
    • symantec: is this forum
      August 22, 2017, 09:02:56 PM
    • symantec: what the fudge
      August 22, 2017, 09:02:52 PM
    • symantec: I just joined to download datmaker, the links are broken and a user named i nelson i has a fudgeing weird signature
      August 22, 2017, 08:59:33 PM
    • stCky: ur so cool and edgy
      August 22, 2017, 04:15:50 PM
    • Deathspirit: anyways, i'm un ip banned now.. but don't even want to be that at this point lmfao
      August 22, 2017, 01:58:14 PM
    • Deathspirit: now it's some sell out half leeched server :')
      August 22, 2017, 01:57:53 PM
    • Deathspirit: gf moparscape, was the best rsps community i've been on since 2006
      August 22, 2017, 01:57:31 PM
    • stCky: yeah, nah. it's cooked. [link] might help u with a backup or something idk man im just a chat bot
      August 22, 2017, 12:13:25 AM
    • flew420: I sure hope someone has a copy of the forum before it was recked
      August 21, 2017, 11:40:52 PM
    • flew420: O wow i see now, just read thru all the news articles. :(  i've been out of the game for a couple years so coming back to this shit is sad.
      August 21, 2017, 11:39:46 PM
    • flew420: Huh?
      August 21, 2017, 10:49:51 PM
    • stCky: got bought by a russian dude, he put a shitty rsps on it for donations, now no one cares
      August 21, 2017, 10:48:30 PM
    • flew420: I came on for some nostalgic reading in old classic development, and it only goes back to 2014 wtf.
      August 21, 2017, 10:43:09 PM
    • flew420: what happened to this site??
      August 21, 2017, 10:42:36 PM
    • Sean56:[link]
      August 21, 2017, 05:33:45 PM
    • kb010: how can i play? i downloaded the client and it doesnt open.
      August 21, 2017, 10:52:56 AM
    • wodkode: shut it down or fix it
      August 20, 2017, 10:11:28 PM
    • wodkode: dude i cant goto no links on here from google
      August 20, 2017, 10:11:13 PM
    • Dell: Greetings
      August 20, 2017, 11:56:30 AM

    Author Topic: [PI] Full Ingame HighScores with Saving  (Read 5638 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    [PI] Full Ingame HighScores with Saving
    « on: August 27, 2012, 10:19:12 PM »
    Adding fully working ingame hiscores with saving for PI.


    In src/server/model/players, make a new class called HighScores.java and add this in:
    Code: Java
    1. packageserver.model.players;
    2.  
    3. importjava.io.*;
    4.  
    5. importserver.Config;
    6. importserver.Server;
    7. importserver.model.players.Client;
    8. importserver.util.Misc;
    9.  
    10. /**
    11.  * Handles the ingame highscores.
    12.  *
    13.  * @author Bradley Carels
    14.  */
    15. publicclass HighScores {
    16.  
    17.         publicstaticObject[][] PLAYERS =newObject[10][3];
    18.  
    19.         publicstaticvoid load(){
    20.                 try{
    21.                         BufferedReader in =newBufferedReader(newFileReader("./Data/highscores.txt"));
    22.                         for(int i =0; i <10; i++){
    23.                                 String[] data = in.readLine().split(" ");
    24.                                 for(int j =0; j < data.length; j++)
    25.                                         PLAYERS[i][j]=(j ==0? data[j]:Integer.parseInt(data[j]));
    26.                         }
    27.                         System.out.println("Loaded HighScores.");
    28.                 }catch(IOException e){
    29.                         System.out.println("Error loading HighScores.");
    30.                 }
    31.         }
    32.  
    33.         publicstaticvoid save(){
    34.                 for(int i =0; i <10; i++){
    35.                         if(PLAYERS[i][0]==null)
    36.                                 return;
    37.                 }
    38.                 try{
    39.                         BufferedWriter out =newBufferedWriter(newFileWriter("./Data/highscores.txt"));
    40.                         for(int i =0; i <10; i++){
    41.                                 String line = PLAYERS[i][0]+" "+ PLAYERS[i][1]+" "+ PLAYERS[i][2];
    42.                                 out.write(line, 0, line.length());
    43.                                 out.newLine();
    44.                         }
    45.                         out.close();
    46.                 }catch(IOException e){
    47.                         System.out.println("Error saving HighScores.");
    48.                 }
    49.         }
    50.  
    51.         publicstaticvoid open(Client c){
    52.                 c.getPA().showInterface(6308);
    53.                 c.getPA().sendFrame126(Config.SERVER_NAME+" HighScores", 6400);
    54.                 c.getPA().sendFrame126("Top PKers:", 6399);
    55.                 for(int i =0; i <40; i++)
    56.                         c.getPA().sendFrame126("", 8578+ i);
    57.                 for(int i =0; i <10; i++)
    58.                         c.getPA().sendFrame126(PLAYERS[i][1]+". "+ PLAYERS[i][0]+" - "+ PLAYERS[i][2]+" Kills", 6402+ i);
    59.         }
    60.  
    61.         publicstaticvoid update(Client c){
    62.                 for(int i =0; i <10; i++){
    63.                         if(c.kills>(Integer) PLAYERS[i][2]&&(c.kills<(Integer) PLAYERS[i -(i ==0?0:1)][2]|| i ==0)){
    64.                                 PLAYERS[i][0]= c.playerName;
    65.                                 PLAYERS[i][2]= c.kills;
    66.                         }
    67.                 }
    68.         }
    69.  
    70. }

    Edit the variables to suit your needs.


    Next in ActionHandler.java search for:
    Code: Java
    1. switch(objectType){

    Under that switch statement add:
    Code: Java
    1.                 case3192:
    2.                         HighScores.open(c);
    3.                         break;

    Now open Client.java and search for:
    Code: Java
    1. process(){

    Under that add:
    Code: Java
    1.                 HighScores.update(this);

    Now go in ShutDownHook.java and search for:
    Code: Java
    1. publicvoid run(){

    Under that line add:
    Code: Java
    1.                 HighScores.save();

    Next open Server.java and search for:
    Code: Java
    1. publicstaticvoid main

    And under that line add:
    Code: Java
    1.                 HighScores.load();

    Next open ObjectManager.java and search for:
    Code: Java
    1. publicvoid loadCustomSpawns(Client c){

    Under that add:
    Code: Java
    1.                 c.getPA().checkObjectSpawn(3192, 3222, 3218, 0, 10);// scoreboard

    Change these coordinates to wherever you want, this currently spawns the scoreboard in Lumbridge.

    Last step!
    Lastly, go into your Data folder and make a new text document called highscores.txt


    If you followed the tutorial correctly, you now have fully working ingame highscores! As always, all credits go to me. Enjoy. ;)


    Picture:


    OfflineRsMakerWoad

    • Member
    • ***
    • Posts: 122
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #1 on: August 28, 2012, 12:28:53 PM »
    Nice work,Bookmark btw;)


    OfflineFridder

    • Member
    • ****
    • Posts: 5,107
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #2 on: August 28, 2012, 01:59:27 PM »
    Nice, looks good.
    what the fudge is this shit

    OfflineTheProdigy

    • Member
    • **
    • Posts: 17
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #3 on: August 28, 2012, 07:11:38 PM »
    Not bad though the update method doesn't need to be in process(). It can simply be used with the player clicks the object.

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #4 on: August 28, 2012, 07:22:52 PM »
    Not bad though the update method doesn't need to be in process(). It can simply be used with the player clicks the object.
    That update's the highscore's data for the individual player and needs to be updated every tick. I think you are talking about the actual Strings, which, yes, are updated when the player clicks the object.

    Offlinepengu

    • Member
    • **
    • Posts: 25
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #5 on: August 28, 2012, 08:09:31 PM »
    Thanks, I needed this.. But I get these errors, how can I fix these?

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #6 on: August 28, 2012, 09:38:02 PM »
    Thanks, I needed this.. But I get these errors, how can I fix these?

    You didn't do step one correctly. Read through the step again.

    As for the ActionHandler error, in ActionHandler.java search for:
    Code: [Select]
    case 3192:And find the case that wasn't added during the tutorial. Delete that case.

    Offlinemr extremez

    • Member
    • ****
    • Posts: 3,048
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #7 on: August 28, 2012, 09:45:22 PM »
    Nice from the title I thought this was 10 players or something, but based on the code and picture this is top 10 pkers which is sorta unique I guess... Nice :D

    Offlinejubagas12345

    • Member
    • ***
    • Posts: 104
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #8 on: August 31, 2012, 05:20:56 AM »
    getting these errors

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #9 on: August 31, 2012, 09:04:48 PM »
    getting these errors


    Change all of the c.kills in HighScores.java to c.pcPoints, and in Server.java at the top of the class add:
    Code: Java
    1. importserver.model.players.HighScores;

    Offlinejubagas12345

    • Member
    • ***
    • Posts: 104
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #10 on: September 01, 2012, 04:37:44 AM »
    1 more error

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #11 on: September 01, 2012, 09:17:56 AM »
    1 more error

    In ShutDownHook.java add this at the top:
    Code: [Select]
    import server.model.players.HighScores;

    Offlinejubagas12345

    • Member
    • ***
    • Posts: 104
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #12 on: September 01, 2012, 10:30:30 AM »
    when i try load it it says error loading highscrores?

    OfflineTheHolyGrail

    • Member
    • ****
    • Posts: 1,053
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #13 on: September 01, 2012, 12:19:56 PM »
    when i try load it it says error loading highscrores?
    You didn't make the .txt file. Go into your Data folder and create a new .txt file and name it highscores.

    OfflineDdragonimp

    • Member
    • ****
    • Posts: 692
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #14 on: September 10, 2012, 03:44:20 PM »
    Pretty good, not hard to convert to any source  Well here's rep but your already at 200.
    Daily[Delta]http://www.moparscape.org/smf/index.php/topic,469569.0.html 
    ^[PI]http://www.moparscape.org/smf/index.php/topic,472774.0.html
    [Delta]RestPts - http://www.moparscape.org/smf/index.php/topic,488755.0.html
    Respect:Clawz Fury Saphire I Vain I

    OfflineJaxus

    • Member
    • ***
    • Posts: 160
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #15 on: September 10, 2012, 09:54:12 PM »
    You should really make it check to see if that person has more than one kill.
    Quote
    <dicklord> compilres are grammar nazis

    OfflineFlower one

    • First Time Poster
    • *
    • Posts: 1
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #16 on: September 13, 2012, 09:43:39 PM »
     :confused: Do you know what I have done wrong? Please help if possible :)

    OfflineDeltascape

    • Member
    • **
    • Posts: 41
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #17 on: October 06, 2012, 11:53:03 AM »
    When I tried to run the source some errors came up it would not let me login it would but its like nulled, look:


    Offlinebroyou9222

    • Member
    • **
    • Posts: 93
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #18 on: November 11, 2012, 01:47:32 PM »
    « Last Edit: November 11, 2012, 01:53:29 PM by broyou9222 »

    Offlinebabushkahead

    • Member
    • ***
    • Posts: 173
    • Thanks: +0/-0
      • View Profile
    Re: [PI] Full Ingame HighScores with Saving
    « Reply #19 on: November 28, 2012, 02:42:24 PM »
    whats wrong i put the highscores.txt in data now i get this when i run?



     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal