Thread: PvP Icon
View Single Post
09-16-09, 07:36 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
What you do:
Code:
-- This goes in the main scope of your layout:
local MyPvPUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end

	local pvp = self.MyPvP
	if(pvp) then
		local factionGroup = UnitFactionGroup(unit)
		-- FFA!
		if(UnitIsPVPFreeForAll(unit)) then
			pvp:SetTexture(0, 0, 1)
			pvp:Show()
		elseif(UnitIsPVP(unit) and factionGroup) then
			if(factionGroup == 'Horde') then
				pvp:SetTexture(1, 0, 0)
			else
				pvp:SetTexture(0, 1, 0)
			end

			pvp:Show()
		else
			pvp:Hide()
		end
	end
end


-- This goes in your layout style function:
	local pvp = self.Health:CreateTexture(nil, "OVERLAY")
	pvp:SetTexture(1, 0, 0)
	pvp:SetHeight(18)
	pvp:SetWidth(18)
	pvp:SetPoint("BOTTOMLEFT", -13, -13)
	self.MyPvP = pvp

	-- This makes oUF update the information.
	self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
	-- This makes oUF update the information on forced updates.
	table.insert(self.__elements, MyPvPUpdate)
  Reply With Quote