H
hat trix
Guest
I NEED HELP! 
ok. well i wanted to add a shop where you buy things with a different type of currancy e.g. trading sticks, but at the same time have the other shops where u can buy from them with money. 2 types of shops
well. to tell you the truth i have no clue what i was doing. so i decided to experiment lol
i started off by making a new cfg folder and a new java folder. named the cfg folder shops1.cfg and the javafolder ticket.java
from there i copied the first line of shop from the regular shop folder, and then i made the shop id 42 because there were 41 shops in the first one.
then i took shophandler.java, copied everything in it, and pasted it in ticket, and changed
"loadShops("shops.cfg");" to "loadShops("shops1.cfg");" that way ticket.java would load shops1.cfg
then i opened up client.java and found
i wanted openupshop to open up the shops from 41 and below so i changed it to this
and then under that i added this
i figured openupshop would only open up 41 and below so i changed the one that opens all above 41 to openupticket. then i searched for openupshop and found this.
so i copied that, and pasted it under it and changed it around and made it look like this
after that i noticed i had to change resetShop(shopID);
so i changed it to resetTicket and then searched for resetshop and found this
so i coppied that, and changed the name to resetTicket, and changed all of the shophandlers to Ticket. that way it will do everything from Ticket.java instead of shophandler.java, after i did that i got this
after i did this i wanted to see if it would open up shops above 41 so i made a new shop in shops1.cfg put the shop id to 43 opened up client, set the wanneshop of an npc to 43 and sure enough the shop worked like i wanted it 2.
now to make it to where i buy it with different currancy, this is what i dont get...
i searched for buyitem and i got this
i copied that and pasted another one under it, named it buyitem1 and changed EVERYTHING that needed to be changed inorder for it to work through ticket.java. and changed the currancy and i got this
then i searched for sellitem and got this
i changed it around just like i did in the other folder and got this.
now. i compiled with ZERO errors... i was happy
i logged into the server. i bought and sold from the regular shopslike normal... but the new shop i had made, the shop id 43. i couldnt buy anything from it. and when i sold something to it it all the items would disapear lol. can ANYONE help me out? tell me how to fix this, or what i did wrong atleast?
ok. well i wanted to add a shop where you buy things with a different type of currancy e.g. trading sticks, but at the same time have the other shops where u can buy from them with money. 2 types of shops
well. to tell you the truth i have no clue what i was doing. so i decided to experiment lol
i started off by making a new cfg folder and a new java folder. named the cfg folder shops1.cfg and the javafolder ticket.java
from there i copied the first line of shop from the regular shop folder, and then i made the shop id 42 because there were 41 shops in the first one.
then i took shophandler.java, copied everything in it, and pasted it in ticket, and changed
"loadShops("shops.cfg");" to "loadShops("shops1.cfg");" that way ticket.java would load shops1.cfg
then i opened up client.java and found
Code:
if (WanneShop < 0) {
if (GoodDistance(skillX, skillY, absX, absY, 1) == true) {
openUpShop(WanneShop);
WanneShop = 0;
}
}
Code:
if (WanneShop < 41) {
if (GoodDistance(skillX, skillY, absX, absY, 1) == true) {
openUpShop(WanneShop);
WanneShop = 41;
}
}
Code:
if (WanneShop > 41) {
if (GoodDistance(skillX, skillY, absX, absY, 1) == true) {
openUpTicket(WanneShop);
WanneShop = 41;
}
}
Code:
public void openUpShop(int ShopID) {
sendFrame126(server.shopHandler.ShopName[ShopID], 3901);
sendFrame248(3824, 3822);
resetItems(3823);
resetShop(ShopID);
IsShopping = true;
MyShopID = ShopID;
}
Code:
public void openUpTicket(int ShopID) {
sendFrame126(server.Ticket.ShopName[ShopID], 3901);
sendFrame248(3824, 3822);
resetItems(3823);
resetTicket(ShopID);
IsShopping = true;
MyShopID = ShopID;
}
so i changed it to resetTicket and then searched for resetshop and found this
Code:
public void resetShop(int ShopID) {
int TotalItems = 0;
for (int i = 0; i < server.shopHandler.MaxShopItems; i++) {
if (server.shopHandler.ShopItems[ShopID][i] > 0) {
TotalItems++;
}
}
if (TotalItems > server.shopHandler.MaxShopItems) {
TotalItems = server.shopHandler.MaxShopItems;
}
outStream.createFrameVarSizeWord(53);
outStream.writeWord(3900);
outStream.writeWord(TotalItems);
int TotalCount = 0;
for (int i = 0; i < server.shopHandler.ShopItems.length; i++) {
if (server.shopHandler.ShopItems[ShopID][i] > 0 || i <= server.shopHandler.ShopItemsStandard[ShopID]) {
if (server.shopHandler.ShopItemsN[ShopID][i] > 254) {
outStream.writeByte(255); // item's stack count. if over 254, write byte 255
outStream.writeDWord_v2(server.shopHandler.ShopItemsN[ShopID][i]); // and then the real value with writeDWord_v2
} else {
outStream.writeByte(server.shopHandler.ShopItemsN[ShopID][i]);
}
if (server.shopHandler.ShopItems[ShopID][i] > 10000 || server.shopHandler.ShopItems[ShopID][i] < 0) {
server.shopHandler.ShopItems[ShopID][i] = 10000;
}
outStream.writeWordBigEndianA(server.shopHandler.ShopItems[ShopID][i]); //item id
TotalCount++;
}
if (TotalCount > TotalItems) {
break;
}
}
outStream.endFrameVarSizeWord();
}
so i coppied that, and changed the name to resetTicket, and changed all of the shophandlers to Ticket. that way it will do everything from Ticket.java instead of shophandler.java, after i did that i got this
Code:
public void resetTicket(int ShopID) {
int TotalItems = 0;
for (int i = 0; i < server.Ticket.MaxShopItems; i++) {
if (server.Ticket.ShopItems[ShopID][i] > 0) {
TotalItems++;
}
}
if (TotalItems > server.Ticket.MaxShopItems) {
TotalItems = server.Ticket.MaxShopItems;
}
outStream.createFrameVarSizeWord(53);
outStream.writeWord(3900);
outStream.writeWord(TotalItems);
int TotalCount = 0;
for (int i = 0; i < server.Ticket.ShopItems.length; i++) {
if (server.Ticket.ShopItems[ShopID][i] > 0 || i <= server.Ticket.ShopItemsStandard[ShopID]) {
if (server.Ticket.ShopItemsN[ShopID][i] > 254) {
outStream.writeByte(255); // item's stack count. if over 254, write byte 255
outStream.writeDWord_v2(server.Ticket.ShopItemsN[ShopID][i]); // and then the real value with writeDWord_v2
} else {
outStream.writeByte(server.Ticket.ShopItemsN[ShopID][i]);
}
if (server.Ticket.ShopItems[ShopID][i] > 10000 || server.Ticket.ShopItems[ShopID][i] < 0) {
server.Ticket.ShopItems[ShopID][i] = 10000;
}
outStream.writeWordBigEndianA(server.Ticket.ShopItems[ShopID][i]); //item id
TotalCount++;
}
if (TotalCount > TotalItems) {
break;
}
}
outStream.endFrameVarSizeWord();
}
after i did this i wanted to see if it would open up shops above 41 so i made a new shop in shops1.cfg put the shop id to 43 opened up client, set the wanneshop of an npc to 43 and sure enough the shop worked like i wanted it 2.
now to make it to where i buy it with different currancy, this is what i dont get...
i searched for buyitem and i got this
Code:
public boolean buyItem(int itemID, int fromSlot, int amount) {
if (amount > 0 && itemID == (server.shopHandler.ShopItems[MyShopID][fromSlot] - 1)) {
if (amount > server.shopHandler.ShopItemsN[MyShopID][fromSlot]) {
amount = server.shopHandler.ShopItemsN[MyShopID][fromSlot];
}
double ShopValue;
double TotPrice;
int TotPrice2;
int Overstock;
int Slot = 0;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
Slot = GetItemSlot(995);
if (Slot == -1) {
sendMessage("You don't have enough tickets.");
break;
}
if(TotPrice2 <= 1)
{
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
}
if (playerItemsN[Slot] >= TotPrice2) {
if (freeSlots() > 0) {
deleteItem(995, GetItemSlot(995), TotPrice2);
addItem(itemID, 1);
server.shopHandler.ShopItemsN[MyShopID][fromSlot] -= 1;
server.shopHandler.ShopItemsDelay[MyShopID][fromSlot] = 0;
if ((fromSlot + 1) > server.shopHandler.ShopItemsStandard[MyShopID]) {
server.shopHandler.ShopItems[MyShopID][fromSlot] = 0;
}
} else {
sendMessage("Not enough space in your inventory.");
break;
}
} else {
sendMessage("You don't have enough coins.");
break;
}
}
resetItems(3823);
resetShop(MyShopID);
UpdatePlayerShop();
return true;
}
return false;
}
Code:
public boolean buyItem1(int itemID, int fromSlot, int amount) {
if (amount > 0 && itemID == (server.Ticket.ShopItems[MyShopID][fromSlot] - 1)) {
if (amount > server.Ticket.ShopItemsN[MyShopID][fromSlot]) {
amount = server.Ticket.ShopItemsN[MyShopID][fromSlot];
}
double ShopValue;
double TotPrice;
int TotPrice2;
int Overstock;
int Slot = 0;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
Slot = GetItemSlot(6306);
if (Slot == -1) {
sendMessage("You don't have enough tickets.");
break;
}
if(TotPrice2 <= 1)
{
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
}
if (playerItemsN[Slot] >= TotPrice2) {
if (freeSlots() > 0) {
deleteItem(6306, GetItemSlot(6306), TotPrice2);
addItem(itemID, 1);
server.Ticket.ShopItemsN[MyShopID][fromSlot] -= 1;
server.Ticket.ShopItemsDelay[MyShopID][fromSlot] = 0;
if ((fromSlot + 1) > server.Ticket.ShopItemsStandard[MyShopID]) {
server.Ticket.ShopItems[MyShopID][fromSlot] = 0;
}
} else {
sendMessage("Not enough space in your inventory.");
break;
}
} else {
sendMessage("You don't have enough tickets.");
break;
}
}
resetItems(3823);
resetTicket(MyShopID);
UpdatePlayerShop1();
return true;
}
return false;
}
then i searched for sellitem and got this
Code:
public boolean sellItem(int itemID, int fromSlot, int amount) {
if (amount > 0 && itemID == (playerItems[fromSlot] - 1)) {
if (server.shopHandler.ShopSModifier[MyShopID] > 1) {
boolean IsIn = false;
for (int i = 0; i <= server.shopHandler.ShopItemsStandard[MyShopID]; i++) {
if (itemID == (server.shopHandler.ShopItems[MyShopID][i] - 1)) {
IsIn = true;
break;
}
}
if (IsIn == false) {
sendMessage("You cannot sell "+GetItemName(itemID)+" in this store.");
return false;
}
}
if (Item.itemSellable[(playerItems[fromSlot] - 1)] == false) {
sendMessage("I cannot sell "+GetItemName(itemID)+".");
return false;
}
if (amount > playerItemsN[fromSlot] && (Item.itemIsNote[(playerItems[fromSlot] - 1)] == true || Item.itemStackable[(playerItems[fromSlot] - 1)] == true)) {
amount = playerItemsN[fromSlot];
} else if (amount > GetXItemsInBag(itemID) && Item.itemIsNote[(playerItems[fromSlot] - 1)] == false && Item.itemStackable[(playerItems[fromSlot] - 1)] == false) {
amount = GetXItemsInBag(itemID);
}
double ShopValue;
double TotPrice;
int TotPrice2;
int Overstock;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 1, fromSlot));
if (freeSlots() > 0) {
if (Item.itemIsNote[itemID] == false) {
deleteItem(itemID, GetItemSlot(itemID), 1);
} else {
deleteItem(itemID, fromSlot, 1);
}
addItem(995, TotPrice2);
addShopItem(itemID, 1);
} else {
sendMessage("Not enough space in your inventory.");
break;
}
}
resetItems(3823);
resetShop(MyShopID);
UpdatePlayerShop();
return true;
}
return true;
}
i changed it around just like i did in the other folder and got this.
Code:
public boolean sellItem1(int itemID, int fromSlot, int amount) {
if (amount > 0 && itemID == (playerItems[fromSlot] - 1)) {
if (server.Ticket.ShopSModifier[MyShopID] > 1) {
boolean IsIn = false;
for (int i = 0; i <= server.Ticket.ShopItemsStandard[MyShopID]; i++) {
if (itemID == (server.Ticket.ShopItems[MyShopID][i] - 1)) {
IsIn = true;
break;
}
}
if (IsIn == false) {
sendMessage("You cannot sell "+GetItemName(itemID)+" in this store.");
return false;
}
}
if (Item.itemSellable[(playerItems[fromSlot] - 1)] == false) {
sendMessage("I cannot sell "+GetItemName(itemID)+".");
return false;
}
if (amount > playerItemsN[fromSlot] && (Item.itemIsNote[(playerItems[fromSlot] - 1)] == true || Item.itemStackable[(playerItems[fromSlot] - 1)] == true)) {
amount = playerItemsN[fromSlot];
} else if (amount > GetXItemsInBag(itemID) && Item.itemIsNote[(playerItems[fromSlot] - 1)] == false && Item.itemStackable[(playerItems[fromSlot] - 1)] == false) {
amount = GetXItemsInBag(itemID);
}
double ShopValue;
double TotPrice;
int TotPrice2;
int Overstock;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 1, fromSlot));
if (freeSlots() > 0) {
if (Item.itemIsNote[itemID] == false) {
deleteItem(itemID, GetItemSlot(itemID), 1);
} else {
deleteItem(itemID, fromSlot, 1);
}
addItem(6306, TotPrice2);
addShopItem1(itemID, 1);
} else {
sendMessage("Not enough space in your inventory.");
break;
}
}
resetItems(3823);
resetTicket(MyShopID);
UpdatePlayerShop1();
return true;
}
return true;
}
now. i compiled with ZERO errors... i was happy

