Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "drop":
- {
- if (data.Length > 1)
- {
- int itemCount;
- if (int.TryParse(data[1], out itemCount) && itemCount >= 0 && itemCount <= ushort.MaxValue)
- {
- int delayInSeconds = 10;
- if (data.Length > 2)
- {
- int delay;
- if (int.TryParse(data[2], out delay))
- {
- delayInSeconds = delay;
- }
- }
- string itemName = data.Length > 3 ? data[3].ToLower() : "db";
- uint itemID = 0;
- bool specialItem = false;
- var itemDict = new Dictionary<string, uint>
- {
- { "chi", 729476 },
- { "cp", 729911 },
- { "db", 1088000 },
- { "met", 1088001 },
- { "stone1", 730001 },
- { "stone2", 730002 },
- { "stone3", 730003 },
- { "stone4", 730004 },
- { "stone5", 730005 },
- { "stone6", 730006 },
- { "stone7", 730007 },
- { "stone8", 730008 },
- { "soul", 800110 }
- };
- foreach (var item in itemDict)
- {
- if (itemName.Contains(item.Key))
- {
- itemID = item.Value;
- specialItem = true;
- break;
- }
- }
- uint amount = 0;
- if (data.Length > 4)
- {
- uint parsedAmount;
- if (uint.TryParse(data[4], out parsedAmount))
- {
- amount = parsedAmount;
- }
- }
- if (specialItem || itemID > 0)
- {
- using (var rec = new ServerSockets.RecycledPacket())
- {
- var stream = rec.GetStream();
- for (int i = 0; i < itemCount; i++)
- {
- MsgGameItem item = new MsgGameItem
- {
- ITEM_ID = itemID,
- Durability = Database.Server.ItemsBase[itemID].Durability,
- MaximDurability = Database.Server.ItemsBase[itemID].Durability,
- 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