Thread Tools Display Modes
10-29-09, 08:46 PM   #1
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Question how to get Officers Note for self?

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
__________________

Last edited by Drshow : 10-29-09 at 09:23 PM.
  Reply With Quote
10-29-09, 09:09 PM   #2
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Aren't you missing a check for "name" being equal? For that matter, you're overwriting name in your for loop when I don't think you want to be. Also, unless I'm misunderstanding what you want to do, your for loop's end should be much higher up in the function. I didn't really completely read through this though; I'm too lazy to try to interpret it without indentation.
  Reply With Quote
10-29-09, 09:25 PM   #3
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Originally Posted by Akryn View Post
Aren't you missing a check for "name" being equal? For that matter, you're overwriting name in your for loop when I don't think you want to be. Also, unless I'm misunderstanding what you want to do, your for loop's end should be much higher up in the function. I didn't really completely read through this though; I'm too lazy to try to interpret it without indentation.
is there anyway you could show me edited code?
__________________
  Reply With Quote
10-29-09, 09:34 PM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Drshow View Post
is there anyway you could show me edited code?
If I understand you right, I think you want something like this:

Code:
...
local myName = UnitName("player")
for index=1, GetNumGuildMembers() do 
     local name,_,_,_,_,_,_,officerNote = GetGuildRosterInfo(index)
     if name == myName then
         officerNote = officerNote:lower()
         settaxamount3 = officerNote:match("tax.+")
         break
     end
end
...
  Reply With Quote
10-29-09, 10:16 PM   #5
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Arrow You my friend are Exellent

"lol spelled excellent wrong."
all seems to be working with your snippet


working lua
Code:
 
function SetGuildTaxRate()
    -- fix provided by Akryn http://www.wowinterface.com/list.php?skinnerid=84579
 -- Overides MOTD & Guild INFO to tax amount set in Officer Note. 
 --Users must have Permision to view officer note or tax amount is set to default 10%
 -- Guild Masters or officers to use add  "tax = 55%" or what ever number you want to users officer note.
local myName = UnitName("player")
 for index=1, GetNumGuildMembers() do 
  local name,_,_,_,_,_,_,officerNote = GetGuildRosterInfo(index)
   if name == myName then
        officerNote = officerNote:lower()
        settaxamount3 = officerNote:match("tax.+")
 break
 end
end
 --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
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » how to get Officers Note for self?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off