Server

Exports - Serverside

toggleLock

(Un)locks the closest vehicle

Parameters playerId - number - The ServerId of the player

exports.msk_vehiclekeys:toggleLock(playerId)

toggleLockAdmin

(Un)locks the closest vehicle without a key needed

Parameters playerId - number - The ServerId of the player

exports.msk_vehiclekeys:toggleLockAdmin(playerId)

GetVehicleLockState

Get whether the vehicle is locked or unlocked

Parameters vehicle - int - A vehicle handle

Retuns 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

Retuns 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

IsVehicleWhitelisted

Parameters plate - string - Vehicle Plate model - int - Vehicle Model

Retuns isWhitelisted - boolean - whether the vehicle is whitelisted or not

local isWhitelisted = exports.msk_vehiclekeys:IsVehicleWhitelisted(plate, model)

IsVehicleBlacklisted

Parameters plate - string - Vehicle Plate model - int - Vehicle Model

Retuns isBlacklisted - boolean - whether the vehicle is blacklisted or not

local isBlacklisted = exports.msk_vehiclekeys:IsVehicleBlacklisted(plate, model)

GetAllVehicleKeys

Gets all vehicle keys saved in vehiclekeys.json

Retuns 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

RefreshPlayerKeys

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

Parameters playerId - number - The ServerId of the player

exports.msk_vehiclekeys:RefreshPlayerKeys(playerId)

GetPlayerKeys

Gets the players vehicle keys

Parameters playerData - table - PlayerData of the player which you want to get the keys from

Retuns keys - table - Players Vehicle Keys

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local keys = exports.msk_vehiclekeys:GetPlayerKeys(playerData)

-- Example: 
local keys = exports.msk_vehiclekeys:GetPlayerKeys({source = 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 playerData - table - PlayerData of the player which you want to get the primary keys from

Retuns keys - table - Players Vehicle Keys

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local keys = exports.msk_vehiclekeys:GetPlayerPrimaryKeys(playerData)

-- Example: 
local keys = exports.msk_vehiclekeys:GetPlayerPrimaryKeys({source = 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 playerData - table - PlayerData of the player which you want to get the secondary keys from

Retuns keys - table - Players Vehicle Keys

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local keys = exports.msk_vehiclekeys:GetPlayerSecondaryKeys(playerData)

-- Example: 
local keys = exports.msk_vehiclekeys:GetPlayerSecondaryKeys({source = 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 playerData - table - PlayerData of the player which you want to get the temporary keys from

Retuns keys - table - Players Vehicle Keys

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local keys = exports.msk_vehiclekeys:GetPlayerTempKeys(playerData)

-- Example: 
local keys = exports.msk_vehiclekeys:GetPlayerTempKeys({source = 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 plate and model or not

Parameters playerData - table - PlayerData of the player which you want to check if he has a key plate - string - Vehicle Plate model - number - Vehicle Model

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

local hasKey = exports.msk_vehiclekeys:HasPlayerKey(playerData, plate, model)

-- Example
local hasKey = exports.msk_vehiclekeys:HasPlayerKey({source = playerId}, plate, model)

HasPlayerPrimaryKey

Checks whether the player has a primary key for the given plate and model or not

Parameters playerData - table - PlayerData of the player which you want to check if he has a primary key plate - string - Vehicle Plate model - number - Vehicle Model

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

local hasKey = exports.msk_vehiclekeys:HasPlayerPrimaryKey(playerData, plate, model)

-- Example
local hasKey = exports.msk_vehiclekeys:HasPlayerPrimaryKey({source = playerId}, plate, model)

HasPlayerSecondaryKey

Checks whether the player has a secondary key for the given plate and model or not

Parameters playerData - table - PlayerData of the player which you want to check if he has a secondary key plate - string - Vehicle Plate model - number - Vehicle Model

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

local hasKey = exports.msk_vehiclekeys:HasPlayerSecondaryKey(playerData, plate, model)

-- Example
local hasKey = exports.msk_vehiclekeys:HasPlayerSecondaryKey({source = playerId}, plate, model)

HasPlayerTempKey

Checks whether the player has a temporary key for the given plate and model or not

Parameters playerData - table - PlayerData of the player which you want to check if he has a temporary key plate - string - Vehicle Plate model - number - Vehicle Model

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

local hasKey = exports.msk_vehiclekeys:HasPlayerTempKey(playerData, plate, model)

-- Example
local hasKey = exports.msk_vehiclekeys:HasPlayerTempKey({source = playerId}, plate, model)

GetPlayerVehicles

Get the players vehicles saved in database: owned_vehicles

Parameters playerData - table - PlayerData of the player which you want to get the vehicles from

Retuns vehicles - table - Players Vehicles

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local vehicles = exports.msk_vehiclekeys:GetPlayerVehicles(playerData)

-- Example
local vehicles = exports.msk_vehiclekeys:GetPlayerVehicles({source = 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 playerData - table - PlayerData of the player which you want to check if he is the vehicle owner

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

local isOwner = exports.msk_vehiclekeys:IsVehicleOwner(playerData)

-- Example
local isOwner = exports.msk_vehiclekeys:IsVehicleOwner({source = playerId})

HasPlayerKeyOrIsVehicleOwner

Checks whether the player has a key or is vehicle owner

Parameters playerData - table - PlayerData of the player which you want to check if he has a key plate - string - Vehicle Plate model - number - Vehicle Model

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

local hasKeyOrIsOwner = exports.msk_vehiclekeys:HasPlayerKeyOrIsVehicleOwner(playerData, plate, model)

-- Example
local hasKeyOrIsOwner = exports.msk_vehiclekeys:HasPlayerKeyOrIsVehicleOwner({source = playerId}, plate, model)

GetPlayerKeysAndVehicles

Gets the player keys and owned vehicles

Parameters playerData - table - PlayerData of the player which you want to get the keys and vehicles from

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

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

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

-- Example
local keys, vehicles = exports.msk_vehiclekeys:GetPlayerKeysAndVehicles({source = 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 playerData - table - PlayerData of the player to whom you want to add the key plate - string - Vehicle Plate type - string - Key Type ['primary', 'secondary', 'temporary']

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:AddKey(playerData, plate, type)

-- Example
exports.msk_vehiclekeys:AddKey({source = playerId}, 'LS 1234', 'secondary')

AddPrimaryKey

Adds a primary key to the player

Parameters playerData - table - PlayerData of the player to whom you want to add the primary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:AddPrimaryKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:AddPrimaryKey({source = playerId}, 'LS 1234')

AddSecondaryKey

Adds a secondary key to the player

Parameters playerData - table - PlayerData of the player to whom you want to add the secondary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:AddSecondaryKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:AddSecondaryKey({source = playerId}, 'LS 1234')

AddTempKey

Adds a temporary key to the player

Parameters playerData - table - PlayerData of the player to whom you want to add the temporary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:AddTempKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:AddTempKey({source = playerId}, 'LS 1234')

RemoveKey

Removes the key from the player

Parameters playerData - table - PlayerData of the player to whom you want to remove the key plate - string - Vehicle Plate type - string - Key Type ['primary', 'secondary', 'temporary']

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:RemoveKey(playerData, plate, type)

-- Example
exports.msk_vehiclekeys:RemoveKey({source = playerId}, 'LS 1234', 'secondary')

RemovePrimaryKey

Removes the primary key from the player

Parameters playerData - table - PlayerData of the player to whom you want to remove the primary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:RemovePrimaryKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:RemovePrimaryKey({source = playerId}, 'LS 1234')

RemoveSecondaryKey

Removes the secondary key from the player

Parameters playerData - table - PlayerData of the player to whom you want to remove the secondary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:RemoveSecondaryKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:RemoveSecondaryKey({source = playerId}, 'LS 1234')

RemoveTempKey

Removes the temporary key from the player

Parameters playerData - table - PlayerData of the player to whom you want to remove the temporary key plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier} - Use this if the player is not Online

exports.msk_vehiclekeys:RemoveTempKey(playerData, plate)

-- Example
exports.msk_vehiclekeys:RemoveTempKey({source = playerId}, 'LS 1234')

ExchangeVehicleLocks

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

Parameters playerData - table - PlayerData of the player who is the vehicle owner plate - string - Vehicle Plate

Description For the Parameter playerData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

exports.msk_vehiclekeys:ExchangeVehicleLocks(playerData, plate)

-- Example
exports.msk_vehiclekeys:ExchangeVehicleLocks({source = playerId}, 'LS 1234')

TransferVehicle

The given vehicle will be transfered to the given player

Parameters ownerData - table - PlayerData of the player who is the current vehicle owner targetData - table - PlayerData of the player who gets the vehicle plate - string - Vehicle Plate

Description For the Parameter ownerData or targetData you can set:

  • {source = playerId}

  • {identifier = playerIdentifier}

exports.msk_vehiclekeys:TransferVehicle(ownerData, targetData, plate)

-- Example
exports.msk_vehiclekeys:TransferVehicle({source = playerId}, {source = targetId}, 'LS 1234')

Last updated