Wassaa

ttt

Jun 22nd, 2021
694
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. C_ChatInfo.RegisterAddonMessagePrefix("TSMPCWA")
  2. aura_env.people = {}
  3.  
  4. local aura_env = aura_env
  5.  
  6. function askIfSend()
  7.     table.sort(aura_env.people, function(a,b) return (a.time > b.time) or (a.time == b.time and a.name > b.name) end)
  8.    
  9.     local myName = UnitName("PLAYER")
  10.     local myScantime = aura_env.lastScan
  11.    
  12.     if myScantime == aura_env.people[1].time and myName == aura_env.people[1].name then
  13.         SendChatMessage(getTSMPrice(aura_env.itemID), "GUILD")
  14.     end
  15.    
  16.    
  17.     wipe(aura_env.people)
  18. end
  19.  
  20.  
  21.  
  22.  
  23.  
  24. function getTSMPrice(itemID)
  25.     local itemInfo = { GetItemInfo(itemID) }
  26.     local bindType = select(14, itemInfo)
  27.    
  28.     if bindType == 1 then return "That item is BoP" end
  29.    
  30.     local regional = false
  31.     local dbmarket = tonumber(TSM_API.GetCustomPriceValue("dbmarket", "i:"..itemID))
  32.     local dbminbuyout = tonumber(TSM_API.GetCustomPriceValue("dbminbuyout", "i:"..itemID))
  33.     local dbregion = tonumber(TSM_API.GetCustomPriceValue("dbregionmarketavg", "i:"..itemID))
  34.     if not dbmarket and not dbminbuyout and not dbregion then return end
  35.    
  36.     local string = nil
  37.    
  38.    
  39.     if dbmarket and dbminbuyout then
  40.        
  41.         dbmarket = (dbmarket > 10000 and math.floor(dbmarket/100)/100 .."g")
  42.         or (dbmarket > 100 and math.floor(dbmarket/100).."s") or dbmarket .. "c"
  43.        
  44.         dbminbuyout = (dbminbuyout > 10000 and math.floor(dbminbuyout/100)/100 .."g")
  45.         or (dbminbuyout > 100 and math.floor(dbminbuyout/100).."s") or dbmarket
  46.        
  47.         string = "Lowest auction ~"..dbminbuyout..", market value ~" .. dbmarket
  48.        
  49.        
  50.     elseif dbmarket and not dbminbuyout then
  51.         dbmarket = (dbmarket > 10000 and math.floor(dbmarket/100)/100 .."g")
  52.         or (dbmarket > 100 and math.floor(dbmarket/100).."s") or dbmarket .. "c"
  53.         string = "Market value ~"..dbmarket..", no auctions posted atm"
  54.        
  55.        
  56.        
  57.     else
  58.         dbregion = (dbregion > 10000 and math.floor(dbregion/100)/100 .."g")
  59.         or (dbregion > 100 and math.floor(dbregion/100).."s") or dbregion .. "c"
  60.        
  61.         string = "No realm data for this item, regional data at ~".. dbregion
  62.        
  63.     end
  64.    
  65.    
  66.     return string
  67. end
  68.  
  69.  
RAW Paste Data