SetVehicleLocked: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This function can be used to set a vehicle to be locked or unlocked | This function can be used to set a vehicle to be locked or unlocked | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setVehicleLocked ( | bool setVehicleLocked ( vehicle theVehicle, bool locked ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''theVehicle:''' 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 | *'''locked:''' Boolean for the status you wish to set. Set ''true'' to lock, ''false'' to unlock | ||
Line 14: | Line 15: | ||
Returns ''true'' if the operation was successful, ''false'' otherwise. | Returns ''true'' if the operation was successful, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example allows a player to lock | This example allows a player to lock his vehicle when he is inside it. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
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 | end | ||
function | function onPlayerSpawn ( theSpawnpoint ) -- when a player spawns | ||
bindKey ( source, "l", "down", "Lock car", lockcar ) -- bind the 'l' key to the 'lockcar' function | |||
end | end | ||
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) -- add an event handler for onPlayerSpawn | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 19:46, 15 August 2007
This function can be used to set a vehicle to be locked or unlocked
Syntax
bool setVehicleLocked ( vehicle theVehicle, bool locked )
Required Arguments
- theVehicle: 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 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 onPlayerSpawn ( theSpawnpoint ) -- when a player spawns bindKey ( source, "l", "down", "Lock car", lockcar ) -- bind the 'l' key to the 'lockcar' function end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) -- 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