SetVehicleLocked: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This | This function can be used to set a vehicle to be locked or unlocked | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''vehicle:''' The vehicle which you wish to change the lock status of | ||
*'''locked:''' Boolean for the status you wish to set. Set ''true'' to lock, ''false'' to unlock | |||
*''' | |||
===Returns=== | ===Returns=== | ||
Returns ''true'' if | Returns ''true'' if the operation was successful, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example | This example allows a player to lock is vehicle when he is inside it. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) --add an event handler for onPlayerSpawn | ||
function onPlayerSpawn ( spawnpoint ) --when a player spawns | |||
-- | bindKey ( source, "l", down, "lockcar", source ) --bind the 'l' key to the 'lockcar' function | ||
end | |||
function lockcar ( player ) | |||
playervehicle = getPlayerOccupiedVehicle ( player ) --define 'playervehicle' as the vehicle the player is in | |||
if ( playervehicle ) then --if a player is in a vehicle | |||
if isVehicleLocked ( playervehicle ) then --and if the vehicle is already locked | |||
setVehicleLocked ( playervehicle, false ) --unlock it | |||
else --otherwise (if it isnt locked) | |||
setVehicleLocked ( playervehicle, true ) --lock it | |||
end | |||
end | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ | {{Vehicle functions}} |
Revision as of 20:15, 13 August 2006
This function can be used to set a vehicle to be locked or unlocked
Syntax
bool setVehicleLocked ( element vehicle, bool locked )
Required Arguments
- vehicle: The vehicle which you wish to change the lock status of
- locked: Boolean for the status you wish to set. Set true to lock, false to unlock
Returns
Returns true if the operation was successful, false otherwise.
Example
This example allows a player to lock is vehicle when he is inside it.
addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) --add an event handler for onPlayerSpawn function onPlayerSpawn ( spawnpoint ) --when a player spawns bindKey ( source, "l", down, "lockcar", source ) --bind the 'l' key to the 'lockcar' function end function lockcar ( player ) playervehicle = getPlayerOccupiedVehicle ( player ) --define 'playervehicle' as the vehicle the player is in if ( playervehicle ) then --if a player is in a vehicle if isVehicleLocked ( playervehicle ) then --and if the vehicle is already locked setVehicleLocked ( playervehicle, false ) --unlock it else --otherwise (if it isnt locked) setVehicleLocked ( playervehicle, true ) --lock it end end end
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