Page 1 of 1

Auto welcome addon for guildmembers

Posted: Thu May 12, 2011 3:43 pm
by Questionmark
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).

WelcomeGuildmember.toc

Code: Select all

## Title: Welcome Guildmember
## Version: 0.1
## Notes: Welcomes guildmembers who come online
## Author: Questionmark

WelcomeGuildmember.xml
WelcomeGuildmember.xml

Code: Select all

<Ui xmlns="http://www.extreme-x.net/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.extreme-x.net/UI.xsd">
	<Script file="WelcomeGuildmember.lua"/>
	<Frame hidden="true">
		<Scripts>
			<OnLoad>
				WelcomeGuildmember_OnLoad(this);
			</OnLoad>
			<OnEvent>
				WelcomeGuildmember_OnEvent(this, event);
			</OnEvent>
		</Scripts>
	</Frame>
</Ui>
WelcomeGuildmember.lua

Code: Select all

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

Re: Auto welcome addon for guildmembers

Posted: Thu May 12, 2011 9:34 pm
by lisa
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.

Re: Auto welcome addon for guildmembers

Posted: Fri May 13, 2011 1:44 am
by rock5
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.

Let me see... Try this

Code: Select all

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