1. Hi, I am working on an addon and part of it is splitting a raid in three arrays based on the talent specs of the raiders. Now my code works fine if I use it on random targets, but when I try to make a for loop to assign raiders to their array, it goes awry. It only grabs one player and puts him in the array. I believe this is because the loop runs faster than the server can respond with the inspect info (which is required to get information about talents). I'm very new to creating addons so I'm probably doing something terribly wrong ^^ I have read chapter 13, there isn't a whole lot about query events. Anyway here are some chunks of my code

          function AssignFrame_OnEvent(self, event, guid)
            spec = GetPrimaryTalentTree(true);
            class = UnitClass(raid[#raid]);
            if (isHealer(class, spec)) then
                table.insert(healers, raid[#raid]);
                elseif (isInterruptor(class, spec)) then
                table.insert(interruptors, raid[#raid]);
                else table.insert(dps, raid[#raid]);
            print(class .. spec);
            print("heal: " .. table.concat(healers,":"));
            print("int: " .. table.concat(interruptors, ":"));
            print("dps: " .. table.concat(dps, ":"));
          function talentTest()
            for i=1, GetNumRaidMembers(), 1 do
          AssignFrame:SetScript("OnEvent", AssignFrame_OnEvent)


     -- Sets class en name
     function getClassName(raidNumber)
        local name = GetRaidRosterInfo(raidNumber);
        table.insert(raid, name)

    btw I just realized some of my names might not be very fitting anymore, I'll change them later on ^^

    It's very difficult to see what is going on without all of the code. You need to register for the correct inspect events, and then its just a matter of looping over the members in your raid, one by one, not moving on to the next member until you've received the inspect information from the first one.

    Can you explain me how to wait till the addon has received the information from the server, because this seems to be the problem and can't for my life figure out how to make the loop wait

    Here is a link to all the code I currently have http://pastebin.com/8SpErWns Thanks!

    You can't just write code in the same way you normally do, because of precisely the reason you are encountering. You need to alter the way you are writing your code. Alternatively you could use coroutines, but that's way beyond anything I'm willing to explain in a forum.

    It's not an easy problem, so I'm not entirely sure what to tell you. You need something to trigger the 'scan', which starts by looking at the first member of your raid. It calls NotifyInspect() and then the function ends and does nothing more.

    When the event handler kicks in (i.e. the inspect event comes through) then once you've processed that raid member you perform another NotifyInspect() on the next player.

    That's the general premise.

    I think I have done it :) Your comment made me realize I shouldn't use a loop, but instead make use of recursive functions, which fixed the problem! Thanks allot ^^