Thread Tools Display Modes
12-09-15, 12:31 PM   #1
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Need help getting realmname from realID whispers

This is returning a blank for realm name. I cant use this unless I can get a realm name. And realm names are working since they show up in friends list on mouse over.

Code:
function GWL:CHAT_MSG_BN_WHISPER(Message, Sender, p3, p4, p5, p6, p7, p8, p9, p10, LineID, p12, p13, PresenceID)
  -- Turn bnet sender into toon name

  print('ID', Message, Sender, p3, p4, p5, p6, p7, p8, p9, p10, LineID, p12, p13, PresenceID)
  local _, ToonName, Client, RealmName = BNGetToonInfo(PresenceID)
end
  Reply With Quote
12-09-15, 12:50 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Their presence ID is argument 13.
  Reply With Quote
12-09-15, 09:43 PM   #3
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
p13 returns a nil, and PresenceID returns a valid number.
So it must be something else.
  Reply With Quote
12-09-15, 10:05 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
This is what a CHAT_MSG_BN_WHISPER event looks like:



The presence ID is the 13th argument, if your 13th argument is nil then your arguments are mislabeled.

Obviously your PresenceID is not a valid number or BNGetToonInfo would be returning valid data.

Here is a scripted example:
Lua Code:
  1. local f = CreateFrame('frame')
  2. f:SetScript('OnEvent', function(self, event, ...)
  3.     print(BNGetToonInfo(select(13, ...)))
  4. end)
  5. f:RegisterEvent('CHAT_MSG_BN_WHISPER')
You can type /run BNSendWhisper((BNGetInfo()), 'message') in-game to test it.

Last edited by semlar : 01-01-16 at 04:25 PM.
  Reply With Quote
12-10-15, 10:51 PM   #5
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
I tried this code. It returns a boolean true. So not sure why im getting different results than you.
  Reply With Quote
12-11-15, 02:27 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
He's running the arg through BNGetToonInfo(), which gives a boolean as its first return.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-19-15, 11:45 PM   #7
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Had someone from a different realm than mine on battlenet friends whisper me. The server name came up blank.

Code:
local f = CreateFrame('frame')
f:SetScript('OnEvent', function(self, event, ...)
      local _, _, _,name =  BNGetToonInfo(select(13, ...))
      print(':' .. name .. ':')
end)
f:RegisterEvent('CHAT_MSG_BN_WHISPER')
So what am I doing wrong?
  Reply With Quote
01-01-16, 01:43 PM   #8
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
So no ideas as to a solution to this problem?
How can I always get a valid realm name from a realID whisper?
  Reply With Quote
01-01-16, 04:34 PM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Since the code you posted works (I just tested it), I'm guessing they aren't sending the message from a character, or you have some other issue confounding it.
  Reply With Quote
01-05-16, 06:14 PM   #10
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Got it working now, not sure what was up.

Thanks
  Reply With Quote
01-06-16, 07:45 PM   #11
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Ok I did some further testing. The realm name is only nil when I get a whisper from someone on the same realm as me. But if it comes from a different realm then I get a realm name.

Is this intendid?
  Reply With Quote
01-06-16, 07:46 PM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by galvin View Post
Ok I did some further testing. The realm name is only nil when I get a whisper from someone on the same realm as me. But if it comes from a different realm then I get a realm name.

Is this intendid?
Yes. 10char
  Reply With Quote
01-06-16, 10:06 PM   #13
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
I don't know what code you're using that you're having a problem with, but BNGetToonInfo is what the interface uses to display information in the tooltip about the characters your friends are logged into when you hover over them in the friends list, which shows their realm regardless of whether you're on the same one.

What you're describing sounds more like you're getting a normal whisper from another player and trying to get the realm by splitting the text after the hyphen, because those don't contain the realm when they're from a player on your own server.

So to me it sounds like you're seeing output from a completely different script and confusing it with this one.
  Reply With Quote
01-08-16, 04:07 PM   #14
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Its not a normal whisper cause the event wouldn't fire unless it comes from battlenet.

I tested this multiple times. If I get a whisper from a friend thats on different realm I can get a realm name. If they're on the same realm the realm name comes back nil. And I have this coded into my addon and it works perfect. Cause my addon only accepts battlenet whisper commands if they're on the same realm and it does that by checking for a nil on the realm name and its working fine.

The code I posted above proves that.
  Reply With Quote
01-09-16, 12:09 PM   #15
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
BNGetToonInfo is not at all guaranteed to return the WoW toon. It can - and seems to prioritise, even (maybe because they logged in to that first) - return the Battle.net desktop client "toon" if they're logged into that. Default UI seems to use the toon ID returned from BNGetFriendInfo, and then pass that to BNGetToonInfo, so you could try that.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-11-16, 09:14 PM   #16
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
How do I use BNGetFriendInfo with bn chat whisper?
Dont think that event returns an index.
  Reply With Quote
01-12-16, 05:50 AM   #17
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
BNGetFriendInfoByID gives all the same info as BNGetFriendInfo, but takes a presenceID (which is somewhere in the message args) instead of an index.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-16, 05:01 PM   #18
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Thanks

I figured out how to use that function to create what I needed. Works very well now.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help getting realmname from realID whispers


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off