this is working for me with the shoppingmall.
just replace it
the npc will eat all dbs
why?
think a bit and you'll be able to change that ;)
good luck
just replace it
Code:
public static void ItemBuy(byte[] Data, ClientSocket CSocket)
{
int ID = PacketProcessor.ReadLong(Data, 8);
int Amount = PacketProcessor.ReadLong(Data, 20);
if (CSocket.Client.Inventory.Count == 40)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Your inventory is full.", Struct.ChatType.Top));
return;
}
string Shop = System.IO.File.ReadAllText("Shop.dat");
if (itemexist(Convert.ToString(ID), Shop))
{
[COLOR="Red"]//Struct.ItemInfo Item = new Struct.ItemInfo();[/COLOR]
if (Nano.Items.ContainsKey(ID))
{
Struct.ItemData NewItem = Nano.Items[ID];
if (NewItem.CPCost > 0)
{
for (int i = 0; i < Amount; i++)
{
if (CSocket.Client.CPs >= NewItem.CPCost)
{
[COLOR="Lime"]Struct.ItemInfo Item = new Struct.ItemInfo();[/COLOR]
Handler.CPs(NewItem.CPCost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
created = Database.Database.NewItem(Item, CSocket);
}
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] You do not have enough CPs.", Struct.ChatType.Top));
}
}
}
else if (NewItem.Cost > 0)
{
if (CSocket.Client.Money >= NewItem.Cost)
{
[COLOR="lime"]Struct.ItemInfo Item = new Struct.ItemInfo();[/COLOR] Handler.Money(NewItem.Cost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
created = Database.Database.NewItem(Item, CSocket);
}
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] You do not have enough money.", Struct.ChatType.Top));
}
}
else
{
[COLOR="lime"]Struct.ItemInfo Item = new Struct.ItemInfo();[/COLOR]
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
created = Database.Database.NewItem(Item, CSocket);
}
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Item does not exist in Shop.dat", Struct.ChatType.Top));
}
}
why?
Code:
[COLOR="Red"]foreach (int DBUID in DBList)[/COLOR]
{
CSocket.Client.Inventory.Remove(DBUID);
CSocket.Send(ConquerPacket.ItemUsage(DBUID, 255, Struct.ItemUsage.RemoveItem));
Database.Database.DeleteItem(DBUID);
}
good luck