Main/resources/[carscripts]/mh_garage/client/retrieve.lua

36 lines
1 KiB
Lua
Raw Normal View History

2025-06-08 16:20:16 +02:00
RegisterNetEvent('mh_garage:retrieveVehicle')
AddEventHandler('mh_garage:retrieveVehicle', function()
2025-06-09 13:28:19 +02:00
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local random = SelectName()
local opt = {}
QBCore.Functions.TriggerCallback('mh_garage:CallVehicles', function(cb)
2025-06-09 14:22:50 +02:00
Debug(json.encode(cb))
2025-06-09 13:28:19 +02:00
for i = 1, #cb, 1 do
2025-06-09 18:48:19 +02:00
local mods = json.decode(cb[i].mods)
2025-06-09 13:28:19 +02:00
table.insert(opt, {
2025-06-09 13:50:04 +02:00
title = cb[i].name,
2025-06-09 18:49:12 +02:00
description = "Kennzeichen: "..cb[i].plate.."\nTankinhalt: "..math.random(mods.fuelLevel, 2).."%",
2025-06-09 13:28:19 +02:00
icon = "car",
onSelect = function()
2025-06-09 18:48:19 +02:00
cb[i].mods = mods
2025-06-09 13:28:19 +02:00
SpawnThisVehicle(cb[i])
end
})
end
lib.registerContext({
id = "retrieveVehicle",
title = random.name,
options = opt
})
lib.showContext("retrieveVehicle")
end, CurrentZone.name)
2025-06-09 18:48:19 +02:00
end)
function SpawnThisVehicle(veh)
print("Spawn VEhicle")
end