Quite a few useless globals there. If you don't specify "local" on a variable (your AllCharNames), it's global by default. Also, all tables are a reference, so all that assigning you're doing between _G and an already global variable is pretty much useless.
Also, you definining AllCharNames in line1 of your code is also useless, as it's overriden by the time your SavedVars are loaded.
Also, craptons of global namespace violations. And I mean craptons.
---------- Post added 2011-04-13 at 08:32 AM ----------
There. Scrap your xml file. Replace your lua file. I ripped out the global leaks and renamed your SavedVar table. Adjust your toc accordingly.
Code:
local addon = CreateFrame("Frame","CS490Frame")
local country = GetCVar("realmList"):sub(1,2)
local realm
local UnitName, GetNumRaidMembers, GetNumPartyMembers, UnitIsPlayer =
UnitName, GetNumRaidMembers, GetNumPartyMembers, UnitIsPlayer
local function savePlayerInfo(uID)
local unitname, unitrealm = UnitName(uID)
realm=realm or GetRealmName()
CS490_CharNames[unitname.."-"..(unitrealm or realm).."-"..country]=""
end
local function GetPartyInfo()
if GetNumRaidMembers() > 0 then
for i=1, GetNumRaidMembers() do
savePlayerInfo("raid"..i)
end
elseif GetNumPartyMembers() > 0 then
for i=1, GetNumPartyMembers() do
savePlayerInfo("party"..i)
end
end
end
local function GetTargetInfo()
if UnitIsPlayer("target") then
savePlayerInfo("target")
end
end
local function GetChatInfo(author)
if author then
realm = realm or GetRealmName()
if not author:find("-") then
author = author.."-"..realm
end
CS490_CharNames[author.."-"..country]=""
end
end
addon:SetScript("OnEvent", function(self, event, arg1, arg2)
if event == "PLAYER_TARGET_CHANGED" then
GetTargetInfo()
elseif event == "PARTY_MEMBERS_CHANGED" then
GetPartyInfo()
elseif event == "ADDON_LOADED" and arg1 == "CS490Final" then
CS490_CharNames = CS490_CharNames or {}
elseif arg2 then
GetChatInfo(arg2)
end
end)
for _, event in ipairs({"PLAYER_TARGET_CHANGED", "PARTY_MEMBERS_CHANGED", "ADDON_LOADED", "CHAT_MSG_CHANNEL", "CHAT_MSG_ACHIEVEMENT", "CHAT_MSG_BATTLEGROUND", "CHAT_MSG_EMOTE", "CHAT_MSG_GUILD", "CHAT_MSG_SAY", "CHAT_MSG_YELL", "CHAT_MSG_WHISPER", "CHAT_MSG_TEXT_EMOTE", "CHAT_MSG_WHISPER_INFORM", "CHAT_MSG_RAID", "CHAT_MSG_PARTY"}) do
addon:RegisterEvent(event)
end