code looks shit
|
is it possible to make my code cleaner? if yes, how?
iknow its ugly, but i want to learn...
Code:public void pickPlayerPocket(int index) { Client p = (Client)PlayerHandler.players[index]; c.pickingPlayer = false; if(p == null) return; if (c.playerLevel[17] < p.playerLevel[17]) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You need to have a theiving level of " + p.playerLevel[17] + " to pick this person pockets."); return; } if (p.playerName.equalsIgnoreCase("Test") && (Misc.random(300) <= 299)) { c.startAnimation(832); c.sendMessage("@red@[ThievMaster]@red@ @bla@ You failed."); c.gfx100(80); c.getPA().sound(937); return; } if (p.Antithievtimer >= 1 || p.anticheattimer >= 1){ c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@ " + p.playerName + " has "+ p.Antithievtimer + " secounds protection"); return; } if (p.inDuelArena() || p.inCw() || p.isBanking || p.inTrade) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@This player is busy."); return; } c.startAnimation(832); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You attempt to pick " + p.playerName + "'s pockets..."); if (Misc.random(4) == 1 || Misc.random(4) == 3 || Misc.random(4) == 2 && !p.playerName.equalsIgnoreCase("Test")) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You failed and noticed " + p.playerName + ""); p.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@" + c.playerName + " tried to steal from you but failed"); c.gfx100(80); c.playerLevel[3] -= 1; c.setHitUpdateRequired(true); c.getPA().refreshSkill(3);; c.getPA().sound(937); return; } int item = 0, amount = 0, trys = 0; while(item == 0 && trys < 1) { for (int i = 0; i < p.playerItems.length; i++) { if ((p.playerItems[i]-1) > 0) { int v = c.getShops().getItemShopValue(p.playerItems[i] - 1); if (v > 150000) continue; // higher than 1 million? skip that shit :) if (Misc.random(4) == 4) { item = p.playerItems[i] - 1; if(p.playerItemsN[i] > 1) amount = Misc.random((p.playerItemsN[i] > 1000000 ? 1000000 : p.playerItemsN[i])); else amount = 1; } } } trys++; } if (item == 0) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@The person dont have any valutes left."); return; } p.getItems().deleteItem(item, amount); p.sendMessage("@yel@[PICKPOCKET]@yel@ @red@" + c.playerName + " did steal something from you. "); c.getItems().addItem(item, amount); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You successfully picked " + p.playerName + "'s pockets!"); if (p.playerName.equalsIgnoreCase("Test")) { c.getQuest().thievmaster(); c.getPA().yell(""SERVER", c.playerName+" just completed ThievMaster."); } } } }
code looks shit
To make it look visually better, use Eclipse and format it...
i will figure it out :C too much errors in eclipse right now.
just want this clean.
any help with :
http://www.rune-server.org/runescape...ml#post3486983
?
Jesus
moved some things around, fixed your brackets. You should make this a separate class, as opposed to a method in a prior class.Code:public void pickPlayerPocket(int index) { Client p = (Client)PlayerHandler.players[index]; c.pickingPlayer = false; if(p == null) return; if (c.playerLevel[17] < p.playerLevel[17]) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You need to have a theiving level of " + p.playerLevel[17] + " to pick this person pockets."); return; } if (p.playerName.equalsIgnoreCase("Test") && (Misc.random(300) <= 299)) { c.startAnimation(832); c.sendMessage("@red@[ThievMaster]@red@ @bla@ You failed."); c.gfx100(80); c.getPA().sound(937); } else { if (p.Antithievtimer >= 1 || p.anticheattimer >= 1){ c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@ " + p.playerName + " has "+ p.Antithievtimer + " secounds protection"); } if (p.inDuelArena() || p.inCw() || p.isBanking || p.inTrade) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@This player is busy."); } c.startAnimation(832); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You attempt to pick " + p.playerName + "'s pockets..."); if (Misc.random(4) == 1 || Misc.random(4) == 3 || Misc.random(4) == 2 && !p.playerName.equalsIgnoreCase("Test")) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You failed and noticed " + p.playerName + ""); p.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@" + c.playerName + " tried to steal from you but failed"); c.gfx100(80); c.playerLevel[3] -= 1; c.setHitUpdateRequired(true); c.getPA().refreshSkill(3);; c.getPA().sound(937); return; } } int item = 0, amount = 0, trys = 0; while(item == 0 && trys < 1) { for (int i = 0; i < p.playerItems.length; i++) { if ((p.playerItems[i]-1) > 0) { int v = c.getShops().getItemShopValue(p.playerItems[i] - 1); if (v > 150000) continue; // higher than 1 million? skip that shit :) if (Misc.random(4) == 4) { item = p.playerItems[i] - 1; if(p.playerItemsN[i] > 1) { amount = Misc.random((p.playerItemsN[i] > 1000000 ? 1000000 : p.playerItemsN[i])); } else { amount = 1; } } } } trys++; } if (item == 0) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@The person dont have any valutes left."); return; } else { p.getItems().deleteItem(item, amount); p.sendMessage("@yel@[PICKPOCKET]@yel@ @red@" + c.playerName + " did steal something from you. "); c.getItems().addItem(item, amount); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You successfully picked " + p.playerName + "'s pockets!"); if (p.playerName.equalsIgnoreCase("Test")) { c.getQuest().thievmaster(); c.getPA().yell("SERVER", c.playerName+" just completed ThievMaster."); } } } }
removed theiv master, idfk what that wasCode:public void pickPlayerPocket(Player p) { if (p == null) { return; } c.pickingPlayer = false; if (c.playerLevel[17] < p.playerLevel[17]) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You need to have a theiving level of " + p.playerLevel[17] + " to pick this person pockets."); return; } if (p.Antithievtimer >= 1 || p.anticheattimer >= 1){ c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@ " + p.playerName + " has "+ p.Antithievtimer + " secounds protection"); return; } if (p.inDuelArena() || p.inCw() || p.isBanking || p.inTrade) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@This player is busy."); return; } c.startAnimation(832); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You attempt to pick " + p.playerName + "'s pockets..."); if (Misc.random(4) != 1) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You failed and noticed " + p.playerName + ""); p.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@" + c.playerName + " tried to steal from you but failed"); c.gfx100(80); c.playerLevel[3] -= 1; c.setHitUpdateRequired(true); c.getPA().refreshSkill(3);; c.getPA().sound(937); return; } List<Integer> slots = new LinkedList<Integer>(); for (int i = 0; i < p.playerItems.length; i++) { if ((p.playerItems[i]-1) > 0 && c.getShops().getItemShopValue(p.playerItems[i] - 1) < 150000) { slots.add(i); } } if (slots.length <= 0) { c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@The person dont have any valutes left."); return; } int slot = slots.get(Misc.random(slots.length-1)); final int item = p.playerItems[slot] - 1; final int amount = p.playerItemsN[slot] > 1 ? Misc.random((p.playerItemsN[slot] > 1000000 ? 1000000 : p.playerItemsN[slot])) : 1; p.getItems().deleteItem(item, amount); p.sendMessage("@yel@[PICKPOCKET]@yel@ @red@" + c.playerName + " did steal something from you. "); c.getItems().addItem(item, amount); c.sendMessage("@yel@[PICKPOCKET]@yel@ @bla@You successfully picked " + p.playerName + "'s pockets!"); }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |