Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local addonName = 'Goldsheet'
- local f = CreateFrame("Frame")
- f:SetScript("OnEvent", function(f, event, ...) f[event](f, event, ...) end)
- f:RegisterEvent("ADDON_LOADED")
- f:RegisterEvent("PLAYER_LOGIN")
- f:RegisterEvent("GUILD_ROSTER_UPDATE")
- local db
- local charProfile
- local guildProfile
- do
- local isLoaded
- local isLogged
- local function Init()
- if not isLoaded or not isLogged then
- return
- end
- local realmName = GetRealmName()
- local charName = UnitName("player")
- local guildName = GetGuildInfo("player")
- local playerLevel = UnitLevel("player")
- if not playerLevel < 120 then
- return
- end
- if not MYNEWGVARS then
- MYNEWGVARS = {}
- end
- db = MYNEWGVARS
- if not db[realmName] then
- db[realmName] = {}
- end
- if not db[realmName][charName] then
- db[realmName][charName] = { money = GetMoney() }
- end
- charProfile = db[realmName][charName]
- if guildName then
- if not db[realmName][guildName] then
- db[realmName][guildName] = { money = -1 }
- end
- guildProfile = db[realmName][guildName]
- end
- if not db["Mail Stuff"] then
- db["Mail Stuff"] = { }
- end
- f:RegisterEvent("PLAYER_MONEY")
- f:RegisterEvent("GUILDBANKFRAME_OPENED")
- f:RegisterEvent("GUILDBANK_UPDATE_MONEY")
- f:RegisterEvent("GUILDBANK_UPDATE_WITHDRAWMONEY")
- f:RegisterEvent("MAIL_SHOW")
- end
- function f:ADDON_LOADED(event, name)
- if name ~= addonName then
- return
- end
- f:UnregisterEvent(event)
- isLoaded = true
- Init()
- end
- function f:PLAYER_LOGIN(event)
- f:UnregisterEvent(event)
- isLogged = true
- Init()
- end
- function f:GUILD_ROSTER_UPDATE()
- Init()
- end
- end
- do
- function f:PLAYER_MONEY()
- charProfile.money = GetMoney()
- end
- local function UpdateGuildMoney()
- if not guildProfile then
- return
- end
- guildProfile.money = GetGuildBankMoney()
- end
- function f:GUILDBANKFRAME_OPENED()
- UpdateGuildMoney()
- end
- function f:GUILDBANK_UPDATE_MONEY()
- UpdateGuildMoney()
- end
- function f:GUILDBANK_UPDATE_WITHDRAWMONEY()
- UpdateGuildMoney()
- end
- local function UpdateMailStuff(charname, title, gold, text)
- if not db["Mail Stuff"][title] then
- db["Mail Stuff"][title] = { name = charname, header = title, money = gold, info = text }
- end
- end
- function f:MAIL_SHOW()
- for i = 1, GetInboxNumItems() do
- local _, _, sender, subject, money, _, daysLeft, hasItem, _, _, _, canReply = GetInboxHeaderInfo(i)
- local bodyText, texture, isTakeable, isInvoice = GetInboxText(i)
- if not bodyText then
- bodyText = " "
- end
- UpdateMailStuff(sender, subject, money, bodyText)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement