Jump to content

Fast sprint script


Recommended Posts

Posted

Hey. I would need an idea how i could make faster sprinting by holding space (not tapping). I mean the "fast sprint" glitch.

- OnClientKey/bindKey, but what later? I don't have any idea how it could be done, maybe a loop?

Posted

use animation for that. you will get smooth fast run without accelerate the game and without glitchs

like this mode : 

 

i will not be a part of a group who support baby killers.

Posted (edited)
1 hour ago, DicoSky said:

use animation for that. you will get smooth fast run without accelerate the game and without glitchs

like this mode : 

 

lmao. This should be custom or standard animation?

Edited by majqq
Posted

its client side script with custom animation combined with setPedAnimationSpeed.

custom animation is just a standard animation edited a bit.

i will not be a part of a group who support baby killers.

Posted

speed run from Slothman's superpowers script;

local obj = {} 
  
function WaterWalk() 
if obj[localPlayer] then 
local x,y,_ = getElementPosition(localPlayer) 
setElementPosition(obj[localPlayer],x,y,-.6) 
end 
end 

  
function WaterOn() 
local px,py,_ = getElementPosition(localPlayer) 
obj[localPlayer] = createObject(3095,px,py,-2) 
setElementAlpha(obj[localPlayer],0)
setElementDimension(obj[localPlayer], getElementDimension(localPlayer))
setTimer ( destroyElement, 50, 1, obj[localPlayer])
end 

function getPointFromDistanceRotation(x, y, dist, angle)

    local a = math.rad(90 - angle);
 
    local dx = math.cos(a) * dist;
    local dy = math.sin(a) * dist;
 
    return x+dx, y+dy;
 
end


speeding = 0
resting = 0
function speedforce( key, keyState, obj )
	if keyState == "down" then
		if speeding == 0 then
			if isTimer(buildup) then
				resetTimer(buildup)
			else
				buildup = setTimer ( startSpeeding, 1000, 1)
			end
		end
	else
		if isTimer(buildup) then
			killTimer(buildup)
			buildup = nil
		end
		if speeding == 1 then
			outofspeed()
		end
	end
end
bindKey ( "sprint", "both", speedforce )


function startSpeeding()
	if resting == 0 then
		speeding = 1
		buildup = nil
		-- endRun = setTimer( outofspeed, 9999999999, 0 )
		addEventHandler("onClientRender",getRootElement(), speedupplayer )
		addEventHandler("onClientRender",getRootElement(), WaterOn )
		addEventHandler ("onClientRender",getRootElement(),WaterWalk) 
		-- triggerServerEvent ("onSpeedChange", getLocalPlayer(), "fast")
		-- triggerEvent( "switchRadialBlur", root, true )
	end
end

function outofspeed()
	speeding = 0
	if isTimer(endRun) then
		killTimer(endRun)
		endRun = nil
	end
	resting = 1
	doneresting = setTimer( resetspeedpower, 50, 1 )
	removeEventHandler("onClientRender",getRootElement(), speedupplayer )
	removeEventHandler("onClientRender",getRootElement(), WaterOn )
	removeEventHandler ("onClientRender",getRootElement(),WaterWalk) 
	-- triggerServerEvent ("onSpeedChange", getLocalPlayer(), "normal")
	-- triggerEvent( "switchRadialBlur", root, false )
end


function resetspeedpower()
	resting = 0
	if getControlState("sprint") == true then
		speedforce( "sprint", "down" )
	end
end

function speedupplayer()
	if getControlState("sprint") == true then
		if getControlState("forwards") == true or getControlState("backwards") == true or getControlState("left") == true or getControlState("right") == true then
			-- setPedWeaponSlot(getLocalPlayer(), 0)
			local x, y, z = getElementPosition(getLocalPlayer())
			local prot = getPedRotation(getLocalPlayer())
			local nx, ny = getPointFromDistanceRotation(x, y, 1, (prot)*-1)
			local clear = isLineOfSightClear( x, y, z, nx, ny, z, true, true, true, true, true, true, true)
			if clear == true then
				local lx, ly = getPointFromDistanceRotation(x, y, 1, (prot-8)*-1)
				local rx, ry = getPointFromDistanceRotation(x, y, 1, (prot+8)*-1)
				local clearl = isLineOfSightClear( x, y, z, lx, ly, z, true, true, true, true, true, true, true)
				local clearr = isLineOfSightClear( x, y, z, rx, ry, z, true, true, true, true, true, true, true)
				if clearl == true and clearr == true then
					local task = getPedSimplestTask(getLocalPlayer())
					if task == "TASK_SIMPLE_PLAYER_ON_FOOT" then
						local nz = getGroundPosition ( nx, ny, z+1 )
						if  getDistanceBetweenPoints3D( x, y, z, nx, ny, nz) < 2 then
							setElementPosition(getLocalPlayer(), nx, ny, nz+1, false)
						end
					elseif task == "TASK_SIMPLE_SWIM" then
						local level = getWaterLevel ( nx, ny, z )
						if level then
							if  getDistanceBetweenPoints3D( x, y, z, nx, ny, level) < 2 then
								local nx2, ny2 = getPointFromDistanceRotation(x, y, 1, (prot)*-1)
								local clear = isLineOfSightClear( x, y, z, nx2, ny2, z, true, true, true, true, true, true, true)
								setElementPosition(getLocalPlayer(), nx, ny, level, false)
							end
						end
					end
				end
			end
		end
	end
end

 

Posted
addEventHandler("onClientRender",getRootElement(),
function()
	if getPedMoveState(localPlayer) == "sprint" and getKeyState("space") and not localPlayer:getData("brokenbone") then
		setPedControlState("sprint",not getPedControlState("sprint")) 
	end
end)

my script from 2015 year. use this in client.lua (clientside script)

Posted
1 hour ago, XaskeL said:

addEventHandler("onClientRender",getRootElement(),function()	if getPedMoveState(localPlayer) == "sprint" and getKeyState("space") and not localPlayer:getData("brokenbone") then		setPedControlState("sprint",not getPedControlState("sprint")) 	endend)

my script from 2015 year. use this in client.lua (clientside script)

Thank you very much :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...