Guest User

Skintest

a guest
Jun 6th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. -- LeoSight.cz (c) 2021
  2.  
  3. local hash
  4.  
  5. function onLoad()
  6.   for _,v in ipairs(getElementsByType("player"))do
  7.     setElementModel(v, 1)
  8.   end
  9. end
  10. addEventHandler("onResourceStart", resourceRoot, onLoad)
  11.  
  12. function restartSkin()
  13.   restartResource(getThisResource())
  14. end
  15. addCommandHandler("testskin", restartSkin, false, false)
  16. addCommandHandler("skintest", restartSkin, false, false)
  17.  
  18. function math.round(number, decimals)
  19.     decimals = decimals or 0
  20.     local factor = 10 ^ decimals
  21.     return tonumber(("%."..decimals.."f"):format(number))
  22. end
  23.  
  24. function readFile(path)
  25.   local file = fileOpen(path)
  26.   if not file then
  27.     return false
  28.   end
  29.   local size = fileGetSize(file)
  30.   local data = fileRead(file, size)
  31.   fileClose(file)
  32.   return data, size
  33. end
  34.  
  35. function fileSize(path)
  36.   local file = fileOpen(path)
  37.   if not file then
  38.     return false
  39.   end
  40.   return fileGetSize(file)
  41. end
  42.  
  43. function fileWatcher()
  44.   local content, txdSize = readFile("skin.txd")
  45.   if(content)then
  46.     local newHash = md5(content)
  47.     if(not hash)then hash = newHash end
  48.     if(hash ~= newHash)then
  49.       local dffSize = fileSize("skin.dff")
  50.       local totalSize = math.round((txdSize + dffSize) / 1024 / 1024, 2)
  51.       outputChatBox("Detekována úprava! Momentální velikost skinu: " .. totalSize .. " MB", root, totalSize > 4 and 255 or 0, totalSize <= 4 and 255 or 0, 0)
  52.       restartSkin()
  53.     end
  54.   end
  55. end
  56. setTimer(fileWatcher, 2000, 0)
  57.  
  58. local testPed
  59.  
  60. function spawnSkinPed()
  61.     testPed = createPed(1, -2416.16821, -599.30127, 132.56250, 0, true)
  62.     if testPed then
  63.         setElementFrozen(testPed, true)
  64.     end
  65. end
  66. addEventHandler("onResourceStart", resourceRoot, spawnSkinPed)
  67.  
  68. function teleportPed(thePlayer, cmd)
  69.     if testPed and getElementType(testPed) == "ped" then
  70.         local x, y, z = getElementPosition(thePlayer)
  71.         local rx,ry,rz = getElementRotation(thePlayer)
  72.         setElementPosition(testPed, x+1, y, z)
  73.         setElementRotation(testPed, rx, ry, rz)
  74.     end
  75. end
  76. addCommandHandler("moveped", teleportPed, false, false)
Advertisement
Add Comment
Please, Sign In to add comment