structura foldere
mutat kq- folders in un singur folder [kq]
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
if Config.TextUI ~= "HelpNotification" then
|
||||
return
|
||||
end
|
||||
|
||||
function TextShow(msg)
|
||||
SetTextComponentFormat("STRING")
|
||||
AddTextComponentString(msg)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
end
|
||||
|
||||
function TextClose()
|
||||
return
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
-- Function to draw 3D text based on the chosen method
|
||||
local isTextVisible = true
|
||||
|
||||
-- Function to draw 3D text based on the chosen method
|
||||
function Draw3DText(x, y, z, text)
|
||||
if isTextVisible then
|
||||
if Config.ReplaceDraw3D then
|
||||
if Config.TextUI == 'okokTextUI' then
|
||||
print("DEBUG: okokTextUI is currently bugged and will not display correctly.")
|
||||
end
|
||||
TextShow(text) -- Use the ox_lib function
|
||||
else
|
||||
DrawText3D(x, y, z, text)
|
||||
end
|
||||
isTextVisible = false
|
||||
end
|
||||
end
|
||||
|
||||
function TextClose()
|
||||
return
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
if Config.TextUI ~= "esx_textui" then
|
||||
return
|
||||
end
|
||||
|
||||
function TextShow(msg, x, y, z)
|
||||
exports["esx_textui"]:TextUI(msg)
|
||||
end
|
||||
|
||||
function TextClose()
|
||||
exports["esx_textui"]:HideUI()
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
if Config.TextUI ~= "okokTextUI" then
|
||||
return
|
||||
end
|
||||
|
||||
function TextShow(msg)
|
||||
exports['okokTextUI']:Open(msg, 'lightblue', 'right')
|
||||
end
|
||||
|
||||
function TextClose()
|
||||
exports['okokTextUI']:Close()
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
local lastTextDisplayed = nil
|
||||
|
||||
if Config.TextUI ~= "ox_lib" then
|
||||
return
|
||||
end
|
||||
|
||||
function TextShow(msg)
|
||||
if lib.isTextUIOpen() then
|
||||
return
|
||||
else
|
||||
local icon = Config.CustomIcon or ''
|
||||
|
||||
if Config.CustomDesignTextUI then
|
||||
lib.showTextUI(msg, {
|
||||
icon = icon,
|
||||
style = {
|
||||
borderRadius = 0,
|
||||
backgroundColor = '#141517',
|
||||
color = '#d6d6d6'
|
||||
}
|
||||
})
|
||||
else
|
||||
lib.showTextUI(msg, { icon = icon })
|
||||
end
|
||||
|
||||
lastTextDisplayed = msg
|
||||
end
|
||||
end
|
||||
|
||||
function TextClose(textToClose)
|
||||
local isOpen, currentText = lib.isTextUIOpen()
|
||||
|
||||
if isOpen then
|
||||
if currentText == textToClose or textToClose == true then
|
||||
lib.hideTextUI()
|
||||
lastTextDisplayed = nil
|
||||
return true
|
||||
elseif lastTextDisplayed and currentText == lastTextDisplayed then
|
||||
lib.hideTextUI()
|
||||
lastTextDisplayed = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
if Config.TextUI ~= "qb" then
|
||||
return
|
||||
end
|
||||
|
||||
function TextShow(msg)
|
||||
exports['qb-core']:DrawText(msg, 'left')
|
||||
end
|
||||
|
||||
function TextClose()
|
||||
exports['qb-core']:HideText()
|
||||
end
|
||||
@@ -0,0 +1,85 @@
|
||||
if Config.Framework ~= "esx" then
|
||||
return
|
||||
end
|
||||
|
||||
ESX = nil
|
||||
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
|
||||
nh_trigger = 'nh-context:createMenu'
|
||||
|
||||
function TriggerServerCallback(name, cb, ...)
|
||||
ESX.TriggerServerCallback(name, cb, ...)
|
||||
end
|
||||
|
||||
function GetVehicleProperties(vehicle)
|
||||
return ESX.Game.GetVehicleProperties(vehicle)
|
||||
end
|
||||
|
||||
function GetPlateVeh(vehicle)
|
||||
local veh = ESX.Game.GetVehicleProperties(vehicle)
|
||||
if not veh then return false end
|
||||
return veh.plate
|
||||
end
|
||||
|
||||
function GetClosestVehicle()
|
||||
return ESX.Game.GetClosestVehicle()
|
||||
end
|
||||
|
||||
function GetJobFramework()
|
||||
return ESX.GetPlayerData().job
|
||||
end
|
||||
|
||||
function GetGangFramework()
|
||||
if Config.Gangs == true then
|
||||
return exports['qs-gangs']:GetGang()
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function GetVehiclesInArea()
|
||||
return ESX.Game.GetVehiclesInArea(GetEntityCoords(PlayerPedId()), Config.LockDistance)
|
||||
end
|
||||
|
||||
function CheckPolice()
|
||||
if Config.ReqPolice then
|
||||
local canRob = nil
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPolice', function(check)
|
||||
canRob = check
|
||||
end)
|
||||
repeat Wait(250) until canRob ~= nil
|
||||
return canRob
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function ProgressBar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
local onFinishCallback = onFinish or function() end
|
||||
local onCancelCallback = onCancel or function() end
|
||||
|
||||
local success = lib.progressCircle({
|
||||
duration = duration,
|
||||
position = 'bottom',
|
||||
label = label,
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
disable = disableControls,
|
||||
anim = animation,
|
||||
prop = prop,
|
||||
propTwo = propTwo,
|
||||
})
|
||||
|
||||
if success then
|
||||
onFinishCallback()
|
||||
else
|
||||
onCancelCallback()
|
||||
end
|
||||
end
|
||||
|
||||
function SendTextMessage(msg, type)
|
||||
if type == 'inform' then lib.notify({title = 'Information', description = msg, type = 'inform', id = msg}) end
|
||||
if type == 'error' then lib.notify({title = 'Error', description = msg, type = 'error', id = msg}) end
|
||||
if type == 'success' then lib.notify({title = 'Success', description = msg, type = 'success', id = msg}) end
|
||||
end
|
||||
@@ -0,0 +1,108 @@
|
||||
if Config.Framework ~= "qb" then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = nil
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
qb_menu_name = 'qb-menu'
|
||||
nh_trigger = 'nh-context:createMenu'
|
||||
|
||||
function TriggerServerCallback(name, cb, ...)
|
||||
QBCore.Functions.TriggerCallback(name, cb, ...)
|
||||
end
|
||||
|
||||
function GetVehicleProperties(vehicle)
|
||||
return QBCore.Functions.GetVehicleProperties(vehicle)
|
||||
end
|
||||
|
||||
function GetPlateVeh(vehicle)
|
||||
return QBCore.Functions.GetPlate(vehicle)
|
||||
end
|
||||
|
||||
function GetClosestVehicle(vehicle)
|
||||
local veh = QBCore.Functions.GetClosestVehicle(vehicle)
|
||||
if not veh then return false end
|
||||
return veh
|
||||
end
|
||||
|
||||
function GetJobFramework()
|
||||
return QBCore.Functions.GetPlayerData().job
|
||||
end
|
||||
|
||||
function GetGangFramework()
|
||||
if Config.Gangs == true then
|
||||
return exports['qs-gangs']:GetGang()
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function GetVehiclesInArea()
|
||||
local result = {}
|
||||
table.clear(result)
|
||||
local vehicles = QBCore.Functions.GetVehicles()
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
for k, v in pairs(vehicles) do
|
||||
local vehicleCoords = GetEntityCoords(v)
|
||||
local distance = #(playerCoords - vehicleCoords)
|
||||
if distance <= Config.LockDistance then
|
||||
table.insert(result, v)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function CheckPolice()
|
||||
if Config.ReqPolice then
|
||||
local canRob = nil
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPolice', function(check)
|
||||
canRob = check
|
||||
end)
|
||||
repeat Wait(250) until canRob ~= nil
|
||||
return canRob
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function ProgressBar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
local onFinishCallback = onFinish or function() end
|
||||
local onCancelCallback = onCancel or function() end
|
||||
|
||||
local success = lib.progressCircle({
|
||||
duration = duration,
|
||||
position = 'bottom',
|
||||
label = label,
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
disable = disableControls,
|
||||
anim = animation,
|
||||
prop = prop,
|
||||
propTwo = propTwo,
|
||||
})
|
||||
|
||||
if success then
|
||||
onFinishCallback()
|
||||
else
|
||||
onCancelCallback()
|
||||
end
|
||||
end
|
||||
|
||||
function SendTextMessage(msg, type)
|
||||
if type == 'inform' then
|
||||
QBCore.Functions.Notify(msg, 'primary', 5000)
|
||||
end
|
||||
if type == 'error' then
|
||||
QBCore.Functions.Notify(msg, 'error', 5000)
|
||||
end
|
||||
if type == 'success' then
|
||||
QBCore.Functions.Notify(msg, 'success', 5000)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
RegisterCommand("getkeys", function()
|
||||
exports['qs-vehiclekeys']:GiveKeysAuto()
|
||||
end)
|
||||
@@ -0,0 +1,106 @@
|
||||
if Config.Framework ~= 'qbx' then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
qb_menu_name = 'qb-menu'
|
||||
|
||||
function TriggerServerCallback(name, cb, ...) -- Sadly have to keep this for compatibility
|
||||
QBCore.Functions.TriggerCallback(name, cb, ...)
|
||||
end
|
||||
|
||||
function GetPlayerData()
|
||||
return exports.qbx_core:GetPlayerData()
|
||||
end
|
||||
|
||||
function GetIdentifier()
|
||||
return GetPlayerData().citizenid
|
||||
end
|
||||
|
||||
function GetPlayers()
|
||||
return GetActivePlayers()
|
||||
end
|
||||
|
||||
function GetVehicleProperties(vehicle)
|
||||
return lib.getVehicleProperties(vehicle)
|
||||
end
|
||||
|
||||
function GetPlateVeh(vehicle)
|
||||
return QBCore.Functions.GetPlate(vehicle)
|
||||
end
|
||||
|
||||
function GetClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
local vehicle, vehicleCoords = lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
if not vehicle then
|
||||
return false
|
||||
end
|
||||
return vehicle
|
||||
end
|
||||
|
||||
function GetJobFramework()
|
||||
return GetPlayerData()?.job?.name
|
||||
end
|
||||
|
||||
function GetGangFramework()
|
||||
if Config.Gangs == true then
|
||||
return exports['qs-gangs']:GetGang()
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function GetVehiclesInArea()
|
||||
local result = {}
|
||||
table.clear(result)
|
||||
local vehicles = QBCore.Functions.GetVehicles()
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
for k, v in pairs(vehicles) do
|
||||
local vehicleCoords = GetEntityCoords(v)
|
||||
local distance = #(playerCoords - vehicleCoords)
|
||||
if distance <= Config.LockDistance then
|
||||
table.insert(result, v)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function CheckPolice()
|
||||
if Config.ReqPolice then
|
||||
local canRob = nil
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPolice', function(check)
|
||||
canRob = check
|
||||
end)
|
||||
repeat Wait(250) until canRob ~= nil
|
||||
return canRob
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function ProgressBar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
local onFinishCallback = onFinish or function() end
|
||||
local onCancelCallback = onCancel or function() end
|
||||
|
||||
local success = lib.progressCircle({
|
||||
duration = duration,
|
||||
position = 'bottom',
|
||||
label = label,
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
disable = disableControls,
|
||||
anim = animation,
|
||||
prop = prop,
|
||||
propTwo = propTwo,
|
||||
})
|
||||
|
||||
if success then
|
||||
onFinishCallback()
|
||||
else
|
||||
onCancelCallback()
|
||||
end
|
||||
end
|
||||
|
||||
function SendTextMessage(msg, type)
|
||||
if type == 'inform' or type == 'error' or type == 'success' then lib.notify({title = 'Vehicle keys', description = msg, type = type}) end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'LegacyFuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['LegacyFuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['LegacyFuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'esx-sna-fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['esx-sna-fuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['esx-sna-fuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'lj-fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['lj-fuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['lj-fuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'okokGasStation' then
|
||||
return 100.0
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['okokGasStation']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['okokGasStation']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
if Config.Fuel ~= 'ox_fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
Entity(vehicle).state.fuel = fuelLevel
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return Entity(vehicle).state.fuel
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'ps-fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['ps-fuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['ps-fuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'qs-fuelstations' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['qs-fuelstations']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['qs-fuelstations']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'rcore_fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['rcore_fuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['rcore_fuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'ti_fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['ti_fuel']:setFuel(vehicle, fuelLevel, 'RON91')
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['ti_fuel']:getFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
if Config.Fuel ~= 'x-fuel' then
|
||||
return
|
||||
end
|
||||
|
||||
function SetFuel(vehicle, fuelLevel)
|
||||
local success, error = pcall(function()
|
||||
exports['x-fuel']:SetFuel(vehicle, fuelLevel)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
Debug('You did not configure your fuel system and it is set to 100.0 in fuel, check in Config.Fuel')
|
||||
return 100.0
|
||||
end
|
||||
end
|
||||
|
||||
function GetFuel(vehicle)
|
||||
return exports['x-fuel']:GetFuel(vehicle)
|
||||
end
|
||||
@@ -0,0 +1,118 @@
|
||||
if Config.MenuType ~= 'esx_context' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.Framework == 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
function OpenCopyKeys()
|
||||
local elements = {}
|
||||
TriggerServerCallback(Config.Eventprefix..':server:getVehicles', function(vehicles)
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE")
|
||||
})
|
||||
for _,v in pairs(vehicles) do
|
||||
local hashVehicule = v.vehicle.model
|
||||
local plate = v.vehicle.plate
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_MODEL").." " .. vehicleName .. " ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate ,
|
||||
name = "take",
|
||||
metadata = {vehicleName, plate}
|
||||
})
|
||||
end
|
||||
ESX.OpenContext("right" , elements, function(menu,element)
|
||||
if element.name == "take" then
|
||||
clonekey(element.metadata[2], element.metadata[1])
|
||||
ESX.CloseContext()
|
||||
end
|
||||
end, function(menu)
|
||||
ESX.CloseContext()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenPlateMenu()
|
||||
|
||||
if Config.PlateType == 'menu' then
|
||||
|
||||
|
||||
local elements = {}
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_BUY_PLATE")
|
||||
})
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_BUY_PLATE_DESCRIPTION")..Config.NPCPlatePrice['price'],
|
||||
name = "take",
|
||||
})
|
||||
table.insert(elements, {
|
||||
title = Lang('VEHICLEKEYS_MENU_BUY_CHANGEPLATE_DESCRIPTION') .. Config.ChangePlateItemPrice['price'],
|
||||
name = "screwdriver",
|
||||
})
|
||||
ESX.OpenContext("right" , elements, function(menu,element)
|
||||
if element.name == "take" then
|
||||
TriggerEvent(Config.Eventprefix..':buyPlate')
|
||||
ESX.CloseContext()
|
||||
elseif element.name == "screwdriver" then
|
||||
TriggerEvent(Config.Eventprefix..':buyScrewdriver')
|
||||
ESX.CloseContext()
|
||||
end
|
||||
end, function(menu)
|
||||
ESX.CloseContext()
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
if Config.PlateType == 'shop' then
|
||||
|
||||
local generatePlate = GeneratePlate()
|
||||
local plate = {
|
||||
plate = generatePlate,
|
||||
}
|
||||
local shop = Lang('VEHICLEKEYS_PLATE_SHOP_NAME')
|
||||
local ShopItems = {
|
||||
label = Lang('VEHICLEKEYS_PLATE_SHOP_LABEL'),
|
||||
items = {
|
||||
{name = Config.PlateItem ,amount = 1, price = Config.PlatePrice['price'], slot= 1, info = plate },
|
||||
{name = Config.ChangePlateItem, amount = 1, price = Config.ChangePlateItemPrice['price'], slot = 2 },
|
||||
},
|
||||
}
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", shop, ShopItems)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function OpenTrackerMenu(gpsdata)
|
||||
local addedVehicles = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPlayerIdentifier', function(PlayerIdentifier)
|
||||
local elements = {}
|
||||
|
||||
for _, v in ipairs(gpsdata) do
|
||||
if v.Player == PlayerIdentifier and not addedVehicles[v.plate] then
|
||||
table.insert(elements, {
|
||||
icon = 'car',
|
||||
title = string.format(Lang('VEHICLEKEYS_TRACKER_MENU_DESC'), v.plate),
|
||||
value = v.plate
|
||||
})
|
||||
addedVehicles[v.plate] = true
|
||||
end
|
||||
end
|
||||
|
||||
if #elements == 0 then
|
||||
table.insert(elements, {
|
||||
icon = 'times',
|
||||
title = Lang('VEHICLEKEYS_TRACKER_NO_VEHICLES'),
|
||||
disabled = true
|
||||
})
|
||||
end
|
||||
|
||||
ESX.OpenContext("right" , elements, function(data)
|
||||
if data.current.value then
|
||||
TriggerEvent(Config.Eventprefix..':client:LocateVehicleWithPlate', data.current.value)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,296 @@
|
||||
if Config.MenuType ~= 'esx_menu_default' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.Framework == 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.InventoryScript == 'qs' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'ox' then
|
||||
function GetPlateFromItem(item)
|
||||
local plate = item.metadata and item.metadata.plate or nil
|
||||
return plate
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
local model = item.metadata and item.metadata.model or nil
|
||||
return model
|
||||
end
|
||||
elseif Config.InventoryScript == 'qb' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'codem' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info[1] and item.info[1].description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'core_inventory' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
else
|
||||
-- Handle other cases or provide a default implementation
|
||||
function GetPlateFromItem(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function OpenCopyKeys()
|
||||
local vehicleMenuElements = {
|
||||
{
|
||||
label = Lang("VEHICLEKEYS_MENU_OWNED_VEHICLES") .. ' - $' .. Config.CopyKeysCost,
|
||||
name = "owned_vehicles",
|
||||
icon = 'car',
|
||||
},
|
||||
{
|
||||
label = Lang("VEHICLEKEYS_MENU_OWNED_KEYS") .. ' - $' .. Config.InventoryCopyKeysCost,
|
||||
name = "owned_keys",
|
||||
icon = 'key',
|
||||
},
|
||||
}
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_keys_menu_choice', {
|
||||
title = Lang("VEHICLEKEYS_MENU_CHOICE_TITLE"),
|
||||
align = Config.MenuPlacement,
|
||||
elements = vehicleMenuElements,
|
||||
}, function(data, menu)
|
||||
-- Handle menu interactions here
|
||||
local currentElement = data.current
|
||||
|
||||
if currentElement.name == "owned_vehicles" then
|
||||
OpenVehicleKeysMenu()
|
||||
elseif currentElement.name == "owned_keys" then
|
||||
OpenOwnedKeysMenu()
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenVehicleKeysMenu()
|
||||
local vehicleMenuElements = {}
|
||||
TriggerServerCallback(Config.Eventprefix..':server:getVehicles', function(vehicles)
|
||||
if Config.Debug then
|
||||
print(json.encode(vehicles))
|
||||
end
|
||||
|
||||
for _,v in pairs(vehicles) do
|
||||
local hashVehicle = v.vehicle.model
|
||||
local plate = v.vehicle.plate
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicle)
|
||||
|
||||
print("Plate: " .. plate)
|
||||
print("Vehicle Name: " .. vehicleName)
|
||||
|
||||
|
||||
table.insert(vehicleMenuElements, {
|
||||
label = Lang("VEHICLEKEYS_MENU_MODEL").." " .. vehicleName .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'car',
|
||||
value = {plate = plate, model = vehicleName},
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(vehicleMenuElements, {
|
||||
label = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
action = "back",
|
||||
})
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_keys_menu', {
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
align = Config.MenuPlacement,
|
||||
elements = vehicleMenuElements,
|
||||
}, function(data, menu)
|
||||
local currentElement = data.current
|
||||
if currentElement.action == "back" then
|
||||
OpenCopyKeys()
|
||||
else
|
||||
clonekey(data.current.value.plate, data.current.value.model, true, Config.CopyKeysCost)
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenOwnedKeysMenu()
|
||||
local elements = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysFound = false
|
||||
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
|
||||
print("Plate:", plate)
|
||||
print("Model:", model)
|
||||
|
||||
if plate and model then
|
||||
table.insert(elements, {
|
||||
label = Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'key',
|
||||
value = {plate = plate, model = model},
|
||||
})
|
||||
|
||||
keysFound = true
|
||||
end
|
||||
end
|
||||
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
label = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
action = "none",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
label = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
action = "back",
|
||||
})
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_keys_menu', {
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
align = Config.MenuPlacement,
|
||||
elements = elements,
|
||||
}, function(data, menu)
|
||||
-- Handle menu interactions here
|
||||
local currentElement = data.current
|
||||
|
||||
if currentElement.action == "back" then
|
||||
OpenCopyKeys()
|
||||
elseif currentElement.action == "none" then
|
||||
return
|
||||
else
|
||||
clonekey(data.current.value.plate, data.current.value.model, true, Config.InventoryCopyKeysCost)
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenPlateMenu()
|
||||
if Config.PlateType == 'menu' then
|
||||
local plateMenuElements = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_MENU_BUY_PLATE_DESCRIPTION') .. ' - $' .. Config.PlatePrice['price'],
|
||||
name = "buy_plate",
|
||||
icon = 'car',
|
||||
onSelect = function(args, menu)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyPlate')
|
||||
end,
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_MENU_BUY_CHANGEPLATE_DESCRIPTION') .. ' - $' .. Config.ChangePlateItemPrice['price'],
|
||||
name = "buy_change_plate",
|
||||
icon = 'screwdriver',
|
||||
onSelect = function(args, menu)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyScrewdriver')
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_keys_menu_plate', {
|
||||
title = Lang('VEHICLEKEYS_MENU_TITLE_PLATE'),
|
||||
align = Config.MenuPlacement,
|
||||
elements = plateMenuElements,
|
||||
}, function(data, menu)
|
||||
-- Handle menu interactions here
|
||||
local currentElement = data.current
|
||||
|
||||
if currentElement.name == "buy_plate" then
|
||||
TriggerEvent(Config.Eventprefix .. ':buyPlate')
|
||||
elseif currentElement.name == "buy_change_plate" then
|
||||
TriggerEvent(Config.Eventprefix .. ':buyScrewdriver')
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
elseif Config.PlateType == 'shop' then
|
||||
local generatePlate = GeneratePlate()
|
||||
local plate = {
|
||||
plate = generatePlate,
|
||||
}
|
||||
local shop = Lang('VEHICLEKEYS_PLATE_SHOP_NAME')
|
||||
local shopItems = {
|
||||
label = Lang('VEHICLEKEYS_PLATE_SHOP_LABEL'),
|
||||
items = {
|
||||
{name = Config.PlateItem, amount = 1, price = Config.PlatePrice['price'], slot = 1, info = plate},
|
||||
{name = Config.ChangePlateItem, amount = 1, price = Config.ChangePlateItemPrice['price'], slot = 2},
|
||||
},
|
||||
}
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", shop, ShopItems)
|
||||
end
|
||||
end
|
||||
|
||||
function OpenTrackerMenu(gpsdata)
|
||||
local addedVehicles = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPlayerIdentifier', function(PlayerIdentifier)
|
||||
local elements = {}
|
||||
|
||||
for _, v in ipairs(gpsdata) do
|
||||
if v.Player == PlayerIdentifier and not addedVehicles[v.plate] then
|
||||
table.insert(elements, {
|
||||
label = string.format(Lang('VEHICLEKEYS_TRACKER_MENU_DESC'), v.plate),
|
||||
icon = 'car',
|
||||
value = v.plate
|
||||
})
|
||||
addedVehicles[v.plate] = true
|
||||
end
|
||||
end
|
||||
|
||||
if #elements == 0 then
|
||||
table.insert(elements, {
|
||||
label = Lang('VEHICLEKEYS_TRACKER_NO_VEHICLES'),
|
||||
disabled = true
|
||||
})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehiclekeys_gps_menu', {
|
||||
title = Lang('VEHICLEKEYS_TRACKER_MENU_TITLE'),
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
}, function(data, menu)
|
||||
if data.current.value then
|
||||
TriggerEvent(Config.Eventprefix..':client:LocateVehicleWithPlate', data.current.value)
|
||||
end
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,240 @@
|
||||
if Config.MenuType ~= 'ox_lib' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.Framework == 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.InventoryScript == 'qs' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'ox' then
|
||||
function GetPlateFromItem(item)
|
||||
local plate = item.metadata and item.metadata.plate or nil
|
||||
return plate
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
local model = item.metadata and item.metadata.model or nil
|
||||
return model
|
||||
end
|
||||
elseif Config.InventoryScript == 'qb' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'codem' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info[1] and item.info[1].description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'core_inventory' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
else
|
||||
-- Handle other cases or provide a default implementation
|
||||
function GetPlateFromItem(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function OpenCopyKeys()
|
||||
local elements = {}
|
||||
local vehicleMenu = {
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_OWNED_VEHICLES") .. ' - $' .. Config.CopyKeysCost,
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
OpenVehicleKeysMenu()
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_OWNED_KEYS") .. ' - $' .. Config.InventoryCopyKeysCost,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
OpenOwnedKeysMenu()
|
||||
end,
|
||||
},
|
||||
}
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_CHOICE',
|
||||
title = Lang("VEHICLEKEYS_MENU_CHOICE_TITLE"),
|
||||
options = vehicleMenu,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_CHOICE')
|
||||
end
|
||||
|
||||
function OpenVehicleKeysMenu()
|
||||
local elements = {}
|
||||
TriggerServerCallback(Config.Eventprefix..':server:getVehicles', function(vehicles)
|
||||
if Config.Debug then
|
||||
print(json.encode(vehicles))
|
||||
end
|
||||
for _,v in pairs(vehicles) do
|
||||
local hashVehicule = v.vehicle.model
|
||||
local plate = v.vehicle.plate
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_MODEL").." " .. vehicleName .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
clonekey(plate, vehicleName, true, Config.CopyKeysCost)
|
||||
end,
|
||||
})
|
||||
end
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenCopyKeys()
|
||||
end,
|
||||
})
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE')
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenOwnedKeysMenu()
|
||||
local elements = {}
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysFound = false
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
keysFound = true
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
clonekey(plate, model, true, Config.InventoryCopyKeysCost)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
title = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenCopyKeys()
|
||||
end,
|
||||
})
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE')
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenPlateMenu()
|
||||
if Config.PlateType == 'menu' then
|
||||
local elements = {}
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang('VEHICLEKEYS_MENU_BUY_PLATE_DESCRIPTION') .. ' - $' .. Config.PlatePrice['price'],
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyPlate')
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang('VEHICLEKEYS_MENU_BUY_CHANGEPLATE_DESCRIPTION') .. ' - $' .. Config.ChangePlateItemPrice['price'],
|
||||
icon = 'screwdriver',
|
||||
onSelect = function(args)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyScrewdriver')
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE_PLATE',
|
||||
title = Lang('VEHICLEKEYS_MENU_TITLE_PLATE'),
|
||||
options = elements,
|
||||
})
|
||||
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE_PLATE')
|
||||
end
|
||||
|
||||
if Config.PlateType == 'shop' then
|
||||
local generatePlate = GeneratePlate()
|
||||
local plate = { plate = generatePlate }
|
||||
local shop = Lang('VEHICLEKEYS_PLATE_SHOP_NAME')
|
||||
local ShopItems = {
|
||||
label = Lang('VEHICLEKEYS_PLATE_SHOP_LABEL'),
|
||||
items = {
|
||||
{ name = Config.PlateItem, amount = 1, price = Config.PlatePrice['price'], slot = 1, info = plate },
|
||||
{ name = Config.ChangePlateItem, amount = 1, price = Config.ChangePlateItemPrice['price'], slot = 2 },
|
||||
},
|
||||
}
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", shop, ShopItems)
|
||||
end
|
||||
end
|
||||
|
||||
function OpenTrackerMenu(gpsdata)
|
||||
local addedVehicles = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPlayerIdentifier', function(PlayerIdentifier)
|
||||
lib.registerContext({
|
||||
id = 'vehiclekeys_gps_menu',
|
||||
title = Lang('VEHICLEKEYS_TRACKER_MENU_TITLE'),
|
||||
options = (function()
|
||||
local options = {}
|
||||
for _, v in ipairs(gpsdata) do
|
||||
if v.Player == PlayerIdentifier and not addedVehicles[v.plate] then
|
||||
table.insert(options, {
|
||||
title = v.model,
|
||||
description = string.format(Lang('VEHICLEKEYS_TRACKER_MENU_DESC'), v.plate),
|
||||
icon = 'car',
|
||||
onSelect = function() TriggerEvent(Config.Eventprefix..':client:LocateVehicleWithPlate', v.plate) end
|
||||
})
|
||||
addedVehicles[v.plate] = true
|
||||
end
|
||||
end
|
||||
if #options == 0 then
|
||||
table.insert(options, { title = Lang('VEHICLEKEYS_TRACKER_NO_VEHICLES'), disabled = true })
|
||||
end
|
||||
return options
|
||||
end)()
|
||||
})
|
||||
|
||||
lib.showContext('vehiclekeys_gps_menu')
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
if Config.MenuType ~= 'ox_lib' then
|
||||
return
|
||||
end
|
||||
if Config.Framework == 'esx' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.InventoryScript == 'qs' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'ox' then
|
||||
function GetPlateFromItem(item)
|
||||
local plate = item.metadata and item.metadata.plate or nil
|
||||
return plate
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
local model = item.metadata and item.metadata.model or nil
|
||||
return model
|
||||
end
|
||||
elseif Config.InventoryScript == 'qb' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'codem' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info[1] and item.info[1].description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'core_inventory' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
else
|
||||
-- Handle other cases or provide a default implementation
|
||||
function GetPlateFromItem(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function OpenCopyKeys()
|
||||
local elements = {}
|
||||
local vehicleMenu = {
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_OWNED_VEHICLES") .. ' - $' .. Config.CopyKeysCost,
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
OpenVehicleKeysMenu()
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_OWNED_KEYS") .. ' - $' .. Config.InventoryCopyKeysCost,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
OpenOwnedKeysMenu()
|
||||
end,
|
||||
},
|
||||
}
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_CHOICE',
|
||||
title = Lang("VEHICLEKEYS_MENU_CHOICE_TITLE"),
|
||||
options = vehicleMenu,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_CHOICE')
|
||||
end
|
||||
|
||||
function OpenVehicleKeysMenu()
|
||||
local elements = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:getVehicles', function(vehicles)
|
||||
if not vehicles or #vehicles == 0 then
|
||||
print('No vehicles received from server callback')
|
||||
return
|
||||
end
|
||||
print(json.encode(vehicles))
|
||||
for _, v in pairs(vehicles) do
|
||||
local vehicleData = QBCore.Shared.Vehicles[v.vehicle]
|
||||
local vehicleName = vehicleData and vehicleData['name']
|
||||
|
||||
if not v.vehicle then
|
||||
print('Missing vehicle information:', v.vehicle)
|
||||
elseif not v.plate then
|
||||
print('Missing plate information for vehicle:', v.vehicle)
|
||||
elseif not vehicleName then
|
||||
print('Missing vehicle details:', v.vehicle, 'QBShared:', vehicleData or 'nil')
|
||||
else
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_MODEL").." " .. vehicleName .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. v.plate,
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
clonekey(v.plate, vehicleData['model'], true, Config.CopyKeysCost)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenCopyKeys()
|
||||
end,
|
||||
})
|
||||
|
||||
if #elements > 0 then
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE')
|
||||
else
|
||||
print('No valid vehicles to display in the menu')
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenOwnedKeysMenu()
|
||||
local elements = {}
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysFound = false
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
keysFound = true
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
clonekey(plate, model, true, Config.InventoryCopyKeysCost)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
title = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenCopyKeys()
|
||||
end,
|
||||
})
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE')
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenPlateMenu()
|
||||
|
||||
if Config.PlateType == 'menu' then
|
||||
|
||||
local elements = {}
|
||||
table.insert(elements, {
|
||||
title = Lang('VEHICLEKEYS_MENU_BUY_PLATE_DESCRIPTION') .. ' - $' .. Config.PlatePrice['price'],
|
||||
icon = 'car',
|
||||
onSelect = function(args)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyPlate')
|
||||
end,
|
||||
})
|
||||
table.insert(elements, {
|
||||
title = Lang('VEHICLEKEYS_MENU_BUY_CHANGEPLATE_DESCRIPTION') .. ' - $' .. Config.ChangePlateItemPrice['price'],
|
||||
icon = 'screwdriver',
|
||||
onSelect = function(args)
|
||||
TriggerEvent(Config.Eventprefix .. ':buyScrewdriver')
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'VEHICLEKEYS_MENU_TITLE_PLATE',
|
||||
title = Lang('VEHICLEKEYS_MENU_TITLE_PLATE'),
|
||||
options = elements,
|
||||
})
|
||||
|
||||
lib.showContext('VEHICLEKEYS_MENU_TITLE_PLATE')
|
||||
|
||||
end
|
||||
|
||||
if Config.PlateType == 'shop' then
|
||||
|
||||
local generatePlate = GeneratePlate()
|
||||
local plate = {
|
||||
plate = generatePlate,
|
||||
}
|
||||
local shop = Lang('VEHICLEKEYS_PLATE_SHOP_NAME')
|
||||
local ShopItems = {
|
||||
label = Lang('VEHICLEKEYS_PLATE_SHOP_LABEL'),
|
||||
items = {
|
||||
{name = Config.PlateItem ,amount = 1, price = Config.PlatePrice['price'], slot= 1, info = plate },
|
||||
{name = Config.ChangePlateItem, amount = 1, price = Config.ChangePlateItemPrice['price'], slot = 2 },
|
||||
},
|
||||
}
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", shop, ShopItems)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function OpenTrackerMenu(gpsdata)
|
||||
local addedVehicles = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPlayerIdentifier', function(PlayerIdentifier)
|
||||
lib.registerContext({
|
||||
id = 'vehiclekeys_gps_menu',
|
||||
title = Lang('VEHICLEKEYS_TRACKER_MENU_TITLE'),
|
||||
options = (function()
|
||||
local options = {}
|
||||
for _, v in ipairs(gpsdata) do
|
||||
if v.Player == PlayerIdentifier and not addedVehicles[v.plate] then
|
||||
table.insert(options, {
|
||||
title = v.model,
|
||||
description = string.format(Lang('VEHICLEKEYS_TRACKER_MENU_DESC'), v.plate),
|
||||
icon = 'car',
|
||||
onSelect = function() TriggerEvent(Config.Eventprefix..':client:LocateVehicleWithPlate', v.plate) end
|
||||
})
|
||||
addedVehicles[v.plate] = true
|
||||
end
|
||||
end
|
||||
if #options == 0 then
|
||||
table.insert(options, { title = Lang('VEHICLEKEYS_TRACKER_NO_VEHICLES'), disabled = true })
|
||||
end
|
||||
return options
|
||||
end)()
|
||||
})
|
||||
|
||||
lib.showContext('vehiclekeys_gps_menu')
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,306 @@
|
||||
if Config.MenuType ~= 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.Framework == 'esx' then
|
||||
return
|
||||
end
|
||||
|
||||
if Config.InventoryScript == 'qs' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'ox' then
|
||||
function GetPlateFromItem(item)
|
||||
local plate = item.metadata and item.metadata.plate or nil
|
||||
return plate
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
local model = item.metadata and item.metadata.model or nil
|
||||
return model
|
||||
end
|
||||
elseif Config.InventoryScript == 'qb' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'codem' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info[1] and item.info[1].description or nil
|
||||
end
|
||||
elseif Config.InventoryScript == 'core_inventory' then
|
||||
function GetPlateFromItem(item)
|
||||
return item.info and item.info.plate or nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return item.info and item.info.description or nil
|
||||
end
|
||||
else
|
||||
-- Handle other cases or provide a default implementation
|
||||
function GetPlateFromItem(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
function GetModelFromItem(item)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function OpenCopyKeys()
|
||||
local elements = {}
|
||||
|
||||
-- Ensure Config is defined and has the expected properties
|
||||
if not Config or not Config.MenuType or not Config.CopyKeysCost or not Config.InventoryCopyKeysCost then
|
||||
print("Error: Config is not properly defined.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Add the menu header
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_CHOICE_TITLE"),
|
||||
icon = 'fa-solid fa-infinity',
|
||||
isMenuHeader = true,
|
||||
})
|
||||
|
||||
-- Add menu options
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_OWNED_VEHICLES") .. ' - $' .. Config.CopyKeysCost,
|
||||
icon = 'car',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = OpenVehicleKeysMenu, -- Reference to the function without ()
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_OWNED_KEYS") .. ' - $' .. Config.InventoryCopyKeysCost,
|
||||
icon = 'key',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = OpenOwnedKeysMenu, -- Reference to the function without ()
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
|
||||
-- Ensure 'qb-menu' is set correctly
|
||||
if not exports['qb-menu'] then
|
||||
print("Error: qb-menu resource not found.")
|
||||
return
|
||||
end
|
||||
|
||||
exports['qb-menu']:openMenu(elements)
|
||||
end
|
||||
|
||||
|
||||
function OpenVehicleKeysMenu()
|
||||
local elements = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:getVehicles', function(vehicles)
|
||||
table.insert(elements, {
|
||||
isMenuHeader = true,
|
||||
header = Lang("VEHICLEKEYS_MENU_TITLE"),
|
||||
icon = 'fa-solid fa-infinity'
|
||||
})
|
||||
|
||||
for k,v in pairs(vehicles) do -- loop through our table
|
||||
if not v.vehicle then
|
||||
return print('Missing vehicle:', v.vehicle)
|
||||
elseif not v.plate then
|
||||
return print('Missing plate:', v.plate, ' Vehicle:', v.vehicle)
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Vehicles or not QBCore.Shared.Vehicles[v.vehicle] or not QBCore.Shared.Vehicles[v.vehicle]['name'] then
|
||||
return print('Missing vehicle details:', v.vehicle, 'QBShared : ', QBCore.Shared.Vehicles[v.vehicle] and QBCore.Shared.Vehicles[v.vehicle]['name'] or 'nil')
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_MODEL").." " .. QBCore.Shared.Vehicles[v.vehicle]['name'] .. " ",
|
||||
txt = Lang("VEHICLEKEYS_MENU_PLATE").." " .. v.plate,
|
||||
icon = 'fa-solid fa-face-grin-tears',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = function()
|
||||
clonekey(v.plate, QBCore.Shared.Vehicles[v.vehicle]['model'], true, Config.CopyKeysCost)
|
||||
end,
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
table.insert(elements, {
|
||||
header = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = OpenCopyKeys,
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
exports[qb_menu_name]:openMenu(elements) -- open our menu
|
||||
end)
|
||||
end
|
||||
|
||||
function OpenOwnedKeysMenu()
|
||||
local elements = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items and next(items) ~= nil then -- Check if items is not empty
|
||||
local keysFound = false
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
keysFound = true
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. " ",
|
||||
txt = Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate,
|
||||
icon = 'fa-solid fa-face-grin-tears',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = function()
|
||||
clonekey(plate, model, true, Config.InventoryCopyKeysCost)
|
||||
end,
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
header = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
table.insert(elements, {
|
||||
header = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
header = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = OpenCopyKeys,
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
|
||||
-- Adapt the following lines for qb-menu
|
||||
exports['qb-menu']:openMenu(elements) -- open our menu
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function OpenPlateMenu()
|
||||
if Config.PlateType == 'menu' then
|
||||
local elements = {}
|
||||
table.insert(elements, {
|
||||
isHeader = true,
|
||||
header = Lang("VEHICLEKEYS_MENU_TITLE_PLATE"),
|
||||
icon = 'fa-solid fa-toolbox',
|
||||
isMenuHeader = true,
|
||||
})
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_BUY_PLATE"),
|
||||
txt = Lang("VEHICLEKEYS_MENU_BUY_PLATE_DESCRIPTION")..Config.PlatePrice['price'],
|
||||
icon = 'fa-solid fa-face-grin-tears',
|
||||
params = {
|
||||
event = Config.Eventprefix..':buyPlate',
|
||||
}
|
||||
})
|
||||
table.insert(elements, {
|
||||
header = Lang("VEHICLEKEYS_MENU_BUY_SCREWDRIVER"),
|
||||
txt = Lang('VEHICLEKEYS_MENU_BUY_CHANGEPLATE_DESCRIPTION') .. Config.ChangePlateItemPrice['price'],
|
||||
icon = 'fa-solid fa-screwdriver',
|
||||
params = {
|
||||
event = Config.Eventprefix..':buyScrewdriver',
|
||||
}
|
||||
})
|
||||
exports[qb_menu_name]:openMenu(elements)
|
||||
end
|
||||
if Config.PlateType == 'shop' then
|
||||
local generatePlate = GeneratePlate()
|
||||
local plate = {
|
||||
plate = generatePlate,
|
||||
}
|
||||
local shop = Lang('VEHICLEKEYS_PLATE_SHOP_NAME')
|
||||
local ShopItems = {
|
||||
label = Lang('VEHICLEKEYS_PLATE_SHOP_LABEL'),
|
||||
items = {
|
||||
{name = Config.PlateItem ,amount = 1, price = Config.PlatePrice['price'], slot= 1, info = plate },
|
||||
{name = Config.ChangePlateItem, amount = 1, price = Config.ChangePlateItemPrice['price'], slot = 2 },
|
||||
},
|
||||
}
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", shop, ShopItems)
|
||||
end
|
||||
end
|
||||
|
||||
function OpenTrackerMenu(gpsdata)
|
||||
local addedVehicles = {}
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix..':server:GetPlayerIdentifier', function(PlayerIdentifier)
|
||||
local elements = {}
|
||||
|
||||
for _, v in ipairs(gpsdata) do
|
||||
if v.Player == PlayerIdentifier and not addedVehicles[v.plate] then
|
||||
table.insert(elements, {
|
||||
header = string.format(Lang('VEHICLEKEYS_TRACKER_MENU_DESC'), v.plate),
|
||||
txt = v.model,
|
||||
icon = 'car',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = function()
|
||||
TriggerEvent(Config.Eventprefix..':client:LocateVehicleWithPlate', v.plate)
|
||||
end,
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
addedVehicles[v.plate] = true
|
||||
end
|
||||
end
|
||||
|
||||
if #elements == 0 then
|
||||
table.insert(elements, {
|
||||
header = Lang('VEHICLEKEYS_TRACKER_NO_VEHICLES'),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
header = Lang('BACK_TO_PREVIOUS_MENU'),
|
||||
icon = 'arrow-left',
|
||||
params = {
|
||||
isAction = true,
|
||||
event = OpenPreviousMenu, -- Cambiar a la función para regresar al menú anterior
|
||||
args = {}
|
||||
}
|
||||
})
|
||||
|
||||
-- Open the menu using qb-menu
|
||||
exports['qb-menu']:openMenu(elements) -- Abre el menú
|
||||
end)
|
||||
end
|
||||
@@ -0,0 +1,58 @@
|
||||
if Config.HotKeys then
|
||||
CreateThread(function()
|
||||
while true do
|
||||
if IsControlJustPressed(0, Config.Controls.UseKey) then
|
||||
UseCommandKey()
|
||||
end
|
||||
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterCommand('usekey', function()
|
||||
UseCommandKey()
|
||||
end, false)
|
||||
|
||||
-- if Config.HotKeys then
|
||||
-- if not Config.ControlerSupport then
|
||||
-- lib.addKeybind({
|
||||
-- name = 'engine',
|
||||
-- description = Lang('VEHICLEKEYS_ENGINE_TOGGLE'),
|
||||
-- defaultKey = Config.Controls.EngineControl,
|
||||
-- onPressed = function()
|
||||
-- toggleEngine()
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
|
||||
-- lib.addKeybind({
|
||||
-- name = 'usekey',
|
||||
-- description = Lang('VEHICLEKEYS_USE_KEY'),
|
||||
-- defaultKey = Config.Controls.UseKey,
|
||||
-- onPressed = function()
|
||||
-- UseCommandKey()
|
||||
-- end
|
||||
-- })
|
||||
|
||||
-- RegisterKeyMapping('hotwire', Lang('VEHICLEKEYS_HOTWIRE'), 'keyboard', Config.Controls.HotwireControl)
|
||||
|
||||
-- if Config.AnchorKeybind then
|
||||
-- lib.addKeybind({
|
||||
-- name = 'anchor',
|
||||
-- description = Lang('VEHICLEKEYS_ANCHOR_BOAT'),
|
||||
-- defaultKey = '',
|
||||
-- onPressed = function()
|
||||
-- ExecuteCommand('anchor')
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- RegisterCommand('usekey', function()
|
||||
-- UseCommandKey()
|
||||
-- end, false)
|
||||
|
||||
-- RegisterCommand('hotwire', function()
|
||||
-- HandleHotwireProcess()
|
||||
-- end, false)
|
||||
@@ -0,0 +1,379 @@
|
||||
-- Check if Context Menu is enabled in the configuration
|
||||
if not Config.Context then return end
|
||||
|
||||
function OpenMainMenu()
|
||||
local elements = {}
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_CLEAN_KEYS_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_CLEAN_KEYS_DESCRIPTION"),
|
||||
icon = 'wrench',
|
||||
onSelect = function(args)
|
||||
CleanVehicleKeys()
|
||||
end,
|
||||
})
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_ACCESS_ALL_KEYS_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_ACCESS_ALL_KEYS_DESCRIPTION"),
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
OpenAllKeysMenu()
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'MAIN_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MAIN_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('MAIN_MENU_TITLE')
|
||||
end
|
||||
|
||||
|
||||
function OpenAllKeysMenu()
|
||||
local elements = {}
|
||||
local function AddKeyToAllKeysMenu(title, plate, model)
|
||||
table.insert(elements, {
|
||||
title = title,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
CreateKeyMenuItem(title, plate, model)
|
||||
end,
|
||||
})
|
||||
end
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysFound = false
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
keysFound = true
|
||||
AddKeyToAllKeysMenu(Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate, plate, model)
|
||||
end
|
||||
end
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
title = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenMainMenu()
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'ALL_KEYS_MENU',
|
||||
title = Lang("VEHICLEKEYS_ALL_KEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('ALL_KEYS_MENU')
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function CreateKeyMenuItem(title, plate, model)
|
||||
lib.registerContext({
|
||||
id = 'keysactions',
|
||||
title = 'Actions',
|
||||
options = {
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_KEY_MENU_HEADER"),
|
||||
icon = "info",
|
||||
disabled = true,
|
||||
description = Lang("VEHICLEKEYS_MENU_KEY_MENU_MODEL") .. " " .. model .. " " ..
|
||||
Lang("VEHICLEKEYS_MENU_KEY_MENU_PLATE") .. " " .. plate
|
||||
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_USE_KEY_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_USE_KEY_DESCRIPTION"),
|
||||
icon = "check",
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_USE_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
handleDoorLock(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_GIVE_KEY_TITLE"),
|
||||
icon = "handshake",
|
||||
description = Lang("VEHICLEKEYS_MENU_GIVE_KEY_DESCRIPTION"),
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_GIVE_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
ShowNearbyPlayersMenu(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_TRASH_KEY_TITLE"),
|
||||
icon = "trash",
|
||||
description = Lang("VEHICLEKEYS_MENU_TRASH_KEY_DESCRIPTION"),
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_TRASH_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = "arrow-left",
|
||||
onSelect = function(args)
|
||||
OpenAllKeysMenu()
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
lib.showContext('keysactions')
|
||||
end
|
||||
|
||||
function getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
return lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
end
|
||||
|
||||
function handleDoorLock(plate, model)
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local vehicle, _ = getClosestVehicle(coords, 5.0, true)
|
||||
if vehicle then
|
||||
local vehiclePlate = GetVehicleNumberPlateText(vehicle)
|
||||
local vehicleModel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
|
||||
if vehiclePlate == plate and vehicleModel == model then
|
||||
local hasKey = exports['qs-vehiclekeys']:GetKey(plate)
|
||||
if hasKey then
|
||||
exports["qs-vehiclekeys"]:DoorLogic(vehicle)
|
||||
for door = 0, 5 do
|
||||
SetVehicleDoorShut(vehicle, door, false, false)
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_KEYS'), 'error')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_MATCH'), 'error')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_VEHICLES'), 'error')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetPlayersInRadius(x, y, z, radius)
|
||||
local currentPlayerId = GetPlayerServerId(PlayerId())
|
||||
local players = ""
|
||||
for i = 0, 255 do
|
||||
if NetworkIsPlayerActive(i) then
|
||||
local playerPed = GetPlayerPed(i)
|
||||
local playerCoords = GetEntityCoords(playerPed, false)
|
||||
local distance = GetDistanceBetweenCoords(x, y, z, playerCoords, true)
|
||||
local playerId = GetPlayerServerId(i)
|
||||
if distance <= radius and playerId ~= currentPlayerId then
|
||||
if players == "" then
|
||||
players = tostring(playerId)
|
||||
else
|
||||
players = players .. "," .. tostring(playerId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
function ShowNearbyPlayersMenu(plate, model)
|
||||
local playerPed = GetPlayerPed(-1) -- Get the player's ped
|
||||
local x, y, z = table.unpack(GetEntityCoords(playerPed, false))
|
||||
local nearbyPlayers = GetPlayersInRadius(x, y, z, 2.0)
|
||||
|
||||
local elements = {}
|
||||
|
||||
if #nearbyPlayers == 0 then
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_NO_PLAYERS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
else
|
||||
local playerIds = {}
|
||||
for playerId in nearbyPlayers:gmatch("[^,]+") do
|
||||
table.insert(playerIds, playerId)
|
||||
end
|
||||
|
||||
for _, playerId in ipairs(playerIds) do
|
||||
table.insert(elements, {
|
||||
title = playerId,
|
||||
icon = 'user',
|
||||
onSelect = function()
|
||||
CheckAndGiveKey(plate, model, playerId)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
CreateKeyMenuItem(title, plate, model)
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'vehiclekeys_nearby_players',
|
||||
title = Lang("VEHICLEKEYS_NEARBY_PLAYERS_MENU_TITLE"),
|
||||
options = elements
|
||||
})
|
||||
lib.showContext('vehiclekeys_nearby_players')
|
||||
end
|
||||
|
||||
function CleanVehicleKeys()
|
||||
if Config.Framework == "esx" then
|
||||
-- ESX Framework logic
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:getVehicles', function(vehicles)
|
||||
if vehicles then
|
||||
local ownedVehicles = {}
|
||||
for _, v in pairs(vehicles) do
|
||||
local hashVehicle = v.vehicle.model
|
||||
local plate = v.vehicle.plate
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicle)
|
||||
ownedVehicles[plate] = vehicleName
|
||||
end
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysRemoved = true
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
if not ownedVehicles[plate] or ownedVehicles[plate] ~= model then
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
keysRemoved = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if keysRemoved then
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_SUCCESS'), 'inform')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
elseif Config.Framework == "qb" then
|
||||
-- QBCore Framework logic
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:getVehicles', function(vehicles)
|
||||
if not vehicles then
|
||||
print('No vehicles received from server callback')
|
||||
return
|
||||
end
|
||||
|
||||
local ownedVehicles = {}
|
||||
for _, v in pairs(vehicles) do
|
||||
if v.vehicle and v.plate then
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(v.vehicle.model)
|
||||
ownedVehicles[v.plate] = vehicleName
|
||||
else
|
||||
print('Missing vehicle or plate information:', v.vehicle, v.plate)
|
||||
end
|
||||
end
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysRemoved = true
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
if not ownedVehicles[plate] or ownedVehicles[plate] ~= model then
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
keysRemoved = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if keysRemoved then
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_SUCCESS'), 'inform')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
else
|
||||
print("Invalid framework specified in configuration.")
|
||||
end
|
||||
end
|
||||
|
||||
function PlayGiveAnimation()
|
||||
local EmoteData = {
|
||||
Animation = 'givetake1_a',
|
||||
Dictionary = 'mp_common',
|
||||
Options = {
|
||||
Duration = 2000,
|
||||
Flags = {
|
||||
Move = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
PlayEmote(EmoteData)
|
||||
end
|
||||
|
||||
function CheckAndGiveKey(plate, model, targetPlayerId)
|
||||
PlayGiveAnimation()
|
||||
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
TriggerServerEvent('vehiclekeys:server:givekeyother', plate, model, targetPlayerId)
|
||||
end
|
||||
|
||||
RegisterNetEvent('vehiclekeys:client:givekeyclient')
|
||||
AddEventHandler('vehiclekeys:client:givekeyclient', function(plate, model)
|
||||
PlayGiveAnimation()
|
||||
|
||||
exports['qs-vehiclekeys']:GiveKeys(plate, model)
|
||||
end)
|
||||
|
||||
|
||||
function PlayEmote(animationData)
|
||||
local dict = animationData.Dictionary
|
||||
local anim = animationData.Animation
|
||||
|
||||
local function LoadAnimationDict(dict, timeout)
|
||||
RequestAnimDict(dict)
|
||||
local startTick = GetGameTimer()
|
||||
while not HasAnimDictLoaded(dict) do
|
||||
Citizen.Wait(0)
|
||||
if GetGameTimer() - startTick > timeout then
|
||||
print("Failed to load animation dictionary: " .. dict)
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function PlayAnimation()
|
||||
if not LoadAnimationDict(dict, 500) then
|
||||
return
|
||||
end
|
||||
TaskPlayAnim(PlayerPedId(), dict, anim, 2.0, 2.0, animationData.Options.Duration, 0, 0, false, false, false)
|
||||
RemoveAnimDict(dict)
|
||||
end
|
||||
|
||||
PlayAnimation()
|
||||
end
|
||||
|
||||
|
||||
RegisterCommand("openkeys", function(source, args, rawCommand)
|
||||
OpenMainMenu()
|
||||
end, false)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
RegisterNetEvent(Config.Eventprefix .. ':client:toggleEngine', function(forcestate)
|
||||
toggleEngine(forcestate)
|
||||
end)
|
||||
|
||||
function toggleEngine(forcestate)
|
||||
|
||||
-- local playerPed = PlayerPedId()
|
||||
-- local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
-- if not vehicle or vehicle == 0 or IsPauseMenuActive() then return end
|
||||
|
||||
-- local isDriver = GetPedInVehicleSeat(vehicle, -1) == playerPed
|
||||
-- local hasKey = exports['qs-vehiclekeys']:GetKey(GetVehicleNumberPlateText(vehicle)) or not Config.ToggleEngineRequireKeys
|
||||
-- local isJobShared = AreKeysJobShared(vehicle)
|
||||
|
||||
-- if not (isDriver and (hasKey or isJobShared)) then
|
||||
-- return SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_PERMISSION'), 'error')
|
||||
-- end
|
||||
|
||||
-- local engineRunning = GetIsVehicleEngineRunning(vehicle)
|
||||
-- if forcestate ~= nil then
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, forcestate)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, forcestate, false, true)
|
||||
-- else
|
||||
-- if engineRunning then
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, false)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, false, false, true)
|
||||
-- SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_ENGINE_STOPPED'), 'error')
|
||||
-- else
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, true)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, true, false, true)
|
||||
-- SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_ENGINE_STARTED'), 'success')
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
-- exports('toggleEngine', toggleEngine)
|
||||
|
||||
function isEngineRunning(vehicle)
|
||||
local playerPed = PlayerPedId()
|
||||
vehicle = vehicle or GetVehiclePedIsIn(playerPed, false)
|
||||
if vehicle and vehicle ~= 0 then
|
||||
local engineRunning = GetIsVehicleEngineRunning(vehicle)
|
||||
if engineRunning == '1' then
|
||||
engineRunning = true
|
||||
end
|
||||
return engineRunning
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
exports('isEngineRunning', isEngineRunning)
|
||||
@@ -0,0 +1,31 @@
|
||||
exports('GiveKeysAuto', function()
|
||||
GiveKeysAuto()
|
||||
end)
|
||||
|
||||
exports('GetKeyAuto', function()
|
||||
return GetKeyAuto()
|
||||
end)
|
||||
|
||||
exports('RemoveKeysAuto', function()
|
||||
RemoveKeysAuto()
|
||||
end)
|
||||
|
||||
exports('GiveKeys', function(plate, model, bypassKeyCheck)
|
||||
GiveKeys(plate, model, bypassKeyCheck)
|
||||
end)
|
||||
|
||||
exports('RemoveKeys', function(plate, model)
|
||||
RemoveKeys(plate, model)
|
||||
end)
|
||||
|
||||
exports('GetKey', function(plate)
|
||||
return GetKey(plate)
|
||||
end)
|
||||
|
||||
exports('OpenCar', function(vehicle)
|
||||
DoorLogic(vehicle)
|
||||
end)
|
||||
|
||||
exports('CloseCar', function(vehicle)
|
||||
DoorLogic(vehicle)
|
||||
end)
|
||||
@@ -0,0 +1,53 @@
|
||||
-- OX inventory
|
||||
if Config.InventoryScript ~= 'ox' then
|
||||
return
|
||||
end
|
||||
|
||||
local ox_inventory = exports.ox_inventory
|
||||
exports('useKey', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseKey', data.metadata.plate, data.metadata.model)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('usePlate', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UsePlate', data.metadata.plate)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useCarlockpick', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
useLockpick(false)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useAdvancedCarlockpick', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
useLockpick(true)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useVehiclegps', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseGPS')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useVehicletracker', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseTracker')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -0,0 +1,307 @@
|
||||
--[[
|
||||
██████╗░░█████╗░██████╗░██╗░█████╗░██╗░░░░░ ███╗░░░███╗███████╗███╗░░██╗██╗░░░██╗
|
||||
██╔══██╗██╔══██╗██╔══██╗██║██╔══██╗██║░░░░░ ████╗░████║██╔════╝████╗░██║██║░░░██║
|
||||
██████╔╝███████║██║░░██║██║███████║██║░░░░░ ██╔████╔██║█████╗░░██╔██╗██║██║░░░██║
|
||||
██╔══██╗██╔══██║██║░░██║██║██╔══██║██║░░░░░ ██║╚██╔╝██║██╔══╝░░██║╚████║██║░░░██║
|
||||
██║░░██║██║░░██║██████╔╝██║██║░░██║███████╗ ██║░╚═╝░██║███████╗██║░╚███║╚██████╔╝
|
||||
╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝╚═╝░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝╚══════╝╚═╝░░╚══╝░╚═════╝░
|
||||
]]--
|
||||
|
||||
-- Check if Radial is enabled in the configuration
|
||||
if not Config.Radial then return end
|
||||
|
||||
function GetClosestVehicle()
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
local vehicles = GetGamePool("CVehicle")
|
||||
|
||||
local closestVehicle, closestDistance
|
||||
|
||||
for _, vehicle in ipairs(vehicles) do
|
||||
local distance = #(playerCoords - GetEntityCoords(vehicle))^2
|
||||
|
||||
if not closestDistance or distance < closestDistance then
|
||||
closestVehicle = vehicle
|
||||
closestDistance = math.sqrt(distance)
|
||||
end
|
||||
end
|
||||
|
||||
return closestVehicle, closestDistance
|
||||
end
|
||||
|
||||
-- CreateThread(function()
|
||||
-- local radialItemAdded = false
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
|
||||
-- while true do
|
||||
-- Wait(1000)
|
||||
-- local maxDistance = 4.0
|
||||
-- local vehicle, distance = GetClosestVehicle()
|
||||
|
||||
-- if vehicle and distance < maxDistance then
|
||||
-- local plate = GetVehicleNumberPlateText(vehicle)
|
||||
-- local hasKey = exports['qs-vehiclekeys']:GetKey(plate)
|
||||
|
||||
-- if hasKey and not radialItemAdded then
|
||||
-- lib.addRadialItem({
|
||||
-- {
|
||||
-- id = 'carkeys',
|
||||
-- label = Lang('VEHICLEKEYS_RADIAL_VEHICLEKEYS_LABEL'),
|
||||
-- icon = "key",
|
||||
-- onSelect = function()
|
||||
-- exports["qs-vehiclekeys"]:DoorLogic(vehicle)
|
||||
-- end
|
||||
-- }
|
||||
-- })
|
||||
-- radialItemAdded = true
|
||||
-- elseif not hasKey and radialItemAdded then
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
-- radialItemAdded = false
|
||||
-- end
|
||||
-- else
|
||||
-- if radialItemAdded then
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
-- radialItemAdded = false
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █▀▄ █▀█ █▀█ █▀█ █▀
|
||||
█▄▄ █▀█ █▀▄ █▄▀ █▄█ █▄█ █▀▄ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_doors',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(3)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_TRUNK_LABEL'),
|
||||
icon = 'car-rear',
|
||||
onSelect = function()
|
||||
doorToggle(5)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_HOOD_LABEL'),
|
||||
icon = 'car',
|
||||
onSelect = function()
|
||||
doorToggle(4)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(2)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█ █▀
|
||||
█▄▄ █▀█ █▀▄ ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_windows',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'caret-right',
|
||||
onSelect = function()
|
||||
windowToggle(2, 3)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
windowToggle(1, 1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
windowToggle(0, 0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'caret-left',
|
||||
onSelect = function()
|
||||
windowToggle(3, 2)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █▀ █▀▀ ▄▀█ ▀█▀ █▀
|
||||
█▄▄ █▀█ █▀▄ ▄█ ██▄ █▀█ ░█░ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_seats',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'caret-right',
|
||||
onSelect = function()
|
||||
changeSeat(2)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
changeSeat(0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
changeSeat(-1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'caret-left',
|
||||
onSelect = function()
|
||||
changeSeat(1)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█░█ █▀▀ █░█ █ █▀▀ █░░ █▀▀ █▀▄▀█ █▀▀ █▄░█ █░█
|
||||
▀▄▀ ██▄ █▀█ █ █▄▄ █▄▄ ██▄ █░▀░█ ██▄ █░▀█ █▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'vehicle_menu',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEENGINE_LABEL'),
|
||||
icon = 'power-off',
|
||||
onSelect = function()
|
||||
toggleEngine()
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEDOORS_LABEL'),
|
||||
icon = 'door-closed',
|
||||
menu = 'car_doors'
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEWINDOWS_LABEL'),
|
||||
icon = 'window-maximize',
|
||||
menu = 'car_windows'
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLECHAIRS_LABEL'),
|
||||
icon = 'chair',
|
||||
menu = 'car_seats'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█░█ █▀▀ █░█ █ █▀▀ █░░ █▀▀ █▀▀ █░█ █▀▀ █▀▀ █▄▀
|
||||
▀▄▀ ██▄ █▀█ █ █▄▄ █▄▄ ██▄ █▄▄ █▀█ ██▄ █▄▄ █░█
|
||||
]]--
|
||||
|
||||
lib.onCache('vehicle', function(value)
|
||||
if value then
|
||||
lib.addRadialItem({
|
||||
{
|
||||
id = 'vehicle',
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLE_LABEL'),
|
||||
icon = 'car',
|
||||
menu = 'vehicle_menu'
|
||||
}
|
||||
})
|
||||
lib.removeRadialItem('carkeys')
|
||||
else
|
||||
lib.removeRadialItem('vehicle')
|
||||
end
|
||||
end)
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █▀▄ █▀█ █▀█ █▀█ ▀█▀ █▀█ █▀▀ █▀▀ █░░ █▀▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ █▄▀ █▄█ █▄█ █▀▄ ░█░ █▄█ █▄█ █▄█ █▄▄ ██▄
|
||||
]]--
|
||||
|
||||
function doorToggle(door)
|
||||
if GetVehicleDoorAngleRatio(cache.vehicle, door) > 0.0 then
|
||||
SetVehicleDoorShut(cache.vehicle, door, false, false)
|
||||
else
|
||||
SetVehicleDoorOpen(cache.vehicle, door, false, false)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █▀▀ █░█ ▄▀█ █▄░█ █▀▀ █▀▀ █▀ █▀▀ ▄▀█ ▀█▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ █▄▄ █▀█ █▀█ █░▀█ █▄█ ██▄ ▄█ ██▄ █▀█ ░█░
|
||||
]]--
|
||||
|
||||
function changeSeat(seat)
|
||||
if IsVehicleSeatFree(cache.vehicle, seat) then
|
||||
lib.progressCircle({
|
||||
duration = 1000,
|
||||
position = 'bottom',
|
||||
label = Lang("VEHICLEKEYS_RADIAL_CHANGE_SEAT_PROGRESS"),
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = { car = true },
|
||||
anim = {
|
||||
dict = 'anim@veh@low@vigilante@front_ps@enter_exit',
|
||||
clip = 'shuffle_seat',
|
||||
flag = 16
|
||||
},
|
||||
})
|
||||
SetPedIntoVehicle(cache.ped, cache.vehicle, seat)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█ ▀█▀ █▀█ █▀▀ █▀▀ █░░ █▀▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀ ░█░ █▄█ █▄█ █▄█ █▄▄ ██▄
|
||||
]]--
|
||||
|
||||
local windows = { true, true, true, true }
|
||||
|
||||
function windowToggle(window, door)
|
||||
if GetIsDoorValid(cache.vehicle, door) and windows[window + 1] then
|
||||
RollDownWindow(cache.vehicle, window)
|
||||
windows[window + 1] = false
|
||||
else
|
||||
RollUpWindow(cache.vehicle, window)
|
||||
windows[window + 1] = true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
if Config.Smartphone ~= 'lb-phone' then
|
||||
return
|
||||
end
|
||||
|
||||
function GetBattery()
|
||||
return exports["lb-phone"]:GetBattery()
|
||||
end
|
||||
|
||||
function SetBattery(battery)
|
||||
exports["lb-phone"]:SetBattery(battery)
|
||||
end
|
||||
|
||||
function ToggleCharging(bool)
|
||||
exports["lb-phone"]:ToggleCharging(bool)
|
||||
end
|
||||
|
||||
function IsPhoneDead()
|
||||
return exports["lb-phone"]:IsPhoneDead()
|
||||
end
|
||||
|
||||
function IsCharging()
|
||||
return exports["lb-phone"]:IsCharging()
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
if Config.Smartphone ~= 'qs-smartphone' then
|
||||
return
|
||||
end
|
||||
|
||||
function GetBattery()
|
||||
return exports["qs-smartphone"]:getBattery()
|
||||
end
|
||||
|
||||
function SetBattery(battery)
|
||||
|
||||
end
|
||||
|
||||
function ToggleCharging(bool)
|
||||
|
||||
end
|
||||
|
||||
function IsPhoneDead()
|
||||
|
||||
end
|
||||
|
||||
function IsCharging()
|
||||
|
||||
end
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user