Advertisement
munciseek

Untitled

Jan 19th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. local MarketplaceService = game:GetService("MarketplaceService")
  2. local HttpService = game:GetService("HttpService")
  3. local Players = game:GetService("Players")
  4.  
  5. local module = {}
  6.  
  7. local function timestampToMillis(timestamp: string | number | DateTime)
  8. return (typeof(timestamp) == "string" and DateTime.fromIsoDate(timestamp).UnixTimestampMillis) or (typeof(timestamp) == "number" and timestamp) or timestamp.UnixTimestampMillis
  9. end
  10.  
  11. module.LoadCustomAsset = function(url: string)
  12. if getcustomasset then
  13. if url:lower():sub(1, 4) == "http" then
  14. local fileName = `temp_{tick()}.txt`
  15. writefile(fileName, game:HttpGet(url))
  16. local result = getcustomasset(fileName, true)
  17. delfile(fileName)
  18. return result
  19.  
  20. elseif isfile(url) then
  21. return getcustomasset(url, true)
  22. end
  23. else
  24. warn("Executor doesn't support 'getcustomasset', rbxassetid only.")
  25. end
  26. if url:find("rbxassetid") or tonumber(url) then
  27. return "rbxassetid://"..url:match("%d+")
  28. end
  29. error(debug.traceback("Failed to load custom asset for:\n"..url))
  30. end
  31.  
  32. module.LoadCustomInstance = function(url: string)
  33. local success, result = pcall(function()
  34. return game:GetObjects(module.LoadCustomAsset(url))[1]
  35. end)
  36. if success then
  37. return result
  38. end
  39. end
  40.  
  41. module.GetGameLastUpdate = function()
  42. return DateTime.fromIsoDate(MarketplaceService:GetProductInfo(game.PlaceId).Updated)
  43. end
  44.  
  45. module.HasGameUpdated = function(timestamp: string | number | DateTime)
  46. local millis = timestampToMillis(timestamp)
  47. if millis then
  48. return millis < module.GetGameLastUpdate().UnixTimestampMillis
  49. end
  50. return false
  51. end
  52.  
  53. module.GetGitLastUpdate = function(owner: string, repo: string, filePath: string)
  54. local url = `https://api.github.com/repos/{owner}/{repo}/commits?per_page=1&path={filePath}`
  55. local success, result = pcall(HttpService.JSONDecode, HttpService, game:HttpGet(url))
  56. if not success then
  57. error(debug.traceback("Failed to get last commit for:\n"..url))
  58. end
  59. return DateTime.fromIsoDate(result[1].commit.committer.date)
  60. end
  61.  
  62. module.HasGitUpdated = function(owner: string, repo: string, filePath: string, timestamp: string | number | DateTime)
  63. local millis = timestampToMillis(timestamp)
  64. if millis then
  65. return millis < module.GetGitLastUpdate(owner, repo, filePath).UnixTimestampMillis
  66. end
  67. return false
  68. end
  69.  
  70. module.TruncateNumber = function(num: number, decimals: number)
  71. local shift = 10 ^ (decimals and math.max(decimals, 0) or 0)
  72. return num * shift // 1 / shift
  73. end
  74.  
  75. for name, func in module do
  76. if typeof(func) == "function" then
  77. getgenv()[name] = func
  78. end
  79. end
  80.  
  81. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement