Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ]]--
- local PRframe = CreateFrame('FRAME')
- PRframe:SetScript("OnEvent", function(the, event, ...)
- PREvents[event](...)
- end)
- PRframe:RegisterEvent("CHAT_MSG_GUILD")
- PREvents = {}
- function PREvents.CHAT_MSG_GUILD(MSG,Auth)
- local MSG = MSG
- local Auth = Auth
- --- Price Get --
- local PRPriceMarket = TSMAPI:GetItemValue(MSG,"DBMarket")
- local PRPriceMin = TSMAPI:GetItemValue(MSG,"DBMinBuyout")
- -- time functions ---
- local Current = time()
- local Past = TSMAPI:GetData("lastCompleteScanTime")
- local PRTimeLastScannedHours = floor(PR_ConvertTime(Current, Past) / 3600)-- 1 min is 60 seconds and 60 minutes in 1 hour so 60 * 60 = 3600
- local PRTimeLastScannedMinutes = floor(PR_ConvertTime(Current, Past) / 60) -- convert minues
- -----------------------------------------------------------------
- if string.find(MSG,"PR:") and PRPriceMarket ~= nil and PRPriceMin ~= nil then
- -- Market Prices --
- local MktGOLD = PR_ConvertPriceToMoney(PRPriceMarket,"Gold")
- local MktSILVER = PR_ConvertPriceToMoney(PRPriceMarket,"Silver")
- local MktCOPPER = PR_ConvertPriceToMoney(PRPriceMarket,"Copper")
- --- Minimum Price --
- local MinGOLD = PR_ConvertPriceToMoney(PRPriceMin,"Gold")
- local MinSILVER = PR_ConvertPriceToMoney(PRPriceMin,"Silver")
- local MinCOPPER = PR_ConvertPriceToMoney(PRPriceMin,"Copper")
- --- Message to send and channel--
- 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")
- print(PRTHEMESSAGE)
- SendChatMessage(PRTHEMESSAGE, "GUILD", "Common", nil)
- end
- end
- function PR_ConvertPriceToMoney(PRICE,TYPE)
- local GOLD
- local SILVER
- local COPPER
- if PRICE == nil then Price = 0 end -- make sure it is a number
- if TYPE == "Gold" then
- GOLD = floor(PRICE/10000) -- divide price by 10000 to decide gold and floor it to get rid of hang overs
- return GOLD or 0 -- Make sure it always returns a number
- elseif TYPE == "Silver" then
- SILVER = floor(strsub(PRICE, -4) / 100) -- strsub will only see the last 4 numbers of a sentece and divide it by 100
- return SILVER or 0
- elseif TYPE == "Copper" then
- COPPER = floor(strsub(PRICE, -2)) -- no division needed for 10th's
- return COPPER or 0
- end
- end
- function PR_ConvertTime(Current, Past)
- local Current = Current
- local Past = Past
- local Difference = (Current - Past)
- return Difference
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement