Server exports

Server exports for Vehicle Keys. Call them as exports.MrNewbVehicleKeys:Name(...).

In-development version. These docs cover the testing build of VehicleKeys. The official release is still documented on the GitBook linked in its README.

Call them as exports.MrNewbVehicleKeys:Name(...). They return false (or an empty table / 0 for lists and counts) if the key system is not ready yet. Wait until the resource is started. plate is trimmed for you. netid is a vehicle network id.

Giving and removing

ExportParamsReturns
GiveKeyssrc, netid, autoKeyring?boolean. autoKeyring = true puts it on their keyring
GiveKeysByPlate / AddKeysByPlatesrc, plate, autoKeyring?boolean. Use when the vehicle is not spawned
GiveKeysCustomsrc, netid, plate, keyType, keyoptions, autoStart, spawnLocked, addToKeyringboolean
RemoveKeyssrc, netid, includeKeyring?boolean
RemoveKeysByPlatesrc, plate, includeKeyring?boolean
TransferKeysrc, targetSrc, plateboolean
DuplicateKeysrc, targetSrc, plateboolean. Target gets a copy, original stays
UpdateKeysrc, oldPlate, newPlateboolean. Re-plates one player’s key
MigratePlateoldPlate, newPlateboolean. Moves the saved key profile. Item keys only. Does not touch held keys
GrantRentalsrc, plate, modelName, netid, rentalLocation?boolean. Keys plus rental_paperwork
RemoveRentalsrc, plate, netidboolean

keyType is smart, luxury, basic, boat, or motorcycle (classic, display, and bike are aliases). keyoptions is a list of fob module ids.

exports.MrNewbVehicleKeys:GiveKeys(src, NetworkGetNetworkIdFromEntity(veh))
exports.MrNewbVehicleKeys:GiveKeysByPlate(src, plate)
exports.MrNewbVehicleKeys:RemoveKeysByPlate(src, plate, true)
exports.MrNewbVehicleKeys:GiveKeysCustom(src, netid, plate, 'smart', {}, true, false, true)

Checking

ExportParamsReturns
HasKeys / HaveKeyssrc, netidboolean
HasKeysByPlatesrc, plateboolean
GetPlayerKeys / GetVehicleKeyListsrctable of held keys
CanAccessVehiclesrc, netid, plate?boolean. Key, temp key, or shared job access
VerifyOwnershipsrc, plateboolean
GetVehicleInfoplatetable or nil
GetLockProfileplatetable or false. Item keys only
IsItemBasedMode / KeyTypenoneboolean. true when keys are items
IsInsertModeEnablednoneboolean
GetKeySystemnoneThe live key system object. For deep integrations only
HasPhoneKey / GetPhoneKeyssrc, plate / srccompanion phone app

Vehicle state

ExportParamsReturns
SetVehicleLocknetid, lockStatusboolean. 1 unlocked, 2 locked
RemoteLocksrc, plate, lockStatusboolean. As if that player used the fob
DisableLockpickingVehiclenetid, statusboolean. true makes it lockpick-proof
IsKeyInIgnitionnetidboolean
SetKeyInIgnitionnetid, inserted, metadata?boolean
SearchForKeyssrc, netIdboolean

Temporary keys

A temp key works without an item. durationMs = nil means it does not expire.

ExportParamsReturns
SetTempKeysrc, plate, durationMs?boolean
RemoveTempKeysrc, plateboolean
SetTempKeyForPlayersplayers, plate, durationMs?count
RemoveTempKeyForPlayersplayers, platecount
SetTempKeyForJobjobName, plate, durationMs?count
RemoveTempKeyForJobjobName, platecount
HasTempKeysrc, plateboolean
exports.MrNewbVehicleKeys:SetTempKeyForJob('mechanic', plate, 30 * 60 * 1000)

Events other scripts already fire

When CompatibilityEvents for that resource is on, these keep working: qb-vehiclekeys:server:AcquireVehicleKeys, :GiveVehicleKeys, :RemoveVehicleKeys, the client AcquireVehicleKeys / AddKeys / RemoveKeys, vehiclekeys:client:SetOwner, and the garage store events that take the key back (qb-garages, esx_garage, qbx park). Boosting, AdvancedParking, ak47 car dealer, and jobs_creator garage events are handled when that resource is present.

For your own server scripts, use the exports. They are not gated on the sender standing next to the car.

MrNewbVehicleKeys:Server:* and MrNewbVehicleKeys:Client:* are internal. Client exports: Client exports.

On this page