local FRFGreet_VERSION="1.1";
local FRFGreet_NameMap = {};
local FRFGreet_MapSize = 0;
local numGNotes = 0
local FRFGreet_ONLINE = ".*%[(.+)%]%S*"..string.sub(ERR_FRIEND_ONLINE_SS, 20)
local FRFGreet_Debug = false;
function FRFGreetInit()
frmFRFGreet:SetScript("Onevent", FRFGreetEvent);
frmFRFGreet:RegisterEvent("PLAYER_ENTERING_WORLD");
frmFRFGreet:RegisterEvent("VARIABLES_LOADED");
frmFRFGreet:RegisterEvent("CHAT_MSG_CHANNEL_JOIN")
SlashCmdList["FRFGreet"] = GuildNoteOnLogin;
SLASH_FRFGreet1 = "/fg";
end
local function FRFGreet_debug(msg)
if( msg ~= nil and FRFGreet_Debug and DEFAULT_CHAT_FRAME ) then
DEFAULT_CHAT_FRAME:AddMessage("FRFGreet Debug: "..msg, .9, .2, .2);
end
end
local function FRFGreet_msg(msg)
if( DEFAULT_CHAT_FRAME ) then
DEFAULT_CHAT_FRAME:AddMessage(msg, .4, .7, .7);
end
end
local function FRFGreet_UpdateRoster()
local showoffline = GetGuildRosterShowOffline();
if(not showoffline) then
SetGuildRosterShowOffline(true);
end
local numONotes = 0;
numGNotes = 0;
local numFNotes = 0;
if IsInGuild() then
local numTotal = GetNumGuildMembers();
for gi=1, numTotal, 1 do
name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(gi);
local fullnote = name.."'s note: ";
if (note and note ~= "") then
fullnote = fullnote..note;
numGNotes = numGNotes + 1;
else
fullnote = fullnote.."(none)";
end
if(officernote and officernote ~= "") then
fullnote = fullnote.."; officer note: "..officernote;
numONotes = numONotes + 1;
end
--FRFGreet_debug("Adding "..name.." with note "..note);
FRFGreet_NameMap[name] = fullnote;
end
end
--[[ local numFriends = GetNumFriends();
for fi=1, numFriends, 1 do
fname, flevel, fclass, farea, fconnected, fstatus, fnote = GetFriendInfo(fi);
if (fnote and fnote ~= "") then
if (FRFGreet_NameMap[fname]) then
--FRFGreet_NameMap[fname] = FRFGreet_NameMap[fname].."; friend note: "..fnote;
else
FRFGreet_NameMap[fname] = "friend note: "..fnote;
end
numFNotes = numFNotes + 1;
end
end ]]--
if(not showoffline) then
SetGuildRosterShowOffline(false);
end
FRFGreet_MapSize = numGNotes + numONotes + numFNotes;
if( not IsInGuild() or numGNotes > 0 ) then
end
end
local function FRFGreet_GuildChannelJoin(msg)
local _, _, player = string.find(msg, FRFGreet_ONLINE);
if(player) then
FRFGreet_debug("Player found: "..player);
if(IsInGuild() and numGNotes < 1) then
FRFGreet_UpdateRoster()
end
local note = FRFGreet_NameMap[player];
if(note) then
---------------------------------------------
SendChatMessage("하이~ ".. player .."님이 접속하였습니다. 모두 차렷! 경례!!", "GUILD");
SendChatMessage("두와~안! 그여어얼!!!", "GUILD");
--------------------------------------------------
end
else
FRFGreet_debug("Player not found: "..msg);
end
end
-- slash handler
function GuildNoteOnLogin(msg)
if(msg == "reload") then
FRFGreet_UpdateRoster();
elseif(msg == "debug") then
FRFGreet_Debug = not (FRFGreet_Debug);
if(FRFGreet_Debug == true) then
FRFGreet_msg("Debugging messages on");
else
FRFGreet_msg("Debugging messages off");
end
elseif(msg == "dump") then
if(FRFGreet_Debug == true) then
FRFGreet_msg("Debugging messages on");
else
FRFGreet_msg("Debugging messages off");
end
FRFGreet_msg("Table size: "..FRFGreet_MapSize);
elseif( DEFAULT_CHAT_FRAME ) then
DEFAULT_CHAT_FRAME:AddMessage("FRFGreet v: "..FRFGreet_VERSION.." is now loaded.", .6, .4, .7);
end
end
function FRFGreetEvent(self, event, ...)
if(event) then
FRFGreet_debug("event: "..event);
end
if(event == "VARIABLES_LOADED") then
-- do nothing
elseif (event == "PLAYER_ENTERING_WORLD") then
FRFGreet_msg("FRFGreet v: "..FRFGreet_VERSION.." is now loaded.");
frmFRFGreet:UnregisterEvent("PLAYER_ENTERING_WORLD")
frmFRFGreet:RegisterEvent("CHAT_MSG_SYSTEM")
FRFGreet_UpdateRoster()
elseif (event == "CHAT_MSG_SYSTEM") then
if(IsInGuild() and numGNotes < 1) then
FRFGreet_UpdateRoster();
end
FRFGreet_GuildChannelJoin(...);
end
end