GetVehicleController: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
This function is used to get the player in control of the specified vehicle.
This function is used to get the player in control of the specified vehicle.


Line 14: Line 15:


==Example==  
==Example==  
<section name="Server" class="server" show="true">
This example does...
This example does...
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onTrailerAttach", root, "onTrailerAttach" )
function scriptOnTrailerAttach ( trailer )
function onTrailerAttach ( trailer )
   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
Line 25: Line 26:
   end
   end
end
end
addEventHandler ( "onTrailerAttach", getRootElement(), scriptOnTrailerAttach )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Vehicle_functions}}
{{Vehicle_functions}}

Revision as of 18:26, 10 August 2007

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

Click to collapse [-]
Server

This example does...

function scriptOnTrailerAttach ( 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
addEventHandler ( "onTrailerAttach", getRootElement(), scriptOnTrailerAttach )

See Also