Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SloMo = {}
- local mod = false
- local mod_toggle = false
- local timeScale = 1.0 -- Default time scale
- function SloMo.unload()
- end
- function SloMo.init()
- end
- function SloMo.tick()
- local playerPed = PLAYER.PLAYER_PED_ID()
- local player = PLAYER.GET_PLAYER_PED(playerPed)
- local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
- if not playerExists then
- return
- end
- -- Check for LT (button 10) and Down D-Pad (button 187) to toggle SloMo
- if CONTROLS.IS_CONTROL_PRESSED(2, 10) and CONTROLS.IS_CONTROL_PRESSED(2, 187) then
- mod_toggle = true
- elseif mod_toggle then
- mod_toggle = false
- mod = not mod -- Toggle mod state
- if mod then
- timeScale = 0.5 -- Set initial time scale when mod is toggled on
- GAMEPLAY.SET_TIME_SCALE(timeScale)
- else
- GAMEPLAY.SET_TIME_SCALE(1.0) -- Reset time scale when mod is toggled off
- end
- end
- if mod then
- -- Modify time scale dynamically only when LT is held down
- if CONTROLS.IS_CONTROL_PRESSED(2, 10) then
- -- Get the vertical axis of the right analog stick (Range: -1.0 to 1.0)
- local stickY = CONTROLS.GET_CONTROL_NORMAL(2, 2) -- Right stick vertical axis (2 for default mappings)
- -- Determine rate of change based on stick position
- local rate = math.abs(stickY) * 0.05 -- Maximum rate is 0.05
- if rate < 0.01 then
- rate = 0.01 -- Minimum rate is 0.01
- end
- -- Adjust time scale based on inverted stick movement
- if stickY > 0 then
- timeScale = math.min(1.0, timeScale + rate) -- Stick up increases speed
- elseif stickY < 0 then
- timeScale = math.max(0.0, timeScale - rate) -- Stick down decreases speed
- end
- -- Apply the current time scale
- GAMEPLAY.SET_TIME_SCALE(timeScale)
- end
- end
- end
- return SloMo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement