Skip to content

Instantly share code, notes, and snippets.

@DrSpeedy
Last active August 1, 2022 00:15
Show Gist options
  • Save DrSpeedy/ac2cd562a4d7bcf1e13742f4a314dba9 to your computer and use it in GitHub Desktop.
Save DrSpeedy/ac2cd562a4d7bcf1e13742f4a314dba9 to your computer and use it in GitHub Desktop.
Better Super Run v2 GTAV - Stand API
-- Discord: DrSpeedy#1852
-- https://github.com/DrSpeedy
require 'lib/natives-1627063482'
local menu_player_sr = menu.my_root()
local srun_enabled = false
local keys = {}
keys['RB'] = 183
local sr_speed_limit = 120
local sr_base_speed = 10
local sr_accel_mult = 0.77
local sr_brake_mult = 0.66
menu.divider(menu_player_sr, '-------------Speedy\'s Super Run-------------')
menu.slider(menu_player_sr, 'Speed Limit', {'setsrspeedlimit'}, '', 0, 200, sr_speed_limit, 1, function(value, prev_value, click_type)
sr_speed_limit = value
end)
menu.slider_float(menu_player_sr, 'Acceleration Multiplier', {'setsraccelmult'}, '', 0, 1000, sr_accel_mult * 100, 10, function(value, prev_value, click_type)
sr_accel_mult = value / 100
end)
menu.slider_float(menu_player_sr, 'Brake Multiplier', {'setsraccelmult'}, '', 0, 1000, sr_brake_mult * 100, 10, function(value, prev_value, click_type)
sr_brake_mult = value / 100
end)
menu.divider(menu_player_sr, '---------------------------------------------')
menu.toggle(menu_player_sr, 'Super Run Enabled', {'ssrunenabled'}, '', function(toggle)
srun_enabled = toggle
local is_super_running = false
-- Our current speed multiplier, this will be increased as the player speeds up
local speed_mult = sr_base_speed
util.create_tick_handler(function()
if (srun_enabled) then
-- Local variables needed updated each tick
local player = PLAYER.PLAYER_PED_ID()
local velocity = ENTITY.GET_ENTITY_VELOCITY(player)
local direction = ENTITY.GET_ENTITY_FORWARD_VECTOR(player)
local sprinting = TASK.IS_PED_SPRINTING(player)
local ragdoll = PED.IS_PED_RAGDOLL(player)
local falling = PED.IS_PED_FALLING(player)
local swimming = PED.IS_PED_SWIMMING(player)
local parastate = PED.GET_PED_PARACHUTE_STATE(player)
local grounddistance = ENTITY.GET_ENTITY_HEIGHT_ABOVE_GROUND(player)
if (PAD.IS_CONTROL_PRESSED(2, keys['RB']) and sprinting and not (parastate == 0)) then
if not (PED.IS_PED_IN_ANY_VEHICLE(player, true) or falling or ragdoll) then
is_super_running = true
-- Mimic acceleration by increasing speed_mult by sr_accel_mult each tick
if (speed_mult <= sr_speed_limit) then
speed_mult = speed_mult + sr_accel_mult
end
-- Set up our velocity vector
local vx = direction.x * speed_mult
local vy = direction.y * speed_mult
local vz = 0
-- Help player stay on ground (kinda) after hitting bumps
if (grounddistance > 1 and not swimming) then
vz = velocity.z - 2
else
vz = velocity.z
end
-- Set the players running velocity
ENTITY.SET_ENTITY_VELOCITY(player, vx, vy, vz)
end
else
-- Applies the initial braking force to the player at full run when activation button is let go of
if (is_super_running and not (falling or ragdoll)) then
is_super_running = false
velocity = ENTITY.GET_ENTITY_VELOCITY(player)
ENTITY.SET_ENTITY_VELOCITY(player, (velocity.x*sr_brake_mult), (velocity.y*sr_brake_mult), velocity.z)
end
-- Bring the speed_mult down if the player is not running at all
if (speed_mult > sr_base_speed) then
speed_mult = speed_mult - sr_brake_mult
if (speed_mult < sr_base_speed) then
speed_mult = sr_base_speed
end
end
end
end
return srun_enabled
end)
end)
while true do
util.yield()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment