Whiroph

Player_LearnReferenceSpellsOnLevelUp

Jan 2nd, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1. --[[
  2.     - Developer(s): Whiroph
  3.     - Thanks to: Eluna Devs & µDev (for base)
  4.     - Complete: %100
  5.     - ScriptName: 'Player_LearnReferenceSpellsOnLevelUp'
  6. ]]
  7.  
  8. local ClassesSpellsReference = {
  9.     -- Warrior
  10.     [1] = {
  11.         -- All
  12.         ["all"]  = {200001,200002},
  13.         -- Alliance only
  14.         [0]  = {},
  15.         -- Horde only
  16.         [1]  = {}
  17.     },
  18.     -- Paladin
  19.     [2] = {
  20.         ["all"]  = {200003,200004},
  21.         [0]  = {200020},
  22.         [1]  = {200021}
  23.     },
  24.     -- Hunter
  25.     [3] = {
  26.         ["all"]  = {200013,200014},
  27.         [0]  = {},
  28.         [1]  = {}
  29.     },
  30.     -- Rogue
  31.     [4] = {
  32.         ["all"]  = {200015,200016},
  33.         [0]  = {},
  34.         [1]  = {}
  35.     },
  36.     -- Priest
  37.     [5] = {
  38.         ["all"]  = {200011,200012},
  39.         [0]  = {},
  40.         [1]  = {}
  41.     },
  42.     -- DeathKnight
  43.     [6] = {
  44.         ["all"]  = {200019},
  45.         [0]  = {},
  46.         [1]  = {}
  47.     },
  48.     -- Shaman
  49.     [7] = {
  50.         ["all"]  = {200017,200018}, -- 200018 Contain: 2825 Bloodlust (only for horde shamans),  32182 Heroism (only for alliance shamans)
  51.         [0]  = {},
  52.         [1]  = {}
  53.     },
  54.     -- Mage
  55.     [8] = {
  56.         ["all"]  = {200007,200008},
  57.         [0]  = {},
  58.         [1]  = {}
  59.     },
  60.     -- Warlock
  61.     [9] = {
  62.         ["all"]  = {200009,200010},
  63.         [0]  = {},
  64.         [1]  = {}
  65.     },
  66.     -- Druid
  67.     [11] = {
  68.         ["all"]  = {200005,200006},
  69.         [0]  = {},
  70.         [1]  = {}
  71.     }
  72. }
  73.  
  74. function Player_LearnReferenceSpellsOnLevelUp(event, player, oldLevel)
  75.     local References = ClassesSpellsReference[player:GetClass()]
  76.     local Delevelling = false
  77.     if (oldLevel >= player:GetLevel()) then
  78.         Delevelling = true
  79.     end
  80.     local SQL_Spells = "SELECT spell FROM npc_trainer WHERE reqlevel"
  81.     if(Delevelling == true) then
  82.         SQL_Spells = SQL_Spells..">"
  83.     else
  84.         SQL_Spells = SQL_Spells.."<="
  85.     end
  86.     SQL_Spells = SQL_Spells..player:GetLevel().." AND reqskill = 0 AND entry IN ("
  87.     for key, value in ipairs(References['all']) do
  88.         if(key <= 1) then
  89.             SQL_Spells = SQL_Spells..value
  90.         else
  91.             SQL_Spells = SQL_Spells..","..value
  92.         end
  93.     end
  94.     for key, value in ipairs(References[player:GetTeam()]) do
  95.         SQL_Spells = SQL_Spells..","..value
  96.     end
  97.     SQL_Spells = SQL_Spells..")"
  98.     local QUERY_Spells = WorldDBQuery(SQL_Spells)
  99.     local SpellID = 0
  100.     if(QUERY_Spells) then
  101.         repeat
  102.             SpellID = QUERY_Spells:GetUInt32(0)
  103.             if(Delevelling == true) then
  104.                 player:RemoveSpell(SpellID)
  105.             else
  106.                 player:LearnSpell(SpellID)
  107.             end
  108.         until not QUERY_Spells:NextRow()
  109.     end
  110. end
  111. RegisterPlayerEvent(13, Player_LearnReferenceSpellsOnLevelUp) -- PLAYER_EVENT_ON_LEVEL_CHANGE
Add Comment
Please, Sign In to add comment