You can get rid of hard coding each class with:
Code:
--Check Player's Role
local playerRole
local function CheckRole()
local specIndex = GetSpecialization()
if specIndex then
local _, _, _, _, _, role, priStat = GetSpecializationInfo(index)
playerRole = role == "DAMAGER" and priStat == 4 and "CASTER" or role
else
playerRole = nil
end
end
local eventHandler = CreateFrame("Frame")
eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
eventHandler:SetScript("OnEvent", CheckRole)
Or you could just use the normal roles and replace
Code:
elseif playerRole == "HEALER" or playerRole == "CASTER" then
with
Code:
elseif isCaster then
by using
Code:
--Check Player's Role
local playerRole, isCaster
local function CheckRole()
local specIndex = GetSpecialization()
if specIndex then
local _, priStat
_, _, _, _, _, playerRole, priStat = GetSpecializationInfo(index)
isCaster = priStat == 4
else
playerRole = nil
end
end
local eventHandler = CreateFrame("Frame")
eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
eventHandler:SetScript("OnEvent", CheckRole)