Code:
public static boolean depositMoney(Player plr, int amount) {
if(amount <= 0)
return false;
if(plr.getInterfaceId() > 0) {
plr.getPacketSender().sendMessage("Please close the interface you have open before opening another one.");
return false;
}
if(plr.getConstitution() <= 0) {
plr.getPacketSender().sendMessage("You cannot do this while dying.");
return false;
}
if(plr.getLocation() == Location.WILDERNESS) {
plr.getPacketSender().sendMessage("You cannot do this here.");
return false;
}
if (validateAmount(plr, amount)) {
long addedMoney = (long)plr.getMoneyInPouch() + (long)amount;
if (addedMoney > Long.MAX_VALUE) {
long canStore = Long.MAX_VALUE - plr.getMoneyInPouch();
plr.getInventory().delete(995, (int)canStore);
plr.setMoneyInPouch(plr.getMoneyInPouch() + canStore);
plr.getPacketSender().sendString(8135, ""+plr.getMoneyInPouch());
plr.getPacketSender().sendMessage("You've added "+canStore + " coins to your money pouch.");
return true;
} else {
plr.getInventory().delete(995, amount);
plr.setMoneyInPouch(plr.getMoneyInPouch() + amount);
plr.getPacketSender().sendString(8135, ""+plr.getMoneyInPouch());
plr.getPacketSender().sendMessage("You've added "+amount+" coins to your money pouch.");
return true;
}
} else {
plr.getPacketSender().sendMessage("You do not seem to have " +amount+" coins in your inventory.");
return false;
}
}
Code:
public static boolean withdrawMoney(Player plr, long amount) {
if(amount <= 0)
return false;
if(plr.getMoneyInPouch() <= 0) {
plr.getPacketSender().sendMessage("Your money pouch is empty.");
return false;
}
boolean allowWithdraw = plr.getTrading().inTrade() || plr.getDueling().inDuelScreen;
if(!allowWithdraw) {
if(plr.getInterfaceId() > 0) {
plr.getPacketSender().sendMessage("Please close the interface you have open before opening another one.");
return false;
}
plr.getPacketSender().sendInterfaceRemoval();
}
if(amount > plr.getMoneyInPouch()/1000000000)
amount = plr.getMoneyInPouch()/1000000000;
if ((plr.getInventory().getAmount(909) + amount) < Integer.MAX_VALUE) {
plr.setMoneyInPouch(plr.getMoneyInPouch() - amount*1000000000);
plr.getInventory().add(909, (int) amount);
plr.getPacketSender().sendString(8135, ""+plr.getMoneyInPouch());
plr.getPacketSender().sendMessage("You withdraw "+amount+" M from your pouch.");
if(allowWithdraw)
plr.getPacketSender().sendItemContainer(plr.getInventory(), 3322);
return true;
} else if((plr.getInventory().getAmount(995) + amount) > Integer.MAX_VALUE) {
int canWithdraw = (Integer.MAX_VALUE - plr.getInventory().getAmount(995));
if(canWithdraw == 0) {
plr.getPacketSender().sendMessage("You cannot withdraw more money into your inventory.");
return false;
}
plr.setMoneyInPouch(plr.getMoneyInPouch() - canWithdraw);
plr.getInventory().add(995, canWithdraw);
plr.getPacketSender().sendString(8135, ""+plr.getMoneyInPouch());
plr.getPacketSender().sendMessage("You could only withdraw "+canWithdraw+" coins.");
if(allowWithdraw)
plr.getPacketSender().sendItemContainer(plr.getInventory(), 3322);
return true;
}
return false;
}
Code:
private static boolean validateAmount(Player plr, int amount) {
return plr.getInventory().getAmount(995) >= amount;
}
}
when withdrawing money, I need 1b or more in the moneypouch to withdraw anything. if I have anything less than 1b I receive the message "you withdraw 0 M from your pouch
I tried placing 20B in the moneypouch and tried to withdraw 1 and tried 1b it gives me everything in the pouch down to 1M gp, and gives me 2x GS coin wich is the itemid 909 from above
if I add the 2x gs coin to the money pouch, it only adds "2" to the pouch, assuming its 2 gp as I cant withdraw it without seeing the 0 m from your pouch message