Advertisement
j311yf1sh

asdasdasdasdasdasdasdas

Nov 14th, 2012
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 KB | None | 0 0
  1. --[[
  2. ]]--
  3.  
  4. local PRframe = CreateFrame('FRAME')
  5. PRframe:SetScript("OnEvent", function(the, event, ...)
  6.     PREvents[event](...)
  7. end)
  8. PRframe:RegisterEvent("CHAT_MSG_GUILD")
  9. PREvents = {}
  10.  
  11. function PREvents.CHAT_MSG_GUILD(MSG,Auth)
  12.     local MSG = MSG
  13.     local Auth = Auth
  14.     --- Price Get --
  15.     local PRPriceMarket = TSMAPI:GetItemValue(MSG,"DBMarket")
  16.     local PRPriceMin = TSMAPI:GetItemValue(MSG,"DBMinBuyout")
  17.     -- time functions ---
  18.     local Current = time()
  19.     local Past = TSMAPI:GetData("lastCompleteScanTime")
  20.     local PRTimeLastScannedHours = floor(PR_ConvertTime(Current, Past) / 3600)-- 1 min is 60 seconds and 60 minutes in 1 hour so 60 * 60 = 3600
  21.     local PRTimeLastScannedMinutes = floor(PR_ConvertTime(Current, Past) / 60) -- convert minues
  22.     -----------------------------------------------------------------
  23.     if string.find(MSG,"PR:") and PRPriceMarket ~= nil and PRPriceMin ~= nil then
  24.  
  25.         -- Market Prices --
  26.         local MktGOLD = PR_ConvertPriceToMoney(PRPriceMarket,"Gold")
  27.         local MktSILVER = PR_ConvertPriceToMoney(PRPriceMarket,"Silver")
  28.         local MktCOPPER = PR_ConvertPriceToMoney(PRPriceMarket,"Copper")
  29.  
  30.         --- Minimum Price --
  31.         local MinGOLD = PR_ConvertPriceToMoney(PRPriceMin,"Gold")
  32.         local MinSILVER = PR_ConvertPriceToMoney(PRPriceMin,"Silver")
  33.         local MinCOPPER = PR_ConvertPriceToMoney(PRPriceMin,"Copper")
  34.  
  35.         --- Message to send and channel--
  36.         local PRTHEMESSAGE = ("Price Relay: Market Price: "..MktGOLD.."g"..MktSILVER.."s"..MktCOPPER.."c".." / ".."Current Min buyout: "..MinGOLD.."g"..MinSILVER.."s"..MinCOPPER.."c".." / ".."Last scanned: "..PRTimeLastScannedHours.." Hrs "..PRTimeLastScannedMinutes.." Mins")
  37.         print(PRTHEMESSAGE)
  38.         SendChatMessage(PRTHEMESSAGE, "GUILD", "Common", nil)
  39.  
  40.     end
  41. end
  42.  
  43.  
  44. function PR_ConvertPriceToMoney(PRICE,TYPE)
  45.     local GOLD
  46.     local SILVER
  47.     local COPPER
  48.     if PRICE == nil then Price = 0 end -- make sure it is a number
  49.     if TYPE == "Gold" then
  50.         GOLD = floor(PRICE/10000) -- divide price by 10000 to decide gold and floor it to get rid of hang overs
  51.         return GOLD or 0 -- Make sure it always returns a number
  52.     elseif TYPE == "Silver" then
  53.         SILVER = floor(strsub(PRICE, -4) / 100) -- strsub will only see the last 4 numbers of a sentece and divide it by 100
  54.         return SILVER or 0
  55.     elseif TYPE == "Copper" then
  56.         COPPER = floor(strsub(PRICE, -2)) -- no division needed for 10th's
  57.         return COPPER or 0
  58.     end
  59. end
  60.  
  61. function PR_ConvertTime(Current, Past)
  62.     local Current = Current
  63.     local Past = Past
  64.     local Difference = (Current - Past)
  65.     return Difference
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement