iNsanex Posted June 10, 2012 Share Posted June 10, 2012 Hello, I earlier posted looking for a fix to CJ run so i set out to make a "Jerry rig" fix. The script im about to post basically unbinds the space key for half a second to prevent the player from sprinting quickly. I get no errors in debug script, but it's just not working local runner = nil function toggleRun(key, state) if (getKeyState("w") == true) and state == "down" then if isTimer(runner) then killTimer(runner) end runner = setTimer(setControlState, 200, 0, "sprint", not getControlState("sprint")) elseif state == "up" then if isTimer(runner) then killTimer(runner) end end end bindKey( "space", "down", toggleRun ) function reBind() bindKey( "space", "down", toggleRun ) end function playerPressedKey(button, press) if (press) then -- Only output when they press it down if button == space then if not isChatBoxActive() then if hitspace == 0 then hitspace = 1 else unbindKey("space") setTimer(reBind, 5000, 1) end end end end end addEventHandler("onClientKey", root, playerPressedKey) Link to comment
Castillo Posted June 10, 2012 Share Posted June 10, 2012 local runner = nil function toggleRun ( key, state ) if ( getKeyState ( "w" ) == true ) and ( state == "down" ) then if isTimer ( runner ) then killTimer ( runner ) end runner = setTimer ( setControlState, 200, 0, "sprint", not getControlState ( "sprint" ) ) elseif ( state == "up" ) then if isTimer ( runner ) then killTimer ( runner ) end end end bindKey ( "space", "down", toggleRun ) function reBind ( ) bindKey ( "space", "down", toggleRun ) end function playerPressedKey ( button, press ) if ( press ) then if ( button == "space" ) then -- You must check if the key pressed is "space", not space without "". if ( not isChatBoxActive ( ) ) then if ( hitspace == 0 ) then hitspace = 1 else unbindKey ( "space" ) setTimer ( reBind, 5000, 1 ) end end end end end addEventHandler ( "onClientKey", root, playerPressedKey ) Read comment. Link to comment
iNsanex Posted June 10, 2012 Author Share Posted June 10, 2012 hm, i added that in and it doesnt unbind space when i hit space to run still Link to comment
TAPL Posted June 10, 2012 Share Posted June 10, 2012 local runner = nil function toggleRun ( key, state ) if ( getKeyState ( "w" ) == true ) and ( state == "down" ) then if isTimer ( runner ) then killTimer ( runner ) end runner = setTimer ( setControlState, 200, 0, "sprint", not getControlState ( "sprint" ) ) elseif ( state == "up" ) then if isTimer ( runner ) then killTimer ( runner ) end end end bindKey ( "space", "down", toggleRun ) function reBind ( ) bindKey ( "space", "down", toggleRun ) end function playerPressedKey ( button, press ) if ( press ) then if ( button == "space" ) then -- You must check if the key pressed is "space", not space without "". if ( isChatBoxInputActive() ) then if ( hitspace == 0 ) then hitspace = 1 else unbindKey ( "space" ) setTimer ( reBind, 5000, 1 ) end end end end end addEventHandler ( "onClientKey", root, playerPressedKey ) 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