IsVehicleTaxiLightOn: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function will get the taxi light state of a taxi (vehicle | This function will get the taxi light state of a taxi (vehicle IDs 420 and 438) | ||
==Syntax== | ==Syntax== | ||
Line 8: | Line 7: | ||
bool isVehicleTaxiLightOn ( vehicle taxi ) | bool isVehicleTaxiLightOn ( vehicle taxi ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:isTaxiLightOn|taxiLightOn|setVehicleTaxiLightOn}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''taxi:''' The vehicle element of the taxi that you wish to get the light state of. | *'''taxi:''' The vehicle element of the taxi that you wish to get the light state of. | ||
Line 20: | Line 19: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function toggleTaxiLight() | function toggleTaxiLight() | ||
local theVehicle = getPedOccupiedVehicle(localPlayer) | |||
if theVehicle then | |||
if localPlayer == getVehicleOccupant(theVehicle, 0) then -- if is a driver | |||
local id = getElementModel(theVehicle) -- getting vehicle model | |||
if ((id == 420) or (id == 438)) then -- if is a taxi | |||
local lights = isVehicleTaxiLightOn(theVehicle) -- getting vehicle lights state | |||
setVehicleTaxiLightOn(theVehicle, not lights) -- switch lights | |||
end | |||
end | |||
end | |||
end | end | ||
bindKey("o", "down", toggleTaxiLight) -- binding the function | bindKey("o", "down", toggleTaxiLight) -- binding the function | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 16:38, 3 August 2020
This function will get the taxi light state of a taxi (vehicle IDs 420 and 438)
Syntax
bool isVehicleTaxiLightOn ( vehicle taxi )
OOP Syntax Help! I don't understand this!
- Method: vehicle:isTaxiLightOn(...)
- Variable: .taxiLightOn
- Counterpart: setVehicleTaxiLightOn
Required Arguments
- taxi: The vehicle element of the taxi that you wish to get the light state of.
Returns
Returns true if the light is on, false otherwise.
Example
Click to collapse [-]
ClientThis example binds the 'o' key to a function that toggles the taxi's light on and off, if you're in a taxi.
function toggleTaxiLight() local theVehicle = getPedOccupiedVehicle(localPlayer) if theVehicle then if localPlayer == getVehicleOccupant(theVehicle, 0) then -- if is a driver local id = getElementModel(theVehicle) -- getting vehicle model if ((id == 420) or (id == 438)) then -- if is a taxi local lights = isVehicleTaxiLightOn(theVehicle) -- getting vehicle lights state setVehicleTaxiLightOn(theVehicle, not lights) -- switch lights end end end end bindKey("o", "down", toggleTaxiLight) -- binding the function
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