This export is used to verify if a player has the vehicle keys of the specified vehicle. With this, you can specify the target or let it without anything.
This example is used to verify if the current player has the keys for a vehicle.
RegisterCommand('hasvehiclekeys', function (source, args)
local isPlayerInVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if isPlayerInVehicle then
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
local hasVehicleKeys = exports['ug-garage']:HasVehicleKeys(vehicle)
print(hasVehicleKeys)
end
end
end, false)
Example #2 (ESX):
This example is used to verify if the closest player has the keys for a vehicle using the ESX 1.1 framework.
ESX = nil
CreateThread(function ()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function (obj)
ESX = obj
end)
Wait(50)
end
while ESX.GetPlayerData().job == nil do
Wait(50)
end
end)
RegisterCommand('hasvehiclekeys', function (source, args)
local isPlayerInVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if isPlayerInVehicle then
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
local closestPlayer, closestPlayerDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestPlayerDistance <= 2.5 then
local hasVehicleKeys = exports['ug-garage']:HasVehicleKeys(vehicle, closestPlayer)
print(hasVehicleKeys)
end
end
end
end, false)
Example #2 (ESX Legacy):
This example is used to verify if the closest player has the keys for a vehicle using the ESX Legacy framework.
ESX = exports['es_extended']:getSharedObject()
RegisterCommand('hasvehiclekeys', function (source, args)
local isPlayerInVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if isPlayerInVehicle then
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
local closestPlayer, closestPlayerDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestPlayerDistance <= 2.5 then
local hasVehicleKeys = exports['ug-garage']:HasVehicleKeys(vehicle, closestPlayer)
print(hasVehicleKeys)
end
end
end
end, false)
Example #2 (QB-Core):
This example is used to verify if the closest player has the keys for a vehicle using the QB-Core framework.
local QBCore = exports['qb-core']:GetCoreObject()
RegisterCommand('hasvehiclekeys', function (source, args)
local isPlayerInVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if isPlayerInVehicle then
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if DoesEntityExist(vehicle) then
local closestPlayer, closestPlayerDistance = QBCore.Functions.GetClosestPlayer()
if closestPlayer ~= -1 and closestPlayerDistance <= 2.5 then
local hasVehicleKeys = exports['ug-garage']:HasVehicleKeys(vehicle, closestPlayer)
print(hasVehicleKeys)
end
end
end
end, false)
Returns:
hasVehicleKeys: boolean
Open Police Impound Menu
This export is used to open the police impound menu. It will trigger the function that checks if the player has the required job authorization to use this menu.
Usage:
exports['ug-garage']:OpenPoliceMenu()
Example:
RegisterNetEvent('myUgDevScript:OpenPoliceMenu', function ()
exports['ug-dispatch']:OpenPoliceMenu()
end)