#RooTs Posted March 29, 2016 Share 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" ) Link to comment
KariiiM Posted March 29, 2016 Share 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 Link to comment
#RooTs Posted March 29, 2016 Author Share 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? Link to comment
RenanPG Posted March 29, 2016 Share Posted March 29, 2016 addEventHandler("onClientKey", root, function(key, press) if(key == "w") then cancelEvent() end end) https://wiki.multitheftauto.com/wiki/OnClientKey Link to comment
#RooTs Posted March 29, 2016 Author Share 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 Link to comment
KariiiM Posted March 29, 2016 Share Posted March 29, 2016 Try this, addEventHandler("onClientKey", root, function ( key, press ) if (key == "w") then if (getKeyState("space")) then cancelEvent() end end end) Link to comment
RenanPG Posted March 29, 2016 Share Posted March 29, 2016 toggleControl Something like this? toggleControl("sprint", false) Link to comment
#RooTs Posted March 29, 2016 Author Share 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 ? Link to comment
#RooTs Posted March 30, 2016 Author Share 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) Link to comment
KariiiM Posted March 30, 2016 Share Posted March 30, 2016 client side: bindKey( "w", "down", function () if (getKeyState("space") == true) then cancelEvent () end end) Link to comment
RenanPG Posted March 30, 2016 Share 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. Link to comment
xScatta Posted March 30, 2016 Share Posted March 30, 2016 Rly men, just do like you did toggleControl it will work... Link to comment
#RooTs Posted March 30, 2016 Author Share 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 ) Link to comment
KariiiM Posted March 30, 2016 Share 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.. Link to comment
KariiiM Posted March 30, 2016 Share 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) Link to comment
#RooTs Posted March 30, 2016 Author Share 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 Link to comment
KariiiM Posted March 30, 2016 Share Posted March 30, 2016 I didn't test it, can you debug the code? Link to comment
RenanPG Posted March 30, 2016 Share 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) Link to comment
#RooTs Posted March 30, 2016 Author Share 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? Link to comment
Fist Posted March 30, 2016 Share 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) 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