kuwalda Posted April 30, 2014 Share Posted April 30, 2014 Hello. I was just messing around with trying to make vehicle clutch system when changing gears. The code looks something like: function setPlayerGear( key, keyState ) if ( key == "num_add" and keyState == "up" ) then if playerGear < 5 then playerGear = playerGear + 1 local sound = playSound("grind.wav") setSoundVolume(sound, 0.3) end elseif ( key == "num_sub" and keyState == "up" ) then if playerGear > -1 then playerGear = playerGear - 1 local sound = playSound("grind.wav") setSoundVolume(sound, 0.3) end end end And it works fine when changing gears, but when I tried to add Cluch system, where player must press LCTRL and then they are allowed to change gear, i failed. I tried something like: if ( key == "num_add" and keyState == "up" ) and ( key == "lctrl" and keyState == "down" ) then But it didn`t work. Maybe someone see where is the problem and can help me out. Link to comment
Dealman Posted April 30, 2014 Share Posted April 30, 2014 You could make use of the function getKeyState to see whether lctrl is being held down or not. Link to comment
Karuzo Posted April 30, 2014 Share Posted April 30, 2014 You could make use of the function getKeyState to see whether lctrl is being held down or not. + Which event are you using to trigger this function? Link to comment
kuwalda Posted April 30, 2014 Author Share Posted April 30, 2014 I use bindKey( "num_add", "both", setPlayerGear ) EDIT: Okey thanks, I got it working with: if key == "num_add" and ( getKeyState( "lctrl" ) == true ) then But how do I force player to release the button, so its not like just driving and holding LCTRL all the time to switch gears? Something like freeze vechile movement speed or... any ideas? 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