Hey all,
I'm new to the development side of WoW addons despite having years of coding experience on the desktop and web. I released my first addon last night - GuildInviteAssist;
http://www.wowinterface.com/download...iteAssist.html
It took around 8 hours of development with most of that being due to a lack of any previous knowledge of LUA.
There was one important thing that I didn't add in prior to release - Guild check. Obviously, the nature of the addon is guild recruitment, and in order to prevent being spammed with the chat message, I could either remove the message completely, or go down the proper route and perform a guild check.
Now, I've made some progress towards fixing this, but I need someone to point me in the right direction. I understand that in order to check if someone is guilded, you have to use the SendWho() and GetWhoInfo() functions. My problem is making this 'seamless'. Here's what I've currently got;
Lua Code:
local function onEvent(self, event, ...)
SetWhoToUI(1);
--else
if ( event == "CHAT_MSG_WHISPER" ) then
local message, senderName = select(1, ...);
if ( keyphraseHash[strlower(strtrim(message))] ~= nil ) then
playerName = senderName;
local whostring = string.format('n-"%s"',playerName);
SendWho(whostring);
--if (event == "WHO_LIST_UPDATE") then
local c,g = GetWhoInfo(1);
if (g ~= "") then
--SendChatMessage("You are currently in a guild. Please leave yours if you would like to join us!","WHISPER",slanguage,playerName); --uncomment to send a whisper back
do return end;
end
--end
hlink = string.format("|Hplayer:%s:1:WHISPER:%s|h[%s]|h", playerName, playerName, playerName);
msg = string.format("|cffff0000GuildInviteAssist:|cffffffff %s would like a guild invite!", hlink);
if tContains(playerList, playerName) then do return end
else table.insert(playerList,1,playerName)
end
local info = UIDropDownMenu_CreateInfo();
info = UIDropDownMenu_CreateInfo()
info.text = playerName
info.value = playerName
info.func = OnClick
UIDropDownMenu_Initialize(DropDownMenuTest, initialize);
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
end
end
You can see that I've had to comment out the "WHO_LIST_UPDATE" event handler. Long story short, this is the only way I could get it working. The problem I have is that this will open the who interface panel. Obviously, this is as bad as, if not worse than, the chatbox being spammed. I did try setting SetWhoToUI(0) and use a CHAT_MSG_SYSTEM handler instead, but I couldn't get it to work properly. The rest of the code works fine, it only adds a player to the table if they aren't already there, and it seems like Blizzards UI blocks repeat messages to the same player by default (within the same UI 'session'/between slash_reloadui's) and so you only ever receive one message for each individual player.
I figure that I need to use an "if elseif" statement for the different events, but I don't know exactly how to lay it out. I'm very much used to the PHP style (a hybrid between OOP and Procedural to be more specific) of coding where I'd call my own custom function from within another function in order to (for example) get a value, but LUA seems much different to that due to the RegisterEvent and SetScript handlers. I also imagine I need to do some sort of queueing due to the /who system limits, but again, I'm extremely new to LUA and I've no idea on where to go from here.
I wish there was an easier way to find out if someone was guilded. I know there's a close-range function, but I'd love to know if there's an easier way of finding out from range if a player is in a guild or not (something like a boolean return from a function, as opposed to dealing with event handlers).
Any guidance from the guru's? I want to avoid third-party libs if possible, unless it'll make my life significantly easier and you can provide a relevant example.