The help section can be found if you click http://www.rune-server.org/runescape...t-server/help/. Please don't ask for help here.
Bare in mind this is a snippet and not fully operational unless you do a few minor edits to your server.
Code:
package com.rs.game.player.content;
import java.io.Serializable;
import java.text.DecimalFormat;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
public class MoneyPouch implements Serializable {
private static final long serialVersionUID = -3847090682601697992L;
private transient Player player;
private boolean usingPouch;
private int coinAmount;
public MoneyPouch(Player player) {
this.player = player;
}
public void switchPouch() {
usingPouch = !usingPouch;
refresh(true);
}
private void refresh(boolean swap) {
if (swap)
player.getPackets().sendRunScript(5557, 1);
player.getPackets().sendRunScript(5560, coinAmount);
}
public void sendDynamicInteraction(int amount, boolean remove) {
int newAmount = remove ? amount - coinAmount : amount + coinAmount;
Item item = new Item(995, amount - (remove ? 0 : Integer.MAX_VALUE));
if (remove) {
if (newAmount <= 0) {
if (player.getInventory().containsItem(item.getId(), item.getAmount()))
player.getInventory().getItems().remove(item);
else
player.getPackets().sendGameMessage("You don't have enough coins.");
return;
} else
player.getPackets().sendGameMessage(getFormattedNumber(amount) +" coins have been removed from your money pouch.");
} else {
if (newAmount > Integer.MAX_VALUE) {
if (player.getInventory().getItems().add(item))
player.getPackets().sendGameMessage("Your money-pouch is currently full. Your coins will now go to your inventory.");
else
player.getPackets().sendGameMessage("Your inventory is currently full.");
return;
} else
player.getPackets().sendGameMessage(getFormattedNumber(amount) +" coins have been added to your money pouch.");
}
setAmount(newAmount, amount, remove);
}
private String getFormattedNumber(int amount) {
return new DecimalFormat("#,###,##0").format(amount).toString();
}
public void sendExamine() {
player.getPackets().sendGameMessage("Your money pouch current contains " + getFormattedNumber(coinAmount) + " coins.");
}
private void setAmount(int coinAmount, int addedAmount, boolean remove) {
this.coinAmount = coinAmount;
player.getPackets().sendRunScript(5561 , remove ? 0 : 1, addedAmount);
refresh(false);
}
public boolean isUsingPouch() {
return usingPouch;
}
public int getCoinsAmount() {
return coinAmount;
}
}
Buttonhandler stuff.
Code:
} else if ((interfaceId == 746 && componentId == 207) || (interfaceId == 548 && componentId == 159)) {
if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
player.getMoneyPouch().switchPouch();
} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
player.getMoneyPouch().sendExamine();
else
if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET) {
if (player.getInterfaceManager().containsScreenInter()) {
player.getPackets()
.sendGameMessage(
"Please finish what you're doing before opening the price checker.");
return;
}
player.stopAll();
player.getPriceCheckManager().openPriceCheck();
}
}
Code:
public void depositMoneyPouch(boolean banking) {
int coinsCount = player.getMoneyPouch().getCoinsAmount();
int space = addItems(new Item[] {new Item(955, coinsCount) }, banking);
if(space != 0) {
if (space < 1) {
player.getPackets().sendGameMessage("Not enough space in your bank.");
return;
}
player.getMoneyPouch().sendDynamicInteraction(coinsCount, true);
}
}
Things that aren't included in the release.
- Withdrawl (I dont want to post a new system).
I was going to release this before Vincent released the cs, however he beat me to it as I had to sleep (faggot). Enjoy, think of this as my welcome back prezzie to all.
Implementation for player :
Originally Posted by
Cjay0091
Declare this in player.java
Code:
private MoneyPouch pouch;
Find the method init in Player.java and put this :
Code:
pouch = new MoneyPouch(this);
under
Code:
petManager.setPlayer(this);
Finally add the getter.
Code:
public MoneyPouch getMoneyPouch() {
return pouch;
}