Originally Posted by
xNova
Post the method you have for it.
Originally Posted by
mikey96
Post your bankitem method.
Code:
public boolean bankItem(int itemID, int fromSlot, int amount, int[] array,
int[] arrayN) {
if (c.inTrade) {
c.sendMessage("You can't store items while trading!");
return false;
}
if (c.playerItems[fromSlot] <= 0 || c.playerItemsN[fromSlot] <= 0) {
return false;
}
if (!Item.itemIsNote[c.playerItems[fromSlot] - 1]) {
if (c.playerItems[fromSlot] <= 0) {
return false;
}
if (Item.itemStackable[c.playerItems[fromSlot] - 1]
|| c.playerItemsN[fromSlot] > 1) {
int toBankSlot = 0;
boolean alreadyInBank = false;
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] == c.playerItems[fromSlot]) {
if (c.playerItemsN[fromSlot] < amount)
amount = c.playerItemsN[fromSlot];
alreadyInBank = true;
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
if (!alreadyInBank && freeBankSlots() > 0) {
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] <= 0) {
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
array[toBankSlot] = c.playerItems[fromSlot];
if (c.playerItemsN[fromSlot] < amount) {
amount = c.playerItemsN[fromSlot];
}
if ((arrayN[toBankSlot] + amount) <= Config.MAXITEM_AMOUNT
&& (arrayN[toBankSlot] + amount) > -1) {
arrayN[toBankSlot] += amount;
} else {
c.sendMessage("Bank full!");
return false;
}
deleteItem((c.playerItems[fromSlot] - 1), fromSlot, amount);
resetBank();
return true;
} else if (alreadyInBank) {
if ((arrayN[toBankSlot] + amount) <= Config.MAXITEM_AMOUNT
&& (arrayN[toBankSlot] + amount) > -1) {
arrayN[toBankSlot] += amount;
} else {
c.sendMessage("Bank full!");
return false;
}
deleteItem((c.playerItems[fromSlot] - 1), fromSlot, amount);
resetBank();
return true;
} else {
c.sendMessage("Bank full!");
return false;
}
} else {
itemID = c.playerItems[fromSlot];
int toBankSlot = 0;
boolean alreadyInBank = false;
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] == c.playerItems[fromSlot]) {
alreadyInBank = true;
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
if (!alreadyInBank && freeBankSlots() > 0) {
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] <= 0) {
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
int firstPossibleSlot = 0;
boolean itemExists = false;
while (amount > 0) {
itemExists = false;
for (int i = firstPossibleSlot; i < c.playerItems.length; i++) {
if ((c.playerItems[i]) == itemID) {
firstPossibleSlot = i;
itemExists = true;
i = 30;
}
}
if (itemExists) {
array[toBankSlot] = c.playerItems[firstPossibleSlot];
arrayN[toBankSlot] += 1;
deleteItem((c.playerItems[firstPossibleSlot] - 1),
firstPossibleSlot, 1);
amount--;
} else {
amount = 0;
}
}
resetBank();
return true;
} else if (alreadyInBank) {
int firstPossibleSlot = 0;
boolean itemExists = false;
while (amount > 0) {
itemExists = false;
for (int i = firstPossibleSlot; i < c.playerItems.length; i++) {
if ((c.playerItems[i]) == itemID) {
firstPossibleSlot = i;
itemExists = true;
i = 30;
}
}
if (itemExists) {
arrayN[toBankSlot] += 1;
deleteItem((c.playerItems[firstPossibleSlot] - 1),
firstPossibleSlot, 1);
amount--;
} else {
amount = 0;
}
}
resetBank();
return true;
} else {
c.sendMessage("Bank full!");
return false;
}
}
} else if (Item.itemIsNote[c.playerItems[fromSlot] - 1]
&& !Item.itemIsNote[c.playerItems[fromSlot] - 2]) {
if (c.playerItems[fromSlot] <= 0) {
return false;
}
if (Item.itemStackable[c.playerItems[fromSlot] - 1]
|| c.playerItemsN[fromSlot] > 1) {
int toBankSlot = 0;
boolean alreadyInBank = false;
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] == (c.playerItems[fromSlot] - 1)) {
if (c.playerItemsN[fromSlot] < amount)
amount = c.playerItemsN[fromSlot];
alreadyInBank = true;
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
if (!alreadyInBank && freeBankSlots() > 0) {
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] <= 0) {
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
array[toBankSlot] = (c.playerItems[fromSlot] - 1);
if (c.playerItemsN[fromSlot] < amount) {
amount = c.playerItemsN[fromSlot];
}
if ((arrayN[toBankSlot] + amount) <= Config.MAXITEM_AMOUNT
&& (arrayN[toBankSlot] + amount) > -1) {
arrayN[toBankSlot] += amount;
} else {
return false;
}
deleteItem((c.playerItems[fromSlot] - 1), fromSlot, amount);
resetBank();
return true;
} else if (alreadyInBank) {
if ((arrayN[toBankSlot] + amount) <= Config.MAXITEM_AMOUNT
&& (arrayN[toBankSlot] + amount) > -1) {
arrayN[toBankSlot] += amount;
} else {
return false;
}
deleteItem((c.playerItems[fromSlot] - 1), fromSlot, amount);
resetBank();
return true;
} else {
c.sendMessage("Bank full!");
return false;
}
} else {
itemID = c.playerItems[fromSlot];
int toBankSlot = 0;
boolean alreadyInBank = false;
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] == (c.playerItems[fromSlot] - 1)) {
alreadyInBank = true;
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
if (!alreadyInBank && freeBankSlots() > 0) {
for (int i = 0; i < Config.BANK_SIZE; i++) {
if (array[i] <= 0) {
toBankSlot = i;
i = Config.BANK_SIZE + 1;
}
}
int firstPossibleSlot = 0;
boolean itemExists = false;
while (amount > 0) {
itemExists = false;
for (int i = firstPossibleSlot; i < c.playerItems.length; i++) {
if ((c.playerItems[i]) == itemID) {
firstPossibleSlot = i;
itemExists = true;
i = 30;
}
}
if (itemExists) {
array[toBankSlot] = (c.playerItems[firstPossibleSlot] - 1);
arrayN[toBankSlot] += 1;
deleteItem((c.playerItems[firstPossibleSlot] - 1),
firstPossibleSlot, 1);
amount--;
} else {
amount = 0;
}
}
resetTempItems();
resetBank();
return true;
} else if (alreadyInBank) {
int firstPossibleSlot = 0;
boolean itemExists = false;
while (amount > 0) {
itemExists = false;
for (int i = firstPossibleSlot; i < c.playerItems.length; i++) {
if ((c.playerItems[i]) == itemID) {
firstPossibleSlot = i;
itemExists = true;
i = 30;
}
}
if (itemExists) {
arrayN[toBankSlot] += 1;
deleteItem((c.playerItems[firstPossibleSlot] - 1),
firstPossibleSlot, 1);
amount--;
} else {
amount = 0;
}
}
resetTempItems();
resetBank();
return true;
} else {
c.sendMessage("Bank full!");
return false;
}
}
} else {
c.sendMessage("Item not supported " + (c.playerItems[fromSlot] - 1));
return false;
}
}
Sorry for the wait ive been busy. Idk if this helps. I might just need an updateBank() method.