SetVehicleOverrideLights: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function changes the light overriding setting on a vehicle | This function changes the light overriding setting on a vehicle. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setVehicleOverrideLights ( vehicle theVehicle, int value )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setVehicleOverrideLights ( vehicle theVehicle, int value )</syntaxhighlight> | ||
Line 7: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle''': The [[vehicle]] you wish to change the override lights setting of. | *'''theVehicle''': The [[vehicle]] you wish to change the override lights setting of. | ||
*'''value''': A whole number representing | *'''value''': A whole number representing the state of the lights: | ||
** '''0''': No override, lights are set to default. | |||
** '''1''': Lights are forced off. | |||
** '''2''': Lights are forced on. | |||
==Returns== | ==Returns== | ||
Line 13: | Line 17: | ||
==Example== | ==Example== | ||
This example will toggle the car lights on and off for a player's vehicle | <section name="Example 1" class="server" show="true"> | ||
This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command. | |||
<syntaxhighlight lang="lua"> | |||
function consoleVehicleLights ( source ) | |||
playerVehicle = getPlayerOccupiedVehicle ( source ) -- get the player's vehicle | |||
if ( playerVehicle ) then -- if he was in one | |||
if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then -- if the current state isn't 'force on' | |||
setVehicleOverrideLights ( playerVehicle, 2 ) -- force the lights on | |||
else | |||
setVehicleOverrideLights ( playerVehicle, 1 ) -- otherwise, force the lights off | |||
end | |||
end | |||
end | |||
addCommandHandler ( "vehiclelights", consoleVehicleLights ) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Example 2" class="client" show="false"> | |||
This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function consoleVehicleLights () | ||
playerVehicle = getPlayerOccupiedVehicle ( getLocalPlayer() ) -- get the local player's vehicle | |||
if ( | if ( playerVehicle ) then -- if he was in one | ||
if ( getVehicleOverrideLights ( | if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then -- if the current state isn't 'force on' | ||
setVehicleOverrideLights ( | setVehicleOverrideLights ( playerVehicle, 2 ) -- force the lights on | ||
else | else | ||
setVehicleOverrideLights ( | setVehicleOverrideLights ( playerVehicle, 1 ) -- otherwise, force the lights off | ||
end | end | ||
end | end | ||
end | end | ||
addCommandHandler ( "vehiclelights", | addCommandHandler ( "vehiclelights", consoleVehicleLights ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 15:13, 29 August 2007
This function changes the light overriding setting on a vehicle.
Syntax
bool setVehicleOverrideLights ( vehicle theVehicle, int value )
Required Arguments
- theVehicle: The vehicle you wish to change the override lights setting of.
- value: A whole number representing the state of the lights:
- 0: No override, lights are set to default.
- 1: Lights are forced off.
- 2: Lights are forced on.
Returns
Returns true if the vehicle's lights setting was changed. Otherwise false.
Example
Click to collapse [-]
Example 1This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.
function consoleVehicleLights ( source ) playerVehicle = getPlayerOccupiedVehicle ( source ) -- get the player's vehicle if ( playerVehicle ) then -- if he was in one if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then -- if the current state isn't 'force on' setVehicleOverrideLights ( playerVehicle, 2 ) -- force the lights on else setVehicleOverrideLights ( playerVehicle, 1 ) -- otherwise, force the lights off end end end addCommandHandler ( "vehiclelights", consoleVehicleLights )
Click to expand [+]
Example 2See 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