Jump to content

[Help] Fatigue


iPanda

Recommended Posts

Posted

Guys, on some servers, I saw that they had a script endurance - ie fatigue while running a sprint.

How it works: The player ran a sprint distance can not run a sprint, and the only light jogging. To start running again, the player must sprint to rest, such as squat and wait.

If you can get me this resource - I will be forever grateful to you!

Oh, I'm sorry for my English, I am a citizen of Russia and do not know much English ...

Posted
toggleControl 

I just recently teaching language Lua and I do not know how to do this function with toggleControl, can give a ready-made script, if not difficult?

Posted
We don't accept requests here.

Here is the endurance. But her work is not quite stable - help fix :cry:

stamina = 10 
  
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), 
  function () 
    stamina = 10 
    setTimer(checkKey,10000,0) 
    setTimer(updateStamina,5000,0) 
  end 
) 
  
function checkKey() 
  if ( getControlState ( "sprint" ) ) and stamina ~= 0 then 
    stamina = stamina -1 
  end 
  if ( stamina == 0 ) then 
    setControlState( "sprint", false ) 
  end 
end 
    
function updateStamina() 
  if stamina ~= 10 and getControlState ( "sprint" ) == false then 
    stamina = stamina +1 
  end 
end 

Posted
When do you want to enable run, and when do you want to disable it?.

Running sprint should last ten seconds, and then to run again sprint to otdohnu six seconds.

Posted
When do you want to enable run, and when do you want to disable it?.

Maybe this is better?

local sprint = 100; 
  
addEventHandler( "onClientRender", getRootElement(), function() 
  if getControlState( "sprint" ) then 
    sprint = sprint - 0.01; 
    if sprint <= 1 then 
      sprint = 0; 
      toggleControl( "sprint", false ); 
    else 
      toggleControl( "sprint", true); 
    end; 
  else 
    if sprint < 100 then 
      sprint = sprint + 0.01; 
    end; 
  end; 
); 

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