currently this code will get the MOTD & guild INFO, look for tax and a number and set tax rate for that number.
I would also like it to search OfficerNote for self, ie. the addon user and set a tax rate to that if exsists. Seems only to error.
full lua function, the code is red is what im trying to make work.
Code:
function SetGuildTaxRate()
for index=1, GetNumGuildMembers() do
officernote = GetGuildRosterInfo(index);
--will give you the 'officernote'.
officernote = officernote:lower();
settaxamount3 = officernote:match("tax.+");
--get Guild MTOD and see if it contains a tax amount, if it does change it to that
guildMOTD = GetGuildRosterMOTD();
guildMOTD = guildMOTD:lower();
settaxamount = guildMOTD:match("tax.+");
--get guild INFO and see if it contains a tax amount, if it does change it to that
guildINFO = GetGuildInfoText();
guildINFO = guildINFO:lower();
settaxamount2 = guildINFO:match("tax.+");
-- Officers Note Tax
if(settaxamount3 ~= nil) then
settaxamount3 = settaxamount3:match("%d+");
SourceTax:SetText("NOTE");
if(settaxamount3 == nil) then
--no tax found in Officers note, set to default of 10%
settaxamount3 = 10;
else
gtax_amount = settaxamount3;
end
-- MOTD tax
elseif(settaxamount ~= nil) then
settaxamount = settaxamount:match("%d+");
SourceTax:SetText("MOTD");
if(settaxamount == nil) then
--no tax found in guildMOTD, set to default of 10%
settaxamount = 10;
else
gtax_amount = settaxamount;
end
-- INFO tax
elseif(settaxamount2 ~= nil) then
settaxamount2 = settaxamount2:match("%d+");
SourceTax:SetText("INFO");
if(settaxamount2 == nil) then
--no tax found in info, set to default of 10%
settaxamount2 = 10;
else
gtax_amount = settaxamount2;
end
else
--no tax found in guildMOTD or info, set to default of 10%
gtax_amount = 10;
SourceTax:SetText("SELF");
end
--Make sure the tax amount isnt set above 100% or below 0%, if it is set it to 10%
gtax_amount = gtax_amount + 0; -- this converts tax to a number
if (gtax_amount > 100) then
gtax_amount = 10;
end
if (gtax_amount < 0) then
gtax_amount = 10;
end
end