SetVehicleNitroCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Improved the explanation of what does this function do)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|4.0140|1.3.1|4993|
{{New feature/item|3.0131|1.3.1|4993|
This function set the nitro count to the [[vehicle]].
This function sets how many times a player can activate the nitro on a specified [[vehicle]].
}}
}}
 
{{Warning|Only works if the vehicle is streamed in.}}
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setVehicleNitroCount ( vehicle theVehicle, int count )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setVehicleNitroCount ( vehicle theVehicle, int count )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]] which you want to set.
*'''theVehicle''': the [[vehicle]] which you want to modify how many times a player can use its nitro.
*'''count''' Nitro count you want to set [0-100] 101 - is infinite.
*'''count''': how many times should the player be able to use the nitro of this [[vehicle]] (from 0-100 times; 0 means that it can't be used and 101 means that it can be used infinite times).


===Returns===
===Returns===
Returns ''true'' if the nitro count was set to vehicle successfully, ''false'' otherwise.
Returns ''true'' if the nitro count was set successfully to the vehicle, ''false'' otherwise.


==Example==
==Example==
<syntaxhighlight lang="lua">addEventHandler( 'onClientVehicleEnter', root,
<section name="Client" class="client" show="true">
function( pPlayer )
This function installs nitro in the vehicle a player enters and then makes it usable only twice.
if pPlayer == localPlayer then
<syntaxhighlight lang="lua">
addVehicleUpgrade( source, 1010 ) -- Install a nitro.
function infiniteNitro(pPlayer)
setVehicleNitroCount( source, 101 ) -- Set up an infinite nitro.
if pPlayer == localPlayer then
if not getVehicleUpgradeOnSlot(source, 8) then -- Does the vehicle have nitro installed or not
addVehicleUpgrade(source, 1010) -- Install nitrous
end
end
setVehicleNitroCount(source, 2) -- Make the nitro usable twice
end
end
)</syntaxhighlight>
end
addEventHandler("onClientVehicleEnter", root, infiniteNitro)
</syntaxhighlight>
</section>


==Requirements==
==Requirements==
Line 29: Line 35:


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

Latest revision as of 17:29, 4 October 2014

This function sets how many times a player can activate the nitro on a specified vehicle.

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

Syntax

bool setVehicleNitroCount ( vehicle theVehicle, int count )

Required Arguments

  • theVehicle: the vehicle which you want to modify how many times a player can use its nitro.
  • count: how many times should the player be able to use the nitro of this vehicle (from 0-100 times; 0 means that it can't be used and 101 means that it can be used infinite times).

Returns

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

Example

Click to collapse [-]
Client

This function installs nitro in the vehicle a player enters and then makes it usable only twice.

function infiniteNitro(pPlayer)
	if pPlayer == localPlayer then
		if not getVehicleUpgradeOnSlot(source, 8) then -- Does the vehicle have nitro installed or not
			addVehicleUpgrade(source, 1010) -- Install nitrous
		end
		setVehicleNitroCount(source, 2) -- Make the nitro usable twice
	end
end
addEventHandler("onClientVehicleEnter", root, infiniteNitro)

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