SetVehicleLocked
Jump to navigation
Jump to search
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