Sign in to follow this  
#RooTs

cancel bind

Recommended Posts

is there any way for me to cancel the "w" and "space" for me I get to create a stamina system.

I want to cancel so I can not run. ( "w" and "space" )

Share this post


Link to post
unbindKey 

As far as I know, cancelEvent is used for events not for functions and "bindKey" is a function not an event

Share this post


Link to post
unbindKey 

As far as I know, cancelEvent is used for events not for functions and "bindKey" is a function not an event

I will cancel the bind of an event that I do not know what it is?

Share this post


Link to post

I think. I did not express myself right.

when I press w + space. it runs faster. I want to cancel it and after a while activate again

Share this post


Link to post

Try this,

addEventHandler("onClientKey", root,  
function ( key, press ) 
    if (key == "w") then  
        if (getKeyState("space")) then 
            cancelEvent() 
        end 
    end 
end) 

Share this post


Link to post
Try this,
addEventHandler("onClientKey", root,  
function ( key, press ) 
    if (key == "w") then  
        if (getKeyState("space")) then 
            cancelEvent() 
        end 
    end 
end) 

server or clientSide ?

Share this post


Link to post

@KariiiM, nothing happens. :lol::lol::lol:

addEventHandler("onClientKey", root, 
function ( key, press ) 
    if (key == "w") then 
        if (getKeyState("space")) then 
        cancelEvent() 
        outputChatBox ( "test" ) 
        end 
    end 
end) 

Share this post


Link to post

client side:

bindKey( "w", "down",  
function () 
    if (getKeyState("space") == true) then 
        cancelEvent () 
    end 
end) 

Share this post


Link to post
client side:
bindKey( "w", "down", "cancel", 
function () 
    if (getKeyState("space") == true) then 
        cancelEvent () 
    end 
end) 

It is not possible to cancel bindKey function, only via event.

Share this post


Link to post
Rly men, just do like you did toggleControl it will work...

my attempt was this. but it did not work

function test(thePlayer, command) 
toggleControl("sprint", false) 
outputChatBox ( "test1" ) 
end 
  
addCommandHandler ( "test", test ) 

Share this post


Link to post
client side:

It is not possible to cancel bindKey function, only via event.

Yeah man I know that, but I can't even think I am too sleepy..

Share this post


Link to post

Try this @Root:

addEventHandler ( "onClientKey", getRootElement(), 
function (button, press) 
    if (button == "w") then 
        setElementData (getLocalPlayer(), "w", press) 
    else  
        return false 
    end 
    if (button == "space" and press) then 
        if (getElementData (getLocalPlayer(), "w")) then 
            cancelEvent() --cancel the event 
        end 
    end 
end) 

Share this post


Link to post

@KariiiM, not work.

maybe with??:

toggleControl("sprint", false) 

addEventHandler ( "onClientKey", getRootElement(), 
function (button, press) 
    if (button == "w") then 
        setElementData (getLocalPlayer(), "w", press) 
    else 
        return false 
    end 
    if (button == "space" and press) then 
        if (getElementData (getLocalPlayer(), "w")) then 
            toggleControl("sprint", false) 
        end 
    end 
end) 

but it also did not work :cry::cry:

Share this post


Link to post
addEventHandler("onClientKey", getRootElement(), function(button, press) 
    if(button == "space") then 
        local keyState = getKeyState("w") 
        if(keyState) then 
            cancelEvent() 
        end 
    end 
end) 

Share this post


Link to post

@Hornet. worked, thx.

I can now improve. and create a stamina system. thanks!

You want to join me to complete the system?

Share this post


Link to post
Rly men, just do like you did toggleControl it will work...

my attempt was this. but it did not work

function test(thePlayer, command) 
toggleControl("sprint", false) 
outputChatBox ( "test1" ) 
end 
  
addCommandHandler ( "test", test ) 

sprint is running, it will only stop running, but if u want to stop walk u can use theese.

  
toggleControl("forwards", false) 
toggleControl("backwards", false) 
toggleControl("left", false) 
toggleControl("right", false) 
  

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.