View Single Post
08-05-13, 05:16 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
if not (myChars or herChars) then return end
Based on this line, the code you posted will never run at all, since myChars and herChars are not defined when that line is read (or anywhere else in the file). Please post your entire, actual code when asking for help with code. Posting partial or fake code is just a waste of time -- both for the person who reads your code and makes suggestions that may not even be relevant to your real code, and for you to read the suggestions and figure out whether they are relevant.

If your real code contains private information (such as your character/server names) you can change them to dummy values, but don't alter the basic structure or the types of variables (eg. if myChars is a table in your real code, it should be a table in the code you post).

Originally Posted by Caellian View Post
I would like a way to feed whoever needs to be promoted or kicked into a table and then do what needs to be done on each of the elements of that table 1 by 1 on a timer (1 or 2 sec between each action) and then obviously remove what's done from the table.
I'd suggest using an animation group instead of your GuildManagement function. Replace the whole function with this:

http://pastebin.com/qiVTsemb

Then, anywhere you would call GuildManagement(), call timer:Play() instead.

Since you cannot pass extra variables (eg. enabled) this way, it uses a flag set on the timer object instead. By default the flag is set, so no actions will actually be performed (you'll just see prints describing the actions that would otherwise happen). To make it actually promote/remove people, set timer.testMode = false before timer:Play().

Other notes:

(1) Rather than mentally switching between 0-based and 1-based rank indices, just add 1 to the rank from GetGuildRosterInfo so it matches the 1-based rank you'll be passing to SetGuildMemberRank and you don't have to think about it.

(2) I cleaned up some of the redundant if (X and Y and Z) or (X and Y and Q) or (X and Y and A) then logic. If you really like checking X every time, I guess you can change it back, but remember that rankIndex needs to be adjsuted by +1 in anything copied from your old code.

(3) There is some basic protection against infinite looping if an action is failing. Rather than attempting the same action over and over, it should print a message telling you about the failed action, and then stop running.

(4) Finally, I did not test anything in-game, so there may be typos. If there are, and you can't figure them out on your own, please post your new complete code and the error message from BugSack.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote