محمد ياسر
2019-04-23, 03:20 PM
الموضوع ده علشان احمد الاسيوطي
ولكل الناس الي عايزه حل لمشكلة السوكت
بوص يا سيدى الحل هتخوش على الباكت هاندر وهتبحث عن الكود ده
#region Item/Ping (1009)
هتقفلو من السالب وهتبدلو كولو بلكود ده
#region Item/Ping (1009)
case 1009:
{
if (client.Action != 2)
return;
ItemUsage usage = new ItemUsage(false);
usage.Deserialize(packet);
if (!client.Entity.Dead || usage.ID == ItemUsage.Ping)
{
switch (usage.ID)
{
case 56://sash
{
if (client.SashSlots < 200)
{
var item = Database.ConquerItemTable.LoadItem(usage.UID);
uint slots = 0;
switch (item.ID)
{
case 1100003:
slots = 3;
break;
case 1100006:
slots = 6;
break;
case 1100009:
slots = 12;
break;
}
client.SashSlots += slots;
//if (client.Warehouses.ContainsKey((Conquer_Online_Ser ver.Game.ConquerStructures.Warehouse.WarehouseID)i tem.UID))
//{
// var sash = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Ware house.WarehouseID)item.UID];
// if (!client.Warehouses.ContainsKey((Conquer_Online_Se rver.Game.ConquerStructures.Warehouse.WarehouseID) client.Entity.UID))
// client.Warehouses.Add((Game.ConquerStructures.Ware house.WarehouseID)client.Entity.UID, new Game.ConquerStructures.Warehouse(client, (Game.ConquerStructures.Warehouse.WarehouseID)clie nt.Entity.UID));
// var invsash = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Ware house.WarehouseID)client.Entity.UID];
// foreach (var whitem in sash.Objects)
// {
// whitem.Warehouse = client.Entity.UID;
// whitem.Position = 0;
// }
//}
client.Inventory.Remove(item, Enums.ItemUse.Remove);
}
else
{
client.Entity.SendSysMesage("you already opened max number of slots");
}
break;
}
case 53:
{
uint ItemAdd = BitConverter.ToUInt32(packet, 12);// ay offset akbr mn 12 htzwdo 4
//:))) that npc is maked by me
ConquerItem item_new = null;
if (client.Inventory.TryGetItem(ItemAdd, out item_new))
{
uint obtined_points = 0;
Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformat ion(ItemAdd, 0);
Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
for (ushort i = 88; i < 88 + 4 * packet[24]; i += 4)
{
uint item_swap = BitConverter.ToUInt32(packet, i);
if (client.Inventory.ContainsUID(item_swap))
{
ConquerItem item = null;
if (client.Inventory.TryGetItem(item_swap, out item))
{
amount.Add(item_swap, i);
}
switch (item.ID)
{
case 191505:
case 191605:
case 191705:
case 191805:
case 191905:
case 191405:
case 183325:
case 183315:
case 183375:
case 183305:
{
obtined_points += 300;
break;
}
default:
obtined_points += 50;
break;
}
}
}
if (iteminfo.BaseInformation.ConquerPointsWorth > obtined_points)
{
uint add_cps = 0;
add_cps = (uint)(iteminfo.BaseInformation.ConquerPointsWorth - obtined_points);
if (add_cps < client.Entity.ConquerPoints)
{
client.Entity.ConquerPoints -= (uint)add_cps;
foreach (uint key in amount.Keys)
{
if (client.Inventory.ContainsUID(key))
client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
}
client.Inventory.Add(ItemAdd, 0, 1);
}
}
else
{
foreach (uint key in amount.Keys)
{
if (client.Inventory.ContainsUID(key))
client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
}
client.Inventory.Add(ItemAdd, 0, 1);
}
}
break;
}
case ItemUsage.MainEquipment:
case ItemUsage.AlternateEquipment:
{
if (client.Entity.ContainsFlag3(Update.Flags3.Assassi n))
{
client.Send(new Message("You cannot switch between equipments while being an assasin!",
Color.Red, Message.Agate));
return;
}
SwitchEquipment(client, usage.ID == ItemUsage.AlternateEquipment);
client.Send(new ClientEquip(client));
break;
}
case 52:
{
var item = Database.ConquerItemTable.LoadItem(usage.UID);
Database.ConquerItemTable.HandleInscribing(item, client);
Database.ItemAddingTable.GetAddingsForItem(item);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.ChatItem ;
item.Send(client);
break;
}
case 41:
{
// var item = Database.ConquerItemTable.LoadItem(usage.UID);
ConquerItem item = new ConquerItem(true);
if (client.Inventory.TryGetItem(usage.UID, out item))
{
var infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, 0);
item.UID = usage.UID;
item.DayStamp = DateTime.Now;
item.Days = (byte)(infos.BaseInformation.Time == 0 ? 7 : (infos.BaseInformation.Time / 24 / 60));
TimeSpan Remain = item.DayStamp.AddDays(item.Days) - DateTime.Now;
item.TimeLeftInMinutes = (uint)Remain.TotalSeconds;
Database.ConquerItemTable.Update_Free(item, client);
usage.dwParam = 5;
client.Send(usage);
}
break;
}
case ItemUsage.ArrowReload:
{
lock (client.ItemSyncRoot)
// ReloadArrows(client.Equipment.TryGetItem(ConquerIt em.LeftWeapon), client);
break;
}
case ItemUsage.ShowBoothItems:
{
lock (client.ItemSyncRoot)
ShowBoothItems(usage, client);
break;
}
case ItemUsage.AddItemOnBoothForSilvers:
case ItemUsage.AddItemOnBoothForConquerPoints:
{
lock (client.ItemSyncRoot)
AddItemOnBooth(usage, client);
break;
}
case ItemUsage.BuyFromBooth:
{
if (client.Entity.PokerTable > 0) break;
lock (client.ItemSyncRoot)
BuyFromBooth(usage, client);
break;
}
case ItemUsage.RemoveItemFromBooth:
{
lock (client.ItemSyncRoot)
RemoveItemFromBooth(usage, client);
break;
}
case ItemUsage.EquipItem:
{
lock (client.ItemSyncRoot)
EquipItem(usage, client);
client.Send(WindowStats(client));
break;
}
case ItemUsage.UnequipItem:
{
lock (client.ItemSyncRoot)
UnequipItem(usage, client);
client.Equipment.UpdateEntityPacket();
client.Send(WindowStats(client));
break;
}
case 55:
case ItemUsage.BuyFromNPC:
{
if (client.Entity.PokerTable > 0) break;
lock (client.ItemSyncRoot)
HandleBuyFromNPC(usage, client);
break;
}
case ItemUsage.SellToNPC:
{
lock (client.ItemSyncRoot)
HandleSellToNPC(usage, client);
break;
}
case ItemUsage.VIPRepair:
{
HandleVIPRepair(usage, client);
break;
}
case ItemUsage.Repair:
{
lock (client.ItemSyncRoot)
HandleRepair(usage, client);
break;
}
case ItemUsage.MeteorUpgrade:
case ItemUsage.DragonBallUpgrade:
{
UpgradeItem(usage, client);
break;
}
case ItemUsage.Ping:
{
client.Send(usage);
break;
}
case ItemUsage.ViewWarehouse:
{
usage.dwParam = client.MoneySave;
client.Send(usage);
break;
}
case ItemUsage.WarehouseDeposit:
{
if (client.Entity.Money >= usage.dwParam)
{
client.Entity.Money -= usage.dwParam;
client.MoneySave += usage.dwParam;
}
break;
}
case ItemUsage.WarehouseWithdraw:
{
if (client.MoneySave >= usage.dwParam)
{
client.Entity.Money += usage.dwParam;
client.MoneySave -= usage.dwParam;
}
break;
}
case ItemUsage.DropItem:
{
DropItem(usage, client);
break;
}
case ItemUsage.DropMoney:
{
DropMoney(usage, client);
break;
}
case ItemUsage.Enchant:
{
EnchantItem(usage, client);
break;
}
case ItemUsage.SocketTalismanWithItem:
{
for (int i = 0; i < usage.dwExtraInfo; i++)
{
usage.dwParam = BitConverter.ToUInt32(packet, 87 + 4 + 9 * i);
SocketTalismanWithItem(usage, client);
}
break;
}
case ItemUsage.SocketTalismanWithCPs:
{
SocketTalismanWithCPs(usage, client);
break;
}
case ItemUsage.RedeemGear:
{
var item = client.DeatinedItem[usage.UID];
if (item != null)
{
if (DateTime.Now > item.Date.AddDays(7))
{
client.Send(new Message("This item is expired!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (client.Entity.ConquerPoints >= item.ConquerPointsCost && client.Inventory.Count < 40)
{
client.Entity.ConquerPoints -= item.ConquerPointsCost;
Database.EntityTable.UpdateCps(client);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
client.Send(usage);
client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Add);
item.Item.Mode = Enums.ItemMode.Update;
item.Item.Send(client);
Database.ClaimItemTable.Redeem(item, client);
Database.DetainedItemTable.Claim(item, client);
client.DeatinedItem.Remove(item.UID);
if (Kernel.GamePool.ContainsKey(item.GainerUID))
{
GameState pClient;
if (Kernel.GamePool.TryGetValue(item.GainerUID, out pClient))
{
if (pClient.Entity != null && pClient != null && pClient.ClaimableItem != null)
{
pClient.ClaimableItem[item.UID].OwnerUID = 500;
pClient.ClaimableItem[item.UID].MakeItReadyToClaim();
usage.dwParam = pClient.Entity.UID;
usage.ID = ItemUsage.ClaimGear;
pClient.Send(usage);
pClient.ClaimableItem[item.UID].Send(pClient);
}
}
}
Message message = new Message(" " + client.Entity.Name + " has redeemed his Gear and Pay " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message, Program.Values);
}
}
else
{
client.Send(new Message("The item you want to redeem has already been redeemed.", System.Drawing.Color.Red, Message.TopLeft));
}
break;
}
case ItemUsage.ClaimGear:
{
if (client.Inventory.Count < 40)
{
var item = client.ClaimableItem[usage.UID];
if (item != null)
{
if (item.Bound && item.OwnerUID != 500)
{
if (DateTime.Now >= item.Date.AddDays(7))
{
Database.ClaimItemTable.Claim(item, client);
client.ClaimableItem.Remove(item.UID);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
client.Send(usage);
}
client.Send(new Message("Unnclaimable item!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (DateTime.Now < item.Date.AddDays(7) && item.OwnerUID != 500)
{
client.Send(new Message("This item is not expired. You cannot claim it yet!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (item.OwnerUID == 500)
client.Entity.ConquerPoints += item.ConquerPointsCost;
else
{
client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Move);
Message message = new Message("Thank you for arresting " + item.OwnerName + " , " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message, Program.Values);
}
Database.ClaimItemTable.Claim(item, client);
client.ClaimableItem.Remove(item.UID);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
//Database.EntityTable.UpdateCps(client);
client.Send(usage);
Message message2 = new Message("Thank you for arresting red/black name players " + client.Entity.Name + " has recived " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message2, Program.Values);
}
else
{
client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.Red, Message.TopLeft));
}
}
break;
}
case ItemUsage.SocketerMan:
{
SocketItem(usage, client);
client.Send(packet);
break;
}
case 40:
{
uint ItemAdd = BitConverter.ToUInt32(packet, 8);
ConquerItem item_new = null;
if (client.Inventory.TryGetItem(ItemAdd, out item_new))
{
var itemtype = item_new.GetItemType();
if (itemtype == ConquerItem.ItemTypes.GemID) return;
ushort pos = PacketHandler.ItemPosition(item_new.ID);
if (pos == ConquerItem.Bottle || pos == ConquerItem.Wing || pos == ConquerItem.Fan || pos == ConquerItem.Garment || pos == ConquerItem.LeftWeaponAccessory || pos == ConquerItem.RightWeaponAccessory || pos == ConquerItem.Steed || pos == ConquerItem.SteedArmor || pos == ConquerItem.SteedCrop || pos == ConquerItem.Tower)
{
client.Send(new Message("Sorry can't bless this item !", System.Drawing.Color.Red, Message.Talk));
return;
}
if (item_new.Bless >= 7) return;
Queue<uint> amount = new Queue<uint>(packet[26]);
for (ushort i = 91; i < 91 + 4 * packet[26]; i += 4)
{
uint uid = BitConverter.ToUInt32(packet, i);
if (client.Inventory.ContainsUID(uid))
amount.Enqueue(uid);
else return;
}
byte oldbless = item_new.Bless;
if (item_new.Bless == 0 && amount.Count == 5)
{
item_new.Bless = 1;
client.Entity.Update(10, "Aegis1", true);
}
else if (item_new.Bless == 1 && amount.Count == 1)
{
item_new.Bless = 3;
client.Entity.Update(10, "Aegis2", true);
}
else if (item_new.Bless == 3 && amount.Count == 3)
{
item_new.Bless = 5;
client.Entity.Update(10, "Aegis3", true);
}
else if (item_new.Bless == 5 && amount.Count == 5)
{
item_new.Bless = 7;
client.Entity.Update(10, "Aegis4", true);
}
if (oldbless == item_new.Bless) return;
while (amount.Count != 0)
client.Inventory.Remove(amount.Dequeue(), Game.Enums.ItemUse.Remove, true);
item_new.Mode = Game.Enums.ItemMode.Update;
item_new.Send(client);
usage.dwParam = 2;
Database.ConquerItemTable.UpdateBless
(item_new);
}
client.Send(packet);
break;
}
case ItemUsage.GemCompose:
{
#region GemCompose
UInt32 Ident = usage.UID;
client.Inventory.Remove(Ident, 15);
client.Inventory.Add(Ident + 1, 0, 1);
usage.dwParam = 1;
client.Send(usage);
#endregion
break;
}
case ItemUsage.ToristSuper:
{
#region GemCompose
if (client.Entity.Money >= 100000)
{
client.Inventory.Remove(700002, 1);
client.Inventory.Remove(700012, 1);
client.Inventory.Remove(700022, 1);
client.Inventory.Remove(700032, 1);
client.Inventory.Remove(700042, 1);
client.Inventory.Remove(700052, 1);
client.Inventory.Remove(700062, 1);
client.Entity.Money -= 100000;
client.Inventory.Add(700072, 0, 1);
client.Send(usage);
usage.dwParam = 1;
}
else
{
client.Send(new Message("Sorry you don`t have 100,000 silver!.", System.Drawing.Color.Red, Message.Talk));
}
#endregion
break;
}
case ItemUsage.SplitStack:
{
ConquerItem mainItem = null;
ConquerItem minorItem = new ConquerItem(true);
Database.ConquerItemInformation infos = null;
minorItem.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Ran dom.Next(4, 8);
if (client.Inventory.TryGetItem(usage.UID, out mainItem))
{
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(mainItem.ID, 0);
if (mainItem.StackSize > 1 && mainItem.StackSize <= infos.BaseInformation.StackSize)
{
if (client.Inventory.Count < 40)
{
ushort Amount = (ushort)usage.dwParam;
mainItem.StackSize -= Amount;
mainItem.Mode = Game.Enums.ItemMode.Update;
mainItem.Send(client);
mainItem.Mode = Game.Enums.ItemMode.Default;
minorItem.ID = mainItem.ID;
minorItem.StackSize += Amount;
minorItem.Durability = mainItem.Durability;
client.Inventory.Add(minorItem, Game.Enums.ItemUse.CreateAndAdd);
Database.ConquerItemTable.UpdateStack(mainItem);
}
}
}
break;
}
case ItemUsage.MergeStackableItems:
{
ConquerItem mainItem = null;
ConquerItem minorItem = new ConquerItem(true);
Database.ConquerItemInformation infos = null;
minorItem.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Ran dom.Next(4, 8);
if (client.Inventory.TryGetItem(usage.UID, out mainItem) && client.Inventory.TryGetItem(usage.dwParam, out minorItem))
{
if (mainItem.ID == minorItem.ID)
{
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(mainItem.ID, 0);
if (mainItem.StackSize < 1)
mainItem.StackSize = 1;
if (minorItem.StackSize < 1)
minorItem.StackSize = 1;
if ((mainItem.StackSize + minorItem.StackSize) <= infos.BaseInformation.StackSize)
{
mainItem.StackSize += minorItem.StackSize;
mainItem.Mode = Game.Enums.ItemMode.Update;
mainItem.Send(client);
mainItem.Mode = Game.Enums.ItemMode.Default;
Database.ConquerItemTable.UpdateStack(mainItem);
client.Inventory.Remove(minorItem, Game.Enums.ItemUse.Remove);
}
}
}
break;
}
case 34:
{
break;
}
case ItemUsage.LowerEquipment:
{
ConquerItem item = null;
if (client.Inventory.TryGetItem(usage.UID, out item))
{
if (IsArrow(item.ID))
return;
ConquerItem upgrade = null;
if (client.Inventory.TryGetItem(usage.UID, out upgrade))
{
if (client.Entity.ConquerPoints < 54)
{
client.Send(new Message("You don't have 54CPs.", Color.Red, Message.TopLeft));
return;
}
client.Entity.ConquerPoints -= 54;
Database.ConquerItemInformation infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, item.Plus);
if (infos.BaseInformation.Level <= 15) return;
int startwith = (int)(infos.BaseInformation.ID / 1000);
int endwith = (int)(infos.BaseInformation.ID % 10);
var sitem = infos.LowestID(ItemMinLevel(ItemPosition(infos.Bas eInformation.ID)));
// var sitem = Conquer_Online_Server.Database.ConquerItemInformat ion.BaseInformations.Values.Where(x => (x.ID % 10) == endwith && (x.ID / 1000) == startwith && x.Level >= 15).OrderBy(y => y.Level).First();
item.ID = sitem;
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, item.Plus);
item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
Database.ConquerItemTable.UpdateItemID(item, client);
Database.ConquerItemTable.UpdateDurabilityItem(ite m);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
item.Send(client);
item = ItemSocket(item, 2);
}
}
break;
}
default:
{
//nta mot2ked enk 3amel update lel client m4 3arf :D
Console.WriteLine("Unhandled item usage type : " + usage.ID);
break;
}
}
}
break;
}
#endregion
هتبحث عن الكود ده
public class ItemUsage : Writer, Interfaces.IPacket
هيوديك على كلاس ItemUsage.cs بس انا قولت اعمل الكود بحث عشان الى مش عارف مكان الكلاس فين
المهم هتمسح كل الى فيه وتحط الاكواد دى
using System;
namespace Conquer_Online_Server.Network.GamePackets
{
public class ItemUsage : Writer, Interfaces.IPacket
{
public const ushort
BuyFromNPC = 1,
SellToNPC = 2,
RemoveInventory = 3,
EquipItem = 4,
UnequipItem = 6,
ArrowReload = 8,
ViewWarehouse = 9,
WarehouseDeposit = 10,
WarehouseWithdraw = 11,
Repair = 14,
VIPRepair = 15,
DragonBallUpgrade = 19,
MeteorUpgrade = 20,
ShowBoothItems = 21,
AddItemOnBoothForSilvers = 22,
RemoveItemFromBooth = 23,
BuyFromBooth = 24,
UpdateDurability = 25,
AddItemOnBoothForConquerPoints = 29,
Ping = 27,
Enchant = 28,
RedeemGear = 32,
ClaimGear = 33,
SocketTalismanWithItem = 35,
SocketTalismanWithCPs = 36,
DropItem = 37,
DropMoney = 38,
GemCompose = 39,
Bless = 40,
Accessories = 41,
MainEquipment = 44,
AlternateEquipment = 45,
LowerEquipment = 54,
ToristSuper = 51,
SocketerMan = 43,
MergeStackableItems = 48,
SplitStack = 49;
byte[] Buffer;
public ItemUsage(bool Create)
{
if (Create)
{
Buffer = new byte[95];
WriteUInt16(87, 0, Buffer);
WriteUInt16(1009, 2, Buffer);
WriteUInt32((uint)Time32.timeGetTime().GetHashCode (), 4, Buffer);
}
}
public uint UID
{
get { return BitConverter.ToUInt32(Buffer, 8); }
set { WriteUInt32(value, 8, Buffer); }
}
public uint dwParam
{
get { return BitConverter.ToUInt32(Buffer, 12); }
set { WriteUInt32(value, 12, Buffer); }
}
public ushort ID
{
get { return BitConverter.ToUInt16(Buffer, 20); }
set { WriteUInt16(value, 20, Buffer); }
}
public uint TimeStamp
{
get { return BitConverter.ToUInt32(Buffer, 24); }
set { WriteUInt32(value, 24, Buffer); }
}
public uint dwExtraInfo
{
get { return BitConverter.ToUInt32(Buffer, 26); }
set { WriteUInt32(value, 26, Buffer); }
}
public uint dwExtraInfo2
{
get { return BitConverter.ToUInt32(Buffer, 88); }
set { WriteUInt32(value, 88, Buffer); }
}
public uint dwExtraInfo3
{
get { return BitConverter.ToUInt32(Buffer, 36); }
set { WriteUInt32(value, 36, Buffer); }
}
public uint[] Batch
{
get
{
uint[] items = new uint[dwExtraInfo];
for (int i = 0; i < dwExtraInfo; i++)
{
items[i] = BitConverter.ToUInt32(Buffer, 91 + 4 * i);
}
return items;
}
set
{
if (value != null)
{
dwExtraInfo = (uint)value.Length;
for (int i = 0; i < dwExtraInfo; i++)
{
WriteUInt32(value[i], 91 + 4 * i, Buffer);
}
}
}
}
public byte[] ToArray()
{
return Buffer;
}
public void Deserialize(byte[] buffer)
{
Buffer = buffer;
}
public void Send(Client.GameState client)
{
client.Send(Buffer);
}
}
}
ولكل الناس الي عايزه حل لمشكلة السوكت
بوص يا سيدى الحل هتخوش على الباكت هاندر وهتبحث عن الكود ده
#region Item/Ping (1009)
هتقفلو من السالب وهتبدلو كولو بلكود ده
#region Item/Ping (1009)
case 1009:
{
if (client.Action != 2)
return;
ItemUsage usage = new ItemUsage(false);
usage.Deserialize(packet);
if (!client.Entity.Dead || usage.ID == ItemUsage.Ping)
{
switch (usage.ID)
{
case 56://sash
{
if (client.SashSlots < 200)
{
var item = Database.ConquerItemTable.LoadItem(usage.UID);
uint slots = 0;
switch (item.ID)
{
case 1100003:
slots = 3;
break;
case 1100006:
slots = 6;
break;
case 1100009:
slots = 12;
break;
}
client.SashSlots += slots;
//if (client.Warehouses.ContainsKey((Conquer_Online_Ser ver.Game.ConquerStructures.Warehouse.WarehouseID)i tem.UID))
//{
// var sash = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Ware house.WarehouseID)item.UID];
// if (!client.Warehouses.ContainsKey((Conquer_Online_Se rver.Game.ConquerStructures.Warehouse.WarehouseID) client.Entity.UID))
// client.Warehouses.Add((Game.ConquerStructures.Ware house.WarehouseID)client.Entity.UID, new Game.ConquerStructures.Warehouse(client, (Game.ConquerStructures.Warehouse.WarehouseID)clie nt.Entity.UID));
// var invsash = client.Warehouses[(Conquer_Online_Server.Game.ConquerStructures.Ware house.WarehouseID)client.Entity.UID];
// foreach (var whitem in sash.Objects)
// {
// whitem.Warehouse = client.Entity.UID;
// whitem.Position = 0;
// }
//}
client.Inventory.Remove(item, Enums.ItemUse.Remove);
}
else
{
client.Entity.SendSysMesage("you already opened max number of slots");
}
break;
}
case 53:
{
uint ItemAdd = BitConverter.ToUInt32(packet, 12);// ay offset akbr mn 12 htzwdo 4
//:))) that npc is maked by me
ConquerItem item_new = null;
if (client.Inventory.TryGetItem(ItemAdd, out item_new))
{
uint obtined_points = 0;
Database.ConquerItemInformation iteminfo = new Conquer_Online_Server.Database.ConquerItemInformat ion(ItemAdd, 0);
Dictionary<uint, uint> amount = new Dictionary<uint, uint>();//packet[20]);
for (ushort i = 88; i < 88 + 4 * packet[24]; i += 4)
{
uint item_swap = BitConverter.ToUInt32(packet, i);
if (client.Inventory.ContainsUID(item_swap))
{
ConquerItem item = null;
if (client.Inventory.TryGetItem(item_swap, out item))
{
amount.Add(item_swap, i);
}
switch (item.ID)
{
case 191505:
case 191605:
case 191705:
case 191805:
case 191905:
case 191405:
case 183325:
case 183315:
case 183375:
case 183305:
{
obtined_points += 300;
break;
}
default:
obtined_points += 50;
break;
}
}
}
if (iteminfo.BaseInformation.ConquerPointsWorth > obtined_points)
{
uint add_cps = 0;
add_cps = (uint)(iteminfo.BaseInformation.ConquerPointsWorth - obtined_points);
if (add_cps < client.Entity.ConquerPoints)
{
client.Entity.ConquerPoints -= (uint)add_cps;
foreach (uint key in amount.Keys)
{
if (client.Inventory.ContainsUID(key))
client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
}
client.Inventory.Add(ItemAdd, 0, 1);
}
}
else
{
foreach (uint key in amount.Keys)
{
if (client.Inventory.ContainsUID(key))
client.Inventory.Remove(key, Conquer_Online_Server.Game.Enums.ItemUse.Remove, true);
}
client.Inventory.Add(ItemAdd, 0, 1);
}
}
break;
}
case ItemUsage.MainEquipment:
case ItemUsage.AlternateEquipment:
{
if (client.Entity.ContainsFlag3(Update.Flags3.Assassi n))
{
client.Send(new Message("You cannot switch between equipments while being an assasin!",
Color.Red, Message.Agate));
return;
}
SwitchEquipment(client, usage.ID == ItemUsage.AlternateEquipment);
client.Send(new ClientEquip(client));
break;
}
case 52:
{
var item = Database.ConquerItemTable.LoadItem(usage.UID);
Database.ConquerItemTable.HandleInscribing(item, client);
Database.ItemAddingTable.GetAddingsForItem(item);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.ChatItem ;
item.Send(client);
break;
}
case 41:
{
// var item = Database.ConquerItemTable.LoadItem(usage.UID);
ConquerItem item = new ConquerItem(true);
if (client.Inventory.TryGetItem(usage.UID, out item))
{
var infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, 0);
item.UID = usage.UID;
item.DayStamp = DateTime.Now;
item.Days = (byte)(infos.BaseInformation.Time == 0 ? 7 : (infos.BaseInformation.Time / 24 / 60));
TimeSpan Remain = item.DayStamp.AddDays(item.Days) - DateTime.Now;
item.TimeLeftInMinutes = (uint)Remain.TotalSeconds;
Database.ConquerItemTable.Update_Free(item, client);
usage.dwParam = 5;
client.Send(usage);
}
break;
}
case ItemUsage.ArrowReload:
{
lock (client.ItemSyncRoot)
// ReloadArrows(client.Equipment.TryGetItem(ConquerIt em.LeftWeapon), client);
break;
}
case ItemUsage.ShowBoothItems:
{
lock (client.ItemSyncRoot)
ShowBoothItems(usage, client);
break;
}
case ItemUsage.AddItemOnBoothForSilvers:
case ItemUsage.AddItemOnBoothForConquerPoints:
{
lock (client.ItemSyncRoot)
AddItemOnBooth(usage, client);
break;
}
case ItemUsage.BuyFromBooth:
{
if (client.Entity.PokerTable > 0) break;
lock (client.ItemSyncRoot)
BuyFromBooth(usage, client);
break;
}
case ItemUsage.RemoveItemFromBooth:
{
lock (client.ItemSyncRoot)
RemoveItemFromBooth(usage, client);
break;
}
case ItemUsage.EquipItem:
{
lock (client.ItemSyncRoot)
EquipItem(usage, client);
client.Send(WindowStats(client));
break;
}
case ItemUsage.UnequipItem:
{
lock (client.ItemSyncRoot)
UnequipItem(usage, client);
client.Equipment.UpdateEntityPacket();
client.Send(WindowStats(client));
break;
}
case 55:
case ItemUsage.BuyFromNPC:
{
if (client.Entity.PokerTable > 0) break;
lock (client.ItemSyncRoot)
HandleBuyFromNPC(usage, client);
break;
}
case ItemUsage.SellToNPC:
{
lock (client.ItemSyncRoot)
HandleSellToNPC(usage, client);
break;
}
case ItemUsage.VIPRepair:
{
HandleVIPRepair(usage, client);
break;
}
case ItemUsage.Repair:
{
lock (client.ItemSyncRoot)
HandleRepair(usage, client);
break;
}
case ItemUsage.MeteorUpgrade:
case ItemUsage.DragonBallUpgrade:
{
UpgradeItem(usage, client);
break;
}
case ItemUsage.Ping:
{
client.Send(usage);
break;
}
case ItemUsage.ViewWarehouse:
{
usage.dwParam = client.MoneySave;
client.Send(usage);
break;
}
case ItemUsage.WarehouseDeposit:
{
if (client.Entity.Money >= usage.dwParam)
{
client.Entity.Money -= usage.dwParam;
client.MoneySave += usage.dwParam;
}
break;
}
case ItemUsage.WarehouseWithdraw:
{
if (client.MoneySave >= usage.dwParam)
{
client.Entity.Money += usage.dwParam;
client.MoneySave -= usage.dwParam;
}
break;
}
case ItemUsage.DropItem:
{
DropItem(usage, client);
break;
}
case ItemUsage.DropMoney:
{
DropMoney(usage, client);
break;
}
case ItemUsage.Enchant:
{
EnchantItem(usage, client);
break;
}
case ItemUsage.SocketTalismanWithItem:
{
for (int i = 0; i < usage.dwExtraInfo; i++)
{
usage.dwParam = BitConverter.ToUInt32(packet, 87 + 4 + 9 * i);
SocketTalismanWithItem(usage, client);
}
break;
}
case ItemUsage.SocketTalismanWithCPs:
{
SocketTalismanWithCPs(usage, client);
break;
}
case ItemUsage.RedeemGear:
{
var item = client.DeatinedItem[usage.UID];
if (item != null)
{
if (DateTime.Now > item.Date.AddDays(7))
{
client.Send(new Message("This item is expired!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (client.Entity.ConquerPoints >= item.ConquerPointsCost && client.Inventory.Count < 40)
{
client.Entity.ConquerPoints -= item.ConquerPointsCost;
Database.EntityTable.UpdateCps(client);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
client.Send(usage);
client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Add);
item.Item.Mode = Enums.ItemMode.Update;
item.Item.Send(client);
Database.ClaimItemTable.Redeem(item, client);
Database.DetainedItemTable.Claim(item, client);
client.DeatinedItem.Remove(item.UID);
if (Kernel.GamePool.ContainsKey(item.GainerUID))
{
GameState pClient;
if (Kernel.GamePool.TryGetValue(item.GainerUID, out pClient))
{
if (pClient.Entity != null && pClient != null && pClient.ClaimableItem != null)
{
pClient.ClaimableItem[item.UID].OwnerUID = 500;
pClient.ClaimableItem[item.UID].MakeItReadyToClaim();
usage.dwParam = pClient.Entity.UID;
usage.ID = ItemUsage.ClaimGear;
pClient.Send(usage);
pClient.ClaimableItem[item.UID].Send(pClient);
}
}
}
Message message = new Message(" " + client.Entity.Name + " has redeemed his Gear and Pay " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message, Program.Values);
}
}
else
{
client.Send(new Message("The item you want to redeem has already been redeemed.", System.Drawing.Color.Red, Message.TopLeft));
}
break;
}
case ItemUsage.ClaimGear:
{
if (client.Inventory.Count < 40)
{
var item = client.ClaimableItem[usage.UID];
if (item != null)
{
if (item.Bound && item.OwnerUID != 500)
{
if (DateTime.Now >= item.Date.AddDays(7))
{
Database.ClaimItemTable.Claim(item, client);
client.ClaimableItem.Remove(item.UID);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
client.Send(usage);
}
client.Send(new Message("Unnclaimable item!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (DateTime.Now < item.Date.AddDays(7) && item.OwnerUID != 500)
{
client.Send(new Message("This item is not expired. You cannot claim it yet!", System.Drawing.Color.Red, Message.TopLeft));
return;
}
if (item.OwnerUID == 500)
client.Entity.ConquerPoints += item.ConquerPointsCost;
else
{
client.Inventory.Add(item.Item, Conquer_Online_Server.Game.Enums.ItemUse.Move);
Message message = new Message("Thank you for arresting " + item.OwnerName + " , " + item.GainerName + ". The arrested one has redeemed his items and you have received a great deal of ConquerPoints as reward. Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message, Program.Values);
}
Database.ClaimItemTable.Claim(item, client);
client.ClaimableItem.Remove(item.UID);
usage.dwParam = client.Entity.UID;
usage.dwExtraInfo3 = item.ConquerPointsCost;
//Database.EntityTable.UpdateCps(client);
client.Send(usage);
Message message2 = new Message("Thank you for arresting red/black name players " + client.Entity.Name + " has recived " + item.ConquerPointsCost + " CPS . Congratulations!", System.Drawing.Color.Wheat, Message.Talk);
Kernel.SendWorldMessage(message2, Program.Values);
}
else
{
client.Send(new Message("The item you want to claim has already been claimed.", System.Drawing.Color.Red, Message.TopLeft));
}
}
break;
}
case ItemUsage.SocketerMan:
{
SocketItem(usage, client);
client.Send(packet);
break;
}
case 40:
{
uint ItemAdd = BitConverter.ToUInt32(packet, 8);
ConquerItem item_new = null;
if (client.Inventory.TryGetItem(ItemAdd, out item_new))
{
var itemtype = item_new.GetItemType();
if (itemtype == ConquerItem.ItemTypes.GemID) return;
ushort pos = PacketHandler.ItemPosition(item_new.ID);
if (pos == ConquerItem.Bottle || pos == ConquerItem.Wing || pos == ConquerItem.Fan || pos == ConquerItem.Garment || pos == ConquerItem.LeftWeaponAccessory || pos == ConquerItem.RightWeaponAccessory || pos == ConquerItem.Steed || pos == ConquerItem.SteedArmor || pos == ConquerItem.SteedCrop || pos == ConquerItem.Tower)
{
client.Send(new Message("Sorry can't bless this item !", System.Drawing.Color.Red, Message.Talk));
return;
}
if (item_new.Bless >= 7) return;
Queue<uint> amount = new Queue<uint>(packet[26]);
for (ushort i = 91; i < 91 + 4 * packet[26]; i += 4)
{
uint uid = BitConverter.ToUInt32(packet, i);
if (client.Inventory.ContainsUID(uid))
amount.Enqueue(uid);
else return;
}
byte oldbless = item_new.Bless;
if (item_new.Bless == 0 && amount.Count == 5)
{
item_new.Bless = 1;
client.Entity.Update(10, "Aegis1", true);
}
else if (item_new.Bless == 1 && amount.Count == 1)
{
item_new.Bless = 3;
client.Entity.Update(10, "Aegis2", true);
}
else if (item_new.Bless == 3 && amount.Count == 3)
{
item_new.Bless = 5;
client.Entity.Update(10, "Aegis3", true);
}
else if (item_new.Bless == 5 && amount.Count == 5)
{
item_new.Bless = 7;
client.Entity.Update(10, "Aegis4", true);
}
if (oldbless == item_new.Bless) return;
while (amount.Count != 0)
client.Inventory.Remove(amount.Dequeue(), Game.Enums.ItemUse.Remove, true);
item_new.Mode = Game.Enums.ItemMode.Update;
item_new.Send(client);
usage.dwParam = 2;
Database.ConquerItemTable.UpdateBless
(item_new);
}
client.Send(packet);
break;
}
case ItemUsage.GemCompose:
{
#region GemCompose
UInt32 Ident = usage.UID;
client.Inventory.Remove(Ident, 15);
client.Inventory.Add(Ident + 1, 0, 1);
usage.dwParam = 1;
client.Send(usage);
#endregion
break;
}
case ItemUsage.ToristSuper:
{
#region GemCompose
if (client.Entity.Money >= 100000)
{
client.Inventory.Remove(700002, 1);
client.Inventory.Remove(700012, 1);
client.Inventory.Remove(700022, 1);
client.Inventory.Remove(700032, 1);
client.Inventory.Remove(700042, 1);
client.Inventory.Remove(700052, 1);
client.Inventory.Remove(700062, 1);
client.Entity.Money -= 100000;
client.Inventory.Add(700072, 0, 1);
client.Send(usage);
usage.dwParam = 1;
}
else
{
client.Send(new Message("Sorry you don`t have 100,000 silver!.", System.Drawing.Color.Red, Message.Talk));
}
#endregion
break;
}
case ItemUsage.SplitStack:
{
ConquerItem mainItem = null;
ConquerItem minorItem = new ConquerItem(true);
Database.ConquerItemInformation infos = null;
minorItem.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Ran dom.Next(4, 8);
if (client.Inventory.TryGetItem(usage.UID, out mainItem))
{
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(mainItem.ID, 0);
if (mainItem.StackSize > 1 && mainItem.StackSize <= infos.BaseInformation.StackSize)
{
if (client.Inventory.Count < 40)
{
ushort Amount = (ushort)usage.dwParam;
mainItem.StackSize -= Amount;
mainItem.Mode = Game.Enums.ItemMode.Update;
mainItem.Send(client);
mainItem.Mode = Game.Enums.ItemMode.Default;
minorItem.ID = mainItem.ID;
minorItem.StackSize += Amount;
minorItem.Durability = mainItem.Durability;
client.Inventory.Add(minorItem, Game.Enums.ItemUse.CreateAndAdd);
Database.ConquerItemTable.UpdateStack(mainItem);
}
}
}
break;
}
case ItemUsage.MergeStackableItems:
{
ConquerItem mainItem = null;
ConquerItem minorItem = new ConquerItem(true);
Database.ConquerItemInformation infos = null;
minorItem.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Ran dom.Next(4, 8);
if (client.Inventory.TryGetItem(usage.UID, out mainItem) && client.Inventory.TryGetItem(usage.dwParam, out minorItem))
{
if (mainItem.ID == minorItem.ID)
{
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(mainItem.ID, 0);
if (mainItem.StackSize < 1)
mainItem.StackSize = 1;
if (minorItem.StackSize < 1)
minorItem.StackSize = 1;
if ((mainItem.StackSize + minorItem.StackSize) <= infos.BaseInformation.StackSize)
{
mainItem.StackSize += minorItem.StackSize;
mainItem.Mode = Game.Enums.ItemMode.Update;
mainItem.Send(client);
mainItem.Mode = Game.Enums.ItemMode.Default;
Database.ConquerItemTable.UpdateStack(mainItem);
client.Inventory.Remove(minorItem, Game.Enums.ItemUse.Remove);
}
}
}
break;
}
case 34:
{
break;
}
case ItemUsage.LowerEquipment:
{
ConquerItem item = null;
if (client.Inventory.TryGetItem(usage.UID, out item))
{
if (IsArrow(item.ID))
return;
ConquerItem upgrade = null;
if (client.Inventory.TryGetItem(usage.UID, out upgrade))
{
if (client.Entity.ConquerPoints < 54)
{
client.Send(new Message("You don't have 54CPs.", Color.Red, Message.TopLeft));
return;
}
client.Entity.ConquerPoints -= 54;
Database.ConquerItemInformation infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, item.Plus);
if (infos.BaseInformation.Level <= 15) return;
int startwith = (int)(infos.BaseInformation.ID / 1000);
int endwith = (int)(infos.BaseInformation.ID % 10);
var sitem = infos.LowestID(ItemMinLevel(ItemPosition(infos.Bas eInformation.ID)));
// var sitem = Conquer_Online_Server.Database.ConquerItemInformat ion.BaseInformations.Values.Where(x => (x.ID % 10) == endwith && (x.ID / 1000) == startwith && x.Level >= 15).OrderBy(y => y.Level).First();
item.ID = sitem;
infos = new Conquer_Online_Server.Database.ConquerItemInformat ion(item.ID, item.Plus);
item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
Database.ConquerItemTable.UpdateItemID(item, client);
Database.ConquerItemTable.UpdateDurabilityItem(ite m);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
item.Send(client);
item = ItemSocket(item, 2);
}
}
break;
}
default:
{
//nta mot2ked enk 3amel update lel client m4 3arf :D
Console.WriteLine("Unhandled item usage type : " + usage.ID);
break;
}
}
}
break;
}
#endregion
هتبحث عن الكود ده
public class ItemUsage : Writer, Interfaces.IPacket
هيوديك على كلاس ItemUsage.cs بس انا قولت اعمل الكود بحث عشان الى مش عارف مكان الكلاس فين
المهم هتمسح كل الى فيه وتحط الاكواد دى
using System;
namespace Conquer_Online_Server.Network.GamePackets
{
public class ItemUsage : Writer, Interfaces.IPacket
{
public const ushort
BuyFromNPC = 1,
SellToNPC = 2,
RemoveInventory = 3,
EquipItem = 4,
UnequipItem = 6,
ArrowReload = 8,
ViewWarehouse = 9,
WarehouseDeposit = 10,
WarehouseWithdraw = 11,
Repair = 14,
VIPRepair = 15,
DragonBallUpgrade = 19,
MeteorUpgrade = 20,
ShowBoothItems = 21,
AddItemOnBoothForSilvers = 22,
RemoveItemFromBooth = 23,
BuyFromBooth = 24,
UpdateDurability = 25,
AddItemOnBoothForConquerPoints = 29,
Ping = 27,
Enchant = 28,
RedeemGear = 32,
ClaimGear = 33,
SocketTalismanWithItem = 35,
SocketTalismanWithCPs = 36,
DropItem = 37,
DropMoney = 38,
GemCompose = 39,
Bless = 40,
Accessories = 41,
MainEquipment = 44,
AlternateEquipment = 45,
LowerEquipment = 54,
ToristSuper = 51,
SocketerMan = 43,
MergeStackableItems = 48,
SplitStack = 49;
byte[] Buffer;
public ItemUsage(bool Create)
{
if (Create)
{
Buffer = new byte[95];
WriteUInt16(87, 0, Buffer);
WriteUInt16(1009, 2, Buffer);
WriteUInt32((uint)Time32.timeGetTime().GetHashCode (), 4, Buffer);
}
}
public uint UID
{
get { return BitConverter.ToUInt32(Buffer, 8); }
set { WriteUInt32(value, 8, Buffer); }
}
public uint dwParam
{
get { return BitConverter.ToUInt32(Buffer, 12); }
set { WriteUInt32(value, 12, Buffer); }
}
public ushort ID
{
get { return BitConverter.ToUInt16(Buffer, 20); }
set { WriteUInt16(value, 20, Buffer); }
}
public uint TimeStamp
{
get { return BitConverter.ToUInt32(Buffer, 24); }
set { WriteUInt32(value, 24, Buffer); }
}
public uint dwExtraInfo
{
get { return BitConverter.ToUInt32(Buffer, 26); }
set { WriteUInt32(value, 26, Buffer); }
}
public uint dwExtraInfo2
{
get { return BitConverter.ToUInt32(Buffer, 88); }
set { WriteUInt32(value, 88, Buffer); }
}
public uint dwExtraInfo3
{
get { return BitConverter.ToUInt32(Buffer, 36); }
set { WriteUInt32(value, 36, Buffer); }
}
public uint[] Batch
{
get
{
uint[] items = new uint[dwExtraInfo];
for (int i = 0; i < dwExtraInfo; i++)
{
items[i] = BitConverter.ToUInt32(Buffer, 91 + 4 * i);
}
return items;
}
set
{
if (value != null)
{
dwExtraInfo = (uint)value.Length;
for (int i = 0; i < dwExtraInfo; i++)
{
WriteUInt32(value[i], 91 + 4 * i, Buffer);
}
}
}
}
public byte[] ToArray()
{
return Buffer;
}
public void Deserialize(byte[] buffer)
{
Buffer = buffer;
}
public void Send(Client.GameState client)
{
client.Send(Buffer);
}
}
}