Dzsozi (h03) Posted May 29, 2014 Share Posted May 29, 2014 Hi! I have a question. How can I check if a button, for example L Shift gets pressed repeatedly? Because I want to do a function if I hold down a key the character starts jogging, but if I keep pushing it the character starts to sprint. How could I do this? Does anyone could help me in this please? Thank you! Link to comment
Karuzo Posted May 29, 2014 Share Posted May 29, 2014 You could use to getKeyState check which key was pressed. And maybe a variable which counts how often that key was pressed so you could do the jogging. Link to comment
Dzsozi (h03) Posted May 29, 2014 Author Share Posted May 29, 2014 Thank you, I will try something! Link to comment
Dzsozi (h03) Posted June 3, 2014 Author Share Posted June 3, 2014 Okay, so I made a script, but my problem is that I don't know how to get the player's sprint key. So for example my sprint is binded to left shift, but other players have other binds, for example my friend's sprint key is space. How can I get the sprint button and bind it? So everyone can use it with their binds. Right now I have this: bindKey( "lshift", "both", function () if getKeyState("lshift") == true then setControlState ( "walk", false ) setControlState ( "sprint", false ) outputChatBox("jogging") elseif getKeyState("lshift") == false then setControlState ( "walk", true ) setControlState ( "sprint", false ) outputChatBox("walking") end end ) And I want to make the script work like if you keep pressing the sprint button the character starts to sprint, but if you just hold it your character will be jogging and if you don't hold or press it then your character just simply walks. Can anybody help me in this please? Link to comment
Dzsozi (h03) Posted June 3, 2014 Author Share Posted June 3, 2014 Nevermind, I fixed it! Anyways, thanks! 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