Thread Tools Display Modes
05-16-19, 10:02 PM   #1
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
BNGetGameAccountInfo() returning nil

This is a weakaura which has been working fine till recently.
So did a test had a friend whisper me thru bnet.
The IDAccount comes back 132.
BNGetFriendInfoByID(132) returns nil
rest blows up

So do I need change something or did blizzard break something?

Code:
function(Event, ...)
    local Msg = nil
    local Sender = nil
    
    if Event == "CHAT_MSG_WHISPER" then
        Msg = select(1, ...)
        Sender = Ambiguate(select(2, ...), 'none')
        
    elseif Event == "CHAT_MSG_BN_WHISPER" then
        Msg = select(1, ...)
        local IDAccount = select(13, ...)
        local IDGameAccount = select(6, BNGetFriendInfoByID(IDAccount))
        local _, ToonName, Client, RealmName = BNGetGameAccountInfo(IDGameAccount)
        
        if Client == 'WoW' and RealmName == GetRealmName() then
            Sender = ToonName
        end
    end
    
    if Sender then
        local Index = 0
        local Found = false
        local Player = nil
        local MaxMembers = GetNumGroupMembers()
        while Index < MaxMembers do
            Index = Index + 1
            Player = GetRaidRosterInfo(Index)
            if  Player and Player ~= '' and Player == Sender then
                Found = true
                aura_env.MessageText = format('%s\n%s', Sender, Msg)
                break
            end
        end
        return Found
    else
        return false
    end
end
  Reply With Quote
05-17-19, 01:05 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by galvin View Post
Code:
function(Event, ...)
The frame always sends itself as the first argument, followed by the event and the rest of the parameters. Everything else looks fine.

PS: You shouldn't run select(1,...) ever. You're telling it to return the list of arguments as-is starting from position 1 (the beginning). This accomplishes nothing and wastes CPU on a global lookup and a function call. The following code does exactly the same without any of the overhead.
Code:
Msg = ...
__________________
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)

Last edited by SDPhantom : 05-17-19 at 01:13 AM.
  Reply With Quote
05-18-19, 03:06 PM   #3
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
So the error is happening cause of something blizzard is doing then?
  Reply With Quote
05-19-19, 05:56 AM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
From what's posted, you have a missing arg in your function parameter list. Without it, the entire list is shifted over by one.

For example, it should be function(self, event, ...) not function(event, ...).
__________________
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
05-20-19, 05:24 AM   #5
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Originally Posted by galvin View Post
So the error is happening cause of something blizzard is doing then?
The manner in which you pass the function you use to process the events affects what arguments you get passed during runtime.

widget:SetScript("OnEvent, function(self, event, ...) end) the self would (in most cases) be same as widget, followed by the event that called the function, and a list of potential arguments.

In your code you mislabel it like widget:SetScript("OnEvent, function(event, ...) end) thus you now use event thinking it's the event name, but it's actually the widget reference, and the arguments following when unpacked like local arg1, arg2 = ... now actually set arg1 to be the event, then arg2 would be the first argument of that event.
__________________
Profile: Curse | Wowhead
  Reply With Quote
05-20-19, 10:40 PM   #6
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Well if I change Event, to a different parm, then its not going to be the actual event every time.
So not sure how I can fix. Its up to weakauras how it calls the function
  Reply With Quote
05-31-19, 02:28 PM   #7
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
This code is working fine now
Thanks for the help
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » BNGetGameAccountInfo() returning nil

Thread Tools
Display Modes

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