Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "drop":
- {
- if (data.Length > 1 && int.TryParse(data[1], out int itemCount) && itemCount >= 0 && itemCount <= ushort.MaxValue)
- {
- int delayInSeconds = data.Length > 2 && int.TryParse(data[2], out int delay) ? delay : 10;
- string itemName = data.Length > 3 ? data[3].ToLower() : "db";
- uint itemID = 0;
- bool specialItem = false;
- if (itemName.Contains("chi"))
- {
- itemID = 729476;
- specialItem = true;
- }
- if (itemName.Contains("cp"))
- {
- itemID = 729911;
- specialItem = true;
- }
- if (itemName.Contains("db"))
- {
- itemID = 1088000;
- specialItem = true;
- }
- else if (itemName.Contains("met"))
- {
- itemID = 1088001;
- specialItem = true;
- }
- else if (itemName.Contains("stone1"))
- {
- itemID = 730001;
- specialItem = true;
- }
- else if (itemName.Contains("stone2"))
- {
- itemID = 730002;
- specialItem = true;
- }
- else if (itemName.Contains("stone3"))
- {
- itemID = 730003;
- specialItem = true;
- }
- else if (itemName.Contains("stone4"))
- {
- itemID = 730004;
- specialItem = true;
- }
- else if (itemName.Contains("stone5"))
- {
- itemID = 730005;
- specialItem = true;
- }
- else if (itemName.Contains("stone6"))
- {
- itemID = 730006;
- specialItem = true;
- }
- else if (itemName.Contains("stone7"))
- {
- itemID = 730007;
- specialItem = true;
- }
- else if (itemName.Contains("stone8"))
- {
- itemID = 730008;
- specialItem = true;
- }
- else if (itemName.Contains("soul"))
- {
- itemID = 800110;
- specialItem = true;
- }
- uint amount = 0;
- if (data.Length > 4 && uint.TryParse(data[4], out uint parsedAmount))
- {
- amount = parsedAmount;
- }
- if (specialItem || itemID > 0)
- {
- using (var rec = new ServerSockets.RecycledPacket())
- {
- var stream = rec.GetStream();
- for (int i = 0; i < itemCount; i++)
- {
- MsgServer.MsgGameItem item = new MsgServer.MsgGameItem();
- item.ITEM_ID = itemID;
- var DBItem = Database.Server.ItemsBase[itemID];
- item.Durability = DBItem.Durability;
- item.MaximDurability = DBItem.Durability;
- item.Color = Role.Flags.Color.Red;
- ushort dropX = (ushort)Program.GetRandom.Next(client.Player.X - 20, client.Player.X + 21);
- ushort dropY = (ushort)Program.GetRandom.Next(client.Player.Y - 20, client.Player.Y + 21);
- if (client.Map.AddGroundItem(ref dropX, ref dropY))
- {
- MsgFloorItem.MsgItem.ItemType itemType = (itemName.Contains("cp"))
- ? MsgFloorItem.MsgItem.ItemType.Cps
- : MsgFloorItem.MsgItem.ItemType.Item;
- MsgFloorItem.MsgItem dropItem = new MsgFloorItem.MsgItem(item, dropX, dropY, itemType, amount, client.Player.DynamicID, client.Player.Map, client.Player.UID, false, client.Map, delayInSeconds);
- if (client.Map.EnqueueItem(dropItem))
- {
- dropItem.SendAll(stream, MsgFloorItem.MsgDropID.Visible);
- }
- }
- }
- }
- }
- else
- {
- client.SendSysMesage("Item type not recognized. Please use 'db', 'met','chi', 'stone', or 'soul'.");
- }
- }
- else
- {
- client.SendSysMesage("Please enter a valid number of items.");
- }
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement