Thread Tools Display Modes
12-09-05, 11:41 PM   #1
Mokaikai
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 5
Party Rank Icons not always there.

OK my latest mod PVP Rank Icons is having a problem I can't seem to cure.

What does not work is the PVP Rank Icon showing on the party members reliably.

The basic principle that I'm working against is the fact that when one joins a party they may more may not be in range for thier honor information to be displayed. The range is limited. So when the player does come in range the script I have does not rerun to get thier rank again. It simply assumes that they had a rank that was less than or equal to zero like they did when they were out of range. I assumed that simply running the script onupdate would force the script to run and recheck every party member regularly. This does not appear to work. If someone new joins the party. All members that were there prior have thier status updated properly. The same thing happens when the player spawns after death in the grave yard. Out of range all ranks are set to zero and do not change until the party changes or the player enters world.

I am including the entire script and hoping one of you can shed some light on this issue for me.

Code:
MAX_PARTY_MEMBERS = 4

function MokaPvPRank_OnLoad()
	this:RegisterEvent("PLAYER_ENTERING_WORLD")
	this:RegisterEvent("PLAYER_TARGET_CHANGED")
	this:RegisterEvent("PARTY_MEMBERS_CHANGED")
end

function MokaPvPRank_OnEvent()
	if ( event == "PLAYER_ENTERING_WORLD" ) then
		MokaPvPRankPlayer_Update()
		MokaPvPRankParty_Update()
	elseif ( event == "PLAYER_TARGET_CHANGED" ) then
		MokaPvPRankTarget_Update()
	elseif ( event == "PARTY_MEMBERS_CHANGED" ) then
		MokaPvPRankParty_Update()
	end
end

function MokaPvPRank_OnUpdate(elapsed)
	MokaPvPRankParty_Update()	
end

function MokaPvPRankPlayer_Update(updateAll)
	local rankName, rankNumber
	rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("player"))
	if ( rankNumber > 0 ) then
		MokaPvPRankPlayerPvPIcon:SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber))
		MokaPvPRankPlayerPvPIcon:Show()
		MokaPvPRankPlayerPvPIcon:SetAlpha(0.6)
	else
		MokaPvPRankPlayerPvPIcon:Hide()
	end
end

function MokaPvPRankTarget_Update(updateAll)
	local rankName, rankNumber
	rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("target"))
	if ( rankNumber > 0 ) then
		MokaPvPRankTargetPvPIcon:SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber))
		MokaPvPRankTargetPvPIcon:Show()
		MokaPvPRankTargetPvPIcon:SetAlpha(0.6)
	else
		MokaPvPRankTargetPvPIcon:Hide()
	end
end

function MokaPvPRankParty_Update(updateAll)
	local i, playerid, rankName, rankNumber
	for i=1, MAX_PARTY_MEMBERS, 1 do
		if ( GetPartyMember( i ) ) then
			playerid = "party"..i
			rankName, rankNumber = GetPVPRankInfo(UnitPVPRank(playerid), playerid)
			if ( rankNumber > 0 ) then
				getglobal("MokaPvPRankPartyPvPIcon"..i):SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber))
			else
				getglobal("MokaPvPRankParty"..i):Hide()
			end
		end
	end
end
  Reply With Quote
12-10-05, 03:04 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
There's a function UnitIsVisible() that returns true when the unit is nearby and information about them is visible. You could use that to determine if a player's pvp status is legitimate.

For updating when they do get in range/join group, does their PVP rank become available when their portrait changes? I'm not sure if that range is the same as the UnitIsVisible() range, but you could try registering for UNIT_PORTRAIT_UPDATE and if arg1 is party1-4 then grab their pvp information.

To minimize the amount of times the game runs through the checks you could see if UNIT_PORTRAIT_UPDATE fires after PARTY_MEMBERS_CHANGED (I suspect so). If so then:

PARTY_MEMBERS_CHANGED:
Register for UNIT_PORTRAIT_UPDATE

UNIT_PORTRAIT_UPDATE:
for i=1,4 do if UnitIsVisible("party"..i) then update PvP rank for "party"..i end
Unregister UNIT_PORTRAIT_UPDATE
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Party Rank Icons not always there.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off