Need help getting arena data

Hi!

I am trying to create a debug print statement that prints a players 3v3 arena cr. Specifically I seek to target a new player and have the addon read the target’s 3v3 rating and print it in as a debug statement.

I am making an addon to do this and want it to be in the main.lua for now.

I am having trouble finding the correct code to execute this. Can anyone help or point to a list of reliable addon API lists (up to date)?

I cannot get

rating, seasonPlayed, seasonWon, weeklyPlayed, weeklyWon = GetInspectArenaData(bracketId)

to execute

Anyone know what I may be doing wrong?

https://github.com/Gethe/wow-ui-source/

https://warcraft.wiki.gg/wiki/World_of_Warcraft_API

https://www.townlong-yak.com/framexml/live

1 Like

wowpedia isn’t getting updated anymore since they moved to wiki.gg, don’t use their wowpedia site anymore.

1 Like

Probably something like:

local rating, seasonBest, weeklyBest, seasonPlayed, seasonWon, weeklyPlayed, weeklyWon, lastWeeksBest, hasWon, pvpTier, ranking, roundsSeasonPlayed, roundsSeasonWon, roundsWeeklyPlayed, roundsWeeklyWon = GetPersonalRatedInfo(CONQUEST_BRACKET_INDEXES[3])
local pvpType = CONQUEST_SIZE_STRINGS[3]
print(format("Current Rating %s: %s", pvpType, rating))

Includes all the returns from GetPersonalRatedInfo but you can just get rating if that’s all you want.

You can see the index of options for CONQUEST_BRACKET_INDEXES and CONQUEST_SIZE_STRINGS with:

/dump CONQUEST_SIZE_STRINGS

Hi. Thanks for this. I should have specified that the addon is to read the targets 3v3 rating and print it as an output statement. I have updated the OP.

I have been able to use GetPersonalRatedInfo() and it has worked!

Then something like:

local notifyUnit
local f = CreateFrame("Frame")
f:RegisterEvent("INSPECT_HONOR_UPDATE")
f:SetScript("OnEvent", function(self)
	if notifyUnit then 
		local rating, seasonPlayed, seasonWon, weeklyPlayed, weeklyWon = GetInspectArenaData(2) -- 2 = 3v3
		if rating > 0 then
			local pvpType = CONQUEST_SIZE_STRINGS[3]
			print(format("Current Rating for %s in %s: %s", notifyUnit, pvpType, rating))
		else
			print(format("%s has no rating!", notifyUnit))
		end
		notifyUnit = nil
	end
end)

SLASH_RATING1 = "/rat"
SlashCmdList.RATING = function(msg)
	if UnitExists("target") and UnitIsPlayer("target") then
		NotifyInspect("target")
		notifyUnit = UnitName("target")
	else
		print("No target selected!")
	end
end

using /rat should show the 3v3 rating for your currently selected target unit if they have a rating greater than 0.

It may not work while in PvP combat but…?

1 Like

Thanks that code worked! Can also confirm it works in arenas.

Is there any way to get this to appear in a window to the player everytime they use /rat?

I have tried to implement this myself but it only works after I use /rat twice on the new target.

Trying to debug and fix but could use a hand.

BTW I am happy to give credit to you in the addon code.

local Backdrop = {
	bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
	edgeFile = "Interface\\DialogFrame\\UI-DialogBox-TestWatermark-Border",
	tileEdge = true,
	edgeSize = 6,
}

local notifyUnit
local f = CreateFrame("Button", "LebanesemvpRatings", UIPArent, "BackdropTemplate")
f:Hide()
f:SetSize(50, 30)
f:SetPoint("TOP", 0, -10)
f:SetBackdrop(Backdrop)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetClampedToScreen(true)
f:SetMovable(true)
f:SetUserPlaced(true)
f:SetScript("OnDragStart", function(self) self:StartMoving() end)
f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
f:SetScript("OnShow", function(self) self:SetWidth(self.Text:GetWidth() + 15) end)
f.Close = CreateFrame("Button", "$parentClose", f, "UIPanelCloseButton")
f.Close:SetPoint("TOPRIGHT", -2, -2)
f.Close:SetSize(13, 13)
f.Title = f:CreateFontString("$parentTitle")
f.Title:SetFontObject(GameFontNormalSmall)
f.Title:SetPoint("TOP", 0, -2)
f.Title:SetText("Rated!")

f.Text = f:CreateFontString("$parentRatingText")
f.Text:SetFontObject(GameFontNormalSmall)
f.Text:SetTextColor(1, 1, 1)
f.Text:SetPoint("TOP", 0, -15)

f:RegisterEvent("INSPECT_HONOR_UPDATE")
f:SetScript("OnEvent", function(self)
	if notifyUnit then 
		local rating, seasonPlayed, seasonWon, weeklyPlayed, weeklyWon = GetInspectArenaData(2) -- 2 = 3v3
		if rating > 0 then
			local pvpType = CONQUEST_SIZE_STRINGS[3]
--			print(format("Current Rating for %s in %s: %s", notifyUnit, pvpType, rating))
			self.Text:SetText(format("Current Rating for %s in %s: %s", notifyUnit, pvpType, rating))
		else
--			print(format("%s has no rating!", notifyUnit))
			self.Text:SetText(format("%s has no rating!", notifyUnit))
		end
		notifyUnit = nil
		self:GetScript("OnShow")(self)
	end
end)

function PVP3V3Rated()
	if UnitExists("target") and UnitIsPlayer("target") then
		NotifyInspect("target")
		notifyUnit = UnitName("target")
		LebanesemvpRatings.Text:SetText("Collecting Rating...")
		if not LebanesemvpRatings:IsShown() then
			LebanesemvpRatings:Show()
		end
	else
		print("No target selected!")
	end
end

SLASH_RATING1 = "/rat"
SlashCmdList.RATING = function(msg)
	PVP3V3Rated()
end

No credit required, have fun with it.

1 Like

Legend. Thanks for the help! I am learning so much from this whole experience. Lua is a fun language. It is nice not needing to add a ; every line lol.

1 Like

I have been able to execute these lines of code while using a slash command however I want to be able to execute them during a ButtonPress event. Ie the addon should only look up the rating of the player after a button press such as “search 3v3”.

Are you able to give me any tips or modify your existing code to allow for this funictionality.

My addon is complete in theory but requrires slash commands to use. I want it to be more graphical hence why im trying to call this while using buttons.

I updated the code in the previous post. You can still use the slash command or you can use:

/run PVP3V3Rated()

in a macro or, you can use:

PVP3V3Rated()

in a buttons OnClick script.

Still requires a target to be selected.

1 Like

Thanks again. I take it you have been doing this for a long time. May I ask which addons you have published?

Aditionally, is there an IDE or IDE tools you use to show syntax errors. Ive been working mostly with notepad++ lua extension.

for debuggin in-game use (the two addons work together):
https://www.curseforge.com/wow/addons/bugsack
and:
https://www.curseforge.com/wow/addons/bug-grabber

Ketho has extensions for use with VS Code

I have a few addons I publish FauxMazzle, MovePadPlus as well as maintaining some older addons DiscordUnitFrames and DiscordArt.

1 Like

Mind giving me a hand again lol? At this point ur my tutor. I have buttons that are not attaching to a frame backdrop. I want to move the whole frame but the buttons are disconnected. Whenever I close the frame with the Cross all UI elements (from the addon) close. Kinda confused.

If you could add a button to your original code I can study that and transfer the principles into my own code. Thanks.

f.Close is a button attached to the frame. The SetPoint(...) line anchors the button to the frame so when the frame moves, the close button moves with it.

When you show/hide a frame, any elements it is the parent of (it’s children) will also show/hide. Setting the parent is done in the code above as either, the third parameter of CreateFrame (eg. the f.Close button) or for regions (Textures/FontStrings) by using the parent to create the region (eg. f.Text).

In other words, it is possible to have a frame/region that is attached (anchored) to one frame but is parented to another frame.

1 Like

Thanks that really helped. Ive been able to fix it now :smiley: