GetVehicleTrunkRatio

From Onset Developer Wiki
Revision as of 12:59, 19 November 2019 by 28days (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
GetVehicleTrunkRatio

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Get the vehicle's trunk ratio.

Syntax

GetVehicleTrunkRatio(vehicle)

Parameters

  • vehicle
    The vehicle identifier.

Return Value

  • The floating point value of the trunk ratio.

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