Jump to content

Disable CJ run


iNsanex

Recommended Posts

CJ walking is faster sprinting in samp the sprint speed is quite a bit slower, I've discovered the MTA sprint speed is 35 KM/h when you tap space bar repeatedly, on samp its around 21 KM/h if i had to guess, I'd like to lower the speed you sprint at when you tap space bar , CJ run is the term used for it, a common SAMP hack because in single player CJ ran faster then any other ped.

Link to comment
there is no need for all those functions :S
  
-- Client 
toggleControl("sprint",false) 
  

rofl, he doesn't want to disable sprinting.. But he believes MTA sprinting is faster than SA-MP sprinting so he wants to alter the maximum sprint speed of the player.

the topic name is 'Disable CJ run'

Link to comment
there is no need for all those functions :S
  
-- Client 
toggleControl("sprint",false) 
  

rofl, he doesn't want to disable sprinting.. But he believes MTA sprinting is faster than SA-MP sprinting so he wants to alter the maximum sprint speed of the player.

the topic name is 'Disable CJ run'

CJ walking is faster sprinting in samp the sprint speed is quite a bit slower, I've discovered the MTA sprint speed is 35 KM/h when you tap space bar repeatedly, on samp its around 21 KM/h if i had to guess, I'd like to lower the speed you sprint at when you tap space bar , CJ run is the term used for it, a common SAMP hack because in single player CJ ran faster then any other ped.
Link to comment

oh , then ..

  
function setElementSpeed(element, unit, speed) -- only work if element is moving! 
    if (unit == nil) then unit = 0 end 
    if (speed == nil) then speed = 0 end 
    speed = tonumber(speed) 
    local acSpeed = getElementSpeed(element, unit) 
    if (acSpeed~=false) then -- if true - element is valid, no need to check again 
        local diff = speed/acSpeed 
        local x,y,z = getElementVelocity(element) 
        setElementVelocity(element,x*diff,y*diff,z*diff) 
        return true 
    end 
  
    return false 
end 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
addEventHandler("onClientRender",root,function() 
    local speed = getElementSpeed(localPlayer,"mph") 
    if ( speed and speed > 21 and getControlState("sprint") == true ) then 
        setElementSpeed(localPlayer,"mph",21) 
    end 
end ) 
  

Link to comment
oh , then ..
  
function setElementSpeed(element, unit, speed) -- only work if element is moving! 
    if (unit == nil) then unit = 0 end 
    if (speed == nil) then speed = 0 end 
    speed = tonumber(speed) 
    local acSpeed = getElementSpeed(element, unit) 
    if (acSpeed~=false) then -- if true - element is valid, no need to check again 
        local diff = speed/acSpeed 
        local x,y,z = getElementVelocity(element) 
        setElementVelocity(element,x*diff,y*diff,z*diff) 
        return true 
    end 
  
    return false 
end 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
addEventHandler("onClientRender",root,function() 
    local speed = getElementSpeed(localPlayer,"mph") 
    if ( speed and speed > 21 and getControlState("sprint") == true ) then 
        setElementSpeed(localPlayer,"mph",21) 
    end 
end ) 
  

Wrong unit, and why do you provide him the code? It's a lot better if he would try himself rather than just being given the code.

Link to comment

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...