BlowVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(updated syntax)
Line 4: Line 4:


==Syntax==  
==Syntax==  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool blowVehicle ( vehicle vehicleToBlow, [ bool explode=true ] )
bool blowVehicle ( vehicle vehicleToBlow, [ bool explode=true ] )
Line 10: Line 11:
===Required Arguments===  
===Required Arguments===  
*'''vehicleToBlow:''' The vehicle that you wish to blow up.
*'''vehicleToBlow:''' The vehicle that you wish to blow up.
{{Deprecated_feature|3.0110|1.1|
===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''explode:''' If this argument is ''true'' then the vehicle will explode, otherwise it will just be blown up silently.
*'''explode:''' If this argument is ''true'' then the vehicle will explode, otherwise it will just be blown up silently.
}}
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
bool blowVehicle ( vehicle vehicleToBlow )
</syntaxhighlight>
 
===Required Arguments===
*'''vehicleToBlow:''' The vehicle that you wish to blow up.
</section>
===Returns===
===Returns===
Returns ''true'' if the vehicle was blown up, ''false'' if invalid arguments were passed to the function.
Returns ''true'' if the vehicle was blown up, ''false'' if invalid arguments were passed to the function.

Revision as of 15:44, 7 August 2011

This function will blow up a vehicle. This will cause an explosion and will kill the driver and any passengers inside it.

Syntax

Click to collapse [-]
Server
bool blowVehicle ( vehicle vehicleToBlow, [ bool explode=true ] )

Required Arguments

  • vehicleToBlow: The vehicle that you wish to blow up.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • explode: If this argument is true then the vehicle will explode, otherwise it will just be blown up silently.
Click to collapse [-]
Client
bool blowVehicle ( vehicle vehicleToBlow )

Required Arguments

  • vehicleToBlow: The vehicle that you wish to blow up.

Returns

Returns true if the vehicle was blown up, false if invalid arguments were passed to the function.

Example

Click to collapse [-]
Example 1: Server and client

This example will blow up every vehicle in the game.

vehicles = getElementsByType ( "vehicle" )
for vehicleKey, vehicleValue in ipairs(vehicles) do
	blowVehicle ( vehicleValue )
end

It is worth noting that the same could be achieved with the following:

root = getRootElement ()
blowVehicle ( root )
Click to collapse [-]
Example 2: Server

This example will blow a player's vehicle when he enters the car, like a carbomb.

riggedVehicle = createVehicle(445, 0, 0, 5)
function blowVehicleEnter ( thePlayer, seat, jacked )
	--ENGINE START BOMB. 
	if seat == 0 then --check if the seat the player got into was id 0 - i.e. driver seat
		blowVehicle ( source ) --if it was, toast him
	end
end
addEventHandler ( "onVehicleEnter", riggedVehicle, blowVehicleEnter ) --trigger the function when a certain vehicle is entered

See Also