Jump to content

Not working properly.


iNsanex

Recommended Posts

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

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