The addon I'm trying to make is for welcoming guildmembers when they come online. The follwing is what I've got so far, it's not working. Therefor I would like some help, since this is my first addon. I've modified addons before, but my knowledge of addon is limited (for now).
function WelcomeGuildmember_OnLoad(this)
self:RegisterEvent("CHAT_MSG_GUILD");
DEFAULT_CHAT_FRAME:AddMessage("Welcome Guildmember v0.1 loaded.",102,153,204);
end
function WelcomeGuildmember_OnEvent(this, event)
if event == "CHAT_MSG_GUILD" then
local online = string.lower(arg1);
local name = string.lower(arg4);
if (string.find(online, " is online") ~= nil) then
SendChatMessage("hi " .. name, "GUILD");
end
end
end
Id probably suguest having it monitor guild chat looking for "is online", trouble is the message isn't from an actual person it just comes up as from [GUILD] so you would need to get what ever is written previous to what you are monitoring for.
I don't know much when it comes to the %d and so on.
What you want though is to monitor for "%c is online" and then print("hi %c")
Obviously %c is wrong.
online messages come up as
[GUILD] : Blahblah is online.
actual chat from guild members comes up as
[GUILD] [Blahblah]: I rock.
So checking for arg4 for the name won't work.
Remember no matter you do in life to always have a little fun while you are at it
I can confirm the guild message about a member coming online or going offline only has a value for arg1. You might be able to parse the message but the name is collored so it's not so straight forward.
function WelcomeGuildmember_OnEvent(this, event)
if event == "CHAT_MSG_GUILD" then
local name, online = string.match(arg1, "|c%x%x%x%x%x%x%x%x (%w*)|r is (%w*)")
if online == "online" then
SendChatMessage("hi " .. name, "GUILD");
end
end
end
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.