WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Is it possible for others players ? (https://www.wowinterface.com/forums/showthread.php?t=59106)

gmarco 04-23-22 07:09 AM

Is it possible for others players ?
 
Hi all,

I am trying to put a m+ score in the tooltip, using the function:

C_PlayerInfo.GetPlayerMythicPlusRatingSummary(name).currentSeasonScore

But it works only for me :)



The code is:

Lua Code:
  1. if event == "UPDATE_MOUSEOVER_UNIT" then
  2.         if (UnitIsPlayer("mouseover")) then
  3.             local name,realm = UnitFullName("mouseover")
  4.            
  5.             -- realm is needed ?
  6.             if realm == nil then
  7.                 realm = GetRealmName()
  8.             end
  9.            
  10.             local score = C_PlayerInfo.GetPlayerMythicPlusRatingSummary(name).currentSeasonScore
  11.             local r, g, b = C_ChallengeMode.GetDungeonScoreRarityColor(C_PlayerInfo.GetPlayerMythicPlusRatingSummary(name).currentSeasonScore):GetRGB()
  12.    
  13.             GameTooltip:AddLine(" ")
  14.             GameTooltip:AddDoubleLine("Mythic+ score",score,1,1,0,r,g,b)       
  15.             GameTooltip:Show()
  16.         end
  17.     end

The links to the function on wowpedia is this:
https://wowpedia.fandom.com/wiki/API...sRatingSummary

and it states:
Returns the players mythic+ rating summary which includes the runs they've completed as well as their current season m+ rating

Now I am not a native speakers but this could be understood also as other players as well ... :)

Thanks for any help :)

Ketho 04-23-22 10:20 PM

You need to use the unit id

gmarco 04-24-22 10:01 AM

Hi Ketho,

now it works thanks to your input and tips.

I have tried also with unitid in my past tries but I use in a wrongly way.

I used:

Lua Code:
  1. guid = UnitGUID("unit")

and then that value in the function to calculate the score.
But it doesn't work.

Now following your suggest I change the code in this way and it works nicely:

Lua Code:
  1. if event == "UPDATE_MOUSEOVER_UNIT" then
  2.         if (UnitIsPlayer("mouseover")) then
  3.             local score = C_PlayerInfo.GetPlayerMythicPlusRatingSummary("mouseover").currentSeasonScore
  4.             local r, g, b = C_ChallengeMode.GetDungeonScoreRarityColor(C_PlayerInfo.GetPlayerMythicPlusRatingSummary("mouseover").currentSeasonScore):GetRGB()
  5.             GameTooltip:AddLine(" ")
  6.             GameTooltip:AddDoubleLine("Mythic+ score",score,1,1,0,r,g,b)       
  7.             GameTooltip:Show()
  8.         end
  9.     end

Don't know why it didn't work in other way :/
But now it works and I am happy :)




Thanks so much for you tips.

Seerah 04-27-22 06:26 PM

Because "unit" isn't a valid UnitID. https://wowpedia.fandom.com/wiki/UnitId

SDPhantom 04-27-22 08:56 PM

A note to add, player names are valid UnitIDs as long as they're in your party/raid.

gmarco 04-30-22 11:52 PM

Good Morning.

Ah thanks all for the usual kind replies.
Now I explain why sometime it works with player names sometimes not :)

Thanks so much to everyone and especially to SDPhantom for let me clarify this oddity :)


All times are GMT -6. The time now is 07:37 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI