protected override bool Process(Player player, RealmTime time, string args) { string item = args; string data = ""; if (args.IndexOf("{") >= 0 && args.EndsWith("}")) { item = args.Remove(args.IndexOf("{")).TrimEnd(); Console.WriteLine(item); data = args.Substring(args.IndexOf("{")); } ushort objType; if (!player.Manager.GameData.IdToObjectType.TryGetValue(item, out objType)) { player.SendError("Unknown item type!"); return(false); } for (int i = 0; i < player.Inventory.Length; i++) { if (player.Inventory[i] == null) { player.Inventory[i] = player.Manager.GameData.Items[objType]; if (data != "") { player.Inventory.Data[i] = ItemData.CreateData(data); } player.UpdateCount++; return(true); } } player.SendError("Not enough space in inventory!"); return(false); }
protected override void Read(NReader rdr) { List <int> slots = new List <int>(); int length = rdr.ReadInt32(); for (int i = 0; i < length; i++) { slots.Add(rdr.ReadInt32()); } List <int> requestItems = new List <int>(); length = rdr.ReadInt32(); for (int i = 0; i < length; i++) { requestItems.Add(rdr.ReadInt32()); } length = rdr.ReadInt32(); List <ItemData> requestDatas = new List <ItemData>(); for (int i = 0; i < length; i++) { requestDatas.Add(ItemData.CreateData(rdr.ReadUTF())); } this.IncludedSlots = slots.ToArray(); this.RequestItems = requestItems.ToArray(); this.RequestDatas = requestDatas.ToArray(); }
public static TradeItem Read(NReader rdr) { var ret = new TradeItem(); ret.Item = rdr.ReadInt32(); ret.Data = ItemData.CreateData(rdr.ReadString()); ret.SlotType = rdr.ReadInt32(); ret.Tradeable = rdr.ReadBoolean(); ret.Included = rdr.ReadBoolean(); return(ret); }
protected override void Read(NReader rdr) { Items = new ushort[rdr.ReadInt16()]; for (int i = 0; i < Items.Length; i++) { Items[i] = (ushort)rdr.ReadInt32(); } Datas = new ItemData[rdr.ReadInt16()]; for (int i = 0; i < Datas.Length; i++) { Datas[i] = ItemData.CreateData(rdr.ReadUTF()); } }
protected override bool Process(Player player, RealmTime time, string args) { var item = args; var dataJson = ""; if (args.IndexOf("{", StringComparison.Ordinal) >= 0 && args.EndsWith("}")) { item = args.Remove(args.IndexOf("{", StringComparison.Ordinal)).TrimEnd(); dataJson = args.Substring(args.IndexOf("{", StringComparison.Ordinal)); } ushort objType; if (!player.Manager.GameData.IdToObjectType.TryGetValue(item, out objType)) { player.SendError("Unknown item type!"); return(false); } for (var i = 0; i < player.Inventory.Length; i++) { if (player.Inventory[i] == null) { player.Inventory[i] = player.Manager.GameData.Items[objType]; player.Inventory.Data[i] = null; //cleaning it out before working with it if (dataJson != "") { player.Inventory.Data[i] = ItemData.CreateData(dataJson); //serializes the itemData } if (player.Inventory.Data[i] != null) { player.Inventory.Data[i].GivenItem = true; //if already serialized, just add a tag change player.Inventory.Data[i].Soulbound = true; } else { player.Inventory.Data[i] = new ItemData { GivenItem = true, Soulbound = true } }; //otherwise, create the object and add the property player.UpdateCount++; var dir = @"logs"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } using (var writer = new StreamWriter(@"logs\GiveLog.log", true)) { writer.WriteLine(player.Name + " gave themselves a " + item + " at " + DateTime.Now); } player.UpdateCount++; return(true); } } player.SendError("Not enough space in inventory!"); return(false); } }
protected override void Read(NReader rdr) { ItemType = rdr.ReadInt32(); ItemData = ItemData.CreateData(rdr.ReadUTF()); }