GetVehicleNitroCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|4.0140|1.3.1|4993| This function get the nitro count from the vehicle. }} ==Syntax== <syntaxhighlight lang="lua">int getVehicleNitroCount...")
 
No edit summary
Line 15: Line 15:


==Example==
==Example==
<syntaxhighlight lang="lua">
This example draws a nitro count on vehicles.
 
<syntaxhighlight lang="lua">addEventHandler( 'onClientRender', root,
</syntaxhighlight>
function()
local fCamX, fCamY, fCamZ = getCameraMatrix()
for _, v in ipairs( getElementsByType 'vehicle' ) do
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
)</syntaxhighlight>


==Requirements==
==Requirements==

Revision as of 15:18, 7 February 2013

ADDED/UPDATED IN VERSION 1.3.1 r4993:

This function get the nitro count from the vehicle.

Syntax

int getVehicleNitroCount ( vehicle theVehicle )

Required Arguments

  • theVehicle The vehicle which you want to get a nitro count.

Returns

This function returns a nitro count from vehicle.

Example

This example draws a nitro count on vehicles.

addEventHandler( 'onClientRender', root,
	function()
		local fCamX, fCamY, fCamZ = getCameraMatrix()
		for _, v in ipairs( getElementsByType 'vehicle' ) do
			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
)

Requirements

This template will be deleted.

See Also