Advertisement
Guest User

SloMo.lua

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