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.