Client

Exports - Clientside

toggleLock

(Un)locks the closest vehicle

Parameters vehicleData - table - Vehicle Data such as plate, model or netId

Description For the Parameter vehicleData you can set:

  • {plate = vehiclePlate, model = vehicleModel}

  • {vehicle = vehicle}

exports.msk_vehiclekeys:toggleLock(nil, vehicleData)

-- Example 1
local vehicle = GetClosestVehicle()
exports.msk_vehiclekeys:toggleLock(nil, {plate = GetVehicleNumberPlateText(vehicle), model = GetEntityModel(vehicle)})

-- Example 2
local vehicle = GetClosestVehicle()
exports.msk_vehiclekeys:toggleLock(nil, {vehicle = vehicle})

GetVehicleLockState

Get whether the vehicle is locked or unlocked

Parameters vehicle - int - A vehicle handle

Returns isLocked - boolean - whether the vehicle is locked or unlocked

local isLocked = exports.msk_vehiclekeys:GetVehicleLockState(vehicle)

-- You can also use this:
local isLocked = Entity(vehicle).state.isLocked

GetVehicleLockStatus

Get the current Lock Status

Parameters vehicle - int - A vehicle handle

Returns lockStatus - number - Lockstate (1 if unlocked / 2 if locked)

local lockStatus = exports.msk_vehiclekeys:GetVehicleLockStatus(vehicle)

-- You can also use this:
local lockStatus = Entity(vehicle).state.lockState

openLocksmithMenu

Opens the Locksmith Menu where you can Exchange the vehicle locks. All Keys that other players might have for this vehicle will be deleted.

exports.msk_vehiclekeys:openLocksmithMenu()

openKeysMenu

Open the Keys Menu where you can see all keys that you have.

exports.msk_vehiclekeys:openKeysMenu()

RefreshPlayerKeys

It will add not existing permanent keys from owned vehicles to the player

exports.msk_vehiclekeys:RefreshPlayerKeys()

GetAllVehicleKeys

Gets all vehicle keys saved in vehiclekeys.json

Returns vehicleKeys - table - All Vehicle Keys

local vehicleKeys = exports.msk_vehiclekeys:GetAllVehicleKeys()

for identifier, keys in pairs(vehicleKeys) do
    for i = 1, #keys do
        print(identifier, keys[i].plate, keys[i].model, keys[i].type)
    end
end

GetPlayerKeys

Gets the players vehicle keys

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns keys - table - Players Vehicle Keys

-- Self
local keys = exports.msk_vehiclekeys:GetPlayerKeys()

-- Other Player
local keys = exports.msk_vehiclekeys:GetPlayerKeys(playerId)

for i = 1, #keys do
    print(keys[i].plate, keys[i].model, keys[i].type)
end

GetPlayerPrimaryKeys

Gets the players primary vehicle keys

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns keys - table - Players Vehicle Keys

-- Self
local keys = exports.msk_vehiclekeys:GetPlayerPrimaryKeys()

-- Other Player
local keys = exports.msk_vehiclekeys:GetPlayerPrimaryKeys(playerId)

for i = 1, #keys do
    print(keys[i].plate, keys[i].model, keys[i].type)
end

GetPlayerSecondaryKeys

Gets the players secondary vehicle keys

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns keys - table - Players Vehicle Keys

-- Self
local keys = exports.msk_vehiclekeys:GetPlayerSecondaryKeys()

-- Other Player
local keys = exports.msk_vehiclekeys:GetPlayerSecondaryKeys(playerId)

for i = 1, #keys do
    print(keys[i].plate, keys[i].model, keys[i].type)
end

GetPlayerTempKeys

Gets the players temporary vehicle keys

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns keys - table - Players Vehicle Keys

-- Self
local keys = exports.msk_vehiclekeys:GetPlayerTempKeys()

-- Other Player
local keys = exports.msk_vehiclekeys:GetPlayerTempKeys(playerId)

for i = 1, #keys do
    print(keys[i].plate, keys[i].model, keys[i].type)
end

HasPlayerKey

Checks whether the player has a key for the given vehicle or not

Parameters vehicle - int - A vehicle handle

Returns hasKey - boolean - whether the player has a key for the given vehicle or not

local hasKey = exports.msk_vehiclekeys:HasPlayerKey(vehicle)

HasPlayerPrimaryKey

Checks whether the player has a primary key for the given vehicle or not

Parameters vehicle - int - A vehicle handle

Returns hasKey - boolean - whether the player has a primary key for the given vehicle or not

local hasKey = exports.msk_vehiclekeys:HasPlayerPrimaryKey(vehicle)

HasPlayerSecondaryKey

Checks whether the player has a secondary key for the given vehicle or not

Parameters vehicle - int - A vehicle handle

Returns hasKey - boolean - whether the player has a secondary key for the given vehicle or not

local hasKey = exports.msk_vehiclekeys:HasPlayerSecondaryKey(vehicle)

HasPlayerTempKey

Checks whether the player has a temporary key for the given vehicle or not

Parameters vehicle - int - A vehicle handle

Returns hasKey - boolean - whether the player has a temporary key for the given vehicle or not

local hasKey = exports.msk_vehiclekeys:HasPlayerTempKey(vehicle)

GetPlayerVehicles

Get the players vehicles saved in database: owned_vehicles

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns vehicles - table - Players Vehicles

-- Self
local vehicles = exports.msk_vehiclekeys:GetPlayerVehicles()

-- Other Player
local vehicles = exports.msk_vehiclekeys:GetPlayerVehicles(playerId)

for i = 1, #vehicles do
    print(vehicles[i].plate, vehicles[i].model)
end

IsVehicleOwner

Checks whether the player is the owner of the given vehicle

Parameters vehicle - int - A vehicle handle

Returns isOwner - boolean - whether the player is the owner of the given vehicle

local isOwner = exports.msk_vehiclekeys:IsVehicleOwner(vehicle)

HasPlayerKeyOrIsVehicleOwner

Checks whether the player has a key or is vehicle owner

Parameters vehicle - int - A vehicle handle

Returns hasKeyOrIsOwner - boolean - whether the player has a key or is vehicle owner

local hasKeyOrIsOwner = exports.msk_vehiclekeys:HasPlayerKeyOrIsVehicleOwner(vehicle)

GetPlayerKeysAndVehicles

Gets the player keys and owned vehicles

Parameters playerId - number - ServerId of the player which you want to get the keys from - Optional

Returns vehicles - table - Players Vehicles keys - table - Players Vehicle Keys

-- Self
local keys, vehicles = exports.msk_vehiclekeys:GetPlayerKeysAndVehicles()

-- Other Player
local keys, vehicles = exports.msk_vehiclekeys:GetPlayerKeysAndVehicles(playerId)

for i = 1, #keys do
    print(keys[i].plate, keys[i].model, keys[i].type)
end

for i = 1, #vehicles do
    print(vehicles[i].plate, vehicles[i].model)
end

AddKey

Adds a key to the player

Parameters vehicle - int - A vehicle handle type - string - Key Type ['primary', 'secondary', 'temporary'] playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:AddKey(vehicle, type, playerId)

-- Self
exports.msk_vehiclekeys:AddKey(vehicle, type)

-- Other Player
exports.msk_vehiclekeys:AddKey(vehicle, type, playerId)

-- Example
exports.msk_vehiclekeys:AddKey(vehicle, 'secondary')

-- You can also use:
exports.msk_vehiclekeys:AddKey({plate = vehiclePlate, model = vehicleModel}, type)

AddPrimaryKey

Adds a primary key to the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:AddPrimaryKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:AddPrimaryKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:AddPrimaryKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:AddPrimaryKey({plate = vehiclePlate, model = vehicleModel})

AddSecondaryKey

Adds a secondary key to the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:AddSecondaryKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:AddSecondaryKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:AddSecondaryKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:AddSecondaryKey({plate = vehiclePlate, model = vehicleModel})

AddTempKey

Adds a temporary key to the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:AddTempKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:AddTempKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:AddTempKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:AddTempKey({plate = vehiclePlate, model = vehicleModel})

RemoveKey

Removes the key from the player

Parameters vehicle - int - A vehicle handle type - string - Key Type ['primary', 'secondary', 'temporary'] playerId - number - ServerId of the player from that the key will be removed - Optional

exports.msk_vehiclekeys:RemoveKey(vehicle, type, playerId)

-- Self
exports.msk_vehiclekeys:RemoveKey(vehicle, type)

-- Other Player
exports.msk_vehiclekeys:RemoveKey(vehicle, type, playerId)

-- Example
exports.msk_vehiclekeys:RemoveKey(vehicle, 'secondary')

-- You can also use:
exports.msk_vehiclekeys:RemoveKey({plate = vehiclePlate, model = vehicleModel}, type)

RemovePrimaryKey

Removes the primary key from the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:RemovePrimaryKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:RemovePrimaryKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:RemovePrimaryKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:RemovePrimaryKey({plate = vehiclePlate, model = vehicleModel})

RemoveSecondaryKey

Removes the secondary key from the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:RemoveSecondaryKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:RemoveSecondaryKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:RemoveSecondaryKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:RemoveSecondaryKey({plate = vehiclePlate, model = vehicleModel})

RemoveTempKey

Removes the temporary key from the player

Parameters vehicle - int - A vehicle handle playerId - number - ServerId of the player that should get the key - Optional

exports.msk_vehiclekeys:RemoveTempKey(vehicle, playerId)

-- Self
exports.msk_vehiclekeys:RemoveTempKey(vehicle)

-- Other Player
exports.msk_vehiclekeys:RemoveTempKey(vehicle, playerId)

-- You can also use:
exports.msk_vehiclekeys:RemoveTempKey({plate = vehiclePlate, model = vehicleModel})

ExchangeVehicleLocks

Exchange the vehicle locks of the given vehicle. All Keys that other players might have for this vehicle will be deleted.

Parameters vehicle - int or table - A vehicle handle or vehicle data

exports.msk_vehiclekeys:ExchangeVehicleLocks(vehicle)

-- You can also use:
exports.msk_vehiclekeys:ExchangeVehicleLocks({plate = vehiclePlate, model = vehicleModel})

TransferVehicle

The given vehicle will be transfered to the given player

Parameters targetId - number - ServerId of the player that should get the vehicle vehicle - int or table - A vehicle handle or vehicle data showDialog - boolean - Show Input Dialog or not

Description If the Parameter showDialog is set to true, then the Owner of the Vehicle get a input field where he can insert a price for the vehicle that the target player has to pay to get the vehicle.

exports.msk_vehiclekeys:TransferVehicle(targetId, vehicle, showDialog)

-- You can also use:
exports.msk_vehiclekeys:TransferVehicle(targetId, {plate = vehiclePlate, model = vehicleModel}, showDialog)

Last updated