Thread: RealID list
View Single Post
04-01-12, 08:15 PM   #10
cormanthor
A Warpwood Thunder Caller
 
cormanthor's Avatar
AddOn Compiler - Click to view compilations
Join Date: Nov 2008
Posts: 97
I was unable to get any response at all from BN_FRIEND_TOON_ONLINE, however the following modifications seem to have fixed it:
Lua Code:
  1. -- People Detector for CormanthorUI
  2.  
  3. -- Create the color table (redundant, but necessary)
  4. local colorScheme = {
  5.     death_knight = "C41F3B",
  6.     druid = "FF7D0A",
  7.     hunter = "ABD473",
  8.     mage = "69CCF0",
  9.     monk = "558A84",
  10.     paladin = "F58CBA",
  11.     priest = "FFFFFF",
  12.     rogue = "FFF569",
  13.     shaman = "0070DE",
  14.     warlock = "9482C9",
  15.     warrior = "C79C6E"
  16. }
  17.  
  18. -- Create the frame and listen to events
  19. local cormPD = CreateFrame("frame", "PeopleDetector", Minimap)
  20. cormPD:SetSize(200,100)
  21. cormPD:SetPoint("TOPRIGHT", Minimap, "TOPLEFT", -10, 0)
  22. cormPD:RegisterEvent("PLAYER_ENTERING_WORLD")
  23. cormPD:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
  24. cormPD:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
  25. cormPD:RegisterEvent("PLAYER_FLAGS_CHANGED")
  26. local text = cormPD:CreateFontString()
  27. text:SetFont("Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE")
  28. text:SetPoint("TOPRIGHT", cormPD)
  29. text:SetJustifyH("RIGHT")
  30. local myRealm = GetRealmName()
  31.  
  32. -- List the first name and toon name of all RealID friends
  33. local function Event_Handler(self, event, ...)
  34.     local online = select(2,BNGetNumFriends())
  35.     local list = ""
  36.     local friendName = ""
  37.     local toonName = ""
  38.     local toonClass = ""
  39.     local toonLevel = ""
  40.     local toonRealm = ""
  41.     for i = 1,online do
  42.         friendName = select(2,BNGetFriendInfo(i)) or "UNKNOWN"
  43.         toonName = select(4,BNGetFriendInfo(i)) or "UNKNOWN"
  44.         toonClass = gsub(strlower(select(8,BNGetFriendToonInfo(i,1)))," ","_") or "priest"
  45.         toonLevel = select(11,BNGetFriendToonInfo(i,1)) or 0
  46.         toonRealm = select(4,BNGetFriendToonInfo(i,1)) or myRealm
  47.         if toonRealm == myRealm then
  48.             list = list..friendName
  49.         else
  50.             list = list.."|cff0080FF"..friendName.."|r"
  51.         end
  52.         if toonClass then
  53.             if toonName then
  54.                 list = list.." (|cff"..colorScheme[toonClass]..toonName.."|r"
  55.             else
  56.                 list = list.." (|cff808080UNKNOWN|r"
  57.             end
  58.             if toonLevel then
  59.                 list = list.." "..toonLevel..")\n"
  60.             else
  61.                 list = list..")\n"
  62.             end
  63.         end
  64.     end
  65.     text:SetText(list)
  66. end
  67.  
  68. cormPD:SetScript("OnEvent", Event_Handler)
__________________
Some days it's just not worth chewing through the restraints...
  Reply With Quote