So here's the issue..
I've been working on a new project and it's partial spawn, so regular players can spawn items that aren't rare. The problem in short is that players can spawn items and sell them in the general store (or a shop that carries the item, for whatever reason it carries a spawnable item) for GP. Obviously I could just disable selling completely, but I still want players to be able to make money killing dragons and selling the bones for example. I've been trying to find a solution to this problem on my own for a couple weeks now, and had plenty of ideas that would work but I don't have the Java knowledge necessary to implement them yet. This is where I'll need one of you to help me, and I'm willing to pay through PayPal if the task seems too hard, otherwise you receive my kind thanks and +1 REP.
Here's my sellToShopPrice method:
[SPOIL]
Code:
public boolean sellItem(int itemID, int fromSlot, int amount) {
for (int i : Config.ITEM_SELLABLE) {
if (i == removeId) {
c.sendMessage("You can't sell "+c.getItems().getItemName(removeId).toLowerCase()+".");
return;
}
}
boolean IsIn = false;
if (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
for (int j = 0; j <= Server.shopHandler.ShopItemsStandard[c.myShopId]; j++) {
if (removeId == (Server.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)";
}
c.sendMessage(c.getItems().getItemName(removeId)+": shop will buy for "+ShopValue+" coins"+ShopAdd);
}
}
[/SPOIL]
And here's my sellItem boolean:
[SPOIL]
Code:
public boolean sellItem(int itemID, int fromSlot, int amount) {
if (c.myShopId == 3 || itemID != itemID || c.inTrade)
return false;
if (c.myShopId == 14)
return false;
for (int i : Config.ITEM_SELLABLE) {
if (i == itemID) {
c.sendMessage("You can't sell "+c.getItems().getItemName(itemID).toLowerCase()+".");
return false;
}
}
if(c.playerRights == 2 && !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 (Server.shopHandler.ShopSModifier[c.myShopId] > 1) {
boolean IsIn = false;
for (int i = 0; i <= Server.shopHandler.ShopItemsStandard[c.myShopId]; i++) {
if (itemID == (Server.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] && (Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == true || Item.itemStackable[(c.playerItems[fromSlot] - 1)] == true)) {
amount = c.playerItemsN[fromSlot];
} else if (amount > c.getItems().getItemAmount(itemID) && Item.itemIsNote[(c.playerItems[fromSlot] - 1)] == false && Item.itemStackable[(c.playerItems[fromSlot] - 1)] == false) {
amount = c.getItems().getItemAmount(itemID);
}
//double ShopValue;
//double TotPrice;
int TotPrice2 = 0;
//int Overstock;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 1, fromSlot));
if (c.getItems().freeSlots() > 0 || c.getItems().playerHasItem(995)) {
if (Item.itemIsNote[itemID] == false) {
c.getItems().deleteItem(itemID, c.getItems().getItemSlot(itemID), 1);
} else {
c.getItems().deleteItem(itemID, fromSlot, 1);
}
c.getItems().addItem(995, TotPrice2);
addShopItem(itemID, 1);
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
}
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
return true;
}
return true;
}
[/SPOIL]
Here's my idea:
If it's possible I need someone to help me alter this so that Config.ITEM_SELLABLE works the opposite way around. This way any items I add to the list CAN be sold, and every other item in the game CANNOT. This would make it a lot easier to do what I'm trying to do with my project, because there are only going to be a handful of items players need to sell. I know I'm sort of trying to have the best of both worlds (spawn/eco) but it's just the approach I wanted to take, and I think I can make it work if I get this fixed.
Of course if you think there's a better way to go about fixing my problem, I don't have any issues implementing that instead. I'm also open to any suggestions or criticism on what I'm trying to do, so feel free to say whatever is on your mind.
Thanks,
Bayrock