1. http://wowprogramming.com/docs/api/GetNumGuildMembers

     

  2. http://wowprogramming.com/docs/api/GetNumGuildMembers

     

  3. ok, hit the save button on this one but didn't realize I was posting.  So I'll start again... ;)

    I'm running into some interesting issues with the guild api, specifically the following:

    http://wowprogramming.com/docs/api/GetNumGuildMembers

    I was having difficulty getting an accurate number of guild members (online and off) from that method until I ironed out the following code:

        if GetGuildRosterShowOffline() == nil then

            SetGuildRosterShowOffline(1)

        end

        GuildRoster()

    Now the problem I'm running into is much simplier, but harder to solve without some sort of sleep or delay method.

    If I run the above code, and then immediately after use a statement that includes GetNumGuildMembers, the value that is returned is 0.  So there is some delay until the GUILD_ROSTER_UPDATE fires.

    Any ideas on how I should attack introducing a delay so that I can get an accurate number?

     

  4. This is standard event based programming, covered in a few different places in the book. Once you've asked the server to update the guild roster, you need to wait for the event before you try processing.  For example:

    -- Create a frame and register an event handler to catch the GUILD_ROSTER_UPDATE

    local frame = CreateFrame("Frame")

    frame:RegisterEvent("GUILD_ROSTER_UPDATE")

    frame:SetScript("OnEvent", function(self, event, ...)

      if event == "GUILD_ROSTER_UPDATE" then

        print("Your guild has " .. GetNumGuildMembers() .. " members in it")

      end

    end)
    -- Trigger the update

    if GetGuildRosterShowOffline() == nil then

        SetGuildRosterShowOffline(1)

    end

    GuildRoster()