WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Trying to see guild bank transaction information (https://www.wowinterface.com/forums/showthread.php?t=32631)

clowcadia 05-21-10 04:59 AM

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);

Xrystal 05-21-10 05:11 AM

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

clowcadia 05-21-10 05:18 AM

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

clowcadia 05-21-10 05:31 AM

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

Xrystal 05-21-10 05:43 AM

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.

Xrystal 05-21-10 06:05 AM

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.

Xrystal 05-21-10 08:57 AM

1 Attachment(s)
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.

clowcadia 05-21-10 01:41 PM

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

Xrystal 05-21-10 01:48 PM

Its cool. And yeah, once I get my head into a problem I don't stop until I resolve it rofl.

clowcadia 05-21-10 04:57 PM

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>?

clowcadia 05-21-10 05:03 PM

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

clowcadia 05-21-10 05:06 PM

ok so i believe arkinventory is preventing from any kind of messege to apear when i go to log window

Xrystal 05-21-10 05:13 PM

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

clowcadia 05-21-10 05:22 PM

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

Xrystal 05-21-10 05:27 PM

1 Attachment(s)
Hmm, okay, I'll zip up the whole project and see if the whole thing works for you.

clowcadia 05-21-10 05:36 PM

ok, i have disabled all the addons, and just that
but it only displays anything once i go to log

clowcadia 05-21-10 05:40 PM

Quote:

Originally Posted by clowcadia (Post 188807)
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

clowcadia 05-21-10 05:53 PM

Quote:

Originally Posted by Xrystal (Post 188799)
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?

Xrystal 05-21-10 06:44 PM

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.

clowcadia 05-21-10 06:50 PM

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


All times are GMT -6. The time now is 05:43 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI