SetVehicleSirensOn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 17: Line 17:
This example toggles siren state when a player enters a vehicle as a driver.
This example toggles siren state when a player enters a vehicle as a driver.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onVehicleEnter", getRootElement(), "example_onVehicleEnter" )
function example_onVehicleEnter ( player, seat, jacked )
function example_onVehicleEnter ( player, seat, jacked )
--If the player entered as a driver
--If the player entered as a driver
if seat == 0 then
if ( seat == 0 ) then
--If siren was off
--If siren was off
if not getVehicleSirensOn ( source ) then
if not getVehicleSirensOn ( source ) then
setVehicleSirenOn ( source, true ) --Turn it on
setVehicleSirensOn ( source, true ) --Turn it on
else
else
setVehicleSirenOn ( source, false ) --Turn it off
setVehicleSirensOn ( source, false ) --Turn it off
end
end
end
end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(), example_onVehicleEnter )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 13:57, 1 August 2007

This function changes the state of the sirens on the specified vehicle.

Syntax

bool setVehicleSirensOn ( vehicle theVehicle , bool sirensOn )

Required Arguments

  • theVehicle: The vehicle that will have the sirens set
  • sirensOn: The state to set the sirens to

Returns

Returns true if the sirens are set for the specified vehicle, false if the sirens can't be set for the specified vehicle, if the vehicle doesn't have sirens or if invalid arguments are specified.

Example

This example toggles siren state when a player enters a vehicle as a driver.

function example_onVehicleEnter ( player, seat, jacked )
	--If the player entered as a driver
	if ( seat == 0 ) then
		--If siren was off
		if not getVehicleSirensOn ( source ) then
			setVehicleSirensOn ( source, true )	--Turn it on
		else
			setVehicleSirensOn ( source, false )	--Turn it off
		end
	end
end
addEventHandler ( "onVehicleEnter", getRootElement(), example_onVehicleEnter )

See Also