View Single Post
05-19-14, 05:56 PM   #6
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
I had to make a couple changes because of some lua errors (arg4 couldn't be nil and NUM_CHAT_FRAMES was not working).

lua Code:
  1. local events = CreateFrame("Frame")
  2.       events:RegisterEvent("BN_TOON_NAME_UPDATED")
  3.       events:RegisterEvent("BN_FRIEND_TOON_ONLINE")
  4.       events:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
  5.  
  6. local t = {}
  7.  
  8. events:SetScript("OnEvent", function()
  9.     for x = 1, BNGetNumFriends() do
  10.         local id, name, _, _, _, _, client, online = BNGetFriendInfo(x)
  11.         local prev = t[id]
  12.         if prev and prev ~= client then
  13.             local message = prev == "App" and "FRIEND_ONLINE" or client == "App" and "FRIEND_OFFLINE"
  14.             if message then
  15.                 for i = 1, NUM_CHAT_WINDOWS do
  16.                     ChatFrame_MessageEventHandler(_G["ChatFrame"..i], "CHAT_MSG_BN_INLINE_TOAST_ALERT", message, name, nil, 0, nil, nil, nil, nil, nil, nil, 0, nil, id)
  17.                 end
  18.             end
  19.         end
  20.         t[id] = online and client or nil
  21.     end
  22. end)

It appears to be working so far. However, is there a way for it to display the message showing what game/character they log on? Right now this code is working in that it's outputting the message but for some reason it's showing the login like it was an app login.

For example (we'll use "A" as the app texture and "W" as the WoW texture), say my btag is Niketa and I want to log onto a toon named Rainbowcat.

I log onto the app.
Niketa (A Niketa) has come online.

I then log into WoW and onto Rainbowcat.
Niketa (A Niketa) has come online.

However, I would like it to display the message as if I wasn't logged into the app and I logged in from the normal client:

Niketa (W Rainbowcat) has come online.

Also when I first logged in it posted 12 people had "come online". Is there anything in the code that would have caused this or did 12 of my friends all happen to come online at the same time? lol
I just logged out and back in and 7 people "came online".

Last edited by Niketa : 05-19-14 at 05:58 PM.
  Reply With Quote