153 lines
4.3 KiB
Lua
153 lines
4.3 KiB
Lua
if Config.Menu ~= 'ox_lib' then
|
|
return
|
|
end
|
|
|
|
function OpenManagementMenu()
|
|
local elements = {
|
|
{
|
|
title = 'Give Key',
|
|
onSelect = function(args)
|
|
TriggerEvent('advancedgarages:openGiveKeyMenu')
|
|
end
|
|
},
|
|
{
|
|
title = 'Key Holders',
|
|
onSelect = function(args)
|
|
TriggerEvent('advancedgarages:openKeyHoldersMenu')
|
|
end
|
|
},
|
|
{
|
|
title = 'Sell Garage',
|
|
onSelect = function(args)
|
|
TriggerEvent('advancedgarages:sellGarage')
|
|
end
|
|
}
|
|
}
|
|
lib.registerContext({
|
|
id = 'management',
|
|
title = 'Management',
|
|
options = elements
|
|
})
|
|
lib.showContext('management')
|
|
end
|
|
|
|
function openGiveKeyMenu(players)
|
|
local elements = {}
|
|
for k, v in pairs(players) do
|
|
table.insert(elements, {
|
|
title = 'Player: ' .. v.name.firstName .. ' ' .. v.name.lastName,
|
|
onSelect = function(args)
|
|
local data = {
|
|
id = v.id,
|
|
garage = ClosestGarage
|
|
}
|
|
TriggerServerEvent('advancedgarages:giveKey', data)
|
|
end
|
|
})
|
|
end
|
|
lib.registerContext({
|
|
id = 'givekey',
|
|
title = 'Give Keys',
|
|
options = elements
|
|
})
|
|
lib.showContext('givekey')
|
|
end
|
|
|
|
function openTakeKeyMenu()
|
|
local elements = {}
|
|
local holders = lib.callback.await('advancedgarages:getGarageKeyHolders', false, ClosestGarage)
|
|
if not holders or #holders == 0 then
|
|
Notification(i18n.t('keyholders.empty_list'), 'info')
|
|
return
|
|
end
|
|
for k, v in pairs(holders) do
|
|
table.insert(elements, {
|
|
title = 'Player: ' .. v.firstname .. ' ' .. v.lastname,
|
|
onSelect = function(args)
|
|
local data = {
|
|
id = v.identifier,
|
|
garage = ClosestGarage
|
|
}
|
|
TriggerServerEvent('advancedgarages:takeKey', data)
|
|
end
|
|
})
|
|
end
|
|
lib.registerContext({
|
|
id = 'keyholders',
|
|
title = 'Key Holders',
|
|
options = elements
|
|
})
|
|
lib.showContext('keyholders')
|
|
end
|
|
|
|
function HandleKeyboard(callback)
|
|
local input = lib.inputDialog('Set a Price', { 'Garage Price...' })
|
|
|
|
if not input then return end
|
|
local price = tonumber(input[1])
|
|
|
|
if price then
|
|
local amount = price
|
|
if amount == nil then
|
|
Notification('Invalid Amount', 'error')
|
|
else
|
|
if amount >= 0 then
|
|
callback(amount)
|
|
else
|
|
Notification('Invalid Amount', 'error')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function HandleGarageJob()
|
|
local input = lib.inputDialog('Job Name (you can leave it blank for everyone)', { 'Job Name' })
|
|
if not input or input[1] == '' then return false end
|
|
return input[1]
|
|
end
|
|
|
|
function OpenRecoveryMenu(vehicleList)
|
|
local menu = {}
|
|
for k, v in pairs(vehicleList) do
|
|
table.insert(menu, {
|
|
title = v.plate,
|
|
onSelect = function(args)
|
|
TriggerServerEvent('advancedgarages:RecoveryVehicle', { plate = v.plate, type = v.type })
|
|
end,
|
|
})
|
|
end
|
|
lib.registerContext({
|
|
id = 'recovery',
|
|
title = 'Recovery Vehicle (OUT)',
|
|
options = menu
|
|
})
|
|
lib.showContext('recovery')
|
|
end
|
|
|
|
function OpenDeleteJobVehicleMenu(garage, job)
|
|
local menu = {}
|
|
local vehicles = lib.callback.await('advancedgarages:getJobVehicles', false, garage, job)
|
|
if not vehicles or #vehicles == 0 then
|
|
Notification(i18n.t('keyholders.empty_out'), 'info')
|
|
return
|
|
end
|
|
for k, v in pairs(vehicles) do
|
|
local data = {
|
|
plate = v.plate,
|
|
garage = garage
|
|
}
|
|
table.insert(menu, {
|
|
title = v.plate,
|
|
onSelect = function(args)
|
|
TriggerServerEvent('advancedgarages:deleteJobVehicle', data)
|
|
end,
|
|
})
|
|
end
|
|
lib.registerContext({
|
|
id = 'deletejobvehicle',
|
|
title = 'Delete work vehicles',
|
|
options = menu
|
|
})
|
|
lib.showContext('deletejobvehicle')
|
|
end
|