Pvp 0 #1 Posted August 28, 2012 [b]Adding fully working ingame hiscores with saving for PI.[/b] In src/server/model/players, make a new class called HighScores.java and add this in: [code]package server.model.players; import java.io.*; import server.Config; import server.Server; import server.model.players.Client; import server.util.Misc; /** * Handles the ingame highscores. * * @author Bradley Carels */ public class HighScores { public static Object[][] PLAYERS = new Object[10][3]; public static void load() { try { BufferedReader in = new BufferedReader(new FileReader("./Data/highscores.txt")); for (int i = 0; i < 10; i++) { String[] data = in.readLine().split(" "); for (int j = 0; j < data.length; j++) PLAYERS[i][j] = (j == 0 ? data[j] : Integer.parseInt(data[j])); } System.out.println("Loaded HighScores."); } catch (IOException e) { System.out.println("Error loading HighScores."); } } public static void save() { for (int i = 0; i < 10; i++) { if (PLAYERS[i][0] == null) return; } try { BufferedWriter out = new BufferedWriter(new FileWriter("./Data/highscores.txt")); for (int i = 0; i < 10; i++) { String line = PLAYERS[i][0] + " " + PLAYERS[i][1] + " " + PLAYERS[i][2]; out.write(line, 0, line.length()); out.newLine(); } out.close(); } catch (IOException e) { System.out.println("Error saving HighScores."); } } public static void open(Client c) { c.getPA().showInterface(6308); c.getPA().sendFrame126(Config.SERVER_NAME + " HighScores", 6400); c.getPA().sendFrame126("Top PKers:", 6399); for (int i = 0; i < 40; i++) c.getPA().sendFrame126("", 8578 + i); for (int i = 0; i < 10; i++) c.getPA().sendFrame126(PLAYERS[i][1] + ". " + PLAYERS[i][0] + " - " + PLAYERS[i][2] + " Kills", 6402 + i); } public static void update(Client c) { for (int i = 0; i < 10; i++) { if (c.kills > (Integer) PLAYERS[i][2] && (c.kills < (Integer) PLAYERS[i - (i == 0 ? 0 : 1)][2] || i == 0)) { PLAYERS[i][0] = c.playerName; PLAYERS[i][2] = c.kills; } } } }[/code] [b]Edit the variables to suit your needs.[/b] Next in ActionHandler.java search for: [code]switch(objectType) {[/code] Under that switch statement add: [code] case 3192: HighScores.open(c); break;[/code] Now open Client.java and search for: [code]process() {[/code] Under that add: [code] HighScores.update(this);[/code] Now go in ShutDownHook.java and search for: [code]public void run() {[/code] Under that line add: [code] HighScores.save();[/code] Next open Server.java and search for: [code]public static void main[/code] And under that line add: [code] HighScores.load();[/code] Next open ObjectManager.java and search for: [code]public void loadCustomSpawns(Client c) {[/code] Under that add: [code] c.getPA().checkObjectSpawn(3192, 3222, 3218, 0, 10); // scoreboard[/code] Change these coordinates to wherever you want, this currently spawns the scoreboard in Lumbridge. [color=red]Last step![/color] Lastly, go into your Data folder and make a new text document called highscores.txt [b]If you followed the tutorial correctly, you now have fully working ingame highscores![/b] As always, all credits go to me. Enjoy. ;) Picture: [IMG]http://i1224.photobucket.com/albums/ee365/ZBradleyX/highscores2.png[/IMG] Share this post Link to post Share on other sites
dustey 0 #2 Posted September 5, 2012 I get this error. Fixed a few can't get these, [CODE]src\server\model\players\Client.java:597: error: cannot find symbol HighScores.update(this); ^ symbol: variable HighScores location: class Client src\server\model\players\ActionHandler.java:25: error: cannot find symbol HighScores.open(c); ^ symbol: variable HighScores location: class ActionHandler src\server\util\ShutDownHook.java:11: error: cannot find symbol HighScores.save(); ^ symbol: variable HighScores location: class ShutDownHook src\server\Server.java:121: error: cannot find symbol HighScores.load(); ^ symbol: variable HighScores location: class Server Note: src\server\model\players\Client.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors Press any key to continue . . .[/CODE] Share this post Link to post Share on other sites
Faab234 0 #3 Posted September 6, 2012 [quote name='dustey']I get this error. Fixed a few can't get these, [CODE]src\server\model\players\Client.java:597: error: cannot find symbol HighScores.update(this); ^ symbol: variable HighScores location: class Client src\server\model\players\ActionHandler.java:25: error: cannot find symbol HighScores.open(c); ^ symbol: variable HighScores location: class ActionHandler src\server\util\ShutDownHook.java:11: error: cannot find symbol HighScores.save(); ^ symbol: variable HighScores location: class ShutDownHook src\server\Server.java:121: error: cannot find symbol HighScores.load(); ^ symbol: variable HighScores location: class Server Note: src\server\model\players\Client.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors Press any key to continue . . .[/CODE][/QUOTE] Is it possible that you didn't import the HighScores class? Share this post Link to post Share on other sites
dustey 0 #4 Posted September 7, 2012 I'm fairly new to Java, and do you mean to put, "import server.model.players.HighScores;" in the files which have the error? Share this post Link to post Share on other sites
dustey 0 #5 Posted September 9, 2012 Anyone else think they know what's wrong? Share this post Link to post Share on other sites
23286027318020 0 #6 Posted September 9, 2012 [quote name='dustey']I'm fairly new to Java, and do you mean to put, "import server.model.players.HighScores;" in the files which have the error?[/QUOTE] That would be what he means yes. Share this post Link to post Share on other sites
dustey 0 #7 Posted September 9, 2012 It gives me 3 more errors when I put them in the files which have the error. "Error cannot find symbol." Share this post Link to post Share on other sites
dustey 0 #8 Posted September 12, 2012 Please someone help me, I've been trying to get this for almost 3 days but I can't. Share this post Link to post Share on other sites
Countryboyaj 3 #9 Posted October 11, 2012 @ dustey... copy/paste the compile errors into a [code][code][/code][/code] box so I (and others) can better assist you... Share this post Link to post Share on other sites
dustey 0 #10 Posted October 12, 2012 [CODE]src\server\model\players\Client.java:597: error: cannot find symbol HighScores.update(this); ^ symbol: variable HighScores location: class Client src\server\model\players\ActionHandler.java:25: error: cannot find symbol HighScores.open(c); ^ symbol: variable HighScores location: class ActionHandler src\server\util\ShutDownHook.java:11: error: cannot find symbol HighScores.save(); ^ symbol: variable HighScores location: class ShutDownHook src\server\Server.java:121: error: cannot find symbol HighScores.load(); ^ symbol: variable HighScores location: class Server Note: src\server\model\players\Client.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors Press any key to continue . . .[/CODE] It was posted above already :L Share this post Link to post Share on other sites