GetVehicleController: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:


===Returns===
===Returns===
Returns a player object, if there isn't a driver, it will search the 'trailer chain' for the front driver.
Returns a [[player]] object, if there isn't a driver, it will search the 'trailer chain' for the front driver.


==Example==  
==Example==  

Revision as of 16:30, 28 August 2006

This function is used to get the player in control of the specified vehicle.

Syntax

player getVehicleController ( vehicle theVehicle )            

Required Arguments

  • theVehicle: The vehicle you want to get the 'controller' of.

Returns

Returns a player object, if there isn't a driver, it will search the 'trailer chain' for the front driver.

Example

This example does...

addEventHandler ( "onTrailerAttach", root, "onTrailerAttach" )
function onTrailerAttach ( trailer )
  thePlayer = getVehicleController ( source ) -- get the controller of the towing vehicle
  if ( thePlayer ) then
    chat ( getClientName ( thePlayer ).. " attached a trailer" )
  else
    chat ( "trailer attached" )
  end
end

See Also