Jump to content

The RuneLocus forum has been archived and does not accept new registrations.
Click here for more information, and click here to join the community on Discord.

Optimum

Member
  • Content count

    47
  • Joined

  • Last visited

  1. [quote name='Emily']Have you considered the fact that Jagex most likely has their own algorithm for estimating drop rates? I believe the wiki is handled by the players, while Jagex may have provided the probability states (low/mid/high/rate/etc.). Your simulator is using the random function: [CODE] return (int) (java.lang.Math.random() * (range + 1)); [/code] The doc says: Now if I was a game developer, a bank programmer, or any other function that required a secure way of estimating, I probably wouldn't use the most commonly used algorithm for my game's commerce. A user on r-s showed the issue with the random class with estimating drops. He used it on popular servers to ruin their trade market. [url]http://bit.ly/1DLaoy8[/url][/QUOTE] Thanks a lot for the feedback, The random was just a place holder haha but i have updated it now; using secure randoms :)
  2. [quote name='RobinGfx']Wow really cool if you get this to work :)[/QUOTE] it does
  3. [quote name='DoseSociety']This would make for a useful tool. How accurate?[/QUOTE] Runescape wiki accurate ! some are like spot on like whip and rares that have a value. The rest is more or less made up
  4. [SIZE=6]The Runescape Drop Simulator[/SIZE] [FONT=Arial Narrow]Hello guys. And welcome to my thread. This is going to be my new project i am working in. Its a old school drop simulator. First let me start of by saying these are not 100% accurate. But i do my best to make them accurate. Let me also say that this will take some time to make. I am writting with javaFx so expect a beautiful interface :). I am making this for experience aswell so no hate right? There will be 2 versions of this: Offline Version - This will be a much larger application. It will only rely on whats in the jar. This will be one that needs to be updated to get the drop list. Online Version - This will be a very small and lightweight application. It will rely on being connected to the internet to download images and place them in the app. [B]Source code [/B]([SIZE=2][COLOR="#FF0000"]Beta[/COLOR][/SIZE]): [url=https://github.com/OptimumLTD/RS-Drop-Tool]Rs drop tool[/url] [B][SIZE=3]Download now:[/SIZE][/B] [url=https://dl.dropboxusercontent.com/s/k0ifxtiam9oq94w/Runescape%20Drop%20Simulator.zip?dl=0]Runescape Drop Simulator.zip[/url] [SIZE=6]What is a drop simulator?[/SIZE] The whole purpose of a drop simulator is to simulate the killing of an npc. Basically you will put in either the id of the npc or the name of the npc and this program will simulate you killing the npc. Pick up all it's loot and put it in the bank for you. But obviously all the loots/items will be within the application and not actual in your bank on osrs. [SIZE=6]Why[/SIZE] All the times that i played runescape i have always wondered 'Is it worth it killing that many .....' So i will maybe make a drop simulator and give back to the community that i actually loved. Initial design: [img]http://i.imgur.com/8yyXqSJ.png[/img] Progress - [spoiler=images] [img]http://i.imgur.com/wwkWVWC.png[/img] [IMG]http://i.imgur.com/AKXUQiL.gif[/IMG] [img]http://i.imgur.com/OVuSp2w.gif[/img] new looting system implemented: [img]http://i.imgur.com/rXvG0wI.png[/img] More changes to labels [img]http://i.imgur.com/dZmsgrh.png[/img] hovers for real values: [img]http://i.imgur.com/T81b6DX.png[/img] multi supporting labels with new lines [img]http://i.imgur.com/zE53q60.png[/img] new label system added. [img]http://i.imgur.com/6f2bUSE.png[/img] [img]http://i.imgur.com/ifoynhb.png[/img] [img]http://i.imgur.com/fWOCGtG.png[/img] [/spoiler] Please send me all your feedback of what you think can be changes[/FONT]
  5. Awhile ago i made a teleport handler that wasn't the best. But im back with a better teleport handler. First off add this class Fix the imports and the packaging [CODE]package org.rs2server.entity.players.teleport; import org.rs2server.Config; import org.rs2server.entity.players.Client; import org.rs2server.entity.players.PlayerHandler; import org.rs2server.event.CycleEvent; import org.rs2server.event.CycleEventContainer; import org.rs2server.event.CycleEventHandler; /** * This class will handle all everything to do with the teleporting * it will check if the player is eligible to teleport and * handle all the animations and gfxs. * @author Zack/Optimum * */ public class Teleport { /** * The player teleporting */ private Client player; /** * The targeted x, y and h coordinates */ private int targetX, targetY, targetH; /** * Constructor for teleporting * [MENTION=75098]Para[/MENTION]m player - the player */ public Teleport(Client player){ this.player = player; } /** * Submits a new teleport tab type * [MENTION=75098]Para[/MENTION]m tarX - the new x coordinates * [MENTION=75098]Para[/MENTION]m tarY - the new y coordinates */ public void submitTab(final int tarX, final int tarY){ this.targetX = tarX; this.targetY = tarY; startTeleport(TeleportType.TELETAB_TELEPORT); } /** * Submits a new ancient teleport type * [MENTION=75098]Para[/MENTION]m tarX - the new x coordinates * [MENTION=75098]Para[/MENTION]m tarY - the new y coordinates */ public void submitAncient(final int tarX, final int tarY){ this.targetX = tarX; this.targetY = tarY; startTeleport(TeleportType.ANICENT_TELEPORT); } /** * Submits a new ancient teleport type * [MENTION=75098]Para[/MENTION]m tarX - the new x coordinates * [MENTION=75098]Para[/MENTION]m tarY - the new y coordinates * [MENTION=75098]Para[/MENTION]m tarH - the new height */ public void submitAncient(final int tarX, final int tarY, final int tarH){ this.targetX = tarX; this.targetY = tarY; this.targetH = tarH; startTeleport(TeleportType.ANICENT_TELEPORT); } /** * Submits a new modern teleport * [MENTION=75098]Para[/MENTION]m tarX - the new x coordinates * [MENTION=75098]Para[/MENTION]m tarY - the new y coordinates */ public void submitModern(final int tarX, final int tarY){ this.targetX = tarX; this.targetY = tarY; startTeleport(TeleportType.MODERN_TELEPORT); } /** * Submits a new modern teleport * [MENTION=75098]Para[/MENTION]m tarX - the new x coordinates * [MENTION=75098]Para[/MENTION]m tarY - the new y coordinates * [MENTION=75098]Para[/MENTION]m tarH - the new height */ public void submitModern(final int tarX, final int tarY, final int tarH){ this.targetX = tarX; this.targetY = tarY; this.targetH = tarH; startTeleport(TeleportType.MODERN_TELEPORT); } /** * Handles the teleport event in 3 stages */ public void startTeleport(final TeleportType teleType){ if(!canTeleport(player)) return; final int startStage = teleType.getTickTimer1Start(); final int middleStage = teleType.getTickTimer2Start(); final int stopStage = teleType.getStopTimer(); cancelTradeAndDuel(player); player.stopMovement(); player.isTeleporting = true; player.startAnimation(teleType.getStartGfxAnim()[0]); if(teleType.getStartGfxAnim()[2] == 100) player.gfx100(teleType.getStartGfxAnim()[1]); else player.gfx0(teleType.getStartGfxAnim()[1]); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { int stage = 0; [MENTION=15855]Over[/MENTION]ride public void execute(CycleEventContainer container) { if (stage == startStage) { player.startAnimation(teleType.getTimer1GfxAnim()[0]); if(teleType.getTimer1GfxAnim()[2] == 100) player.gfx100(teleType.getTimer1GfxAnim()[1]); else player.gfx0(teleType.getTimer1GfxAnim()[1]); } if (stage == middleStage){ player.startAnimation(teleType.getTimer2GfxAnim()[0]); if(teleType.getTimer2GfxAnim()[2] == 100) player.gfx100(teleType.getTimer2GfxAnim()[1]); else player.gfx0(teleType.getTimer2GfxAnim()[1]); player.getPA().movePlayer(targetX, targetY, targetH); } if(stage == stopStage){ player.startAnimation(65535); player.resetWalkingQueue(); container.stop(); } stage++; System.out.println("Teleport Stage: " + stage); } [MENTION=15855]Over[/MENTION]ride public void stop() { player.isTeleporting = false; } }, 1); } /** * Checks to see if the player is eligible for teleporting * [MENTION=75098]Para[/MENTION]m player - The target player * [MENTION=184045]return[/MENTION] true if the player can teleport */ public boolean canTeleport(Client player){ if(player == null) return false; if(player.isDead) return false; if (isDueling(player)) return false; if(isTeleBlocked(player)) return false; if(player.isTeleporting) return false; if(wildyLevelCheck(player)) return false; return true; } /** * Checks to see if the player is in a duel * [MENTION=75098]Para[/MENTION]m player - The target player * [MENTION=184045]return[/MENTION] true if the player is in a duel */ public boolean isDueling(Client player){ if (player.duelStatus == 5) { player.sendMessage("You can't teleport during a duel!"); return true; } else return false; } /** * Checks if the player is teleblocked * [MENTION=75098]Para[/MENTION]m player - The target player * [MENTION=184045]return[/MENTION] true if player is teleblocked */ public boolean isTeleBlocked(Client player){ if (System.currentTimeMillis() - player.teleBlockDelay < player.teleBlockLength) { player.sendMessage("You are teleblocked and can't teleport."); return true; } else return false; } /** * Cancels the trade and duel for {@link player} and * the opponent he is dueling / trading with * [MENTION=75098]Para[/MENTION]m player - the target player */ public void cancelTradeAndDuel(Client player){ if (player.duelStatus >= 1 && player.duelStatus <= 4) { Client o = (Client) PlayerHandler.players[player.duelingWith]; player.duelStatus = 0; o.duelStatus = 0; o.getTradeAndDuel().declineDuel(); player.getTradeAndDuel().declineDuel(); } } /** * Checks the current player wilderness level and returns true * if the player is above the max teleport wilderness level * [MENTION=75098]Para[/MENTION]m player - The target player * [MENTION=184045]return[/MENTION] if player is in wildy > 20 */ public boolean wildyLevelCheck(Client player){ if (player.inWild() && player.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) { player.sendMessage("You can't teleport above level " + Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness."); return true; } else return false; } } [/CODE] Now add this class inside the same package [CODE]package org.rs2server.entity.players.teleport; /** * Contains all the teleport types and all their data * @author Zack/Optimum * */ public enum TeleportType { MODERN_TELEPORT( new int[] {714, -1, 0}, 1, new int[] {-1, 308, 100}, 3, new int[] {715, -1, 0}, 6), ANICENT_TELEPORT( new int[] {9599, 1681, 0}, 5, new int[] {-1, -1, 0}, 5, new int[] {-1, -1, 0}, 5), TELETAB_TELEPORT( new int[] {9597, 1680, 0}, 2, new int[] {4731, -1, 0}, 3, new int[] {9598, -1, 0}, 4); int[] startGfxAnim; int tickTimer1Start; int[] timer1GfxAnim; int tickTimer2Start; int[] timer2GfxAnim; int stopTimer; TeleportType(int[] startGfxAnim, int tickTimer1Start, int[] timer1GfxAnim, int tickTimer2Start, int[] timer2GfxAnim, int stopTimer){ this.startGfxAnim = startGfxAnim; this.tickTimer1Start = tickTimer1Start; this.timer1GfxAnim = timer1GfxAnim; this.tickTimer2Start = tickTimer2Start; this.timer2GfxAnim = timer2GfxAnim; this.stopTimer = stopTimer; } public int[] getStartGfxAnim(){ return startGfxAnim; } public int getTickTimer1Start(){ return tickTimer1Start; } public int[] getTimer1GfxAnim(){ return timer1GfxAnim; } public int getTickTimer2Start(){ return tickTimer2Start; } public int[] getTimer2GfxAnim(){ return timer2GfxAnim; } public int getStopTimer(){ return stopTimer; } } [/CODE] now go to Client.java and add these: [code] private Teleport teleport = new Teleport(this); public Teleport getTeleportHandler(){ return teleport; }[/code] this is an example of how to use this: [code] case 4171: case 117048: case 75010: case 50056: case 84237: if(c.playerMagicBook != 1) { c.getTeleportHandler().submitModern(Config.RESPAWN_X, Config.RESPAWN_Y); } else { c.getTeleportHandler().submitAncient(Config.RESPAWN_X, Config.RESPAWN_Y); } break;[/code] If i have missed anything please tell me.
  6. [quote name='Danielxx']Nice work, great release thanks for contributing :)[/QUOTE] Thank you [quote name='rage 0wnz890']Nice release.[/QUOTE] Thank you
  7. [quote name='high105']Nice job! Looks good and great release.[/QUOTE] Thanks
  8. So a little while ago i made this but i dont think i released it on runelocus but This is what you're adding: [IMG]http://i.imgur.com/pRHeihH.png[/img] Now that i have started my woodcutting base on my server i have made a better birds nests class. than my other class - First make a new class called BirdsNests.java and add all this in it [COLOR=red]You will need to change the impot of your client and the package location [/COLOR] [code] package org.rs2server.entity.players.skills.woodcutting; import java.util.Random; import org.rs2server.Server; import org.rs2server.entity.players.Client; /** * @author Zack/optimum * */ public class BirdsNests { /** * This will randomly generate a percentage */ Random rnd = new Random(); /** * This contains all of the nest item ids. */ static final int[] NESTS = { 5070, 5071, 5072, 5073, 5074, 5075 }; /** * This holds all the ring data: ItemId, Percentage */ static final int[][] RINGS = { {1635, 35}, {1637, 75}, {1639, 90}, {1641, 99}, {1643, 100} }; /** * This holds all the seeds data: ItemId, Percentage */ static final int[][] SEEDS = { {5317, 1}, {5290, 3}, {5289, 5}, {5288, 9}, {5287, 13}, {5286, 19}, {5285, 28}, {5284, 38}, {5283, 54}, {5316, 55}, {5315, 58}, {5314, 64}, {5313, 79}, {5312, 100}, }; /** * This method will check if the item being clicked is * a nest. * [MENTION=75098]Para[/MENTION]m itemId - Is the item being clicked * [MENTION=184045]return[/MENTION] if the itemIf is a nest */ public boolean isNest(int itemId) { for(int i : NESTS) { if(i == itemId) { return true; } } return false; } /** * This handles the opening of a birds nest * [MENTION=75098]Para[/MENTION]m player * [MENTION=75098]Para[/MENTION]m itemId - this is the item id thats being clicked */ public void handleOpen(Client player, int itemId) { if(player.getItems().freeSlots() < 1){ player.sendMessage("You need atleast 1 free inventory space to open this!"); return; } switch(itemId) { case 5073: openSeedNest(player); player.getItems().deleteItem(itemId, 1); player.getItems().addItem(5075, 1); return; case 5074: openRingNest(player); player.getItems().deleteItem(itemId, 1); player.getItems().addItem(5075, 1); return; case 5070: case 5071: case 5072: player.getItems().addItem(itemId + 6, 1); player.getItems().deleteItem(itemId, 1); player.getItems().addItem(5075, 1); return; } } /** * This opens the Seed Nests and gives the player * a random seed item based on the seed percentage. * [MENTION=75098]Para[/MENTION]m player */ void openSeedNest(Client player) { int random = 1 + rnd.nextInt(100); for(int i = 0; i < SEEDS.length; i++) { if(random <= SEEDS[i][1]) { player.getItems().addItem(SEEDS[i][0], 1); return; } } } /** * This opens the Ring Nests and gives the player * a random ring item based on the ring percentage. * [MENTION=75098]Para[/MENTION]m player */ void openRingNest(Client player) { int random = 1 + rnd.nextInt(100); for(int i = 0; i < RINGS.length; i++) { if(random <= RINGS[i][1]) { player.getItems().addItem(RINGS[i][0], 1); return; } } } /** * This method drops a birds nest right at a players feet * at a chance of 500 */ public void dropNest(Client player) { if(rnd.nextInt(500) == 0) { Server.itemHandler.createGroundItem( player, NESTS[rnd.nextInt(NESTS.length)], player.getX(), player.getY(), 1, player.playerId); return; } } } [/code] now in clickItem.java add this at the top : [code] BirdsNests nest = new BirdsNests(); [/code] now in this method - processPacket add this: [code] if(nest.isNest(itemId)){ nest.handleOpen(c, itemId); return; } [/code] Thats you done. Constructive critisism is welcome. Feel free to use the rep button Also if i have missed anything please tell me
  9. [quote name='officiallulzs3c']as a matter of fact I do. More people leech tutorials and add them to there own server than people do host leeched servers. therefore you end up with a insidiaxV2 leech with this runecrafting base, someone releases it, 100,000 kids host it, add more leeched tutorials and that's how shitty unstable servers start. its common knowledge[/QUOTE] Actually, the proper insidaxV2 literally do nothing, they just host it, its just a tut, i made it for people who wanna use it you know :P either way, this is a skill for the leeches to use.
  10. [quote name='officiallulzs3c']well written but not any more or less efficient then the original runecrafting base. instead of releasing multiple tutorials why not just release a server with all of the content you come up with, that way people won't leech as much.[/QUOTE] because its my base, i will be hosting it, im going to try rewrite all skills, as efficient as possible, and make it as fun as possible
  11. add this as a class in skills [COLOR=Red]but rename the packaging and imports[/COLOR] [code] package org.rs2server.entity.players.skills.runecrafting; import org.rs2server.Config; import org.rs2server.entity.players.Client; /** * EC * @author Zack/Optimum * */ public class Runecrafting { /** * Rune essence id */ public final static int RUNE_ESS = 1436; /** * This method handles and crafts the runes * @param the player * @param Level required to do the craftRunes * @param The item to add - Runes * @param The amount of runes to add * @param The experience to add * @param Tiara required to do */ public void craftRunes( Client player, int levReq, int itemToAdd, int amountToAdd, int xpToAdd, int tiara, int divide){ int setAmount = player.getItems().getItemAmount(RUNE_ESS); if(!player.getItems().playerHasItem(RUNE_ESS)){ player.sendMessage("You need a rune essence to do this."); return; } for(int i = 0; i < setAmount; i++){ if(!(player.playerEquipment[player.playerHat] == tiara)){ player.sendMessage("You need a " + player.getItems().getItemName(tiara) +" to do this!"); return; } if(player.playerLevel[player.playerRunecrafting] < levReq){ player.sendMessage("You need a Runecrafting level of " + levReq + " to do this."); return; } int level = player.getPA().getLevelForXP(player.playerXP[20]); int totalAmount = amountToAdd * (level / divide); player.getPA().addSkillXP(xpToAdd * Config.RUNECRAFTING_EXPERIENCE, player.playerRunecrafting); player.getItems().getItemAmount(RUNE_ESS); player.getItems().deleteItem(RUNE_ESS, 28); player.getItems().addItem(itemToAdd, totalAmount); } } } [/code] now in actioHandler above firstClickObjects add this [code] Runecrafting rc = new Runecrafting(); [/code] now below firstClickObject add these [code] case 2478: rc.craftRunes(c, 1, 556, 1, 4, 5527, 10); break; case 2479: rc.craftRunes(c, 2, 558, 1, 5, 5529, 14); break; case 2480: rc.craftRunes(c, 5, 555, 1, 6, 5531, 19); break; case 2581: rc.craftRunes(c, 9, 557, 1, 7, 5535, 26); break; case 2582: rc.craftRunes(c, 14, 554, 1, 8, 5537, 35); break; case 2583: rc.craftRunes(c, 20, 559, 1, 9, 5533, 46); break; case 2584: rc.craftRunes(c, 27, 564, 1, 10, 5539, 59); break; case 2585: rc.craftRunes(c, 35, 562, 1, 11, 5543, 72); break; case 2586: rc.craftRunes(c, 44, 561, 1, 12, 5541, 91); break; case 2587: rc.craftRunes(c, 54, 563, 1, 14, 5545, 100); break; case 2588: rc.craftRunes(c, 65, 560, 1, 15, 5547, 100); break; case 2589: rc.craftRunes(c, 77, 565, 1, 16, 5549, 100); break; [/code] thats you done keep in mind, i have not tested a few things, so tell me how everything works, any bugs etc tell me and ill fix
  12. [quote name='officiallulzs3c']this is for re-packed PI's. this wont work on most normal pi's as the imports are wrong. also this isn't really any better or less resource intensive, you've basically made a whole new file just to handle special attacks[/QUOTE] By the first sentence i knew you had no clue what so ever what you are doing, this isnt processing the checks to see if spec has been drained every cylce, this is called when the player used spec, and about the improt, look at the bottom of the thread, let me quote : 'Remember to change all your imports', this is me telling people to change the imports because i have a different packaged server, so dont bother commenting unless you know exactly what this is doing
  13. This is a better way to handle restore spec - first off go to player.java and add this [CODE]public boolean isRestoringSpec = false;[/CODE] then go to combatAssistand and search for this: (should be in the attackPlayer method) [CODE]if (c.getCombat().checkSpecAmount(c.playerEquipment[c.playerWeapon])) { c.lastArrowUsed = c.playerEquipment[c.playerArrows]; c.getCombat().activateSpecial( c.playerEquipment[c.playerWeapon], i); c.followId = c.playerIndex;[/CODE] under that add this: [CODE] if(!c.isRestoringSpec){ RestoreSpecialAttack.execute(c); }[/CODE] then look for: (should be in attackNpc method) [CODE]if(c.getCombat().checkSpecAmount(c.playerEquipment[c.playerWeapon])){ c.lastWeaponUsed = c.playerEquipment[c.playerWeapon]; c.lastArrowUsed = c.playerEquipment[c.playerArrows]; c.getCombat().activateSpecial(c.playerEquipment[c.playerWeapon], i);[/CODE] under it add [CODE] if(!c.isRestoringSpec){ RestoreSpecialAttack.execute(c); }[/CODE] now go to client and find this: [CODE]public void initialize() {[/CODE] under it add this [CODE] if(this.specAmount < 10){ RestoreSpecialAttack.execute(this); }[/CODE] [COLOR=red]Now you can remove all the restore special attack in process()[/COLOR] now in players folder make a new folder called content and make a class called RestoreSpecialAttack and add this [CODE]package org.rs2server.entity.players.content; import org.rs2server.entity.players.*; import org.rs2server.event.*; public class RestoreSpecialAttack { public static void execute(final Client player){ player.isRestoringSpec = true; CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { if (player.specAmount < 10) { player.specAmount += 1; if (player.specAmount > 10) { player.specAmount = 10; container.stop(); } player.getItems().addSpecialBar(player.playerEquipment[player.playerWeapon]); } } @Override public void stop() { player.isRestoringSpec = false; } }, 29); } } [/CODE] [COLOR=red][I]Remember to change all your imports[/I][/COLOR]
  14. in client.java find [code]if (System.currentTimeMillis() - restoreStatsDelay > 60000) { restoreStatsDelay = System.currentTimeMillis(); for (int level = 0; level < playerLevel.length; level++) { if (playerLevel[level] < getLevelForXP(playerXP[level])) { if (level != 5) { // prayer doesn't restore playerLevel[level] += 1; getPA().setSkillLevel(level, playerLevel[level], playerXP[level]); getPA().refreshSkill(level); } } else if (playerLevel[level] > getLevelForXP(playerXP[level])) { playerLevel[level] -= 1; getPA().setSkillLevel(level, playerLevel[level], playerXP[level]); getPA().refreshSkill(level); } }[/code] Remove it, add this class [COLOR="#FF0000"]Note* [/COLOR] you will need to change packages and imports [code] package org.rs2server.entity.players.content; import org.rs2server.entity.players.*; import org.rs2server.event.*; /** * This class handles the restore stats * @author Zack * */ public class RestoreStats { /** * Checks if the player count is above 1 then * it will automatically restore stats */ public static void processs() { EventManager.getSingleton().addEvent(new Event() { @Override public void execute(EventContainer e) { if (playerCount() > 0) { for (Player player : PlayerHandler.players) { if(player != null) for (int level = 0; level < player.playerLevel.length; level++) { if (player.playerLevel[level] < player.getLevelForXP(player.playerXP[level])) { if (level != 5) { // prayer doesn't restore player.playerLevel[level] += 1; player.getPA().setSkillLevel(level, player.playerLevel[level], player.playerXP[level]); player.getPA().refreshSkill(level); } } else if (player.playerLevel[level] > player.getLevelForXP(player.playerXP[level])) { player.playerLevel[level] -= 1; player.getPA().setSkillLevel(level, player.playerLevel[level], player.playerXP[level]); player.getPA().refreshSkill(level); } } } } } }, 60000); } /** * Counts the amount of players * @return */ private static int playerCount() { int players = 0; for (Player p : PlayerHandler.players) { if (p != null) players++; } return players; } } [/code] Now go to server.java and add this under main [code] RestoreStats.processs(); [/code] make sure you import
  15. This can be done slighly better, but this is a better way of handling teleporting. first go to player.java and add this: [code] public boolean isTeleporting = false; [/code] now in client.java go to process() and remove all these [code] if (teleTimer > 0) { teleTimer--; if (!isDead) { if (teleTimer == 1 && newLocation > 0) { teleTimer = 0; getPA().changeLocation(); } if (teleTimer == 5) { teleTimer--; getPA().processTeleport(); } if (teleTimer == 9 && teleGfx > 0) { teleTimer--; gfx100(teleGfx); } } else { teleTimer = 0; } } [/code] then add this class remember to change the [COLOR="#FF0000"]packaging and imports[/COLOR] [spoiler=TeleportHandler] [code] package org.rs2server.entity.players.content; import org.rs2server.Config; import org.rs2server.entity.players.*; import org.rs2server.event.*; public class TeleportHandler { /** * normal teleport * @param player * @param x - X coordinates to go to * @param y - Y coordinates to go to * @param h - H height to go to */ public static void normalTeleport(final Client player, final int x, final int y, final int h){ if(!canTeleport(player)){ return; } cancelTradeAndDuel(player); player.isTeleporting = true; player.startAnimation(714); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { player.gfx100(308); container.stop(); } @Override public void stop() { } }, 1); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { player.startAnimation(715); player.getPA().movePlayer(x, y, h); container.stop(); } @Override public void stop() { player.isTeleporting = false; } }, 3); } /** * Ancient teleport * @param player * @param x - X coordinates to go to * @param y - Y coordinates to go to * @param h - H height to go to */ public static void ancientTeleport(final Client player, final int x, final int y, final int h){ if(!canTeleport(player)){ return; } cancelTradeAndDuel(player); player.isTeleporting = true; player.startAnimation(1979); player.gfx0(392); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { player.getPA().movePlayer(x, y, h); container.stop(); } @Override public void stop() { player.isTeleporting = false; } }, 3); } /** * tab teleport * @param player * @param x - X coordinates to go to * @param y - Y coordinates to go to * @param h - H height to go to */ public static void tabTeleport(final Client player, final int x, final int y, final int h, final int itemId){ if(!canTeleport(player)){ return; } cancelTradeAndDuel(player); player.isTeleporting = true; player.startAnimation(4731); player.gfx0(678); player.getItems().deleteItem(itemId, 1); CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() { @Override public void execute(CycleEventContainer container) { player.getPA().movePlayer(x, y, h); container.stop(); } @Override public void stop() { player.isTeleporting = false; player.startAnimation(65535); } }, 2); } /** * This process checks everything to see if the player can teleport */ public static boolean canTeleport(Client player){ if(isDead(player)){ return false; } if (isDueling(player)) { return false; } if(isTeleBlocked(player)){ return false; } if(isTeleporting(player)){ return false; } if(wildyLevelCheck(player)){ return false; } else return true; } /** * Checks if the player is dead * @param player * @return */ public static boolean isDead(Client player){ return player.isDead; } /** * Checks to see if the player is dueling * @param player */ public static boolean isDueling(Client player){ if (player.duelStatus == 5) { player.sendMessage("You can't teleport during a duel!"); return true; } else return false; } /** * Checks if the player is teleblocked */ public static boolean isTeleBlocked(Client player){ if (System.currentTimeMillis() - player.teleBlockDelay < player.teleBlockLength) { player.sendMessage("You are teleblocked and can't teleport."); return true; } else return false; } /** * Checks to see if the player is already teleporting * @param player * @return */ public static boolean isTeleporting(Client player){ return player.isTeleporting; } /** * Cancels the trade and duel */ public static void cancelTradeAndDuel(Client player){ if (player.duelStatus >= 1 && player.duelStatus <= 4) { Client o = (Client) PlayerHandler.players[player.duelingWith]; player.duelStatus = 0; o.duelStatus = 0; o.getTradeAndDuel().declineDuel(); player.getTradeAndDuel().declineDuel(); } } /** * Checks to see if player is under level 20 in the wild */ public static boolean wildyLevelCheck(Client player){ if (player.inWild() && player.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) { player.sendMessage("You can't teleport above level " + Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness."); return true; } else return false; } } [/code] [/spoiler] go to walking.java and add this: [code] if(c.isTeleporting == true){ //c.sendMessage("you cannot run while teleporting"); return; } [/code] IF I HAVE MISSED ANYTHING COMMENT IT i will now give you an example of how the teleporting works: go to itemClick.java and add these [code] if(itemId == 8007){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.VARROCK_X, Config.VARROCK_Y, 0, itemId); } if(itemId == 8008){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.LUMBY_X, Config.LUMBY_Y, 0, itemId); } if(itemId == 8009){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.FALADOR_X, Config.FALADOR_Y, 0, itemId); } if(itemId == 8010){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.CAMELOT_X, Config.CAMELOT_Y, 0, itemId); } if(itemId == 8011){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.ARDOUGNE_X, Config.ARDOUGNE_Y, 0, itemId); } if(itemId == 8012){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.WATCHTOWER_X, Config.WATCHTOWER_Y, 0, itemId); } if(itemId == 8013){ if(TeleportHandler.isTeleporting(c)){ return; } else TeleportHandler.tabTeleport(c, Config.EDGEVILLE_X, Config.EDGEVILLE_Y, 0, itemId); } [/code]
×