Jump to content

Help make the endurance


iPanda

Recommended Posts

-

Guys, I have a problem! My endurance script does not work, help fix the problem ...

local sprint = 100 
  
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), 
  function () 
    local sprint = 100 
    setTimer( sprintDown, 10000, 0 ) 
    setTimer( sprintUp, 10000, 0 ) 
  end 
) 
  
function sprintDown ( ) 
  if ( getControlState( "sprint" ) ) and sprint == 100 then 
    sprint = sprint - 0.01 
  end 
  if sprint <= 1 then 
    sprint = 0 
    toggleControl( "sprint", false ) 
  end 
end 
  
function sprintUp ( ) 
  if ( getControlState ( "sprint" ) ) == false and sprint < 100 then 
    sprint = sprint + 0.01 
    toggleControl( "sprint", true ) 
  end 
end 

Link to comment

try this:

local sprint = 100 
  
addEventHandler ( "onClientPlayerSpawn",localPlayer,function () 
    local sprint = 100 
    addEventHandler("onClientRender",root,sprintDown) 
    addEventHandler("onClientRender",root,sprintUp) 
end) 
  
function sprintDown ( ) 
    if ( getControlState( "sprint" ) ) and sprint == 100 then 
        sprint = sprint - 0.01 
    end 
    if sprint <= 1 then 
        sprint = 0 
        toggleControl( "sprint", false ) 
    end 
end 
  
function sprintUp ( ) 
    if ( getControlState ( "sprint" ) ) == false and sprint < 100 then 
        sprint = sprint + 0.01 
        toggleControl( "sprint", true ) 
    end 
end 

Link to comment
try this:
local sprint = 100 
  
addEventHandler ( "onClientPlayerSpawn",localPlayer,function () 
    local sprint = 100 
    addEventHandler("onClientRender",root,sprintDown) 
    addEventHandler("onClientRender",root,sprintUp) 
end) 
  
function sprintDown ( ) 
    if ( getControlState( "sprint" ) ) and sprint == 100 then 
        sprint = sprint - 0.01 
    end 
    if sprint <= 1 then 
        sprint = 0 
        toggleControl( "sprint", false ) 
    end 
end 
  
function sprintUp ( ) 
    if ( getControlState ( "sprint" ) ) == false and sprint < 100 then 
        sprint = sprint + 0.01 
        toggleControl( "sprint", true ) 
    end 
end 

Sorry, your version does not work ...

Link to comment
local sprint = 100 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        if ( getElementHealth ( localPlayer ) > 0 ) then 
            sprint = 100 
            addEventHandler ( "onClientRender", root, onPlayerSprint ) 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerSpawn", localPlayer, 
    function ( ) 
        sprint = 100 
        addEventHandler ( "onClientRender", root, onPlayerSprint ) 
    end 
) 
  
function onPlayerSprint ( ) 
    if getControlState ( "sprint" ) then 
        if ( sprint > 0 ) then 
            sprint = ( sprint - 0.01 ) 
            if ( sprint == 0 ) then 
                toggleControl ( "sprint", false ) 
            end 
        end 
    else 
        if ( sprint < 100 ) then 
            sprint = ( sprint + 0.01 ) 
            if ( sprint == 100 ) then 
                toggleControl ( "sprint", true ) 
            end 
        end 
    end 
end 

Link to comment
local sprint = 100 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        if ( getElementHealth ( localPlayer ) > 0 ) then 
            sprint = 100 
            addEventHandler ( "onClientRender", root, onPlayerSprint ) 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerSpawn", localPlayer, 
    function ( ) 
        sprint = 100 
        addEventHandler ( "onClientRender", root, onPlayerSprint ) 
    end 
) 
  
function onPlayerSprint ( ) 
    if getControlState ( "sprint" ) then 
        if ( sprint > 0 ) then 
            sprint = ( sprint - 0.01 ) 
            if ( sprint == 0 ) then 
                toggleControl ( "sprint", false ) 
            end 
        end 
    else 
        if ( sprint < 100 ) then 
            sprint = ( sprint + 0.01 ) 
            if ( sprint == 100 ) then 
                toggleControl ( "sprint", true ) 
            end 
        end 
    end 
end 

It is server or client?

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