Jump to content

[HELP] Car clutch system


kuwalda

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...