SetVehicleFuelTankExplodable: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(Added sections, minor changes, fixed example) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function changes 'explodable state' of a vehicle's fuel tank | This function changes the 'explodable state' of a vehicle's fuel tank, which toggles the ability to blow the vehicle up by shooting the tank. This function will have no effect on vehicles with tanks that cannot be shot in single player. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setVehicleFuelTankExplodable ( vehicle theVehicle, bool explodable )</syntaxhighlight> | <section name="Server and Client" class="both" show="true"> | ||
<syntaxhighlight lang="lua"> | |||
bool setVehicleFuelTankExplodable ( vehicle theVehicle, bool explodable ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 9: | Line 13: | ||
*'''explodable''': A boolean value representing whether or not the fuel tank will be explodable. | *'''explodable''': A boolean value representing whether or not the fuel tank will be explodable. | ||
==Returns== | ===Returns=== | ||
Returns ''true'' if the vehicle's fuel tank explodable state was successfully changed, ''false'' otherwise. | Returns ''true'' if the vehicle's fuel tank explodable state was successfully changed, ''false'' otherwise. | ||
</section> | |||
==Example== | ==Example== | ||
This example will make fuel tanks explodable for 10 seconds after they're entered | <section name="Serverside example" class="server" show="true"> | ||
This example will make vehicles' fuel tanks explodable for 10 seconds after they're entered. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | -- create a table to keep track of vulnerable vehicles | ||
if | -- so we don't set the state-reset timer twice when reentering a vulnerable vehicle | ||
setVehicleFuelTankExplodable ( theVehicle, true ) | local isVulnerable = {} | ||
-- this function makes a vehicle vulnerable and sets a timer to unset it in 10 seconds | |||
function setVehicleVulnerable ( theVehicle, enteredSeat ) | |||
-- we'll ignore vehicles that are already vulnerable. | |||
if not isVulnerable[theVehicle] then | |||
-- if they're getting into the driver seat | |||
if enteredSeat == 0 then | |||
-- make the fuel tank explodable | |||
setVehicleFuelTankExplodable ( theVehicle, true ) | |||
-- flag this vehicle as vulnerable | |||
isVulnerable[theVehicle] = true | |||
-- make it non vulnerable in 10 seconds | |||
setTimer ( unsetVehicleVulnerable, 10000, 1, theVehicle ) | |||
end | |||
end | end | ||
end | end | ||
addEventHandler ( "onPlayerEnterVehicle", getRootElement ( ), | |||
-- this function makes a vehicle not vulnerable | |||
function unsetVehicleVulnerable ( theVehicle ) | |||
-- make the fuel tank unexplodable | |||
setVehicleFuelTankExplodable ( theVehicle, false ) | |||
-- remove the vulnerable flag | |||
isVulnerable[theVehicle] = nil | |||
end | |||
-- add the 'makeVehicleVulnerable' function as a handler for "onPlayerEnterVehicle" | |||
addEventHandler ( "onPlayerEnterVehicle", getRootElement ( ), setVehicleVulnerable ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 23:24, 27 August 2007
This function changes the 'explodable state' of a vehicle's fuel tank, which toggles the ability to blow the vehicle up by shooting the tank. This function will have no effect on vehicles with tanks that cannot be shot in single player.
Syntax
Click to collapse [-]
Server and Clientbool setVehicleFuelTankExplodable ( vehicle theVehicle, bool explodable )
Required Arguments
- theVehicle: The vehicle you wish to change the fuel tank explodable state of.
- explodable: A boolean value representing whether or not the fuel tank will be explodable.
Returns
Returns true if the vehicle's fuel tank explodable state was successfully changed, false otherwise.
Example
Click to collapse [-]
Serverside exampleThis example will make vehicles' fuel tanks explodable for 10 seconds after they're entered.
-- create a table to keep track of vulnerable vehicles -- so we don't set the state-reset timer twice when reentering a vulnerable vehicle local isVulnerable = {} -- this function makes a vehicle vulnerable and sets a timer to unset it in 10 seconds function setVehicleVulnerable ( theVehicle, enteredSeat ) -- we'll ignore vehicles that are already vulnerable. if not isVulnerable[theVehicle] then -- if they're getting into the driver seat if enteredSeat == 0 then -- make the fuel tank explodable setVehicleFuelTankExplodable ( theVehicle, true ) -- flag this vehicle as vulnerable isVulnerable[theVehicle] = true -- make it non vulnerable in 10 seconds setTimer ( unsetVehicleVulnerable, 10000, 1, theVehicle ) end end end -- this function makes a vehicle not vulnerable function unsetVehicleVulnerable ( theVehicle ) -- make the fuel tank unexplodable setVehicleFuelTankExplodable ( theVehicle, false ) -- remove the vulnerable flag isVulnerable[theVehicle] = nil end -- add the 'makeVehicleVulnerable' function as a handler for "onPlayerEnterVehicle" addEventHandler ( "onPlayerEnterVehicle", getRootElement ( ), setVehicleVulnerable )
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates