AreVehicleLightsOn: Difference between revisions
Jump to navigation
Jump to search
m (fix newline) |
JavadOmidi (talk | contribs) |
||
Line 18: | Line 18: | ||
==Example== | ==Example== | ||
This example checks if your vehicle lights are on/off and tells you the reason | |||
<syntaxhighlight lang="lua">addCommandHandler('checkMyLights' , function () | |||
if not isPedInVehicle(localPlayer) then | |||
outputChatBox('Please enter your vehicle first' , 150 , 50 , 0 ) | |||
end | |||
local message = '' | |||
local myVehicle = getPedOccupiedVehicle(localPlayer) | |||
local checkIfOverrided = getVehicleOverrideLights(myVehicle) | |||
if checkIfOverrided == 0 then | |||
if areVehicleLightsOn(myVehicle) then | |||
local h , m = getTime() | |||
if h > 6 and h < 20 then | |||
message = 'on. Reason: You are in a dark place' -- vehicle lights turn on in some dark places during the day like this position x:-1513 y:-287 z:6 | |||
else | |||
message = 'on. Reason: It is night' | |||
end | |||
else | |||
message = 'off. Reason: It is day' | |||
end | |||
elseif checkIfOverrided == 1 then | |||
message = 'off. Reason: They are forced off' | |||
else | |||
message = 'on. Reason: They are forced on' | |||
end | |||
outputChatBox('Your vehicle lights are turned '..message , 0 , 150 , 50 ) | |||
end)</syntaxhighlight> | |||
By javadOmidi | |||
==See Also== | ==See Also== | ||
{{Client vehicle functions}} | {{Client vehicle functions}} |
Revision as of 07:41, 28 October 2019
This function is used to find out whether the lights of the vehicle are on.
Syntax
bool areVehicleLightsOn ( vehicle theVehicle )
OOP Syntax Help! I don't understand this!
- Method: vehicle:areLightsOn(...)
- Variable: .lightsOn
Required Arguments
- theVehicle: the vehicle you wish to retrieve the lights state of.
Returns
Returns true if the lights are on, false otherwise.
Example
This example checks if your vehicle lights are on/off and tells you the reason
addCommandHandler('checkMyLights' , function () if not isPedInVehicle(localPlayer) then outputChatBox('Please enter your vehicle first' , 150 , 50 , 0 ) end local message = '' local myVehicle = getPedOccupiedVehicle(localPlayer) local checkIfOverrided = getVehicleOverrideLights(myVehicle) if checkIfOverrided == 0 then if areVehicleLightsOn(myVehicle) then local h , m = getTime() if h > 6 and h < 20 then message = 'on. Reason: You are in a dark place' -- vehicle lights turn on in some dark places during the day like this position x:-1513 y:-287 z:6 else message = 'on. Reason: It is night' end else message = 'off. Reason: It is day' end elseif checkIfOverrided == 1 then message = 'off. Reason: They are forced off' else message = 'on. Reason: They are forced on' end outputChatBox('Your vehicle lights are turned '..message , 0 , 150 , 50 ) end)
By javadOmidi
See Also
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- 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