SetVehicleHoodRatio: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetVehicleHoodRatio(vehicle, openRatio)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{F..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Sets a vehicles hood to a specific open ratio.}} | ||
{{FuncSyntax|SetVehicleHoodRatio(vehicle, openRatio)}} | {{FuncSyntax|SetVehicleHoodRatio(vehicle, openRatio)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The identifier of the vehicle.}} | ||
{{FuncParam|openRatio| | {{FuncParam|openRatio|The ratio to open the hood in degrees. 0 closes the hood.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|This function returns ''true'' on success.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function cmd_trunk(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 (GetVehicleTrunkRatio(vehicle) > 0.0) then | |||
SetVehicleTrunkRatio(vehicle, 0.0) | |||
else | |||
SetVehicleTrunkRatio(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 | |||
SetVehicleTrunkRatio(vehicle, ratio) | |||
end | |||
end | |||
AddCommand("trunk", cmd_trunk) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{VehicleFunctions}} |
Latest revision as of 16:25, 1 July 2019
Description
Sets a vehicles hood to a specific open ratio.
Syntax
SetVehicleHoodRatio(vehicle, openRatio)
Parameters
- vehicle
The identifier of the vehicle. - openRatio
The ratio to open the hood in degrees. 0 closes the hood.
Return Value
- This function returns true on success.
Example
function cmd_trunk(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 (GetVehicleTrunkRatio(vehicle) > 0.0) then
SetVehicleTrunkRatio(vehicle, 0.0)
else
SetVehicleTrunkRatio(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
SetVehicleTrunkRatio(vehicle, ratio)
end
end
AddCommand("trunk", cmd_trunk)
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