You're doing return wich makes the loop stop. Change it to continue; at the locations when it doesnt complete the tanning
EDIT: or if you want it to tan all things you got in the inventory you should set all to continue instead of return.
|
Been a while since I worked with enums and just need some slight help with it.
This only works for cow hide and no other leathers for some reason and I'm not too sure why. Any help with be massive appreciatedCode:package com.rs.game.player.actions.skills.crafting; import com.rs.cache.loaders.ItemDefinitions; import com.rs.game.player.Player; import com.rs.utils.Utils; public class Tanning { public enum hides { COW(1739, 1741, 10), GREEN(1753, 1745, 30), BLUE(1751, 2505, 30), RED(1749, 2507, 30), BLACK(1747, 2509, 30), ROYAL(24372, 24374, 30); public int hide, leather, cost; hides(int hide, int leather, int cost) { this.hide = hide; this.leather = leather; this.cost = cost; } public int getHide() { return hide; } public int getLeather() { return leather; } public int getCost() { return cost; } } public static void hideChecker(Player player) { for (hides hide : hides.values()) { int i = player.getInventory().getNumerOf(hide.getHide()); int pouch = player.money; if (!player.getInventory().contains(hide.getHide())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have any hides for me to tan."); return; } if (pouch < i*hide.getCost() && !player.getInventory().containsItem(995, i*hide.getCost())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have enough money."); return; } if (pouch >= hide.getCost()) { player.money -= i*hide.getCost(); player.refreshMoneyPouch(); } else { player.getInventory().deleteItem(995, i*hide.getCost()); } player.getInventory().deleteItem(hide.getHide(), i); player.getInventory().addItem(hide.getLeather(), i); player.sm("Ellis tans x" +i+ " " +ItemDefinitions.getItemDefinitions(hide.getHide()).getName()+ " for you for x"+Utils.format(i*hide.getCost())+" coins."); player.getDialogueManager().finishDialogue(); return; } } }
You're doing return wich makes the loop stop. Change it to continue; at the locations when it doesnt complete the tanning
EDIT: or if you want it to tan all things you got in the inventory you should set all to continue instead of return.
Thanks for the fast reponses guys. I have added the continue to the end of the hideChecker method but as Stu said, this now spams though the enum looking for the other hides and responses with "no hides". It tans correctly now, just a bit still for it to not just stop after it's done the hides in your inventory.
He's the current method now:
EDIT: And for the record, the loop didn't work.Code:public static void hideChecker(Player player) { for (hides hide : hides.values()) { int i = player.getInventory().getNumerOf(hide.getHide()); int pouch = player.money; if (!player.getInventory().containsItem(hide.getHide(), i)) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have any hides for me to tan."); return; } if (pouch < i*hide.getCost() && !player.getInventory().containsItem(995, i*hide.getCost())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have enough money."); return; } if (pouch >= hide.getCost()) { player.money -= i*hide.getCost(); player.refreshMoneyPouch(); } else { player.getInventory().deleteItem(995, i*hide.getCost()); } player.getInventory().deleteItem(hide.getHide(), i); player.getInventory().addItem(hide.getLeather(), i); player.sm("Ellis tans x" +i+ " " +ItemDefinitions.getItemDefinitions(hide.getHide()).getName()+ " for you for x"+Utils.format(i*hide.getCost())+" coins."); player.getDialogueManager().finishDialogue(); int loop = 0; if (loop < i) { loop++; continue; } else { return; } } }
due to:Makes the loop stop if you dont have any hides of that kind... thats what I meant with continue.. oh well I was just trying to point what the trouble was, why it only did the cow hides.Code:if (!player.getInventory().containsItem(hide.getHide(), i)) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have any hides for me to tan."); return; }
When you dont have any cow hides left in the inventory, it will not go to the next one
And when you got the cow hides in the inventory it does continue because it does not get stuck at that part as I pasted.
you could do it this way instead:
but then you would not get the message of that you dont have anything to tan if you dont have any hides..Code:public static void hideChecker(Player player) { for (hides hide : hides.values()) { int i = player.getInventory().getNumerOf(hide.getHide()); if (i == 0) continue; // so if you dont have any of that kind it continues to look at the next hide in the enumset int pouch = player.money; if (!player.getInventory().contains(hide.getHide())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have any hides for me to tan."); return; } if (pouch < i*hide.getCost() && !player.getInventory().containsItem(995, i*hide.getCost())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have enough money."); return; } if (pouch >= hide.getCost()) { player.money -= i*hide.getCost(); player.refreshMoneyPouch(); } else { player.getInventory().deleteItem(995, i*hide.getCost()); } player.getInventory().deleteItem(hide.getHide(), i); player.getInventory().addItem(hide.getLeather(), i); player.sm("Ellis tans x" +i+ " " +ItemDefinitions.getItemDefinitions(hide.getHide()).getName()+ " for you for x"+Utils.format(i*hide.getCost())+" coins."); player.getDialogueManager().finishDialogue(); return; } }
idk, off the top of my hea, while playing bo3. just an idea.Code:public static void hideChecker(Player player) { List<hides> avail = new ArrayList<>(); for (hides hide : hides.values()) { if (player.getInventory().contains(hide.getHide())) avail.add(hide); } if (avail.isEmpty()) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have any hides for me to tan."); return; } for (hides hide : avail) { int i = player.getInventory().getNumerOf(hide.getHide()); int pouch = player.money; if (pouch < i*hide.getCost() && !player.getInventory().containsItem(995, i*hide.getCost())) { player.getDialogueManager().startDialogue("SimpleNPCMessage", 2824, "Sorry you don't have enough money."); return; } if (pouch >= hide.getCost()) { player.money -= i*hide.getCost(); player.refreshMoneyPouch(); } else { player.getInventory().deleteItem(995, i*hide.getCost()); } player.getInventory().deleteItem(hide.getHide(), i); player.getInventory().addItem(hide.getLeather(), i); player.sm("Ellis tans x" +i+ " " +ItemDefinitions.getItemDefinitions(hide.getHide()).getName()+ " for you for x"+Utils.format(i*hide.getCost())+" coins."); } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |