PDA

View Full Version : GuildInfo()


wisywig
03-11-2006, 09:46 AM
The API command GuildInfo() returns the date of creation of the guiold, number of members and number of accounts - exctly the information I want to collect regularly.

However this information is printed to the chat channel, and what I want to do is capture it in a string (or set of strings) so that I can save it to the addon table which is stored in SavedVariables on logout.

Any ideas of the basic code needed to get this into a string ready to save, please? (Looking for the lua code here).

(I'm already grabbing data on individual members and saving that out on logout with no difficulty).

Suggestions appreciated

Thanks

Klishu
03-11-2006, 10:17 AM
Hi there Wisywig!

Well I don't know exactly why you would need the number of accounts and there doesn't seem to be any API function that returns the number of accounts but you can check for the other two easily:

For the Guild Name:
local guildName = GetGuildInfo("player");

For the Number of Members in the guild:
local guildMembers = GetNumGuildMembers(true);

You can use GetNumGuildMembers() instead to get the number of guild members which are online.

GetGuildInfo(): http://www.wowwiki.com/API_GetGuildInfo
GetNumGuildMembers(): http://www.wowwiki.com/API_GetNumGuildMembers

Hope that helps! :thumbsup:

wisywig
03-11-2006, 10:39 AM
Ah, the reason I want the number of accounts is to help keep track of alts:mains ratios, and which alt belongs to which main.

The only way I can see to obtain the number of accounts (ie. individual players rather than the number of characters) is through the GuildInfo() call.

The problem is how to intercept the result of that call so that instead of it being displayed in the chat channel it can be stored in a variable and saved out with other information about the guild and its members later on.

The saved information is later dumped to a database and used for various purposes such as displaying on the guild website, checking a username is a member etc, etc.

So what I'm trying to find out is:

How do I intercept the result of the GuildInfo() call such that the text it returns can be directed to a variable rather than go to the chat channel.

(I think I have now figured out that I need to check one of the 'On CHAT' or similar events and compare the message in that with the format of the message GuildInfo() returns... then intercept from there.)

I should imagine the same issue would arise if someone was trying to log the chat channel and save the conversation out for later study.

Klishu
03-11-2006, 10:55 AM
Well I don't see any way of hiding message you print to the chat window but you could try doing it in when the player enters the world so that it appears alongside the other useless information that no one takes any notice of.

So after you register for the event "CHAT_MSG_SYSTEM" and sending a GuildInfo() call: (arg1 is the variable that gets contains the text sent by CHAT_MSG_SYSTEM


numMembers = tonumber(string.sub(arg1,string.find(arg1,"(%d+) players"),string.find(arg1," players") - 1));
numAccounts = tonumber(string.sub(arg1,string.find(arg1,"(%d+) accounts"),string.find(arg1," accounts") - 1));


That will most probably do it! :wink:

wisywig
03-11-2006, 04:24 PM
Thanks, that's exactly the sort of help I was after. I should be able to manage the rest from that.

Hiding the chat message is irrelevant really as the little tool is only for me anyway (I'm the mug who volunteered to do the guild website, recordkeeping and related admin). *grin*

(Although I have plenty of coding experience in different languages, and integrating different systems to work together, these addon structures together with lua are sending me in screaming, hair-tearing circles! Who needs nasty elites and bosses and gankers and bots and farmers in Wow... this is just as masochistic? *grin*)