GetVehicleHoodRatio: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server & Client|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get the vehicle's hood ratio.}} | ||
{{FuncSyntax|GetVehicleHoodRatio(vehicle)}} | {{FuncSyntax|GetVehicleHoodRatio(vehicle)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the ratio of the vehicle hood.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
function cmd_hood(player, ratio) | |||
local vehicle = GetPlayerVehicle(player) | |||
if (vehicle == 0) then | |||
return AddPlayerChat(player, "You must be in a vehicle") | |||
end | |||
if (GetPlayerVehicleSeat(player) ~= 1) then | |||
return AddPlayerChat(player, "You must be the driver of the vehicle") | |||
end | |||
if (ratio == nil) then | |||
if (GetVehicleHoodRatio(vehicle) > 0.0) then | |||
SetVehicleHoodRatio(vehicle, 0.0) | |||
else | |||
SetVehicleHoodRatio(vehicle, 60.0) | |||
end | |||
else | |||
ratio = tonumber(ratio) | |||
if (ratio > 90.0) then | |||
ratio = 90.0 | |||
elseif (ratio < 0.0) then | |||
ratio = 0.0 | |||
end | |||
SetVehicleHoodRatio(vehicle, ratio) | |||
end | |||
end | |||
AddCommand("hood", cmd_hood) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:VehicleFunctions}} |
Latest revision as of 10:23, 19 November 2019
Description
Get the vehicle's hood ratio.
Syntax
GetVehicleHoodRatio(vehicle)
Parameters
- vehicle
The vehicle identifier.
Return Value
- Returns the ratio of the vehicle hood.
Example
function cmd_hood(player, ratio)
local vehicle = GetPlayerVehicle(player)
if (vehicle == 0) then
return AddPlayerChat(player, "You must be in a vehicle")
end
if (GetPlayerVehicleSeat(player) ~= 1) then
return AddPlayerChat(player, "You must be the driver of the vehicle")
end
if (ratio == nil) then
if (GetVehicleHoodRatio(vehicle) > 0.0) then
SetVehicleHoodRatio(vehicle, 0.0)
else
SetVehicleHoodRatio(vehicle, 60.0)
end
else
ratio = tonumber(ratio)
if (ratio > 90.0) then
ratio = 90.0
elseif (ratio < 0.0) then
ratio = 0.0
end
SetVehicleHoodRatio(vehicle, ratio)
end
end
AddCommand("hood", cmd_hood)
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