Code:
uint Amount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
ConquerItem item = new ConquerItem(true);
switch (shop.MoneyType)
{
case Database.ShopFile.MoneyType.Gold:
{
if (iteminfo.BaseInformation.GoldWorth * Amount > client.Entity.Money)
return;
if (client.Entity.Money - (iteminfo.BaseInformation.GoldWorth * Amount) > client.Entity.Money)
return;
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
while (NewAmount > 0)
{
if (iteminfo.BaseInformation.StackSize == 0)
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
item.MaxStackSize = item.StackSize = 1;
NewAmount--;
}
else
{
if (client.Inventory.GetStackContainer(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, 1, out _ExistingItem))
{
_ExistingItem.StackSize++;
Database.ConquerItemTable.UpdateStack(_ExistingItem);
_ExistingItem.Mode = Game.Enums.ItemMode.Update;
_ExistingItem.Send(client);
NewAmount -= 1;
}
else
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
item.MaxStackSize = iteminfo.BaseInformation.StackSize;
item.StackSize = 1;
if (NewAmount >= item.MaxStackSize)
{
item.StackSize = item.MaxStackSize;
NewAmount -= item.StackSize;
}
else
{
item.StackSize = (ushort)NewAmount;
NewAmount = 0;
}
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
Database.ConquerItemTable.UpdateStack(item);
}
}
}
client.Entity.Money -= (iteminfo.BaseInformation.GoldWorth * Amount);
break;
}
case Database.ShopFile.MoneyType.ConquerPoints:
{
bool bound = true;
if (itemUsage.dwExtraInfo3 == 2 || shop.UID == 20574)
{
if (shop.UID == 20574)
bound = false;
if (iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.BoundCps)
return;
if (client.Entity.BoundCps - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.BoundCps)
return;
item.ID = itemUsage.dwParam;
if (item.ID % 730000 <= 12)
item.Plus = (Byte)(item.ID % 730000);
item.Color = (Game.Enums.Color)Kernel.Random.Next(4, 8);
item.Bound = bound;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
while (NewAmount > 0)
{
if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
{
if (_ExistingItem.StackSize == 0)
_ExistingItem.StackSize = 0;
ushort _StackCount = iteminfo.BaseInformation.StackSize;
_StackCount -= (ushort)_ExistingItem.StackSize;
try
{
_ExistingItem.Bound = bound;
}
catch (Exception e)
{
Console.WriteLine(e);
}
if (_StackCount >= NewAmount)
_StackCount = (ushort)NewAmount;
_ExistingItem.StackSize += _StackCount;
Database.ConquerItemTable.UpdateStack(_ExistingItem);
_ExistingItem.Mode = Game.Enums.ItemMode.Update;
_ExistingItem.Send(client);
_ExistingItem.Mode = Game.Enums.ItemMode.Default;
NewAmount -= _StackCount;
}
else
{
if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
item.Bound = bound;
ushort _StackCount = iteminfo.BaseInformation.StackSize;
if (NewAmount <= iteminfo.BaseInformation.StackSize)
_StackCount = (ushort)NewAmount;
item.StackSize = (ushort)_StackCount;
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
Database.ConquerItemTable.UpdateStack(item);
NewAmount -= _StackCount;
}
else
{
if ((itemUsage.dwParam % 730000) <= 12)
{
ConquerItem newItem = new GamePackets.ConquerItem(true);
newItem.ID = itemUsage.dwParam;
newItem.Plus = (Byte)(newItem.ID % 730000);
newItem.Bound = bound;
client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
}
else
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Bound = bound;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
item.StackSize = 1;
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
}
NewAmount--;
}
}
}
client.Entity.BoundCps -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
}
else
{
if (shop.UID == 20574 || iteminfo.BaseInformation.ConquerPointsWorth * Amount > client.Entity.ConquerPoints) return;
if (client.Entity.ConquerPoints - (iteminfo.BaseInformation.ConquerPointsWorth * Amount) > client.Entity.ConquerPoints)
return;
item.ID = itemUsage.dwParam;
if (item.ID % 730000 <= 12)
item.Plus = (Byte)(item.ID % 730000);
item.Color = (Game.Enums.Color)Kernel.Random.Next(4, 8);
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
uint NewAmount = itemUsage.dwExtraInfo > 0 ? itemUsage.dwExtraInfo : 1;
while (NewAmount > 0)
{
if (client.Inventory.Contains(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, out _ExistingItem))
{
if (_ExistingItem.StackSize == 0)
_ExistingItem.StackSize = 1;
ushort _StackCount = iteminfo.BaseInformation.StackSize;
_StackCount -= (ushort)_ExistingItem.StackSize;
if (_StackCount >= NewAmount)
_StackCount = (ushort)NewAmount;
_ExistingItem.StackSize += _StackCount;
Database.ConquerItemTable.UpdateStack(_ExistingItem);
_ExistingItem.Mode = Game.Enums.ItemMode.Update;
_ExistingItem.Send(client);
_ExistingItem.Mode = Game.Enums.ItemMode.Default;
NewAmount -= _StackCount;
}
else
{
if (iteminfo.BaseInformation.StackSize > 1 && itemUsage.dwExtraInfo > 1)
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
ushort _StackCount = iteminfo.BaseInformation.StackSize;
if (NewAmount <= iteminfo.BaseInformation.StackSize)
_StackCount = (ushort)NewAmount;
item.StackSize = (ushort)_StackCount;
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
Database.ConquerItemTable.UpdateStack(item);
NewAmount -= _StackCount;
}
else
{
if ((itemUsage.dwParam % 730000) <= 12)
{
ConquerItem newItem = new GamePackets.ConquerItem(true);
newItem.ID = itemUsage.dwParam;
newItem.Plus = (Byte)(newItem.ID % 730000);
client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
}
else
{
item = new ConquerItem(true);
item.ID = itemUsage.dwParam;
item.Durability = item.MaximDurability = iteminfo.BaseInformation.Durability;
item.Color = (Game.Enums.Color)3;
item.StackSize = 1;
client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);
}
NewAmount--;
}
}
}
client.Entity.ConquerPoints -= (iteminfo.BaseInformation.ConquerPointsWorth * Amount);
}
break;
}
}
}
}
}






