SetVehicleNitroActivated: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (fixes)
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 activate the nitro on the [[vehicle]].
This function activates the nitro on the [[vehicle]].
}}
}}


'''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 setVehicleNitroActivated ( vehicle theVehicle, bool state )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setVehicleNitroActivated ( vehicle theVehicle, bool state )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]] which you want to check an activation.
*'''theVehicle''' The [[vehicle]], which you want to check an activation.
*'''state''' true if you want to activate the nitro, false if you want to disable it.
*'''state''' ''true'' if you want to activate the nitro, ''false'' if you want to disable it.


===Returns===
===Returns===
Line 18: Line 17:


==Example==
==Example==
<syntaxhighlight lang="lua">addEventHandler( 'onClientVehicleEnter', root,
<syntaxhighlight lang="lua">
function( pPlayer )
function activateNitro(pPlayer)
if pPlayer == localPlayer then
if pPlayer == localPlayer then
if not getVehicleUpgradeOnSlot( source, 8 ) then -- Nitro doesn't installed?
if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro installed or not
addVehicleUpgrade( source, 1010 ) -- Install a nitro.
addVehicleUpgrade(source, 1010) -- Install the nitrous
setVehicleNitroActivated( source, true ) -- Activate the nitro.
setVehicleNitroActivated(source, true) -- Activate the nitro
end
else
setVehicleNitroActivated(source, true)
end
end
end
end
)</syntaxhighlight>
end
addEventHandler("onClientVehicleEnter", root, activateNitro) -- When the player enters a vehicle, it executes the function
</syntaxhighlight>


==Requirements==
==Requirements==

Revision as of 11:51, 14 March 2013

ADDED/UPDATED IN VERSION 1.3.1 r4993:

This function activates the nitro on the vehicle.

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

Syntax

bool setVehicleNitroActivated ( vehicle theVehicle, bool state )

Required Arguments

  • theVehicle The vehicle, which you want to check an activation.
  • state true if you want to activate the nitro, false if you want to disable it.

Returns

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

Example

function activateNitro(pPlayer)
	if pPlayer == localPlayer then
		if not getVehicleUpgradeOnSlot(source, 8) then -- Check if the vehicle has nitro installed or not
			addVehicleUpgrade(source, 1010) -- Install the nitrous
			setVehicleNitroActivated(source, true) -- Activate the nitro
		else
			setVehicleNitroActivated(source, true)
		end
	end
end
addEventHandler("onClientVehicleEnter", root, activateNitro) -- When the player enters a vehicle, it executes the function

Requirements

This template will be deleted.

See Also