Advertisement
SmooKy

Untitled

Dec 4th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. local addonName = 'Goldsheet'
  2.  
  3. local f = CreateFrame("Frame")
  4. f:SetScript("OnEvent", function(f, event, ...) f[event](f, event, ...) end)
  5. f:RegisterEvent("ADDON_LOADED")
  6. f:RegisterEvent("PLAYER_LOGIN")
  7. f:RegisterEvent("GUILD_ROSTER_UPDATE")
  8.  
  9. local db
  10. local charProfile
  11. local guildProfile
  12. do
  13. local isLoaded
  14. local isLogged
  15.  
  16. local function Init()
  17. if not isLoaded or not isLogged then
  18. return
  19. end
  20. local realmName = GetRealmName()
  21. local charName = UnitName("player")
  22. local guildName = GetGuildInfo("player")
  23. local playerLevel = UnitLevel("player")
  24.  
  25. if not playerLevel < 120 then
  26. return
  27. end
  28. if not MYNEWGVARS then
  29. MYNEWGVARS = {}
  30. end
  31. db = MYNEWGVARS
  32. if not db[realmName] then
  33. db[realmName] = {}
  34. end
  35. if not db[realmName][charName] then
  36. db[realmName][charName] = { money = GetMoney() }
  37. end
  38. charProfile = db[realmName][charName]
  39. if guildName then
  40. if not db[realmName][guildName] then
  41. db[realmName][guildName] = { money = -1 }
  42. end
  43. guildProfile = db[realmName][guildName]
  44. end
  45. if not db["Mail Stuff"] then
  46. db["Mail Stuff"] = { }
  47. end
  48. f:RegisterEvent("PLAYER_MONEY")
  49. f:RegisterEvent("GUILDBANKFRAME_OPENED")
  50. f:RegisterEvent("GUILDBANK_UPDATE_MONEY")
  51. f:RegisterEvent("GUILDBANK_UPDATE_WITHDRAWMONEY")
  52. f:RegisterEvent("MAIL_SHOW")
  53. end
  54.  
  55. function f:ADDON_LOADED(event, name)
  56. if name ~= addonName then
  57. return
  58. end
  59. f:UnregisterEvent(event)
  60. isLoaded = true
  61. Init()
  62. end
  63.  
  64. function f:PLAYER_LOGIN(event)
  65. f:UnregisterEvent(event)
  66. isLogged = true
  67. Init()
  68. end
  69.  
  70. function f:GUILD_ROSTER_UPDATE()
  71. Init()
  72. end
  73. end
  74.  
  75. do
  76. function f:PLAYER_MONEY()
  77. charProfile.money = GetMoney()
  78. end
  79.  
  80. local function UpdateGuildMoney()
  81. if not guildProfile then
  82. return
  83. end
  84. guildProfile.money = GetGuildBankMoney()
  85. end
  86.  
  87. function f:GUILDBANKFRAME_OPENED()
  88. UpdateGuildMoney()
  89. end
  90.  
  91. function f:GUILDBANK_UPDATE_MONEY()
  92. UpdateGuildMoney()
  93. end
  94.  
  95. function f:GUILDBANK_UPDATE_WITHDRAWMONEY()
  96. UpdateGuildMoney()
  97. end
  98.  
  99. local function UpdateMailStuff(charname, title, gold, text)
  100. if not db["Mail Stuff"][title] then
  101. db["Mail Stuff"][title] = { name = charname, header = title, money = gold, info = text }
  102. end
  103. end
  104.  
  105. function f:MAIL_SHOW()
  106. for i = 1, GetInboxNumItems() do
  107. local _, _, sender, subject, money, _, daysLeft, hasItem, _, _, _, canReply = GetInboxHeaderInfo(i)
  108. local bodyText, texture, isTakeable, isInvoice = GetInboxText(i)
  109. if not bodyText then
  110. bodyText = " "
  111. end
  112. UpdateMailStuff(sender, subject, money, bodyText)
  113. end
  114. end
  115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement