Originally Posted by
linas
If its the problem that it sells for less (or doesn't show that it will sell for less) then post your 'sellItem' and your 'sellItemPrice' methods here.
Originally Posted by
Our Promise
post your sell method
I fixed that problem, but now i have another one.
In my prices.txt for exemple my AGS is defined to by 500m but when i check how mutch the shop buy for it say 440m, and if i sell i will get440m not the price defined.
Sell to shop price:
Code:
public void sellToShopPrice(int removeId, int removeSlot) {
for (int i : Config.ITEM_SELLABLE) {
if (i == removeId) {
c.sendMessage("You can't sell "+ItemAssistant.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 "+ItemAssistant.getItemName(removeId).toLowerCase() +" to this store.");
} else {
int ShopValue = (int)Math.round(getItemShopValue(removeId, 1, removeSlot) * 0.80);
String ShopAdd = "";
if (ShopValue >= 1000 && ShopValue < 1000000) {
ShopAdd = " (" + (ShopValue / 1000) + "K)";
} else if (ShopValue >= 1000000) {
ShopAdd = " (" + (ShopValue / 1000000) + " million)";
}
c.sendMessage(ItemAssistant.getItemName(removeId)+" : shop will buy for "+ShopValue+" coins"+ShopAdd);
}
}
Sell item:
Code:
public boolean sellItem(int itemID, int fromSlot, int amount) {
if (c.myShopId == 14) {
return false;
}
if(c.inTrade) {
return false;
}
for (int i : Config.ITEM_SELLABLE) {
if (i == itemID) {
c.sendMessage("You can't sell "+ItemAssistant.getItemName(itemID).toLowerCase()+".");
return false;
}
}
if(c.playerRights == 2 && !Config.ADMIN_CAN_SELL_ITEMS) {
c.sendMessage("Administrators cannot sell.");
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 "+ItemAssistant.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.itemStackable[itemID] && c.getItems().playerHasItem(itemID, amount)) {
c.getItems().addItem(995, TotPrice2*amount);
c.getItems().deleteItem(itemID,c.getItems().getItemSlot(itemID),amount);
addShopItem(itemID, amount);
Server.shopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
c.getItems().resetItems(3823);
resetShop(c.myShopId);
updatePlayerShop();
return false;
}
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 *= 0.80);
//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;
}