edit: so my question is how can i make low mana alert only plays when I'm on mage/warlock/priest/paladin, and disable low mana alert when I'm on dk/rouge/warrior/hunter?
--------------------------------------------------------------------
I use this code to play a alert sound when I'm low health or mana
but how can I disable low mana alert when I'm playing DK?
Lua Code:
local lowHealth = .2
local lowMana = .3
local playedHp, playedMp
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, unit, pType)
if unit ~= "player" then return end
if event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" then
if UnitHealth("player") / UnitHealthMax("player") < lowHealth then
if not playedHp then
playedHp = true
PlaySoundFile("Interface\\AddOns\\media\\LowHealth.ogg")
end
else
playedHp = false
end
elseif event == "UNIT_POWER" or event == "UNIT_MAXPOWER" and pType == "MANA" then
if UnitPower("player") / UnitPowerMax("player") < lowMana then
if not playedMp then
playedMp = true
PlaySoundFile("Interface\\AddOns\\media\\LowMana.ogg")
end
else
playedMp = false
end
end
end)
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_POWER")
f:RegisterEvent("UNIT_MAXHEALTH")
f:RegisterEvent("UNIT_MAXPOWER")