Jump to content

Get driver of tow vehicle


Captain Cody

Recommended Posts

towingVehicle = getVehicleTowedByVehicle ( trailer ) 
playeraab = getVehicleOccupant ( towingVehicle ) 
  
trailer = createVehicle (435, 64.477539, -268.84082, 3, 0, 0, 360) 

error in debugscript - Expected vehicle argument for getVehicleTowedbyVehicle and GetVehicleOccupant.

The error is happening because you first check for the trailer and after that you create it.

trailer = createVehicle (435, 64.477539, -268.84082, 3, 0, 0, 360) 
towingVehicle = getVehicleTowedByVehicle ( trailer ) 
playeraab = getVehicleOccupant ( towingVehicle ) 

That should do the trick.

Oh and also, you should warp a player or ped inside of it before checking out for the occupant. How are you supposed to check for the occupants at the exact moment when the vehicle is created? Use the "OnVehicleEnter" function or some timer.

Ex:

trailer = createVehicle (435, 64.477539, -268.84082, 3, 0, 0, 360) 
towingVehicle = getVehicleTowedByVehicle ( trailer ) 
  
addEventHandler ("onVehicleEnter",towingVehicle,function() 
playeraab = getVehicleOccupant ( towingVehicle ) 
end) 

Remember that te scripted functions always get executed in the same order:

  
-- RIGHT WAY 
ped = createPed (0,0,0,5) -- You first create the ped 
setElementRotation (ped,0,0,60) -- Then you use a function to interact with it 
  
  
-- WRONG WAY 
setElementRotation (ped,0,0,60) -- You first interact with the ped 
ped = createPed (0,0,0,5) -- Then you create it 
  

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...