1. ok, ive tried to write this code 5 times now, and i keep failing..

    the 2nd time i wrote it, it worked... 30%, and was not a queue, it had an error where the script was talking to itself and not on the addon channel... yes it did communicate on the addon channel but was very random in making its descions...

    now... this is what im trying to accomplish.. it is a guild chat addon, so keep in mind.

    Build a QUEUE that allows many people to run this addon, and who ever is LEADER in the queue shuts off all other addons by "ADDONNAME:UnregisterEvent("THISEVENT")" but at the same time, the others that arent lead, still scan the addon channel to find out when the leader logs off, using the isUnitOnline(), the main idea is to give the GuildMaster priority over Officers and give Officers priority over Veterans.. etc...

    Now, The next part of the code, which i havent started ... mainly because i cant get the queue to turn off and turn on the addon on specified users the way it should, is to transmit the SAVEDVARIABLES in their database, and share them with other users running this addon, so they operate on a shared level of information... some information must allways remain unchangeable on the GuildMasters Database thou...

    here is my 4th attempt at writting this code... it is severly broken, but it is because i didnt waste time putting the exact variables in, Because im not sure how it is exactly gonna operate - But this is the design and style.. (i believe?!) and format it should look like..

     guildbot2 = CreateFrame("frame")
     local queue = 0
     guildbot2:SetScript("OnEvent", function(_, event, ...) guildbot2[event](...) end);
     local databaseupdate = CreateFrame("Frame", "ViewAddonMessageFrame")
     local function printMsg(_, _, prefix, msg2, type, sender)
     function QueueAdd( queue, qnewname, qnewvalue ) -- adds or creates a new value
        if queue == nil then -- if the queue is empty create a new one
           queue = { qname = qnewname, qvalue = qnewvalue } -- add this as root
           return queue -- return the new queue
           if qnewvalue < 1 then -- if less, recursively add
              return QueueAdd( queue, qnewname, qnewvalue )
           else -- otherwise, add same
              return QueueAdd( queue, qname, qvalue )
     function QueueMin( queue, qname) -- returns with the smallest value
        if queue == nil then -- if the queue is empty, return nil
           return nil
        else if queue ~= 0 then -- recursively
           return QueuePeek( queue, qname )
        else -- if no name is found, it will be the smallest value
           return queue
     function QueuePeek( queue, qname ) -- returns the next value without removing it
        local min = QueueMin ( queue, qname )
        return min.qvalue
     function QueueNext( queue, name )-- returns the next value after removing it from the queue
        local min = QueueMin ( queue, name )
        local minValue = min.qvalue
        if min.qvalue == nil then-- check to see if the minimum has children
           min = nil -- if so, remove it
        else -- otherwise, replace the minimum with the other value
           min = min.qvalue
        return minValue -- return the minimum value
        SendAddonMessage("GBOT!Q", "QUEUE DATA:", "GUILD", "SENDER")
     databaseupdate:SetScript("OnEvent", printMsg)
     function guildbot2.CHAT_MSG_GUILD(msg, sender, ...)
     --    if strfind(msg, string.upper("$TEST")) then
         queue = queue + 1
     SendAddonMessage("GBOT!Q", queue, "GUILD", "SENDER")
     --print("test?channel") --debugging
     --    end;

    and like i said, this doesnt work, its an almost perfect frame for the final code... just how it works...

    You don't really ask a question, and what you are attempting to solve is a very very difficult problem. If you have a specific question, I can try to answer it for you, but I'm not sure how to respond when there's no actual question..

    the question is:

    i failed 5 times, how do i make this work?

    I can't tell you how to write the addon.. I barely have time enough to write my own addons, spec things out and get everything working precisely as they need to. I can answer any specific questions you have, but a bunch of code with no description of what it does or what doesn't work doesn't give me all that much to work with.

    I'm a really helpful person, but I can't copy your code, put it in an addon, load up WoW, get people with the guild ready to test it, etc. You see my point, I'm sure..

    You've gotta give me more to work with.. I can't just make it work for you.

    The only comments I would make:

    You're conflating the 'queue' and the communication portion of the addon. A queue is trivial, its just a table that you add things to the end of the queue using table.insert and pop things from the queue using table.remove. You can peek just by looking at the first element. None of that is relevant really, since that's the easy part of the addon.

    You've gotta pick one. Do you want the communication working first or the queue? If it's a queue implementation, that's simple. Give me what you have and tell me what doesn't work and we'll see what we can do. If you want the communication stuff, drop the queue nonsense and just get that code working properly.

    Don't try to do them both at once, that's just going to confuse both of us.

    yea... i figured the communications would be easy... easier than this...

    What im trying to accomplish is this:

    Share QUEDATA variable on the addonchannel and it should be formated like this:

    username - Queue position - Rank

    client1 - 0 - GM

    client2 - 1 - officer

    client3 - 2 - officer

    client4 - 3 - member

    basically, client1 tells all the others to addon:unregisterEvent("ThisEvent")

    and client2-4 (or more..) continue to run this check

     if isUserOnline() == 0 then
     if Queue position = 0 then
     --remarked cause it shouldnt have to dissable if it is allready dissabled - unnecessary, just for example.
     --then somewhere down the code the final end would come in to close function

    but the queue has to function properly (not exactly sure how to do it either, i drove myself insane with saying the word QUEUE over and over..) to add the users in the queue who are currently running the addon by once again brodcasting on the addonchannel.. it really doesnt need a peek function, just a register and remove...

    maybe something like this: SendAddonMessage("GBOT!Q", "ONLINE", "GUILD", "SENDER")

    I don't know why you need a queue at all. What you're talking about is the dynamic election of a 'master' based on some criteria. Don't worry about unregistering events, just have it running all the time.

    1. When someone new signs on, they broadcast asking who the master is and what their rank is.
    2. If the new player has a higher rank than the current master, then they call for an election.
    3. Only those people who are higher than the current master send their rank, and one of those is chosen deterministically by some algorithm.
    4. The new master is broadcast to the channel so everyone knows who it is

    Why doesn't something like that work.

    ok 1 more time... i have an addon i built... and it has to unregister the event on all the other users running it otherwise when you enter a command you will get double posts... spam...

    ok about the 1,2,3,4... it might work,.,, but... the addon is a guild chat mod...

    basically it takes commands typed into the guild chat for example:


    will give you a list of commands availible... i choose a command driven interface, because other users dont have to download this addon and install it to have functionality with it... I will add more gui later...

    (reason why the addon has to have a master and dissable the others, otherwise your one command will trigger 5 responses...)

    you can check the addon out on curse or curseforge.. this is one of my most technical updates... and the queue is only 10% of the update from version 1.6.25 ---> 1.7

    here are some links if you need a little help understanding why it must shut the others off... trust me it will make perfect sense!




    all the same project... but this is killing me... i have some ideas to try, but... its not working the way i wanted it to...

    here is the list for this planned update from 1.6.25 --> 1.7

    adding this functionality, no new data just gears:

    --add Guildmaster detection, give priority to GM over officers, Give officers priority over Members.

    --if other users are using guildbot dissable and check queue for online update status

    -- disable guildmaster $GM command if not GM

    --check database --- update new users in database so officers can use guildbot and remain online when the gm isn't

    --check other status's and update current values for stats

    -- modify values for raidbot so when a new value is added when gm isnt online, it continually adds them to a total database

    --modify lagbot - can now share data to give average of users w/ guildbot

    --events - contests - website need to STAY on GM's database values at all times

    (sorry for the long post... but u can see its kinda techie...)

    Again, I cannot write the addon for you. If you have a question, I can answer it but I frankly just do not have the time to download your addon and then try to figure out what needs to be changed. I just cannot.