GetVehicleController: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(11 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function is used to get the player in control of the specified vehicle. | {{Server client function}} | ||
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== | ==Syntax== | ||
Line 6: | Line 7: | ||
player getVehicleController ( vehicle theVehicle ) | player getVehicleController ( vehicle theVehicle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:getController|controller}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle:''' | *'''theVehicle:''' the [[vehicle]] you want to get the 'controller' of. | ||
===Returns=== | ===Returns=== | ||
Returns a | Returns a [[player]] object, if there isn't a driver, it will search the 'trailer chain' for the front driver, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example | <section name="Server" class="server" show="true"> | ||
This example outputs a chatbox message when a vehicle gets a trailer attached. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function scriptOnTrailerAttach ( towedBy ) | |||
function | |||
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 | ||
outputChatBox ( getPlayerName ( thePlayer ).. " attached a trailer" ) | |||
else | else | ||
outputChatBox ( "trailer attached" ) | |||
end | end | ||
end | end | ||
addEventHandler ( "onTrailerAttach", root, scriptOnTrailerAttach ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Vehicle_functions}} |
Latest revision as of 09:09, 4 November 2020
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 )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getController(...)
- Variable: .controller
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 [-]
ServerThis 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
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates