36 lines
		
	
	
		
			No EOL
		
	
	
		
			1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			No EOL
		
	
	
		
			1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
RegisterNetEvent('mh_garage:retrieveVehicle')
 | 
						|
AddEventHandler('mh_garage:retrieveVehicle', function()
 | 
						|
    local ped = PlayerPedId()
 | 
						|
    local coords = GetEntityCoords(ped)
 | 
						|
    local random = SelectName()
 | 
						|
 | 
						|
    local opt = {}
 | 
						|
 | 
						|
    QBCore.Functions.TriggerCallback('mh_garage:CallVehicles', function(cb)
 | 
						|
        Debug(json.encode(cb))
 | 
						|
        for i = 1, #cb, 1 do
 | 
						|
            local mods = json.decode(cb[i].mods)
 | 
						|
            table.insert(opt, {
 | 
						|
                title = cb[i].name,
 | 
						|
                description = "Kennzeichen: "..cb[i].plate.."\nTankinhalt: "..mods.fuelLevel.."%",
 | 
						|
                icon = "car",
 | 
						|
                onSelect = function()
 | 
						|
                    cb[i].mods = mods
 | 
						|
                    SpawnThisVehicle(cb[i])
 | 
						|
                end
 | 
						|
            })
 | 
						|
        end
 | 
						|
 | 
						|
        lib.registerContext({
 | 
						|
            id = "retrieveVehicle",
 | 
						|
            title = random.name,
 | 
						|
            options = opt
 | 
						|
        })
 | 
						|
 | 
						|
        lib.showContext("retrieveVehicle")
 | 
						|
    end, CurrentZone.name)
 | 
						|
end)
 | 
						|
 | 
						|
function SpawnThisVehicle(veh)
 | 
						|
    print("Spawn VEhicle")
 | 
						|
end |