GetVehicleController: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:
   thePlayer = getVehicleController ( source ) -- get the controller of the towing vehicle
   thePlayer = getVehicleController ( source ) -- get the controller of the towing vehicle
   if ( thePlayer ) then
   if ( thePlayer ) then
     chat ( getClientName ( thePlayer ).. " attached a trailer" )
     outputChatBox ( getClientName ( thePlayer ).. " attached a trailer" )
   else
   else
     chat ( "trailer attached" )
     outputChatBox ( "trailer attached" )
   end
   end
end
end

Revision as of 16:35, 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
    outputChatBox ( getClientName ( thePlayer ).. " attached a trailer" )
  else
    outputChatBox ( "trailer attached" )
  end
end

See Also