Player and server name from received whisper
Hello,
Sender's name from event CHAT_MSG_WHISPER now looks like "John-KirinTor" (without any space) if a whisp is received from John from Kirin Tor server (with a space) and even if you also play on Kirin Tor server. So, as we cann't perform a test on the server name because in this case the builtin function GetRealmName() will return "Kirin Tor", how could I do to know if John is on the same server as me ? If John is on the same server as me, and only in this case, I would like to split the server name, the easy part. Thanks. |
I remove the Space from the name i got from GetRealmName(), this seems to be the same what Blizzard does.
Ofcourse nobody can say what funny ideas they have next, perhaps changing case unpredictable. :) At the moment i use following in my code (which you have then to concatenate with the player's name): Lua Code:
PS: to get player and realm from sender i use following: Lua Code:
|
For any unit with a valid unitID UnitRealmRelationship(unitID) will return a constant among LE_REALM_RELATION_SAME|LE_REALM_RELATION_COALESCED|LE_REALM_RELATION_VIRTUAL
For chat you might be able to use name, realm = UnitFullName("player") and compare the realm return (I'm not sure if the realm return here is normalized and can be used for a direct comparison, no access to wow to test atm) You can also try passing the full name through Ambiguate("name","none") it should strip off the realm if it's same realm as you so you have an indirect way to test. Edit:Saw GnomeTEC's response, that should work for most cases but it also needs to strip out apostrophes and I'm not sure for the realms with special characters in their name (some French, Italian and Portuguese/Brazilian) The armory at least does Unicode normalization converting the accented chars to their base equivalent. |
Thanks for your replies :)
Is it interesting to know that the "shortened" server name can be found with Code:
local player, serverShortName = UnitFullName("player") |
Ah, i didn't know this thing with UnitFullName("player"). :)
But if this "shortens" the realm name corectly it's surely the better solution to get the own realm name. I will also have a look at this and propably change my own code. |
Quote:
I couldn't find anyone with a non-ASCII character, and didn't feel like going and making a character on a FR/IT/PT realm to check, but I suspect they are also used as-is in-game. |
Quote:
You can safely ignore my edit and use the first part of the post that's relevant to the question and apparently provides a suitable method. Edit: I also (with regard to armory) wasn't referring to the player name but the realm name. As an example this is what happens to the url for "Pozzo dell'Eternità" (an Italian realm) |
I don't know why but UnitFullName("player") sometimes returns NIL if called just after the VARIABLES_LOADED event, so I finally use GnomeTEC function :
Code:
shortenedSeverName = string.gsub(GetRealmName(), "%s+", "") Quote:
|
Quote:
You either want ADDON_LOADED with arg1 == 'YourAddonName' which guarantees saved variables initialization but not much else or even better PLAYER_LOGIN which ensures player information (including name / realm) are available. |
Quote:
:eek: :eek: |
All times are GMT -6. The time now is 10:24 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI