Advertisement
Guest User

SloMoNeo.lua

a guest
Jan 5th, 2025
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. local SloMo = {}
  2.  
  3. local mod = false
  4. local mod_toggle = false
  5. local timeScale = 1.0 -- Default time scale
  6.  
  7. function SloMo.unload()
  8. end
  9.  
  10. function SloMo.init()
  11. end
  12.  
  13. function SloMo.tick()
  14. local playerPed = PLAYER.PLAYER_PED_ID()
  15. local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
  16. if not playerExists then
  17. return
  18. end
  19.  
  20. -- Check for LT (button 10) and Down D-Pad (button 187) to toggle SloMo
  21. if CONTROLS.IS_CONTROL_PRESSED(2, 10) and CONTROLS.IS_CONTROL_PRESSED(2, 187) then
  22. mod_toggle = true
  23. elseif mod_toggle then
  24. mod_toggle = false
  25. mod = not mod -- Toggle mod state
  26. if mod then
  27. timeScale = 0.5 -- Set initial time scale when mod is toggled on
  28. GAMEPLAY.SET_TIME_SCALE(timeScale)
  29. else
  30. GAMEPLAY.SET_TIME_SCALE(1.0) -- Reset time scale when mod is toggled off
  31. end
  32. end
  33.  
  34. if mod then
  35. -- Modify time scale dynamically only when LT is held down
  36. if CONTROLS.IS_CONTROL_PRESSED(2, 10) then
  37. -- Get the vertical axis of the right analog stick (Range: -1.0 to 1.0)
  38. local stickY = CONTROLS.GET_CONTROL_NORMAL(2, 2) -- Right stick vertical axis (2 for default mappings)
  39.  
  40. -- Determine rate of change based on stick position
  41. local rate = math.abs(stickY) * 0.05 -- Maximum rate is 0.05
  42. if rate < 0.01 then
  43. rate = 0.01 -- Minimum rate is 0.01
  44. end
  45.  
  46. -- Adjust time scale based on inverted stick movement
  47. if stickY > 0 then
  48. timeScale = math.min(1.0, timeScale + rate) -- Stick up increases speed
  49. elseif stickY < 0 then
  50. timeScale = math.max(0.0, timeScale - rate) -- Stick down decreases speed
  51. end
  52.  
  53. -- Apply the current time scale
  54. GAMEPLAY.SET_TIME_SCALE(timeScale)
  55. end
  56. end
  57.  
  58. -- Wait for the next tick to prevent the script from running in an infinite loop
  59. Wait(0)
  60. end
  61.  
  62. return SloMo
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement