darraghd493

geturlasset - A URL wrapper for getcustomasset

Sep 4th, 2023 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | Source Code | 0 0
  1. --[[
  2.     geturlasset - An improved version of synurlasset (pastebin.com/bWzYk6Lh0)
  3.  
  4.     This adds support for other exploits and pre-caches all files
  5. ]]
  6.  
  7. local cache = {}
  8.  
  9. if isfolder("temp") then
  10.     for i,v in pairs(listfiles("temp")) do
  11.         cache[v] = readfile(v)
  12.     end
  13. end
  14.  
  15. local getcustomasset = getsynasset or getcustomasset
  16. local b64encode = syn.crypt.base64.encode or crypt.base64encode or base64.encode
  17.  
  18. function geturlasset(url)
  19.     local eurl = b64encode(url)
  20.  
  21.     if cache[eurl] then return cache[eurl] end
  22.  
  23.     local file = "temp/" .. tostring(os.time()) .. ".png"
  24.     makefolder("temp")
  25.     writefile(file, game:HttpGet(url, true))
  26.  
  27.     local asset = getcustomasset(file)
  28.     cache[eurl] = asset
  29.     return asset
  30. end
  31.  
  32. return geturlasset
Add Comment
Please, Sign In to add comment