#RooTs Posted March 29, 2016 Posted March 29, 2016 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" )
KariiiM Posted March 29, 2016 Posted March 29, 2016 unbindKey As far as I know, cancelEvent is used for events not for functions and "bindKey" is a function not an event
#RooTs Posted March 29, 2016 Author Posted March 29, 2016 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?
RenanPG Posted March 29, 2016 Posted March 29, 2016 addEventHandler("onClientKey", root, function(key, press) if(key == "w") then cancelEvent() end end) https://wiki.multitheftauto.com/wiki/OnClientKey
#RooTs Posted March 29, 2016 Author Posted March 29, 2016 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
KariiiM Posted March 29, 2016 Posted March 29, 2016 Try this, addEventHandler("onClientKey", root, function ( key, press ) if (key == "w") then if (getKeyState("space")) then cancelEvent() end end end)
RenanPG Posted March 29, 2016 Posted March 29, 2016 toggleControl Something like this? toggleControl("sprint", false)
#RooTs Posted March 29, 2016 Author Posted March 29, 2016 Try this, addEventHandler("onClientKey", root, function ( key, press ) if (key == "w") then if (getKeyState("space")) then cancelEvent() end end end) server or clientSide ?
#RooTs Posted March 30, 2016 Author Posted March 30, 2016 @KariiiM, nothing happens. addEventHandler("onClientKey", root, function ( key, press ) if (key == "w") then if (getKeyState("space")) then cancelEvent() outputChatBox ( "test" ) end end end)
KariiiM Posted March 30, 2016 Posted March 30, 2016 client side: bindKey( "w", "down", function () if (getKeyState("space") == true) then cancelEvent () end end)
RenanPG Posted March 30, 2016 Posted March 30, 2016 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.
xScatta Posted March 30, 2016 Posted March 30, 2016 Rly men, just do like you did toggleControl it will work...
#RooTs Posted March 30, 2016 Author Posted March 30, 2016 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 )
KariiiM Posted March 30, 2016 Posted March 30, 2016 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..
KariiiM Posted March 30, 2016 Posted March 30, 2016 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)
#RooTs Posted March 30, 2016 Author Posted March 30, 2016 @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
RenanPG Posted March 30, 2016 Posted March 30, 2016 addEventHandler("onClientKey", getRootElement(), function(button, press) if(button == "space") then local keyState = getKeyState("w") if(keyState) then cancelEvent() end end end)
#RooTs Posted March 30, 2016 Author Posted March 30, 2016 @Hornet. worked, thx. I can now improve. and create a stamina system. thanks! You want to join me to complete the system?
Fist Posted March 30, 2016 Posted March 30, 2016 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)
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