SetVehicleNitroCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (fixes)
Line 5: Line 5:
}}
}}


'''Note:''' This function return ''false'' if nitro is not exists. So you need add nitro via function [[addVehicleUpgrade]].
{{Warning|Function is not working correctly. -[[User:Ccw|Ccw]]}}
{{Warning|Function not working correctly}}  
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setVehicleNitroCount ( vehicle theVehicle, int count )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setVehicleNitroCount ( vehicle theVehicle, int count )</syntaxhighlight>  
Line 18: Line 17:


==Example==
==Example==
<syntaxhighlight lang="lua">addEventHandler( 'onClientVehicleEnter', root,
<section name="Client" class="client" show="true">
function( pPlayer )
This function installs nitro in the vehicle and then sets the count to infinite when the player enters the vehicle.
if pPlayer == localPlayer then
<syntaxhighlight lang="lua">
if not getVehicleUpgradeOnSlot( source, 8 ) then -- Nitro doesn't installed?
function infiniteNitro(pPlayer)
addVehicleUpgrade( source, 1010 ) -- Install a nitro.
if pPlayer == localPlayer then
setVehicleNitroCount( source, 101 ) -- Set up an infinite nitro.
if not getVehicleUpgradeOnSlot(source, 8) then -- Does the vehicle have nitro installed or not
end
addVehicleUpgrade(source, 1010) -- Install nitrous
setVehicleNitroCount(source, 101) -- Set the nitro count to infinite
else
setVehicleNitroCount(source, 101) -- Set the nitro count to infinite
end
end
end
end
)</syntaxhighlight>
end
addEventHandler("onClientVehicleEnter", root, infiniteNitro)
</syntaxhighlight>
</section>


==Requirements==
==Requirements==

Revision as of 11:55, 14 March 2013

ADDED/UPDATED IN VERSION 1.3.1 r4993:

This function set the nitro count to the vehicle.


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

Syntax

bool setVehicleNitroCount ( vehicle theVehicle, int count )

Required Arguments

  • theVehicle The vehicle which you want to set.
  • count Nitro count you want to set [0-100] 101 - is infinite.

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 and then sets the count to infinite when the player enters the vehicle.

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
			setVehicleNitroCount(source, 101) -- Set the nitro count to infinite
		else
			setVehicleNitroCount(source, 101) -- Set the nitro count to infinite
		end
	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