Originally Posted by Velveeta
This is what I was trying to do with my earlier post on page 5 regarding the pvp icon but its not been answered as of yet and I haven't found the answer myself.
|
I don't use rUnits anymore, and I have not tested this, but I believe this should work. This is similar to how I accomplished adding a combat icon to my rUnits, previously.
Let's take what you have from your previous post:
local pvp = self:CreateTexture(nil, "OVERLAY")
pvp:SetHeight(16)
pvp:SetWidth(16)
pvp:SetPoint("RIGHT", self, "LEFT")
pvp:SetTexture"Interface\\PVPFrame\\PVP-Currency-Horde"
self.PvP = pvp
Along with this, we must add the event that checks whether or not you are flagged. Checking
WoWWiki, it seems that the function we want to use is UNIT_FACTION. We need to add this event to the core.lua.
Open up core.lua and scroll to 'local subTypes' (should be around line 83). We need to add the line:
Once we do this, we need to add the event. Scroll down to 'local events', which should be right below the subTypes one. We will add this line here:
UNIT_FACTION = "UpdatePvP",
After that, scroll towards the bottom around line 367 and find the 'function rUnits:RegisterObject(object, subType)'. Here we will add:
elseif(subType == "PvP") then
object:RegisterEvent"UNIT_FACTION"
After we have completed all of this, we need to create a new file. Let us call it pvp.lua. Open up this blank file and we will create this function:
function rUnits:UpdatePvP(event)
if(UnitIsPVP("player")) then
self.PvP:Show()
else
self.PvP:Hide()
end
end
Make sure everything is saved and try it out. As I said, I can't guarantee this will work as I haven't tested it myself.
Also, I am not sure that is the correct texture for the actual PvP status icon (unless you chose that texture out of preference); the correct one, I believe is this: "SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA");"