IsVehicleLocked: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Server client function}} | |||
__NOTOC__ | __NOTOC__ | ||
This will tell you if a vehicle is locked. | |||
This | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">isVehicleLocked ( vehicle )</syntaxhighlight> | <syntaxhighlight lang="lua">bool isVehicleLocked ( vehicle theVehicle )</syntaxhighlight> | ||
{{OOP||[[vehicle]]:isLocked|locked|setVehicleLocked}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''theVehicle:''' The [[vehicle]] that you want to obtain the locked status of. | ||
===Returns=== | |||
Returns ''true'' if the vehicle specified is locked, ''false'' if is unlocked or the vehicle specified is invalid. | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <section name="Server" class="server" show="true"> | ||
if | This example allows a player to lock his vehicle when he is inside it. | ||
<syntaxhighlight lang="lua"> | |||
else | function lockcar ( thePlayer ) | ||
playervehicle = getPlayerOccupiedVehicle ( thePlayer ) -- define 'playervehicle' as the vehicle the player is in | |||
end</syntaxhighlight> | 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 isn't locked) | |||
setVehicleLocked ( playervehicle, true ) -- lock it | |||
end | |||
end | |||
end | |||
function bindLockOnSpawn ( theSpawnpoint ) -- when a player spawns | |||
bindKey ( source, "l", "down", "Lock car", lockcar ) -- bind the 'l' key to the 'lockcar' function | |||
end | |||
addEventHandler ( "onPlayerSpawn", root, bindLockOnSpawn ) -- add an event handler for onPlayerSpawn | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | |||
{{Vehicle functions}} |
Latest revision as of 07:51, 4 November 2020
This will tell you if a vehicle is locked.
Syntax
bool isVehicleLocked ( vehicle theVehicle )
OOP Syntax Help! I don't understand this!
- Method: vehicle:isLocked(...)
- Variable: .locked
- Counterpart: setVehicleLocked
Required Arguments
- theVehicle: The vehicle that you want to obtain the locked status of.
Returns
Returns true if the vehicle specified is locked, false if is unlocked or the vehicle specified is invalid.
Example
Click to collapse [-]
ServerThis example allows a player to lock his vehicle when he is inside it.
function lockcar ( thePlayer ) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) -- 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 isn't locked) setVehicleLocked ( playervehicle, true ) -- lock it end end end function bindLockOnSpawn ( theSpawnpoint ) -- when a player spawns bindKey ( source, "l", "down", "Lock car", lockcar ) -- bind the 'l' key to the 'lockcar' function end addEventHandler ( "onPlayerSpawn", root, bindLockOnSpawn ) -- add an event handler for onPlayerSpawn
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