Jump to content

Co-Driver can control car?


ChisleLP

Recommended Posts

Hey... I currently a little new. Or I would say, I'm not anymore new. So it started 2 days MTA Scripting (I can before Lua/Java) so its feel for me really easy. but now I'm thinking about:

 

Is it there a way to make co-drivers can control the cars? 

I couldn't find the Events/Function for it. :/

 

Thanks.

 

 

Link to comment

 

function driverAccelerate (keyPresser, key, keyState)
  
  if key == "W" and getPedOccupiedVehicleSeat(keyPresser) and getPedOccupiedVehicleSeat(keyPresser) ~= 0 then
   
    local veh = getPedOccupiedVehicle(keyPresser)
    local driver = getVehicleController(veh)
    
    if driver then
        if keyState == "down" then 
            setControlState (driver,"accelerate",true)
        else
            setControlState (driver,"accelerate",false)
        end
    else
      
      return
      
    end
    
  end
  
end

bindKey ( player, "W", "both", driverAccelerate) 


Untested :)

Edited by Zorgman
tweaked code
  • Thanks 1
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...