View Single Post
11-03-10, 06:22 PM   #15
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
WoW doesn't give you any details about who logged on in the guild via any guild or player event. Therefore your only main option is to register for the CHAT_MSG_SYSTEM event, then parse the arguments that are passed in.

http://wowprogramming.com/docs/events/CHAT_MSG_SYSTEM

In this code, "self" is the frame that registered the event, I shall repeat this, it is the frame that registered the event, not some reference to your player, playername or whatever, it is a FRAME.

"event" is the event that was triggered.

Code:
function GuildLevelUp.OnEvent(self, event, ...)
	local lvl = UnitLevel("player")
	local race = UnitClass("player")
	if event == "PLAYER_LEVEL_UP" then
		SendChatMessage("DING! Yeah thats right im now a level "..lvl.." "..race..".", "GUILD", nil, nil);
	elseif event =="CHAT_MSG_SYSTEM" then
                local message = ...
                print(message)	
	end
end
Here, you want to replace the print(message) with code to extract the name out from the string "ABC" from the string "ABC has come online." and then use it to send a greeting over guild chat.

Google a bit for the Lua string functions string.match() or string.find().

You don't want to use PLAYER_ENTERING_WORLD. This event only fires whenever you (and only you) zone across worlds, and does not have any varargs passed in.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote