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:
local events = CreateFrame("Frame")
events:RegisterEvent("BN_TOON_NAME_UPDATED")
events:RegisterEvent("BN_FRIEND_TOON_ONLINE")
events:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
local t = {}
events:SetScript("OnEvent", function()
for x = 1, BNGetNumFriends() do
local id, name, _, _, _, _, client, online = BNGetFriendInfo(x)
local prev = t[id]
if prev and prev ~= client then
local message = prev == "App" and "FRIEND_ONLINE" or client == "App" and "FRIEND_OFFLINE"
if message then
for i = 1, NUM_CHAT_WINDOWS do
ChatFrame_MessageEventHandler(_G["ChatFrame"..i], "CHAT_MSG_BN_INLINE_TOAST_ALERT", message, name, nil, 0, nil, nil, nil, nil, nil, nil, 0, nil, id)
end
end
end
t[id] = online and client or nil
end
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".