Faction from GetPlayerInfoByGUID()
It would be nice to have faction as a return from GetPlayerInfoByGUID(). Currently, lack of this information hinders the default language set support for addons that add custom languages. For now, this specifically applies to Pandaren since both factions share the same racial language.
|
|
If you're using GetPlayerInfoByGUID, it's probably because you're dealing with people who are talking in chat, or doing something else where no UnitID is available.
If a UnitID was available, there'd be no reason to use GetPlayerInfoByGUID, because all of the information it provides -- class, race, gender, name, server -- is available through other, more specific, UnitID-based API functions. |
I remember asking for this ability during the beta... One of my addons needs to be able to tell if a person is of the same faction from only the guid... and there is no way for me that doesn't introduce some sort of lag... I could try a search but then I have to make the addon wait for the who list update event... and then users would see I did it... If SendAddonChatMessage had a return value instead of printing the error to chat that could help too
|
If you're getting GUIDs from chat (the usual reason for calling GetPlayerInfoByGUID) then you can determine the faction based on the message language.
|
Quote:
|
Can't you use ChatFrame_AddMessageEventFilter and just catch the language argument (arg3) passed with the chat message? I can't recall the last time I saw anyone /say or /yell anything in a language other than their faction's default language, so just checking for Orcish or Common should catch 99% of cases.
Another option would be to do what BadBoy_Levels does to check levels, and attempt to add the player to your friends list and catch the result message. If it's successful, the player is part of your faction; if it failed, the player is of the opposing faction. This wouldn't work for cross-realm players, but I think the chances of someone of the opposite faction from another server /saying or /yelling anything in a non-default language are pretty slim. Finally, SendAddonMessage doesn't need a return value, as it's trivial to catch the message printed to the chat frame when sending fails, and hide it from the user. |
I, myself, am using the guid from achievements and as such, I get no information that can tell me what faction besides race... now with the Pandaren, I am out of luck... There is no valid unit for me to check the affiliation with... I mean if Blizz is going to classify them as 3 different races then they should return 3 different race returns or supply some method for distinguishing from guid or something besides by units.
|
Quote:
Quote:
As for the other addon examples, this may be an option, but for ChatLinkIcons, requesting additional data from the servers costs additional time that doesn't fit the time restraint I feel is appropriate. Quote:
|
As for the SendAddonChatMessage() needing a return, what I meant was that if it had a return value then it could be used for a opposing faction test without needing to wait for another event to fire. I get person's name from the guid, send an addon whisper, and if it failed with a return code then I wouldn't need faction from the GUID. I could also do the same thing with who-s but again I would have to wait for another event to continue on in the program( which I am guessing is my best bet to filter out the horde achievements )
I chose SendAddonChatMessage() as it would be invisible to the person receiving the message for my example... |
Quote:
If SendAddonChatMessage had a return value instead of printing the error to chat that could help too. Also, the delay between you trying to send an addon message and the client printing a "player not found" or similar error message to the chat frame is so infinitesimally small that I can't imagine it being unacceptable for something that is really just cosmetic, especially since you'd only "need" to do it for pandaren in /say and /yell. How often does that really happen, anyway? |
what I am doing is trying to filter out non same faction achievements out from my addon... who wants a popup asking if you want to congratulate a person of the opposing faction when they get an achievement? my problem is that the addon can work for people near you as well as people in your group and guild that nearby opposing pandaren can trigger the frame to appear. I can rewrite my faction test to treat them differently but what I was hoping for was some way to test within that event cycle instead of having to wait for another event to fire...
I looked through the events that I can register for the chat frame but http://www.wowwiki.com/Events/Communication has no listing for an error event... does anyone know what event fires when the SendAddonChatMessage fails to find its whisper target? I figure I will just put the Pandaren achievements into a queue for a second and send the message... if a error pops on the name the chat filter can remove them from the queue... if they still exist the onupdate handler can send them off to continue on their way to the grat frame. I looked into using the SendWho but it says that the WHO_LIST_UPDATED event only fires when the who list is open so that is a no go I already broke my achievement processing function into 2 pieces so it can now wait for a response from SendAddonChatMessage without freezing the computer. (I also rewrote my SameFaction function so it can call one of two passed functions to continue the processing if they match or not so it can handle waiting on pandaren) |
Wow Instant Messenger tries to look up the guild, class and level of whatever name you whisper. It appears to be using LibWho-2.0 for that. The call is made in Modules/Filters.lua. Maybe you can use that or its methodologies?
|
Quote:
However, you'd want to use ChatFrame_AddMessageEventFilter to catch and hide the message instead of registering your frame for the CHAT_MSG_SYSTEM event: Code:
-- Have a filter function ready: Quote:
|
Here'a a "quick" and dirty method for getting the faction from a unit's GUID using its tooltip:
Lua Code:
Probably not the best solution but maybe it'll help somebody. |
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
|
I left it as a global so I could test it directly in-game, if you're going to use it then it should probably be localized.
I should mention that the reason I had it cache the results wasn't for faster lookups but because sometimes OnTooltipSetUnit would fire more than once and I didn't want it calling the function again. I actually have to make a slight edit because unit GUIDs on the PTR (which was where I was testing this) are not the same as they are on live, which I didn't realize when I posted it. It's just the check that the GUID belongs to a player-type unit, which isn't strictly necessary anyway. Using debugprofilestop and scanning a handful of units it takes anywhere between 0.1 and 0.3 milliseconds for the first lookup. For reference, 60 fps is one frame every ~16 milliseconds, so I don't think it'll be too much of a problem. I did notice one caveat while scanning for players in the combat log to test it: if they're sufficiently higher level than you the tooltip doesn't say what faction they are, just their name and "Level ?? Race Class (Player)". I don't know how much this matters because as long as it doesn't match your faction string it's probably not your faction. An alternative might be to compare the :GetTextColor of the first line of the tooltip (the name) since it appears to be colored based on reaction. edit: I don't think it actually does change the color of the text unless it has a unit id or something, so that won't work. |
All times are GMT -6. The time now is 08:37 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI