private static IEnumerable <PetItem> GetPets(int userId, int characterId) { using (var data = Connection.RunQuery( @"SELECT ci.*, l.slot FROM cashitem_pet ci JOIN itemlocker l ON l.cashid = ci.cashid AND l.userid = @userid AND l.characterid = @charid AND l.worldid = @worldid LIMIT 400", "@userid", userId, "@worldid", WorldID, "@charid", characterId ) as MySqlDataReader) { while (data.Read()) { var bundleItem = BaseItem.CreateFromItemID(data.GetInt32("itemid")); bundleItem.Load(data); bundleItem.InventorySlot = data.GetInt16("slot"); Console.WriteLine("Loading pet {0} cashid {1}", bundleItem.ItemID, bundleItem.CashId); yield return(bundleItem as PetItem); } } }
public static BaseItem CreateCashItem(LockerItem li, CommodityInfo ci) { li.CashId = (long)((long)(Rand32.Next()) << 32 | Rand32.Next()); li.CashId &= 0x00FFFFFFFFFFFFFF; // Get rid of the first byte var item = BaseItem.CreateFromItemID(li.ItemId); item.Amount = li.Amount; item.CashId = li.CashId; item.Expiration = li.Expiration; if (item is PetItem pi) { pi.Name = DataProvider.Pets[pi.ItemID].Name; pi.Closeness = 0; pi.Fullness = 100; pi.Level = 1; } return(item); }
public static void Load(MySQL_Connection connection, string baseTableName, string whereStatement, AddItemCallback callback) { using (var data = connection.RunQuery($"SELECT * FROM {GetInventoryTableName(InventoryType.Eqp, baseTableName)} WHERE {whereStatement}") as MySqlDataReader) { while (data.Read()) { var item = BaseItem.CreateFromItemID(data.GetInt32("itemid")); item.Load(data); callback(InventoryType.Eqp, 1, data.GetInt16("slot"), item); } } using (var data = connection.RunQuery($"SELECT * FROM {GetInventoryTableName(InventoryType.Bundle, baseTableName)} WHERE {whereStatement}") as MySqlDataReader) { while (data.Read()) { var item = BaseItem.CreateFromItemID(data.GetInt32("itemid")); item.Load(data); callback(InventoryType.Bundle, (byte)data.GetInt16("inv"), data.GetInt16("slot"), item); } } }
public override bool FilterAdminCommand(Character character, CommandHandling.CommandArgs command) { switch (command.Command) { case "omok": OnStart(character, GameKindEnum.Omok); return(true); case "senduser": // Arg: <charname> <portalname> if (command.Count == 2) { var charName = command[0].Value; var portalName = command[1].Value; if (Portals.TryGetValue(portalName, out Portal portal)) { var c = FindUser(charName); if (c != null) { c.ChangeMap(ID, portal); } } } return(true); case "reset": // Do map reset.... return(true); case "matchtable": { SendAvatarInfo(character); var p = new Packet(ServerMessages.TOURNAMENT_MATCH_TABLE); // This one is nasty. We cannot write lots of data at once. for (var i = 0; i < SLOTS; i++) { for (var j = 0; j < 6; j++) { p.WriteInt(character.ID); } } var round = CurrentRound; if (round >= 100) { round -= 100; } p.WriteByte((byte)round); character.SendPacket(p); return(true); } case "prize": // Arg: <itemid1> <itemid2> // TODO add validation if (command.Count == 2) { PrizeSet = true; var p = new Packet(ServerMessages.TOURNAMENT_SET_PRIZE); ItemID[0] = command[0].GetInt32(); ItemID[1] = command[1].GetInt32(); p.WriteBool(true); p.WriteByte(1); p.WriteInt(ItemID[0]); p.WriteInt(ItemID[1]); SendPacket(p); // For the user himself p = new Packet(ServerMessages.TOURNAMENT_SET_PRIZE); p.WriteBool(true); p.WriteByte(0); character.SendPacket(p); } return(true); case "giveprize": // Arg: <itemid> <portalname> if (command.Count == 2) { var itemid = command[0].GetInt32(); var portalName = command[1].Value; if (Portals.TryGetValue(portalName, out Portal portal)) { var item = BaseItem.CreateFromItemID(itemid); item.GiveStats(ItemVariation.None); var reward = Reward.Create(item); // Drops through floor with X + 50 on pt 2 DropPool.Create( reward, 0, 0, DropType.Normal, 0, new Pos((short)(portal.X + 40), portal.Y), portal.X + 40, 0, false, 0, true, // Yes, by pet??!? false ); } } return(true); } return(false); }