iPanda Posted July 23, 2013 Share Posted July 23, 2013 - 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
Jaysds1 Posted July 23, 2013 Share Posted July 23, 2013 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
iPanda Posted July 24, 2013 Author Share Posted July 24, 2013 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
Castillo Posted July 24, 2013 Share Posted July 24, 2013 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
iPanda Posted July 27, 2013 Author Share Posted July 27, 2013 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
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