SetVehicleEngineState: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Added sections, minor changes, improved example) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function | This function turns a vehicle's engine on or off. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setVehicleEngineState ( vehicle theVehicle, bool | <section name="Server and Client" class="both" show="true"/> | ||
<syntaxhighlight lang="lua"> | |||
bool setVehicleEngineState ( vehicle theVehicle, bool engineState ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle''': The [[vehicle]] you wish to change the engine state of. | *'''theVehicle''': The [[vehicle]] you wish to change the engine state of. | ||
*''' | *'''engineState''': A boolean value representing whether the engine will be turned on (''true'') or off (''false''). | ||
==Returns== | ===Returns=== | ||
Returns ''true'' if the vehicle's engine state was successfully changed, ''false'' otherwise. | Returns ''true'' if the vehicle's engine state was successfully changed, ''false'' otherwise. | ||
</section> | |||
==Example== | ==Example== | ||
This example will | <section name="Serverside example" class="server" show="true"/> | ||
This example will turn off a vehicle's engine when the driver gets out of the car. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function turnEngineOff ( theVehicle, leftSeat, jackerPlayer ) | ||
if | -- if it's the driver who got out, and he was not jacked, | ||
setVehicleEngineState ( theVehicle, false ) | if leftSeat == 0 and not jackerPlayer then | ||
-- turn off the engine | |||
setVehicleEngineState ( theVehicle, false ) | |||
end | end | ||
end | end | ||
addEventHandler ( " | -- add 'turnEngineOff' as a handler for "onPlayerExitVehicle" | ||
addEventHandler ( "onPlayerExitVehicle", getRootElement ( ), turnEngineOff ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 21:20, 27 August 2007
This function turns a vehicle's engine on or off.
Syntax
Click to collapse [-]
Server and Clientbool setVehicleEngineState ( vehicle theVehicle, bool engineState )
Required Arguments
- theVehicle: The vehicle you wish to change the engine state of.
- engineState: A boolean value representing whether the engine will be turned on (true) or off (false).
Returns
Returns true if the vehicle's engine state was successfully changed, false otherwise. </section>
Example
Click to collapse [-]
Serverside exampleThis example will turn off a vehicle's engine when the driver gets out of the car.
function turnEngineOff ( theVehicle, leftSeat, jackerPlayer ) -- if it's the driver who got out, and he was not jacked, if leftSeat == 0 and not jackerPlayer then -- turn off the engine setVehicleEngineState ( theVehicle, false ) end end -- add 'turnEngineOff' as a handler for "onPlayerExitVehicle" addEventHandler ( "onPlayerExitVehicle", getRootElement ( ), turnEngineOff )
</section>
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