Quantcast Trying to see guild bank transaction information - WoWInterface
Thread Tools Display Modes
05-21-10, 04:59 AM   #1
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
Trying to see guild bank transaction information

ok, this is a function i am testing via macros for my add on
the only problem i am facing
i am trying to have a messege box apear when the tab slots have been changed, displaying that newest transactions info. for now i just want to know the item name that has been transacted


what i am trying to do is copy the guild log latest entry into messege box, when any transaction is made in the guild vault(it seams that i need to open the log tab for any value to appear, witch is what i dont want(but if it must happen then it must)
or what my main goal is when any transaction happens i want to know what that transaction was = deposit/withdraw itemname

what does not work: the only thing my message box displays is the type of the transaction

this is my test script that i use in my macro to see how to work it

/script local name = GetGuildBankTransaction(1,25);message(name);

Last edited by clowcadia : 05-21-10 at 05:31 AM.
  Reply With Quote
05-21-10, 05:11 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
You need to provide other variables to get all the information you need.

type, name, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, index)

http://www.wowwiki.com/API_GetGuildBankTransaction
__________________
  Reply With Quote
05-21-10, 05:18 AM   #3
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
yes i relised that
but even then i did so, and it only displays the type or transaction.
i am not in a rush nor difficult
so even one block of info would help
  Reply With Quote
05-21-10, 05:31 AM   #4
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok, i have done what u have told me to look at
and my wow froze
what i am trying to do is copy the guild log latest entry into messege box, when any transaction is made in the guild vault(it seams that i need to open the log tab for any value to appear, witch is what i dont want(but if it must happen then it must)
or what my main goal is when any transaction happens i want to know what that transaction was = deposit/withdraw itemname
  Reply With Quote
05-21-10, 05:43 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Hmm, okay, the macro angle doesn't work. But then again I never use macros for stuff like that.

Okay, looks like you will have to use an addon even to just test this as you have to use a query function to get it to grab the information. Here's a block of code I used and it works in a simplistic way.

Code:
local tType, tName, itemLink, count, tab1, tab2, year, month, day, hour;

local function onEvent(self,event,...)
	if ( event == "GUILDBANKFRAME_OPENED" ) then
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
			for index = 1,GetNumGuildBankTransactions(tab) do
				tType, tName, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, index);
				print(tab,index,tType, tName, itemLink, count, tab1, tab2, year, month, day, hour);
			end
		end
		QueryGuildBankLog(GetNumGuildBankTabs()+1);
		for index = 1, GetNumGuildBankMoneyTransactions() do
			tType, tName, amount, years, months, days, hours = GetGuildBankMoneyTransaction(index);
			print("Money",index,tType, tName, amount, year, month, day, hour);
		end
	end
end

local evFrame = CreateFrame("Frame","evFrame",UIParent);
evFrame:SetScript( "OnEvent", onEvent );
evFrame:RegisterEvent( "GUILDBANKFRAME_OPENED" );
Open the Guild Bank window to trigger the Query function. It doesn't use it straight away though so close the window and reopen and it should then display the print info lines. It's not perfect and you will probably need to tweak when to use the query function and transaction functions but its a start.
__________________

Last edited by Xrystal : 05-21-10 at 06:03 AM.
  Reply With Quote
05-21-10, 06:05 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Rofl, tried to turn the addon into a slash command system and it crashed rofl.

The listing way works though so I'll try and work via that route to get the trans info.

Ah, looking at the way blizzard deals with the guildbank frame themselves it looks like you have to have the guild bank frame open for the query function and the transaction functions to work properly. Also, it seems directly accessing the newest transaction doesn't work either. You have to go through the whole for loop with the last entry being the newest and 1 being the oldest.

Trying another route to make it more useful.


Aha, it looks like QueryGuildBankLog function triggers the GUILDBANKLOG_UPDATE event for each tab/tab+1 query it makes. But I still can't get it to just query the last transaction so you may have to read through all transactions and just display the last one.
__________________

Last edited by Xrystal : 05-21-10 at 07:05 AM.
  Reply With Quote
05-21-10, 08:57 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Aha finally got it to work... its annoying but finally works the moment you open the guildbank frame. You have to have it open for it to work unfortunately.

Final Code and a screenshot to show how it is outputting the information :

Code:
local tType, tName, itemLink, count, tab1, tab2, year, month, day, hour;
local queryCount = 0;

local function onEvent(self,event,...)

             -- Only work if the Guild Bank Frame is open 
	if ( not GuildBankFrame:IsVisible() ) then
		return;
	end

             -- If the Guild Bank Frame has been opened then query each
             -- tabs log and contents.  And then query the money log.
	if ( event == "GUILDBANKFRAME_OPENED" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
             -- Each QueryGuildBank.... call will trigger this update but we only 
             -- want to display the final report which will contain everything 
             -- found.  queryCount is used to keep track of which stage we are
             -- at
	elseif ( event == "GUILDBANKLOG_UPDATE" ) then
		queryCount = queryCount + 1;
		if queryCount == GetNumGuildBankTabs() + 1 then
			for tab = 1, GetNumGuildBankTabs() do
				local maxTabTrans = GetNumGuildBankTransactions(tab);
                                      -- For each transaction in the current tab extract the information required.
				for trans = 1,maxTabTrans do
					tType, tName, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, trans);
                                      -- If this is the last transaction then we want to display it in some form
					if trans == maxTabTrans then
						if ( tab1 ) then tab1 = GetGuildBankTabInfo(tab1); end
						if ( tab2 ) then tab2 = GetGuildBankTabInfo(tab2); end
						print("Last Item Transaction: ",tab,maxTabTrans,tType, tName, itemLink, count, tab1, tab2, year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");					
					end
				end
			end
                                      -- Now repeat the same process for the money log
			local maxMoneyTrans = GetNumGuildBankMoneyTransactions();
			for trans = 1,maxMoneyTrans do
				tType, tName, amount, years, months, days, hours = GetGuildBankMoneyTransaction(trans);
				if ( trans == maxMoneyTrans ) then
					print("Last Money Transaction: ",maxMoneyTrans,tType, tName, amount, year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");
				end
			end
		end
	end
end

local evFrame = CreateFrame("Frame","evFrame",UIParent);
evFrame:SetScript( "OnEvent", onEvent );
evFrame:RegisterEvent( "PLAYER_LOGIN" );
evFrame:RegisterEvent( "GUILDBANKLOG_UPDATE" );
evFrame:RegisterEvent( "GUILDBANKFRAME_OPENED" );
Changing amount to GetDenominationsFromCopper(amount) will convert it to x Gold x Silver x Copper etc as calculated.
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_052110_155343.jpg
Views:	872
Size:	416.3 KB
ID:	4286  
__________________

Last edited by Xrystal : 05-21-10 at 05:19 PM.
  Reply With Quote
05-21-10, 01:41 PM   #8
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
god thank you very much Crystal
i am very surprised u guided me through the add on making of this function but i am also glad. maybe its because of 2 factors that i actually put in some effort to make a working function just not understanding a few parts and maybe u were kind of intrigued by the idea
thank you once more ur the best
  Reply With Quote
05-21-10, 01:48 PM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Its cool. And yeah, once I get my head into a problem I don't stop until I resolve it rofl.
__________________
  Reply With Quote
05-21-10, 04:57 PM   #10
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok i tested the addon code for the 2nd part that u said would work properly
and somehow id doesn't display any transactions for me maybe because i move things ill test depositing items now

but ive been trying to figure out and i dont understand exactly what each line does
will u be able to guide me through it>?
  Reply With Quote
05-21-10, 05:03 PM   #11
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok it worked now but i had to go to log tab and i disabled arkinventory.. or maybe i dint have to

is there a way i can have it with out going to log tab
i want it to react only when i make an transaction
  Reply With Quote
05-21-10, 05:06 PM   #12
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok so i believe arkinventory is preventing from any kind of messege to apear when i go to log window
  Reply With Quote
05-21-10, 05:13 PM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Hmm strange. All I did was open the bank and it displayed the transactions linked to each of the bank tabs.


Ah, unless it is to do with permissions. Can you usually view items or the log for each tab ? If not perhaps that functionality isn't available without the right permission. I am an officer in my guild so I have full access to the tabs so could explain why it worked for me.

I'll edit the last code post and add comments for you.

The updatelog event I would have thought would get triggered but if not you could try adding the following events with RegisterEvent lines:
"GUILDBANKBAGSLOTS_CHANGED" - Fired when the guild-bank contents change
"GUILDBANK_ITEM_LOCK_CHANGED"
"GUILDBANK_UPDATE_MONEY"
"GUILDBANK_UPDATE_TABS"
"GUILDBANK_UPDATE_TEXT"
"GUILDBANK_UPDATE_WITHDRAWMONEY"

And then adjust the following line so that each event is checked to run the same query code. Or you could add them as separate elseif sections and call the same block of code the GUILDBANKFRAME_OPENED event uses:

if ( event == "GUILDBANKFRAME_OPENED" or event == "GUILDBANKBAGSLOTS_CHANGED" or "GUILDBANK_ITEM_LOCK_CHANGED") then
__________________

Last edited by Xrystal : 05-21-10 at 05:24 PM.
  Reply With Quote
05-21-10, 05:22 PM   #14
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
thank you i will look at it and see
although on both accounts i am GM, one is GM but not fully since i made a second GM rank , but testing the addon using the original GM
  Reply With Quote
05-21-10, 05:27 PM   #15
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
Hmm, okay, I'll zip up the whole project and see if the whole thing works for you.
Attached Files
File Type: zip GuildBankTransactions.zip (1.2 KB, 606 views)
__________________
  Reply With Quote
05-21-10, 05:36 PM   #16
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
ok, i have disabled all the addons, and just that
but it only displays anything once i go to log
  Reply With Quote
05-21-10, 05:40 PM   #17
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
Originally Posted by clowcadia View Post
ok, i have disabled all the addons, and just that
but it only displays anything once i go to log
i shall try somethign u said with register events right now.. i dont want u to do all the work^^ not nice of me
  Reply With Quote
05-21-10, 05:53 PM   #18
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
Originally Posted by Xrystal View Post
Hmm strange. All I did was open the bank and it displayed the transactions linked to each of the bank tabs.


Ah, unless it is to do with permissions. Can you usually view items or the log for each tab ? If not perhaps that functionality isn't available without the right permission. I am an officer in my guild so I have full access to the tabs so could explain why it worked for me.

I'll edit the last code post and add comments for you.

The updatelog event I would have thought would get triggered but if not you could try adding the following events with RegisterEvent lines:
"GUILDBANKBAGSLOTS_CHANGED" - Fired when the guild-bank contents change
"GUILDBANK_ITEM_LOCK_CHANGED"
"GUILDBANK_UPDATE_MONEY"
"GUILDBANK_UPDATE_TABS"
"GUILDBANK_UPDATE_TEXT"
"GUILDBANK_UPDATE_WITHDRAWMONEY"

And then adjust the following line so that each event is checked to run the same query code. Or you could add them as separate elseif sections and call the same block of code the GUILDBANKFRAME_OPENED event uses:

if ( event == "GUILDBANKFRAME_OPENED" or event == "GUILDBANKBAGSLOTS_CHANGED" or "GUILDBANK_ITEM_LOCK_CHANGED") then
elseif section? can u please elaborate?

Last edited by clowcadia : 05-21-10 at 05:58 PM.
  Reply With Quote
05-21-10, 06:44 PM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,306
My apologies, I'll break down the onEvent function to make things clearer:

Code:
-- Each QueryGuildBank.... call will trigger this update but we only 
-- want to display the final report which will contain everything 
-- found.  queryCount is used to keep track of which stage we are at
local function refreshLogInfo()
  queryCount = 0;
  for tab = 1,GetNumGuildBankTabs() do
    QueryGuildBankLog(tab);
    QueryGuildBankTab(tab);
  end		
  QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
end

-- Call this function after a queryGuildBankLog has been called.
local function getLogInfo()
  queryCount = queryCount + 1;
  if queryCount == GetNumGuildBankTabs() + 1 then
    for tab = 1, GetNumGuildBankTabs() do
      local maxTabTrans = GetNumGuildBankTransactions(tab);
        -- For each transaction in the current tab extract the information required.
        for trans = 1,maxTabTrans do
          tType, tName, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, trans);
            -- If this is the last transaction then we want to display it in some form
            if trans == maxTabTrans then
              if ( tab1 ) then tab1 = GetGuildBankTabInfo(tab1); end
              if ( tab2 ) then tab2 = GetGuildBankTabInfo(tab2); end
              print("Last Item Transaction: ",tab,maxTabTrans,tType, tName, itemLink, count, tab1, tab2, year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");
            end
         end
      end
      -- Now repeat the same process for the money log
      local maxMoneyTrans = GetNumGuildBankMoneyTransactions();
      for trans = 1,maxMoneyTrans do
        tType, tName, amount, years, months, days, hours = GetGuildBankMoneyTransaction(trans);
        if ( trans == maxMoneyTrans ) then
          print("Last Money Transaction: ",maxMoneyTrans,tType, tName, amount, year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");
       end
     end
  end
end

-- For each event that is triggered by a bank change refresh the Log Info
-- which then triggers the UPDATE event to then get the Log Info.
local function onEvent(self,event,...)

             -- Only work if the Guild Bank Frame is open 
	if ( not GuildBankFrame:IsVisible() ) then
		return;
	end

	if ( event == "GUILDBANKFRAME_OPENED" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANKBAGSLOTS_CHANGED" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANK_ITEM_LOCK_CHANGED" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANK_UPDATE_MONEY" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANK_UPDATE_TABS" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANK_UPDATE_TEXT" ) then
                  refreshLogInfo();

            elseif ( event == "GUILDBANK_UPDATE_WITHDRAWMONEY" ) then
                  refreshLogInfo();

	elseif ( event == "GUILDBANKLOG_UPDATE" ) then
                  getLogInfo();

	end
end
Hopefully this helps make a bit more sense to you. If you are still getting problems I will try and figure out why it isn't working the same for you.
__________________
  Reply With Quote
05-21-10, 06:50 PM   #20
clowcadia
A Chromatic Dragonspawn
Join Date: Apr 2010
Posts: 186
Code:
local addonName, addonData = ...;
local tType, tName, itemLink, count, tab1, tab2, year, month, day, hour;
local queryCount = 0;

local function onEvent(self,event,...)

	if ( not GuildBankFrame:IsVisible() ) then
		return;
	end

	if ( event == "GUILDBANKFRAME_OPENED" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANK_ITEM_LOCK_CHANGED" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANKBAGSLOTS_CHANGED" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANK_UPDATE_MONEY" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANK_UPDATE_TABS" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANK_UPDATE_TEXT" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	if ( event == "GUILDBANK_UPDATE_WITHDRAWMONEY" ) then
		queryCount = 0;
		for tab = 1,GetNumGuildBankTabs() do
			QueryGuildBankLog(tab);
			QueryGuildBankTab(tab);
		end		
		QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
	elseif ( event == "GUILDBANKLOG_UPDATE" ) then
		queryCount = queryCount + 1;
		if queryCount == GetNumGuildBankTabs() + 1 then
			for tab = 1, GetNumGuildBankTabs() do
				local maxTabTrans = GetNumGuildBankTransactions(tab);
				for trans = 1,maxTabTrans do
					tType, tName, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, trans);
					if trans == maxTabTrans then
						if ( tab1 ) then tab1 = GetGuildBankTabInfo(tab1); end
						if ( tab2 ) then tab2 = GetGuildBankTabInfo(tab2); end
						print("Last Item Transaction: ",tab,maxTabTrans,tType, tName, itemLink, count, tab1, tab2, year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");					
					end
				end
			end
			local maxMoneyTrans = GetNumGuildBankMoneyTransactions();
			for trans = 1,maxMoneyTrans do
				tType, tName, amount, years, months, days, hours = GetGuildBankMoneyTransaction(trans);
				if ( trans == maxMoneyTrans ) then
					print("Last Money Transaction: ",maxMoneyTrans,tType, tName, GetDenominationsFromCopper(amount), year, month, day, hour, "Time Conversion = (", RecentTimeDate(year, month, day, hour),")");
				end
			end
		end
	end
end

local evFrame = CreateFrame("Frame","evFrame",UIParent);
evFrame:SetScript( "OnEvent", onEvent );
evFrame:RegisterEvent( "PLAYER_LOGIN" );
evFrame:RegisterEvent( "GUILDBANKLOG_UPDATE" );
evFrame:RegisterEvent( "GUILDBANKFRAME_OPENED" );
i did that and nothign at all happens
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trying to see guild bank transaction information

Thread Tools
Display Modes

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