Squirrel/Server/Functions/Vehicles/LightState
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|Vehicle.LightState}} This ''Vehicle'' class member returns or sets the status of the lights. Possible values are listed [[Squirrel/Server/Constants#Vehicle_Light…') |
|||
Line 17: | Line 17: | ||
== Example 1. Returning the value == | == Example 1. Returning the value == | ||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( pPlayer, szCommand, szText ) | |
+ | { | ||
+ | if ( szCommand == "lights" ) | ||
+ | { | ||
+ | if ( pPlayer.Vehicle ) MessagePlayer( "Your light state is currently set to " + pPlayer.Vehicle.LightState, pPlayer ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. | |
== Example 2. Setting a new value == | == Example 2. Setting a new value == | ||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( pPlayer, szCommand, szText ) | |
+ | { | ||
+ | if ( szCommand == "lights2" ) | ||
+ | { | ||
+ | if ( pPlayer.Vehicle ) pPlayer.Vehicle.LightState = LIGHTSTATE_ON; | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in this example. More info about this in the corresponding page. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Vehicles}} | {{Squirrel/Server/Functions/Vehicles}} |
Latest revision as of 17:08, 29 September 2010
This Vehicle class member returns or sets the status of the lights. Possible values are listed here.
[edit] Syntax
You can either return or set a new value using this member:
int Vehicle.LightState
Vehicle.LightState = int lights
[edit] Arguments
- lights - This is the new state for the lights.
- LIGHTSTATE_AUTO - lights are turned on and off automatically depending of the time and weather
- LIGHTSTATE_ON - vehicle lights are always on
- LIGHTSTATE_OFF - vehicle lights are always off
[edit] Example 1. Returning the value
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "lights" ) { if ( pPlayer.Vehicle ) MessagePlayer( "Your light state is currently set to " + pPlayer.Vehicle.LightState, pPlayer ); } return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
[edit] Example 2. Setting a new value
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "lights2" ) { if ( pPlayer.Vehicle ) pPlayer.Vehicle.LightState = LIGHTSTATE_ON; } return 1; }
[edit] Notes
The event onPlayerCommand was used in this example. More info about this in the corresponding page.
[edit] Related Functions
- CreateVehicle
- FindVehicle
- GetClosestVehicle
- GetVehicleCount
- GetVehicleHandlingData
- GetVehicleIDFromName
- GetVehicleName
- SetVehicleHandlingData
- Vehicle.Alpha
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.EngineDamage
- Vehicle.Explode
- Vehicle.Fix
- Vehicle.GetAddon
- Vehicle.GetPassenger
- Vehicle.GetHandlingData
- Vehicle.GetWheelStatus
- Vehicle.Health
- Vehicle.ID
- Vehicle.IdleRespawnTime
- Vehicle.IdleTime
- Vehicle.LightState
- Vehicle.Locked
- Vehicle.Marker
- Vehicle.MarkerScale
- Vehicle.MarkerSprite
- Vehicle.Model
- Vehicle.OneTime
- Vehicle.PassengerCount
- Vehicle.Pos
- Vehicle.Remove
- Vehicle.Respawn
- Vehicle.RespawnTime
- Vehicle.RGBColour1
- Vehicle.RGBColour2
- Vehicle.SetHandlingData
- Vehicle.SetWheelStatus
- Vehicle.SpawnAngle
- Vehicle.SpawnPos
- Vehicle.SetAddon
- Vehicle.SetEngineState
- Vehicle.SetRadio
- Vehicle.Siren
- Vehicle.SirenLight
- Vehicle.TaxiLight
- Vehicle.Velocity
- Vehicle.VirtualWorld
- Vehicle.Wrecked