GetVehicleEngineState: Difference between revisions
From Onset Developer Wiki
No edit summary |
FlyingFork (talk | contribs) No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server & Client|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get the vehicle's engine state.}} | ||
{{FuncSyntax|GetVehicleEngineState(vehicle)}} | {{FuncSyntax|GetVehicleEngineState(vehicle)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true''' if on.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
AddCommand("engine", function(playerid) | |||
local vehicle = GetPlayerOccupiedVehicle(playerid) | |||
if vehicle == 0 then | |||
return AddPlayerChat(playerid, "You must be in a vehicle!") | |||
end | |||
local state = not GetVehicleEngineState(vehicle) | |||
if state == true then | |||
StopVehicleEngine(vehicle) | |||
else | |||
StartVehicleEngine(vehicle) | |||
end | |||
return AddPlayerChat(playerid, "Vehicle engine state changed to: " .. (state and "on" or "off") .. "!") | |||
end) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:VehicleFunctions}} |
Latest revision as of 16:11, 27 May 2021
Description
Get the vehicle's engine state.
Syntax
GetVehicleEngineState(vehicle)
Parameters
- vehicle
The vehicle identifier.
Return Value
- Returns true if on.
Example
AddCommand("engine", function(playerid)
local vehicle = GetPlayerOccupiedVehicle(playerid)
if vehicle == 0 then
return AddPlayerChat(playerid, "You must be in a vehicle!")
end
local state = not GetVehicleEngineState(vehicle)
if state == true then
StopVehicleEngine(vehicle)
else
StartVehicleEngine(vehicle)
end
return AddPlayerChat(playerid, "Vehicle engine state changed to: " .. (state and "on" or "off") .. "!")
end)
See also
- CreateVehicle
- DestroyVehicle
- IsValidVehicle
- GetVehicleCount
- GetAllVehicles
- GetVehicleModel
- GetVehicleModelName
- SetVehicleRespawnParams
- IsVehicleStreamedIn
- GetStreamedVehiclesForPlayer
- GetStreamedVehicles
- SetVehicleLocation
- GetVehicleLocation
- SetVehicleRotation
- GetVehicleRotation
- SetVehicleHeading
- GetVehicleHeading
- SetVehicleHealth
- GetVehicleHealth
- SetVehicleLicensePlate
- GetVehicleVelocity
- GetVehicleDriver
- GetVehiclePassenger
- GetVehicleNumberOfSeats
- SetVehicleColor
- GetVehicleColor
- SetVehicleLinearVelocity
- SetVehicleAngularVelocity
- GetVehicleGear
- SetVehicleHoodRatio
- GetVehicleHoodRatio
- SetVehicleTrunkRatio
- GetVehicleTrunkRatio
- StartVehicleEngine
- StopVehicleEngine
- GetVehicleEngineState
- SetVehicleLightEnabled
- GetVehicleLightState
- SetVehicleDamage
- GetVehicleDamage
- AttachVehicleNitro