This is working perfectly in all three places (Ashran, Tol Barad and Wintergrasp):
Lua Code:
local f = CreateFrame("Frame")
f:SetScript("OnEvent",function(self,event,...)
if event=="PLAYER_ENTERING_WORLD" then
local _,_,_,_,_,_,_,instance_id = GetInstanceInfo()
if instance_id==1191 or IsInActiveWorldPVP() then
f.in_active_world_combat_zone = true
else
f.in_active_world_combat_zone = false
end
elseif event=="BATTLEFIELD_MGR_ENTERED" then
if ...==1 or ...==21 or ...==24 then
f.in_active_world_combat_zone = true
end
elseif event=="BATTLEFIELD_MGR_EJECTED" then
if ...==1 or ...==21 or ...==24 then
f.in_active_world_combat_zone = false
end
elseif event=="BATTLEFIELD_MGR_STATE_CHANGE" then
if (...==1 or ...==21) and IsInActiveWorldPVP()==false then
f.in_active_world_combat_zone = false
end
end
print(f.in_active_world_combat_zone)
end)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("BATTLEFIELD_MGR_ENTERED")
f:RegisterEvent("BATTLEFIELD_MGR_EJECTED")
f:RegisterEvent("BATTLEFIELD_MGR_STATE_CHANGE")
Side note: I noticed that GetInstanceInfo() does not return the right id after ZONE_CHANGED_NEW_AREA (it returns the area you just left instead), at least when running into and out of Ashran.