Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using WorldServer.Networking;
using WorldServer.Packets;
using WorldServer.Structures;
namespace WorldServer.Handlers
{
public partial class Handler
{
public static void ItemBuy(byte[] Data, ClientSocket CSocket)
{
int Shop = PacketProcessor.ReadLong(Data, 4);
int Item = PacketProcessor.ReadLong(Data, 8);
int Amount = PacketProcessor.ReadLong(Data, 20);
{
if (Amount == 0)
Amount = 1;
if (CSocket.Client.Inventory.Count == 41 - Amount)
{
CSocket.Send(CoPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Your inventory is full.", Struct.ChatType.Top));
return;
}
foreach (KeyValuePair<int, Struct.Shops> NewItem in World.Shops)
{
int ShopID = NewItem.Value.ShopID;
int ItemType = NewItem.Value.ItemType;
int MoneyType = NewItem.Value.MoneyType;
if (ShopID == Shop && ItemType == Item)
{
Struct.ItemData I = World.Items[ItemType];
Struct.ItemInfo Items = new Struct.ItemInfo();
for (byte x = 0; x < Amount; x++)
{
Items.Color = new Random().Next(3, 9);
Items.ItemID = ItemType;
Items.UID = Database.ItemCount += 1;
if (Items.ItemID == 730001)
Items.Plus = 1;
if (Items.ItemID == 730002)
Items.Plus = 2;
if (Items.ItemID == 730003)
Items.Plus = 3;
if (Items.ItemID == 730004)
Items.Plus = 4;
if (Items.ItemID == 730005)
Items.Plus = 5;
if (Items.ItemID == 730006)
Items.Plus = 6;
if (Items.ItemID == 730007)
Items.Plus = 7;
Items.Dura = I.MaxDura;
Items.MaxDura = I.MaxDura;
if (MoneyType == 0 && CSocket.Client.Money >= I.Cost)
{
bool created = Database.NewItem(Items, CSocket);
while (!created)
{
Items.UID = Database.ItemCount += 1;
Database.ItemCount = Items.UID;
created = Database.NewItem(Items, CSocket);
}
CSocket.Client.Inventory.Add(Items.UID, Items);
CSocket.Send(CoPacket.ItemInfo(Items.UID, Items.ItemID, Items.Plus, 0, 0, 0, 0, 0, Items.MaxDura, Items.MaxDura, 0, 0, 0, 0, 0, 0, Items.Color));
CSocket.Client.Money -= I.Cost;
CSocket.Send(CoPacket.Status(CSocket, 2, CSocket.Client.Money, Struct.StatusTypes.InvMoney));
Database.ItemCount = Items.UID;
if (FileLogger.LogItemBuy)
FileLogger.ItemBuy(Items, Amount, ShopID, "Gold", CSocket);
}
else if (MoneyType == 1 && CSocket.Client.Money >= I.CPCost)
{
bool created = Database.NewItem(Items, CSocket);
while (!created)
{
Items.UID = Database.ItemCount += 1;
Database.ItemCount = Items.UID;
created = Database.NewItem(Items, CSocket);
}
CSocket.Client.Inventory.Add(Items.UID, Items);
CSocket.Send(CoPacket.ItemInfo(Items.UID, Items.ItemID, Items.Plus, 0, 0, 0, 0, 0, Items.MaxDura, Items.MaxDura, 0, 0, 0, 0, 0, 0, Items.Color));
CSocket.Client.CPs -= I.CPCost;
CSocket.Send(CoPacket.Status(CSocket, 2, CSocket.Client.CPs, Struct.StatusTypes.InvCPoints));
Database.ItemCount = Items.UID;
}
else
{
CSocket.Send(CoPacket.Chat(0, "System", CSocket.Client.Name, "[Error] You do not have enough to buy that Item(s)", "yellow", Struct.ChatType.Top));
}
}
if (Amount > 1)
if (FileLogger.LogItemBuy)
FileLogger.ItemBuy(Items, Amount, ShopID, "Cps", CSocket);
}
}
}
}
}
}
can can some one tell me why this doesnt work
case 18880://elfstar
{
if (LinkBack == 0)
{
Text("Here is some stuff from the Blackmarket?", CSocket);
Link("GoldPrize-10mil cps", 1, CSocket);
Link("SilverPrize-5mil cps", 2, CSocket);
Link("BronzePrize-1mil cps", 3, CSocket);
Link("MoonBox-25k cps", 4, CSocket);
Link("Emerald-10k cps", 5, CSocket);
Link("Nah No thanks!!", 255, CSocket);
End(CSocket);
}
else if (LinkBack == 1)
if (CSocket.Client.CPs >= 10000000)
{
CPs(-10000000, CSocket);
AddItem(2100075, 1, CSocket);
}
else if (LinkBack == 2)
if (CSocket.Client.CPs >= 5000000)
{
CPs(-5000000, CSocket);
AddItem(2100065, 1, CSocket);
}
else if (LinkBack == 3)
if (CSocket.Client.CPs >= 1000000)
{
CPs(-1000000, CSocket);
AddItem(2100055, 1, CSocket);
}
else if (LinkBack == 4)
if (CSocket.Client.CPs >= 25000)
{
CPs(-25000, CSocket);
AddItem(721090, 1, CSocket);
}
else if (LinkBack == 5)
if (CSocket.Client.CPs >= 10000)
{
CPs(-10000, CSocket);
AddItem(1080001, 1, CSocket);
}
else
{
Text("How dare you try to rip me off! Get lost, Or get my money!", CSocket);
Link("I'm sorry, I didn't realize.", 255, CSocket);
End(CSocket);
}
}
break;
it wont let me buy anything but the goldprize






