GetVehicleNitroCount: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{New feature/item| | {{New feature/item|3.0131|1.3.1|4993| | ||
This function | This function gets the nitro count of the [[vehicle]]. | ||
}} | }} | ||
{{Warning|Only works if the vehicle is streamed in, use [[isElementStreamedIn]] to check.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">int getVehicleNitroCount ( vehicle theVehicle )</syntaxhighlight> | <syntaxhighlight lang="lua">int getVehicleNitroCount ( vehicle theVehicle )</syntaxhighlight> | ||
Line 14: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns ''an integer'' determining the amount of nitro counts of the vehicle, ''false'' if there is no nitro in the vehicle. | |||
==Example== | ==Example== | ||
This example draws | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | This example draws the nitro count on vehicle on the player's screen. | ||
<syntaxhighlight lang="lua"> | |||
function drawNitroCounts() | |||
local fCamX, fCamY, fCamZ = getCameraMatrix() | |||
for _, v in ipairs(getElementsByType("vehicle")) do | |||
if getVehicleUpgradeOnSlot(v, 8) then -- Check if the vehicle has nitro installed | |||
local fX, fY, fZ = getElementPosition(v) | |||
local fCamX, fCamY, fCamZ = getCameraMatrix() | |||
local fX2, fY2 = getScreenFromWorldPosition(fX, fY, fZ + 0.85, 0.08) | |||
if fX2 then | |||
local fDistance = getDistanceBetweenPoints3D(fX, fY, fZ, fCamX, fCamY, fCamZ) | |||
if fDistance < 60 then | |||
if isLineOfSightClear(fCamX, fCamY, fCamZ, fX, fY, fZ, true, false, false, true, false) then | |||
local pVehicle = getPedOccupiedVehicle(localPlayer) | |||
if not pVehicle or pVehicle ~= v then | |||
local fScale = (60 / fDistance) * 0.7 | |||
local iNitroCount = getVehicleNitroCount(v) | |||
dxDrawText("Nitro count: " .. iNitroCount, fX2 + 1, fY2 + 1, fX2 + 1, fY2 + 1, tocolor(0, 0, 255), fScale, "default", "center", "bottom") | |||
dxDrawText("Nitro count: " .. iNitroCount, fX2, fY2, fX2, fY2, tocolor(255, 255, 255), fScale, "default", "center", "bottom") | |||
end | end | ||
end | end | ||
Line 43: | Line 41: | ||
end | end | ||
end | end | ||
)</syntaxhighlight> | end | ||
addEventHandler("onClientRender", root, drawNitroCounts) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Client_vehicle_functions}} |
Latest revision as of 17:10, 7 November 2024
This function gets the nitro count of the vehicle.
Syntax
int getVehicleNitroCount ( vehicle theVehicle )
Required Arguments
- theVehicle The vehicle which you want to get a nitro count.
Returns
Returns an integer determining the amount of nitro counts of the vehicle, false if there is no nitro in the vehicle.
Example
Click to collapse [-]
ClientThis example draws the nitro count on vehicle on the player's screen.
function drawNitroCounts() local fCamX, fCamY, fCamZ = getCameraMatrix() for _, v in ipairs(getElementsByType("vehicle")) do if getVehicleUpgradeOnSlot(v, 8) then -- Check if the vehicle has nitro installed local fX, fY, fZ = getElementPosition(v) local fCamX, fCamY, fCamZ = getCameraMatrix() local fX2, fY2 = getScreenFromWorldPosition(fX, fY, fZ + 0.85, 0.08) if fX2 then local fDistance = getDistanceBetweenPoints3D(fX, fY, fZ, fCamX, fCamY, fCamZ) if fDistance < 60 then if isLineOfSightClear(fCamX, fCamY, fCamZ, fX, fY, fZ, true, false, false, true, false) then local pVehicle = getPedOccupiedVehicle(localPlayer) if not pVehicle or pVehicle ~= v then local fScale = (60 / fDistance) * 0.7 local iNitroCount = getVehicleNitroCount(v) dxDrawText("Nitro count: " .. iNitroCount, fX2 + 1, fY2 + 1, fX2 + 1, fY2 + 1, tocolor(0, 0, 255), fScale, "default", "center", "bottom") dxDrawText("Nitro count: " .. iNitroCount, fX2, fY2, fX2, fY2, tocolor(255, 255, 255), fScale, "default", "center", "bottom") end end end end end end end addEventHandler("onClientRender", root, drawNitroCounts)
See Also
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates