IsVehicleNitroActivated: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Example made a bit clearer and comments added, fixed typos.)
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{New feature/item|4.0132|1.3.1|4993|
{{New feature/item|4.0132|1.3.1|4993|
This function check if nitro is activated on the [[vehicle]].
This function checks if nitro is activated on the [[vehicle]].
}}
}}


'''Note:''' This function return ''false'' if nitro is not exists. So you need add nitro via function [[addVehicleUpgrade]].
This function checks whether a vehicle has activated nitro as set by [[setVehicleNitroActivated]] or the player.
{{Warning|Function not working correctly}}  
 
{{Warning|Function is not working correctly.}}
 
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool isVehicleNitroActivated ( vehicle theVehicle )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool isVehicleNitroActivated ( vehicle theVehicle )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]] which you want to check for an activation.
*'''theVehicle''' The [[vehicle]], which you want to check for an activation.


===Returns===
===Returns===
Returns ''true'' if the nitro is activated successfully on the vehicle, ''false'' otherwise.
Returns ''true'' if the nitro is currently activated on the vehicle, ''false'' otherwise.


==Example==
==Example==
This example create an explosions if nitro is activated and if velocity not zero and ped in the vehicle.
This example creates an explosion if nitro is activated.
<syntaxhighlight lang="lua">local iTickCount
<syntaxhighlight lang="lua">local iTickCount


addEventHandler( 'onClientRender', root,
function explodeNitrousVehicle()
function()
if isPedInVehicle(localPlayer) then -- Check if the player is in a vehicle
if isPedInVehicle( localPlayer ) then
local pVehicle = getPedOccupiedVehicle(localPlayer)
local pVehicle = getPedOccupiedVehicle( localPlayer )
if pVehicle and getVehicleUpgradeOnSlot(pVehicle, 8) then -- Check if the vehicle has nitrous added in it
if pVehicle and getVehicleUpgradeOnSlot( pVehicle, 8 ) then
local fVelX, fVelY, fVelZ = getElementVelocity(pVehicle)
local fVelX, fVelY, fVelZ = getElementVelocity( pVehicle )
if isVehicleNitroActivated(pVehicle) and fVelX ~= 0 and fVelY ~= 0 and fVelZ ~= 0 then -- Check if the nitro is activated and the vehicle is not moving
if isVehicleNitroActivated( pVehicle ) and fVelX ~= 0 and fVelY ~= 0 and fVelZ ~= 0 then
if not iTickCount or getTickCount() - iTickCount > 100 then
if not iTickCount or getTickCount() - iTickCount > 100 then
local fX, fY, fZ = getElementPosition(pVehicle)
local fX, fY, fZ = getElementPosition( pVehicle )
createExplosion(fX, fY, fZ, 10, true, -1.0, false) -- Create an explosion in the vehicle
createExplosion( fX, fY, fZ, 10, true, - 1.0, false )
iTickCount = getTickCount()
iTickCount = getTickCount()
end
end
end
end
end
end
end
end
end
)</syntaxhighlight>
end
addEventHandler("onClientRender", root, explodeNitrousVehicle)</syntaxhighlight>


==Requirements==
==Requirements==

Revision as of 11:25, 14 March 2013

ADDED/UPDATED IN VERSION 1.3.1 r4993:

This function checks if nitro is activated on the vehicle.

This function checks whether a vehicle has activated nitro as set by setVehicleNitroActivated or the player.


[[|link=|]] Warning: Function is not working correctly.

Syntax

bool isVehicleNitroActivated ( vehicle theVehicle )

Required Arguments

  • theVehicle The vehicle, which you want to check for an activation.

Returns

Returns true if the nitro is currently activated on the vehicle, false otherwise.

Example

This example creates an explosion if nitro is activated.

local iTickCount

function explodeNitrousVehicle()
	if isPedInVehicle(localPlayer) then -- Check if the player is in a vehicle
		local pVehicle = getPedOccupiedVehicle(localPlayer)
		if pVehicle and getVehicleUpgradeOnSlot(pVehicle, 8) then -- Check if the vehicle has nitrous added in it
			local fVelX, fVelY, fVelZ = getElementVelocity(pVehicle)
			if isVehicleNitroActivated(pVehicle) and fVelX ~= 0 and fVelY ~= 0 and fVelZ ~= 0 then -- Check if the nitro is activated and the vehicle is not moving
				if not iTickCount or getTickCount() - iTickCount > 100 then
					local fX, fY, fZ = getElementPosition(pVehicle)
					createExplosion(fX, fY, fZ, 10, true, -1.0, false) -- Create an explosion in the vehicle
					iTickCount = getTickCount()
				end
			end
		end
	end
end
addEventHandler("onClientRender", root, explodeNitrousVehicle)

Requirements

Minimum server version n/a
Minimum client version 1.3.1-9.04993

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.1-9.04993" />

See Also