1. class AccountMounts : public PlayerScript
  2. {
  3. static const bool limitrace = false; // This set to true will only learn mounts from chars on the same team, do what you want.
  4. public:
  5. AccountMounts() : PlayerScript("AccountMounts") { }
  6. void OnLogin(Player* pPlayer)
  7. {
  8. std::vector<uint32> Guids;
  9. QueryResult result1 = CharacterDatabase.PQuery("SELECT guid, race FROM characters WHERE account = %u", pPlayer->GetSession()->GetAccountId());
  10. if (!result1)
  11. return;
  12. do
  13. {
  14. Field* fields = result1->Fetch();
  15. uint32 guid = fields[0].GetUInt32();
  16. uint32 race = fields[1].GetUInt8();
  17. if ((Player::TeamForRace(race) == Player::TeamForRace(pPlayer->getRace())) || !limitrace)
  18. Guids.push_back(result1->Fetch()[0].GetUInt32());
  19. } while (result1->NextRow());
  20. std::vector<uint32> Spells;
  21. for (auto& i : Guids)
  22. {
  23. QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM character_spell WHERE guid = %u", i);
  24. if (!result2)
  25. continue;
  26. do
  27. {
  28. Spells.push_back(result2->Fetch()[0].GetUInt32());
  29. } while (result2->NextRow());
  30. }
  31. for (auto& i : Spells)
  32. {
  33. auto sSpell = sSpellStore.LookupEntry(i);
  34. if (sSpell->Effect[0] == SPELL_EFFECT_APPLY_AURA && sSpell->EffectApplyAuraName[0] == SPELL_AURA_MOUNTED)
  35. pPlayer->learnSpell(sSpell->Id, false);
  36. }
  37. }
  38. };
  39. void AddSC_accontmounts()
  40. {
  41. new AccountMounts;
  42. }