GetVehicleController

From Multi Theft Auto: Wiki
Revision as of 10:30, 26 July 2012 by Arran Fortuna (talk | contribs)
Jump to navigation Jump to search

This function is used to get the player in control of the specified vehicle which includes somebody who is trying to enter the drivers seat.

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, false otherwise.

Example

Click to collapse [-]
Server

This example outputs a chatbox message when a vehicle gets a trailer attached.

function scriptOnTrailerAttach ( towedBy )
  thePlayer = getVehicleController ( source ) -- get the controller of the towing vehicle
  if ( thePlayer ) then
    outputChatBox ( getPlayerName ( thePlayer ).. " attached a trailer" )
  else
    outputChatBox ( "trailer attached" )
  end
end
addEventHandler ( "onTrailerAttach", getRootElement(), scriptOnTrailerAttach )

See Also