SetVehicleNitroLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Fix typo.)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|4.0132|1.3.1|4993|
{{New feature/item|3.0131|1.3.1|4993|
This function set the nitro level to the [[vehicle]].
This function sets the nitro level of the [[vehicle]].
}}
}}
 
{{Warning|Only works if the vehicle is streamed in.}}
'''Note:''' This function return ''false'' if nitro is not exists. So you need add nitro via function [[addVehicleUpgrade]].
 
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setVehicleNitroLevel ( vehicle theVehicle, float level )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setVehicleNitroLevel ( vehicle theVehicle, float level )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]] which you want to set.
*'''theVehicle''' The [[vehicle]], which you want to set.
*'''level''' Nitro level you want to set [0.0001-1.0].
*'''level''' Nitro level you want to set (ranges from 0.0001 to 1.0).


===Returns===
===Returns===
Line 18: Line 16:


==Example==
==Example==
<syntaxhighlight lang="lua">addEventHandler( 'onClientVehicleEnter', root,
<section name="Client" class="client" show="true">
function( pPlayer )
This function installs nitrous to the vehicle and sets the level of it to 0.1 when a player enters the vehicle.
if pPlayer == localPlayer then
<syntaxhighlight lang="lua">
if not getVehicleUpgradeOnSlot( source, 8 ) then
function changeNitroLevel(pPlayer)
addVehicleUpgrade( source, 1010 ) -- Install a nitro.
if pPlayer == localPlayer then
setVehicleNitroLevel( source, 0.1 ) -- Set up an 0.1 level for nitro.
if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro in it or not
end
addVehicleUpgrade(source, 1010) -- Install nitrous
end
end
setVehicleNitroLevel(source, 0.1) -- Set a nitro level of 0.1 to the vehicle
end
end
)</syntaxhighlight>
end
addEventHandler("onClientVehicleEnter", root, changeNitroLevel)
</syntaxhighlight>
</section>


==Requirements==
==Requirements==
Line 33: Line 35:


==See Also==
==See Also==
{{Vehicle functions}}
{{Client_vehicle_functions}}

Latest revision as of 19:08, 15 June 2021

This function sets the nitro level of the vehicle.

[[|link=|]] Warning: Only works if the vehicle is streamed in.

Syntax

bool setVehicleNitroLevel ( vehicle theVehicle, float level )

Required Arguments

  • theVehicle The vehicle, which you want to set.
  • level Nitro level you want to set (ranges from 0.0001 to 1.0).

Returns

Returns true if the nitro level was set successfully to the vehicle, false otherwise.

Example

Click to collapse [-]
Client

This function installs nitrous to the vehicle and sets the level of it to 0.1 when a player enters the vehicle.

function changeNitroLevel(pPlayer)
	if pPlayer == localPlayer then
		if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro in it or not
			addVehicleUpgrade(source, 1010) -- Install nitrous
		end
		setVehicleNitroLevel(source, 0.1) -- Set a nitro level of 0.1 to the vehicle
	end
end
addEventHandler("onClientVehicleEnter", root, changeNitroLevel)

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