Skip to Content
Cobalt

cobalt_vehiclekeys

Vehicle keys, locks and hotwiring.

GiveKey

Server

Gives a player a key for a plate and notifies them with the plate when the key is new; false when the plate is not a string or the grant fails. Pass the vehicle so the key is dropped when that vehicle leaves the world and no player owns the plate.

exports.cobalt_vehiclekeys:GiveKey(source, plate, entity)
ParameterTypeOptionalDescription
sourceintegerNoserver id
platestringNo
entityintegerYesserver vehicle handle carrying the plate
ReturnsDescription
boolean
Example
local ok = exports.cobalt_vehiclekeys:GiveKey(source, 'COBALT01', vehicle)

RemoveKeys

Server

Revokes every key for a plate.

exports.cobalt_vehiclekeys:RemoveKeys(plate)
ParameterTypeOptionalDescription
platestringNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_vehiclekeys:RemoveKeys('COBALT01')

TakeKey

Server

Takes one player's key for a plate.

exports.cobalt_vehiclekeys:TakeKey(source, plate)
ParameterTypeOptionalDescription
sourceintegerNoserver id
platestringNo
ReturnsDescription
boolean
Example
local ok = exports.cobalt_vehiclekeys:TakeKey(source, 'COBALT01')

HasKey

Server

Whether that player holds a key. Given a vehicle, it also counts the job's shared keys for its model and a key given for that vehicle under another plate. Given a plate, it checks that plate only. There is no client export: a client could fake its answer.

exports.cobalt_vehiclekeys:HasKey(source, vehicle)
ParameterTypeOptionalDescription
sourceintegerNoserver id
vehicleinteger | stringNoserver vehicle handle, or a plate
ReturnsDescription
boolean
Example
local ok = exports.cobalt_vehiclekeys:HasKey(source, vehicle)

UseLockpick

Client

The lockpick and advancedlockpick items' client export. On usedItem it picks the ignition of the vehicle the player sits in, or the door of the closest locked vehicle.

exports.cobalt_vehiclekeys:UseLockpick(event, item)
ParameterTypeOptionalDescription
event'usingItem' | 'usedItem'No
itemtableNo
Example
exports.cobalt_vehiclekeys:UseLockpick('usingItem', { name = 'lockpick' })

On this page