iPanda Posted July 16, 2013 Share Posted July 16, 2013 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 ... Link to comment
iPanda Posted July 21, 2013 Author Share Posted July 21, 2013 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? Link to comment
Castillo Posted July 21, 2013 Share Posted July 21, 2013 We don't accept requests here. Link to comment
iPanda Posted July 22, 2013 Author Share Posted July 22, 2013 We don't accept requests here. Here is the endurance. But her work is not quite stable - help fix 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 Link to comment
iMr.3a[Z]eF Posted July 23, 2013 Share Posted July 23, 2013 When do you want to enable run, and when do you want to disable it?. Link to comment
iPanda Posted July 23, 2013 Author Share Posted July 23, 2013 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. Link to comment
iPanda Posted July 23, 2013 Author Share Posted July 23, 2013 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; ); Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now