public static void SendTrainerList(this NPC trainer, Character chr, IEnumerable<TrainerSpellEntry> spells, string msg) { using ( var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TRAINER_LIST, 8 + 4 + 4 + (30 * 38) + msg.Length + 1)) { packet.Write(trainer.EntityId); packet.Write((uint)trainer.TrainerEntry.TrainerType); var countPos = packet.Position; packet.Position += 4; var spellCount = 0; foreach (var trainerSpell in spells) { if (!chr.CanLearn(trainerSpell)) { continue; } var spell = trainerSpell.Spell; if (spell.IsTeachSpell) { spell = spell.LearnSpell; } //packet.Position = offset + (spell.Index * entryLength); packet.Write(trainerSpell.Spell.Id); packet.Write((byte)trainerSpell.GetTrainerSpellState(chr)); packet.Write(trainerSpell.GetDiscountedCost(chr, trainer)); packet.Write(spell.Talent != null ? 1u : 0u); // talent cost packet.Write(trainerSpell.Spell.IsProfession && trainerSpell.Spell.TeachesApprenticeAbility ? 1 : 0); // Profession cost packet.Write((byte)trainerSpell.RequiredLevel); packet.Write((uint)trainerSpell.RequiredSkillId); packet.Write(trainerSpell.RequiredSkillAmount); packet.Write((uint)trainerSpell.RequiredSpellId); // The following are infrequent Ids of some sort - Possibly spell replacements? packet.Write(0u); packet.Write(0u); ++spellCount; } packet.Write(msg); packet.Position = countPos; packet.Write(spellCount); chr.Send(packet); } }