Ok, this is what I have now:
Code:
local frame = CreateFrame("Frame", nil, UIParent);
local rechallenge = {};
frame:RegisterEvent("DUEL_REQUESTED");
frame:SetScript("OnEvent", function(self, event, name)
local message = "Uh-uh-uh!";
if UnitFactionGroup("player") == UnitFactionGroup(name) then
if not rechallenge[name] then
message = message .. " You didn't say the magic word!";
end
else
DoEmote("NO", name);
end
HideUIPanel(StaticPopup1);
CancelDuel();
SendChatMessage(message);
rechallenge[name] = true;
end);
It works well except it repeats the message 3 times for some reason. So when someone first duels me it will say "Uh-uh-uh! You didn't say the magic word" thrice, then when that same person duels me again it will say "Uh-uh-uh!" thrice as well.
Any ideas on how to just say the message once?