-
Posted by elfyau on Fri, 12 Dec 2014 06:33:50
this is the code i am using to welcome people to my guild but I would like it to wait 5-10 seconds before sending the message... how do i do this?
local function ProcessSystemMsg(msg)
place = strfind(ERR_GUILD_JOIN_S, "%s", 1, true) n = strsub(msg,place) name = strsub(n, 0,(strfind(n,"%s") or 0)-1) if format(ERR_GUILD_JOIN_S,name) == msg then return "join",name end
end local function HandleSystemMsg(event, ...)
local msg = select(2,...) local p, playerName = ProcessSystemMsg(msg) if p == "join" then --Edit the line below to make your own message. SendChatMessage("Welcome " .. playerName .. ", If you (or anyone else) are interested in joining our raid team please send a mail to Willybob.", "GUILD", nil) end
end k = CreateFrame("Frame") k:RegisterEvent("CHATMSGSYSTEM") k:SetScript("OnEvent", HandleSystemMsg)
-
Posted by boodaah on Fri, 19 Dec 2014 08:25:14
There's a new function you can use. C_Timer.After(duration, callback) – Calls the callback after duration seconds.
Try this change to the last line of your code:
local function ProcessSystemMsg(msg) place = strfind(ERR_GUILD_JOIN_S, "%s", 1, true) n = strsub(msg,place) name = strsub(n, 0,(strfind(n,"%s") or 0)-1) if format(ERR_GUILD_JOIN_S,name) == msg then return "join",name end end local function HandleSystemMsg(event, ...) local msg = select(2,...) local p, playerName = ProcessSystemMsg(msg) if p == "join" then --Edit the line below to make your own message. SendChatMessage("Welcome " .. playerName .. ", If you (or anyone else) are interested in joining our raid team please send a mail to Willybob.", "GUILD", nil) end end k = CreateFrame("Frame") k:RegisterEvent("CHATMSGSYSTEM") k:SetScript("OnEvent", C_Timer.After(5, HandleSystemMsg))