What you want to add dialogue? Explain what you want to improve
|
okay, so basically i'm making a code that would exchanged the fish you have into your inventory into noted, but i want it so when you click and npc it will automatically take ALL your fish insted of clicking 28 times..
NOTE: SOMEON RELEASED THIS IN SNIPPETS. I WANT TO IMPROVE IT.
Code:public void tradeFish() { c.getItems().addItem(318, c.getItems().getItemAmount(317)); c.getItems().deleteItem(317, c.getItems().getItemAmount(317)); c.sendMessage("You give your fish to the fisherman and he notes them for you."); }
What you want to add dialogue? Explain what you want to improve
Make a method that checks the inventory for how much of an item you have in it?
Yeah you put that in the original post. I feel stupid
It looks like it would work the way it's setup.
There's the methodCode:public int getItemAmount(int ItemID) { int itemCount = 0; for (int i = 0; i < c.playerItems.length; i++) { if((c.playerItems[i] - 1) == ItemID) { itemCount += c.playerItemsN[i]; } } return itemCount; }
See what this does for you. Its pretty much the same thing but hey, it wont hurt to try I guess
Little more concise. Also it makes sense to delete the items before you add them.Code:public void tradeFish() { int fish = c.getItems().getItemAmount(317); c.getItems().deleteItem(317, fish); c.getItems().addItem(318, fish); c.sendMessage("You give your fish to the fisherman and he notes them for you."); }
Read that post I edited it above.
got it to work, but thanks anyway & repp+
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |