isVehicleLocked | Multi Theft Auto: Wiki Skip to content

isVehicleLocked

Client-side
Server-side
Shared

Pair: setVehicleLocked

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This will tell you if a vehicle is locked.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:isLocked(...)
  • Variable: .locked

Syntax

bool isVehicleLocked ( vehicle theVehicle )
Required Arguments
  • theVehicle: The vehicle that you want to obtain the locked status of.

Returns

  • bool: value

Returns true if the vehicle specified is locked, false if is unlocked or the vehicle specified is invalid.

Code Examples

shared

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 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

Vehicle Functions