help debug plz

85 Orc Warrior
5390
Hi need a lil help debugging this code,

for i = 1, GetNumGuildMembers() do
local rank, rankIndex, repstanding = GetGuildRosterInfo(i)
if (repstanding == 4) then
SetGuildMemberRank(index, 7)
elseif repstanding == 5 then
SetGuildMemberRank(index, 6)
elseif repstanding == 5 then
SetGuildMemberRank(index, 5)
elseif repstanding == 6 then
SetGuildMemberRank(index, 4)
elseif repstanding == 7 then
SetGuildMemberRank(index, 3)
end
end

It's meant to promote guild members based on there guild rep, just needs a lil tweeking.
Reply Quote
100 Dwarf Mage
11375
You're using i as the for loop variable, but you're passing index (which is undefined, so it will always be nil) to SetGuildMemberRank.

for i = 1, GetNumGuildMembers() do
local rank, ranki, repstanding = GetGuildRosterInfo(i)
if (repstanding == 4) then
SetGuildMemberRank(i, 7)
elseif repstanding == 5 then
SetGuildMemberRank(i, 6)
elseif repstanding == 5 then
SetGuildMemberRank(i, 5)
elseif repstanding == 6 then
SetGuildMemberRank(i, 4)
elseif repstanding == 7 then
SetGuildMemberRank(i, 3)
end
end
Reply Quote
85 Orc Warrior
5390
OMG /bow
Reply Quote
85 Orc Warrior
5390
still needs tweeking,it demoted every1 to rank 7 only

for i = 1, GetNumGuildMembers() do
local rank, ranki, repstanding = GetGuildRosterInfo(i)
if (repstanding == 4) then
SetGuildMemberRank(i, 7)
elseif repstanding == 5 then
SetGuildMemberRank(i, 6)
elseif repstanding == 6 then
SetGuildMemberRank(i, 5)
elseif repstanding == 7 then
SetGuildMemberRank(i, 4)
elseif repstanding == 8 then
SetGuildMemberRank(i, 3)
end
end

any idea what the mistake is?
Edited by Badsyntex on 9/24/2012 12:46 AM PDT
Reply Quote
100 Dwarf Mage
11375
After looking at the documentation on GetGuildRosterInfo, it turns out that the standingID is the sixteenth return value, not the third.

for i = 1, GetNumGuildMembers() do
local repstanding = select(16, GetGuildRosterInfo(i))
if repstanding == 4 then
SetGuildMemberRank(i, 7)
elseif repstanding == 5 then
SetGuildMemberRank(i, 6)
elseif repstanding == 6 then
SetGuildMemberRank(i, 5)
elseif repstanding == 7 then
SetGuildMemberRank(i, 4)
elseif repstanding == 8 then
SetGuildMemberRank(i, 3)
end
end


You could also use this code:local repranks = { -- [repStanding] = rankIndex
[4] = 7,
[5] = 6,
[6] = 5
[7] = 4,
[8] = 3,
}

for i = 1, GetNumGuildMembers() do
local repStanding = select(16, GetGuildRosterInfo(i))
local newRank = repranks[repStanding]
if newRank then
SetGuildMemberRank(i, newRank)
end
end


http://www.wowpedia.org/API_GetGuildRosterInfo
Edited by Choonster on 9/24/2012 12:58 AM PDT
Reply Quote
85 Orc Warrior
5390
Legend!!!!!!!!!!!!!!!!!
Reply Quote
85 Orc Warrior
5390
Hi again, next question is,

for i = 1, GetNumGuildMembers() do
local repstanding = select(16, GetGuildRosterInfo(i))
if repstanding == 4 then
SetGuildMemberRank(i, 9)
elseif repstanding == 5 then
SetGuildMemberRank(i, 8)
elseif repstanding == 6 then
SetGuildMemberRank(i, 7)
elseif repstanding == 7 then
SetGuildMemberRank(i, 6)
elseif repstanding == 8 then
SetGuildMemberRank(i, 5)
end
end

This works perfectly, but need to be able to promote to raiders/officers rank regardless of there guild rep,

is there some way so once there promoted to this rank the mod will just ignore them.
Reply Quote
100 Dwarf Mage
11375
-- The index of the rank at or above which members should not be promoted/demoted based on reputation
-- Rank 0 is the GM, rank 1 is the rank below GM, rank 2 is the rank below that, etc.
local MIN_RANK_INDEX = 4

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
if rankIndex > MIN_RANK_INDEX then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
if repstanding == 4 then
SetGuildMemberRank(i, 9)
elseif repstanding == 5 then
SetGuildMemberRank(i, 8)
elseif repstanding == 6 then
SetGuildMemberRank(i, 7)
elseif repstanding == 7 then
SetGuildMemberRank(i, 6)
elseif repstanding == 8 then
SetGuildMemberRank(i, 5)
end
end
end


Change MIN_RANK_INDEX to suit your needs.
Reply Quote
85 Orc Warrior
5390
its coming back with LUA error

Message: Interface\AddOns\Promotions\Promotions.lua:5: attempt to compare number with nil
Time: 09/24/12 21:45:21
Count: 1
Stack: Interface\AddOns\Promotions\Promotions.lua:5: in main chunk

Locals: MIN_RANK_INDEX = 4
(for index) = 1
(for limit) = 864
(for step) = 1
i = 1
rankIndex = nil
(*temporary) = "Snuffler"
(*temporary) = 1
(*temporary) = "Snuffler"
(*temporary) = "attempt to compare number with nil"
Reply Quote
100 Dwarf Mage
11375
That's odd that the rankIndex would be nil. I forgot to change the case on the repStanding variable, but that wouldn't cause the error.

Try this:-- The index of the rank at or above which members should not be promoted/demoted based on reputation
-- Rank 0 is the GM, rank 1 is the rank below GM, rank 2 is the rank below that, etc.
local MIN_RANK_INDEX = 4

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
if rankIndex and rankIndex > MIN_RANK_INDEX then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
if repStanding == 4 then
SetGuildMemberRank(i, 9)
elseif repStanding == 5 then
SetGuildMemberRank(i, 8)
elseif repStanding == 6 then
SetGuildMemberRank(i, 7)
elseif repStanding == 7 then
SetGuildMemberRank(i, 6)
elseif repStanding == 8 then
SetGuildMemberRank(i, 5)
end
end
end
Reply Quote
85 Orc Warrior
5390
AWESOME TYVM,

One last question, it spams me with "Internal guild error." in my chat window, but no LUA error pop up. any idea what that is?
Edited by Badsyntex on 9/24/2012 5:26 AM PDT
Reply Quote
100 Dwarf Mage
11375
I think it might be the game taking time to update to all the changes you've just made. It probably won't harm anything.
Reply Quote
85 Orc Warrior
5390
TY once again for all your help today!!!!
Reply Quote
85 Orc Warrior
5390
Still getting internal guild error msg in game chat window,
is there a function to ignore if ppl are the correct rank or a way to disable the error msg


local MIN_RANK_INDEX = 4

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
if rankIndex and rankIndex > MIN_RANK_INDEX then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
if repStanding == 5 then
SetGuildMemberRank(i, 8)
elseif repStanding == 6 then
SetGuildMemberRank(i, 7)
elseif repStanding == 7 then
SetGuildMemberRank(i, 6)
elseif repStanding == 8 then
SetGuildMemberRank(i, 5)
end
end
end

Plz help :)
Edited by Badsyntex on 9/24/2012 6:11 PM PDT
Reply Quote
100 Dwarf Mage
11375
local repranks = { -- [repStanding] = rankIndex
[5] = 8,
[6] = 7
[7] = 6,
[8] = 5,
}

local MIN_RANK_INDEX = 4

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
local newRank = repranks[rankIndex]
if rankIndex and rankIndex > MIN_RANK_INDEX and newRank and newRank ~= rankIndex then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
SetGuildMemberRank(i, newRank)
end
end
Reply Quote
85 Orc Warrior
5390
WOOT, no more "Internal guild error" TYVM /bow

/ Choonster for president 2013
Edited by Badsyntex on 9/28/2012 3:40 PM PDT
Reply Quote
85 Orc Warrior
5390
question 1,

is there a variable to limit this to maybe 50 people at a time? (over 900 people at once is hardcore.)

question 2,

something is wrong with this code, (idea is for it to premote when opening the guild tab, instead of reload ui)

GuildFrame:HookScript('OnShow', UpdateRanks)

if(GuildFrame:IsShown()) then
UpdateRanks()
end
Reply Quote
100 Dwarf Mage
11375
question 1,

is there a variable to limit this to maybe 50 people at a time? (over 900 people at once is hardcore.)

local repranks = { -- [repStanding] = rankIndex
[5] = 8,
[6] = 7
[7] = 6,
[8] = 5,
}

local MIN_RANK_INDEX = 4
local MAX_COUNT = 50 -- The maximum number of people to promote at once.

local function UpdateRanks()
local count = 0

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, _, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
local newRank = repranks[rankIndex]
if rankIndex and rankIndex > MIN_RANK_INDEX and newRank and newRank ~= rankIndex then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
SetGuildMemberRank(i, newRank)
count = count + 1
if count == MAX_COUNT then
break
end
end
end
end


09/28/2012 06:35 PMPosted by Badsyntex
something is wrong with this code, (idea is for it to premote when opening the guild tab, instead of reload ui)

What's it doing wrong? Do you get any errors?
Reply Quote
85 Orc Warrior
5390
once again /bow :)

next question, is it possible to add the level variable? eg.

local repranks = { -- [repStanding] and/or level = rankIndex
[4] = 9,
[5] = 8,
[6] = 7
[7] = 6,
[8] = 5 & level <=90,
[9] = 5 & level ==90,

Hopefully my attempt doesn't make u laugh to hard :P
Edited by Badsyntex on 9/28/2012 6:57 PM PDT
Reply Quote
100 Dwarf Mage
11375
local generalRanks = { -- [repStanding] and/or level = rankIndex
[4] = 9,
[5] = 8,
[6] = 7
[7] = 6,
[8] = 5
}

local maxLevelRanks = { -- Override ranks for max level players (same format as generalRanks table)
[9] = 5
}

local MAX_LEVEL = 90 -- The current level cap
local MAX_COUNT = 50 -- The maximum number of people to promote at once.
local MIN_RANK_INDEX = 4

local function UpdateRanks()
local count = 0

for i = 1, GetNumGuildMembers() do
local _, _, rankIndex, level, _, _, _, _, _, _, _, _, _, _, _, repStanding = GetGuildRosterInfo(i)
local newRank = ( level == MAX_LEVEL and maxLevelRanks[repStanding] ) or ( generalRanks[repStanding] )
-- If the player is max level and their reputation level has an override rank, use it;
-- otherwise use the general rank for their reputation level (if there is one)

if (rankIndex and rankIndex > MIN_RANK_INDEX) and (newRank and newRank ~= rankIndex) then -- If this member is in a rank below MIN_RANK_INDEX, promote them based on reputation.
SetGuildMemberRank(i, newRank)
count = count + 1
if count == MAX_COUNT then
break
end
end
end
end


I just realised my previous two versions were using rankIndex as the table index instead of repStanding like they should have been. I've fixed that now.
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]