getVehicleController | Multi Theft Auto: Wiki Skip to content

getVehicleController

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:getController(...)
  • Variable: .controller

Syntax

player getVehicleController ( vehicle theVehicle )
Required Arguments
  • theVehicle: the vehicle you want to get the 'controller' of.

Returns

  • player: value

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

Code Examples

shared

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", root, scriptOnTrailerAttach )

See Also

Vehicle Functions