View Single Post
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