forked from Simnation/Main
76 lines
No EOL
2.5 KiB
Lua
76 lines
No EOL
2.5 KiB
Lua
RegisterNetEvent('mh_garage:verwaltungVeh')
|
|
AddEventHandler('mh_garage:verwaltungVeh', function()
|
|
QBCore.TriggerCallback('mh_garage:verwaltung', function(cb)
|
|
Debug("Verwaltung CB: "..json.encode(cb))
|
|
if cb[1] ~= nil then
|
|
local opt = {}
|
|
|
|
for i = 1, #cb, 1 do
|
|
|
|
local isingarage = cb[i].current_in_garage
|
|
local des = ""
|
|
|
|
if isingarage then
|
|
des = "Bearbeite das Fahrzeug\nKennzeichen: "..cb[i].current_plate.."\nGarage: "..cb[i].current_garage
|
|
else
|
|
des = "Bearbeite das Fahrzeug\nKennzeichen: "..cb[i].current_plate.."\nLetzte bekannte Garage: "..cb[i].current_garage
|
|
end
|
|
|
|
table.insert(opt, {
|
|
title = cb[i].current_name,
|
|
description = des,
|
|
icon = "car",
|
|
onSelect = function()
|
|
OpenVerwaltung(cb[i])
|
|
end
|
|
})
|
|
end
|
|
else
|
|
lib.notify({
|
|
title = "Fahrzeug Verwaltung",
|
|
description = "Du bist nicht im Besitz eines Fahrzeuges!",
|
|
type = "inform"
|
|
})
|
|
end
|
|
end)
|
|
end)
|
|
|
|
function OpenVerwaltung(vehicleInfos)
|
|
Debug("OpenVerwaltung: "..json.encode(vehicleInfos))
|
|
local garages = {}
|
|
for k, v in pairs(Config.Zonen) do
|
|
table.insert(garages, v.name)
|
|
end
|
|
lib.registerMenu({
|
|
id = 'some_menu_id',
|
|
title = 'Menu title',
|
|
position = 'top-right',
|
|
onSideScroll = function(selected, scrollIndex, args)
|
|
print("Scroll: ", selected, scrollIndex, args)
|
|
end,
|
|
onSelected = function(selected, secondary, args)
|
|
if not secondary then
|
|
print("Normal button")
|
|
else
|
|
if args.isCheck then
|
|
print("Check button")
|
|
end
|
|
|
|
if args.isScroll then
|
|
print("Scroll button")
|
|
end
|
|
end
|
|
print(selected, secondary, json.encode(args, {indent=true}))
|
|
end,
|
|
options = {
|
|
{label = "Name ändern", icon = "paper"},
|
|
{label = 'Transport to:', icon = 'arrows-up-down-left-right', values=garages},
|
|
}
|
|
}, function(selected, scrollIndex, args)
|
|
print(selected, scrollIndex, args)
|
|
end)
|
|
|
|
RegisterCommand('testmenu', function()
|
|
lib.showMenu('some_menu_id')
|
|
end)
|
|
end |