To make the shops buy and sell using coins and not free, replace your ShopAssistant.java with this.
Code:
package org.brutality.model.shops;
import org.brutality.Config;
import org.brutality.Server;
import org.brutality.model.items.ItemDefinition;
import org.brutality.model.players.Player;
import org.brutality.model.players.PlayerHandler;
import org.brutality.model.players.PlayerSave;
import org.brutality.util.Misc;
import org.brutality.world.ShopHandler;
public class ShopAssistant {
private Player c;
public ShopAssistant(Player client) {
this.c = client;
}
public boolean shopSellsItem(int itemID) {
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
if (itemID == (ShopHandler.ShopItems[c.myShopId][i] - 1)) {
return true;
}
}
return false;
}
public static final int[][] PKP_DATA = { { 1050, 100000000 } };
/**
* Shops
**/
public void openShop(int ShopID) {
if (Server.getMultiplayerSessionListener().inAnySession(c)) {
return;
}
c.getItems().resetItems(3823);
resetShop(ShopID);
c.isShopping = true;
c.myShopId = ShopID;
c.getPA().sendFrame248(3824, 3822);
if (ShopID == 68)
c.getPA().sendFrame126("Fishing Tourney Shop - Points: " + c.fishingTourneyPoints, 3901);
else if (ShopID == 72)
c.getPA().sendFrame126("Blast Mine Shop - Points: " + c.blastPoints, 3901);
else if (ShopID == 74)
c.getPA().sendFrame126("Sacrifice Shop - Points: " + c.hungerPoints, 3901);
else
c.getPA().sendFrame126(ShopHandler.ShopName[ShopID], 3901);
}
public void updatePlayerShop() {
for (int i = 1; i < Config.MAX_PLAYERS; i++) {
if (PlayerHandler.players[i] != null) {
if (PlayerHandler.players[i].isShopping == true && PlayerHandler.players[i].myShopId == c.myShopId
&& i != c.index) {
PlayerHandler.players[i].updateShop = true;
}
}
}
}
public void updateshop(int i) {
resetShop(i);
}
public void resetShop(int ShopID) {
// synchronized (c) {
int TotalItems = 0;
for (int i = 0; i < ShopHandler.MaxShopItems; i++) {
if (ShopHandler.ShopItems[ShopID][i] > 0) {
TotalItems++;
}
}
if (TotalItems > ShopHandler.MaxShopItems) {
TotalItems = ShopHandler.MaxShopItems;
}
if (ShopID == 80) {
c.getPA().sendFrame171(0, 28050);
c.getPA().sendFrame126("Bounties: " + Misc.insertCommas(Integer.toString(c.getBH().getBounties())), 28052);
} else {
c.getPA().sendFrame171(1, 28050);
}
c.getOutStream().createFrameVarSizeWord(53);
c.getOutStream().writeWord(3900);
c.getOutStream().writeWord(TotalItems);
int TotalCount = 0;
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
if (ShopHandler.ShopItems[ShopID][i] > 0 || i <= ShopHandler.ShopItemsStandard[ShopID]) {
if (ShopHandler.ShopItemsN[ShopID][i] > 254) {
c.getOutStream().writeByte(255);
c.getOutStream().writeDWord_v2(ShopHandler.ShopItemsN[ShopID][i]);
} else {
c.getOutStream().writeByte(ShopHandler.ShopItemsN[ShopID][i]);
}
if (ShopHandler.ShopItems[ShopID][i] > Config.ITEM_LIMIT || ShopHandler.ShopItems[ShopID][i] < 0) {
ShopHandler.ShopItems[ShopID][i] = Config.ITEM_LIMIT;
}
c.getOutStream().writeWordBigEndianA(ShopHandler.ShopItems[ShopID][i]);
TotalCount++;
}
if (TotalCount > TotalItems) {
break;
}
}
c.getOutStream().endFrameVarSizeWord();
c.flushOutStream();
// }
}
public double getItemShopValue(int ItemID, int Type, int fromSlot) {
double ShopValue = 1;
double TotPrice = 0;
// int price = getSpecialItemValue(ItemID);
int price = ItemDefinition.forId(ItemID).getGeneralPrice();
int tokkul = ((ItemDefinition.forId(ItemID).getHighAlchValue() * 2)
+ (ItemDefinition.forId(ItemID).getHighAlchValue() / 2));
if (c.myShopId != 65 || c.myShopId != 66 || c.myShopId != 67) {
ShopValue = price;
} else if ((c.myShopId != 65 || c.myShopId != 66 || c.myShopId != 67) && price < 1) {
ShopValue = price + 1;
} else if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
ShopValue = tokkul;
}
TotPrice = ShopValue;
return TotPrice;
}
/**
* buy item from shop (Shop Price)
**/
public void buyFromShopPrice(int removeId, int removeSlot) {
int ShopValue = (int) Math.floor(getItemShopValue(removeId, 0, removeSlot));
ShopValue *= 1.00;
String ShopAdd = "";
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
c.sendMessage(c.getItems().getItemName(removeId) + ": currently costs "
+ ((ItemDefinition.forId(removeId).getHighAlchValue() * 2)
+ (ItemDefinition.forId(removeId).getHighAlchValue() / 2))
+ " tokkul.");
return;
}
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
} else if (ShopValue >= 1000000) {
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
}
c.sendMessage(c.getItems().getItemName(removeId) + ": currently costs " + ShopValue + " Coins." + ShopAdd);
}
public int getBountyHunterItemCost(int itemId) {
switch (itemId) {
case 12783:
return 500_000;
case 12804:
return 25_000_000;
case 12851:
return 10_000_000;
case 12855:
case 12856:
return 2_500_000;
case 12833:
return 50_000_000;
case 12831:
return 35_000_000;
case 12829:
return 25_000_000;
case 14484:
return 125_000_000;
case 12800:
case 12802:
return 350_000;
case 12786:
return 100_000;
case 10926:
return 2_500;
case 12846:
return 8_000_000;
case 12420:
case 12421:
case 12419:
case 12457:
case 12458:
case 12459:
return 10_000_000;
case 12757:
case 12759:
case 12761:
case 12763:
case 12788:
return 500_000;
case 12526:
return 1_500_000;
case 12773:
return 15_000_000;
case 12849:
case 12798:
return 250_000;
case 12608:
case 12610:
case 12612:
return 350_000;
case 12775:
case 12776:
case 12777:
case 12778:
case 12779:
case 12780:
case 12781:
case 12782:
return 5_000;
default:
return Integer.MAX_VALUE;
}
}
public int getItemValueHungerGames(int id) {
switch (id) {
case 6762:
return 500;
case 20035:
case 20038:
case 20041:
case 20044:
case 20047:
return 2500;
case 13072:
case 13073:
return 7000;
case 11663:
case 11664:
case 11665:
case 8842:
return 5000;
}
return 0;
}
/**
* Sell item to shop (Shop Price)
**/
public void sellToShopPrice(int removeId, int removeSlot) {
// if (c.myShopId == 22 || c.myShopId == 49 || c.myShopId == 116 ||
// c.myShopId == 9 || c.myShopId == 50 || c.myShopId == 12 || c.myShopId
// == 20 || c.myShopId == 2 || c.myShopId == 88 || c.myShopId == 111 ||
// c.myShopId == 113 || c.myShopId == 3
// || c.myShopId == 4 || c.myShopId == 5 || c.myShopId == 16) {
// //c.sendMessage("@red@You can't sell items to this shop!");
// return;
// }
for (int i : Config.ITEMS_KEPT_ON_DEATH) {
if (i == removeId) {
c.sendMessage("You can't sell " + c.getItems().getItemName(removeId).toLowerCase() + ".");
return;
}
}
boolean IsIn = false;
if (ShopHandler.ShopSModifier[c.myShopId] > 1) {
for (int j = 0; j <= ShopHandler.ShopItemsStandard[c.myShopId]; j++) {
if (removeId == (ShopHandler.ShopItems[c.myShopId][j] - 1)) {
IsIn = true;
break;
}
}
} else {
IsIn = true;
}
if (IsIn == false) {
c.sendMessage("You can't sell " + c.getItems().getItemName(removeId).toLowerCase() + " to this store.");
} else {
int ShopValue = (int) Math.floor(getItemShopValue(removeId, 1, removeSlot));
String ShopAdd = "";
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
} else if (ShopValue >= 1000000) {
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
}
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
c.sendMessage(c.getItems().getItemName(removeId) + ": shop will buy for "
+ ItemDefinition.forId(removeId).getLowAlchValue() + " tokkul" + ShopAdd);
} else {
c.sendMessage(c.getItems().getItemName(removeId) + ": shop will buy for "
+ (ItemDefinition.forId(removeId).getLowAlchValue() + 1) + " Coins.");
}
}
}
int items[] = { 661, 662 };
@SuppressWarnings("unused")
public boolean sellItem(int itemID, int fromSlot, int amount) {
if (Server.getMultiplayerSessionListener().inAnySession(c)) {
return false;
}
// if (c.myShopId == 22 || c.myShopId == 49 || c.myShopId == 116 ||
// c.myShopId == 9 || c.myShopId == 50 || c.myShopId == 12 || c.myShopId
// == 20 || c.myShopId == 2 || c.myShopId == 88 || c.myShopId == 111 ||
// c.myShopId == 113 || c.myShopId == 3
// || c.myShopId == 4 || c.myShopId == 5 || c.myShopId == 16) {
// c.sendMessage("@red@You can't sell items to this shop!");
// return false;
// }
for (int i : Config.ITEMS_KEPT_ON_DEATH) {
if (i == itemID) {
c.sendMessage("You can't sell " + c.getItems().getItemName(itemID).toLowerCase() + ".");
return false;
}
}
// if (c.myShopId == 115 || c.myShopId == 77 || c.myShopId == 14||
// c.myShopId == 116 || c.myShopId == 117 || c.myShopId == 71 ||
// c.myShopId == 78
// || c.myShopId == 80 || c.myShopId == 44 || c.myShopId == 22 ||
// c.myShopId == 66 || c.myShopId == 67
// || c.myShopId == 56 || c.myShopId == 20 || c.myShopId == 210 ||
// c.myShopId == 200 || c.myShopId == 68 || c.myShopId == 74 ||
// c.myShopId == 72
// || c.myShopId == 70 || c.myShopId == 69 || c.myShopId == 88) {
// c.sendMessage("@red@You can't sell items to this shop!");
// return false;
// }
if (c.getRights().isAdministrator() && !Config.ADMIN_CAN_SELL_ITEMS) {
c.sendMessage("Selling items as an admin has been disabled.");
return false;
}
if (amount > 0 && itemID == (c.playerItems[fromSlot] - 1)) {
if (ShopHandler.ShopSModifier[c.myShopId] > 1) {
boolean IsIn = false;
for (int i = 0; i <= ShopHandler.ShopItemsStandard[c.myShopId]; i++) {
if (itemID == (ShopHandler.ShopItems[c.myShopId][i] - 1)) {
IsIn = true;
break;
}
}
if (IsIn == false) {
c.sendMessage(
"You can't sell " + c.getItems().getItemName(itemID).toLowerCase() + " to this store.");
return false;
}
}
if (amount > c.playerItemsN[fromSlot] && (ItemDefinition.forId((c.playerItems[fromSlot] - 1)).isNoted()
|| ItemDefinition.forId((c.playerItems[fromSlot] - 1)).isStackable())) {
amount = c.playerItemsN[fromSlot];
} else if (amount > c.getItems().getItemAmount(itemID)
&& !ItemDefinition.forId((c.playerItems[fromSlot] - 1)).isNoted()
&& !ItemDefinition.forId((c.playerItems[fromSlot] - 1)).isStackable()) {
amount = c.getItems().getItemAmount(itemID);
}
int TotPrice2 = 0;
int TotPrice3 = 0;
for (int i = amount; i > 0; i--) {
TotPrice2 = ItemDefinition.forId(itemID).getLowAlchValue() + 1;
if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995)) {
if (!ItemDefinition.forId(itemID).isNoted()) {
c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
} else {
c.getItems().deleteItem(itemID, fromSlot, 1);
}
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
c.getItems().addItem(6529, TotPrice2 - 1);
} else {
c.getItems().addItem(995, (TotPrice2));
}
}
}
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
return true;
}
return true;
}
public boolean addShopItem(int itemID, int amount) {
boolean Added = false;
if (amount <= 0) {
return false;
}
if (ItemDefinition.forId(itemID).isNoted()) {
itemID = c.getItems().getUnnotedItem(itemID);
}
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
if ((ShopHandler.ShopItems[c.myShopId][i] - 1) == itemID) {
ShopHandler.ShopItemsN[c.myShopId][i] += amount;
Added = true;
}
}
if (Added == false) {
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
if (ShopHandler.ShopItems[c.myShopId][i] == 0) {
ShopHandler.ShopItems[c.myShopId][i] = (itemID + 1);
ShopHandler.ShopItemsN[c.myShopId][i] = amount;
ShopHandler.ShopItemsDelay[c.myShopId][i] = 0;
break;
}
}
}
return true;
}
public void handleOtherShop(int itemID, int fromSlot, int amount) {
if (!shopSellsItem(itemID))
return;
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
int itemId = c.getItems().getItemSlot(6529);
if (itemId != itemID) {
return;
}
if (c.getItems().playerHasItem(6529)
&& c.getItems().getItemAmount(6529) >= ItemDefinition.forId(itemID).getHighAlchValue() * 2.5) {
if (c.getItems().freeSlots() > 0) {
c.getItems().deleteItem(6529, (ItemDefinition.forId(itemID).getHighAlchValue() * 2)
+ (ItemDefinition.forId(itemID).getHighAlchValue() / 2));
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
}
} else {
c.sendMessage("You do not have enough tokkul to buy this item.");
}
}
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
PlayerSave.saveGame(c);
}
public boolean buyItem(int itemID, int fromSlot, int amount) {
if (c.inTrade) {
return false;
}
// Fixes dupe within shop via cheat engine.
if (!shopSellsItem(itemID) && c.myShopId != 14)
return false;
if (!shopSellsItem(itemID)) {
return false;
}
if (amount > 0) {
if (!shopSellsItem(itemID))
return false;
if (amount > ShopHandler.ShopItemsN[c.myShopId][fromSlot]) {
amount = ShopHandler.ShopItemsN[c.myShopId][fromSlot];
}
if (amount > c.getItems().freeSlots()) {
if (c.getItems().isStackable(itemID) && c.getItems().freeSlots() < 1)
return false;
if (!c.getItems().isStackable(itemID)) {
amount = c.getItems().freeSlots();
c.sendMessage("You do not have enough inventory space to buy that many.");
}
}
int TotPrice2 = 0;
int Slot, Slot1, Slot2 = 0;// Tokkul
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
handleOtherShop(itemID, fromSlot, amount);
return false;
}
for (int i = amount; i > 0; i--) {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot));
Slot = c.getItems().getItemSlot(995);
Slot1 = c.getItems().getItemSlot(6529);
if (Slot == -1 && c.myShopId != 65 && c.myShopId != 66 && c.myShopId != 67) {
c.sendMessage("You don't have enough coins.");
break;
}
if (Slot1 == -1 && c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
c.sendMessage("You don't have enough tokkul.");
break;
}
if (TotPrice2 <= 0) {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0, fromSlot));
TotPrice2 *= 1.66;
} else {
if (c.myShopId == 65 || c.myShopId == 66 || c.myShopId == 67) {
if (c.playerItemsN[Slot1] >= TotPrice2) {
if (c.getItems().freeSlots() > 0) {
c.getItems().deleteItem(6529, c.getItems().getItemSlot(6529), TotPrice2);
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
} else {
c.sendMessage("You don't have enough tokkul.");
break;
}
}
if (c.myShopId != 65 || c.myShopId != 66 || c.myShopId != 67) {
if (c.playerItemsN[Slot] >= TotPrice2) {
if (c.getItems().freeSlots() > 0) {
c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
} else {
c.sendMessage("You don't have enough coins.");
break;
}
}
}
}
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
PlayerSave.saveGame(c);
return true;
}
return false;
}
public void handleOtherShop(int itemID, int amount) {
if (!shopSellsItem(itemID)) {
c.sendMessage("Stop trying to cheat!");
return;
}
if (amount <= 0) {
c.sendMessage("You need to buy atleast one or more of this item.");
return;
}
if (!c.getItems().isStackable(itemID)) {
if (amount > c.getItems().freeSlots()) {
amount = c.getItems().freeSlots();
}
}
/*
* if (c.myShopId == 115) { if (c.votePoints >=
* getSpecialItemValue(itemID) * amount) { if (c.getItems().freeSlots()
* > 0) { c.votePoints -= getSpecialItemValue(itemID) * amount;
* c.getPA().loadQuests(); c.getItems().addItem(itemID, amount);
* c.getItems().resetItems(3823); } } else { c.sendMessage(
* "You do not have enough vote points to buy this item."); } }
*/
}
public void openSkillCape() {
int capes = get99Count();
if (capes > 1)
capes = 1;
else
capes = 0;
c.myShopId = 14;
setupSkillCapes(capes, get99Count());
}
/*
* public int[][] skillCapes =
* {{0,9747,4319,2679},{1,2683,4329,2685},{2,2680
* ,4359,2682},{3,2701,4341,2703
* },{4,2686,4351,2688},{5,2689,4347,2691},{6,2692,4343,2691},
* {7,2737,4325,2733
* },{8,2734,4353,2736},{9,2716,4337,2718},{10,2728,4335,2730
* },{11,2695,4321,2697},{12,2713,4327,2715},{13,2725,4357,2727},
* {14,2722,4345
* ,2724},{15,2707,4339,2709},{16,2704,4317,2706},{17,2710,4361,
* 2712},{18,2719,4355,2721},****,2737,4331,2739},{20,2698,4333,2700}};
*/
public int[] skillCapes = { 9747, 9753, 9750, 9768, 9756, 9759, 9762, 9801, 9807, 9783, 9798, 9804, 9780, 9795,
9792, 9774, 9771, 9777, 9786, 9810, 9765, 9789, 9948 };
public int get99Count() {
int count = 0;
for (int j = 0; j < c.playerLevel.length; j++) {
if (Player.getLevelForXP(c.playerXP[j]) >= 99) {
count++;
}
}
return count;
}
public void setupSkillCapes(int capes, int capes2) {
c.getPA().sendFrame171(1, 28050);
c.getItems().resetItems(3823);
c.isShopping = true;
c.myShopId = 14;
c.getPA().sendFrame248(3824, 3822);
c.getPA().sendFrame126("Skillcape Shop", 3901);
int TotalItems = 0;
TotalItems = capes2;
if (TotalItems > ShopHandler.MaxShopItems) {
TotalItems = ShopHandler.MaxShopItems;
}
c.getOutStream().createFrameVarSizeWord(53);
c.getOutStream().writeWord(3900);
c.getOutStream().writeWord(TotalItems);
for (int i = 0; i <= 22; i++) {
if (Player.getLevelForXP(c.playerXP[i]) < 99)
continue;
if (skillCapes[i] == -1)
continue;
c.getOutStream().writeByte(1);
c.getOutStream().writeWordBigEndianA(skillCapes[i] + 2);
}
c.getOutStream().endFrameVarSizeWord();
c.flushOutStream();
// }
}
public void skillBuy(int item) {
int nn = get99Count();
if (nn > 1)
nn = 1;
else
nn = 0;
for (int j = 0; j < skillCapes.length; j++) {
if (skillCapes[j] == item || skillCapes[j] + 1 == item) {
if (c.getItems().freeSlots() > 1) {
if (c.getItems().playerHasItem(995, 99000)) {
if (Player.getLevelForXP(c.playerXP[j]) >= 99) {
c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 99000);
c.getItems().addItem(skillCapes[j] + nn, 1);
c.getItems().addItem(skillCapes[j] + 2, 1);
} else {
c.sendMessage("You must have 99 in the skill of the cape you're trying to buy.");
}
} else {
c.sendMessage("You need 99,000 coins to buy this item.");
}
} else {
c.sendMessage("You must have at least 1 inventory spaces to buy this item.");
}
}
}
c.getItems().resetItems(3823);
}
public void openVoid() {
}
public void buyVoid(int item) {
}
}
This wont be perfect, and it might screw up some of your existing shops that use other points. This is more so if you want to completely remove all that and start fresh from a coin base shop system and work around that. Buy price is item high alch value and sell price is low alch value. If the value is 0, it returns it as 1 so at least some of those items like buckets are 1 coin. Also shops 65, 66 and 67 I use as my tokkul shops so i just left them in there. Feel free to change or remove those, or just use them (probably easiest).