forked from Simnation/Main
change Funktion GARAGE
This commit is contained in:
parent
eab3df34be
commit
a1dd0e2dd1
3 changed files with 74 additions and 41 deletions
|
@ -115,11 +115,17 @@ function AddTargetOptions()
|
|||
icon = "fas fa-parking",
|
||||
label = "Fahrzeug einparken",
|
||||
},
|
||||
{
|
||||
type = "client",
|
||||
event = "mh_garage:retrieveOwnerVehicle",
|
||||
icon = "fas fa-car",
|
||||
label = "Eigene Fahrzeug ausparken",
|
||||
},
|
||||
{
|
||||
type = "client",
|
||||
event = "mh_garage:retrieveVehicle",
|
||||
icon = "fas fa-car",
|
||||
label = "Fahrzeug ausparken",
|
||||
label = "Schlüssel Fahrzeug ausparken",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,32 @@
|
|||
RegisterNetEvent('mh_garage:retrieveOwnerVehicle')
|
||||
AddEventHandler('mh_garage:retrieveOwnerVehicle', function()
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
local random = SelectName()
|
||||
|
||||
local opt = {}
|
||||
|
||||
QBCore.Functions.TriggerCallback('mh_garage:retrieveOwnerVehicle', function(cb)
|
||||
if cb == false then
|
||||
Notification("Es ist kein Fahrzeug hier!", "inform")
|
||||
return
|
||||
end
|
||||
|
||||
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: "..math.round(mods.fuelLevel, 2).."%" ]]
|
||||
icon = "car",
|
||||
onSelect = function()
|
||||
cb[i].mods = mods
|
||||
SpawnThisVehicle(cb[i])
|
||||
end
|
||||
})
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('mh_garage:retrieveVehicle')
|
||||
AddEventHandler('mh_garage:retrieveVehicle', function()
|
||||
local ped = PlayerPedId()
|
||||
|
@ -6,7 +35,7 @@ AddEventHandler('mh_garage:retrieveVehicle', function()
|
|||
|
||||
local opt = {}
|
||||
|
||||
QBCore.Functions.TriggerCallback('mh_garage:CallVehicles', function(cb)
|
||||
QBCore.Functions.TriggerCallback('mh_garage:retrieveKeyVehicle', function(cb)
|
||||
Debug(json.encode(cb))
|
||||
for i = 1, #cb, 1 do
|
||||
if cb[i].garage ~= "OUT" then
|
||||
|
|
|
@ -4,7 +4,7 @@ local test_vari = {}
|
|||
RegisterServerEvent('mh_garage:setMods')
|
||||
AddEventHandler('mh_garage:setMods', function(mods)
|
||||
if test_vari[mods.plate] == true then
|
||||
|
||||
return
|
||||
else
|
||||
MySQL.query("SELECT mods FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs)
|
||||
-- Prüfen ob rs überhaupt Daten enthält
|
||||
|
@ -77,54 +77,52 @@ function DelVehParking(plate)
|
|||
end)
|
||||
end
|
||||
|
||||
QBCore.Functions.CreateCallback('mh_garage:CallVehicles', function(source, cb, zone)
|
||||
QBCore.Functions.CreateCallback('mh_garage:retrieveOwnerVehicle', function(source, cb, zone)
|
||||
local _source = source
|
||||
local Player = QBCore.Functions.GetPlayer(_source)
|
||||
local vehicles = {}
|
||||
local vehicle_keys = {}
|
||||
|
||||
if Config.CallKeyVehicles then
|
||||
MySQL.query("SELECT plate FROM vehicle_keys WHERE owner = ?", {Player.PlayerData.citizenid}, function(rs)
|
||||
if rs and rs[1] then
|
||||
for k, v in pairs(rs) do
|
||||
table.insert(vehicle_keys, {plate = v.plate})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Wait(100)
|
||||
if vehicle_keys[1] ~= nil then
|
||||
print(json.encode(vehicle_keys))
|
||||
for k, v in pairs(vehicle_keys) do
|
||||
MySQL.query("SELECT vehicle, plate, mods, name FROM player_vehicles WHERE plate = ?", {v.plate}, function(rs)
|
||||
if rs and rs[1] then
|
||||
table.insert(vehicles, {
|
||||
vehicle = rs[1].vehicle,
|
||||
mods = rs[1].mods,
|
||||
plate = rs[1].plate,
|
||||
name = rs[1].name
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MySQL.query("SELECT vehicle, plate, mods FROM player_vehicles WHERE citizenid = ? AND garage = ?", {Player.PlayerData.citizenid, zone}, function(rs)
|
||||
if rs and rs[1] then
|
||||
for k, v in pairs(rs) do
|
||||
table.insert(vehicles, {
|
||||
local pedid = Player.PlayerData.citizenid
|
||||
local veh = {}
|
||||
|
||||
MySQL.query("SELECT * FROM player_vehicles WHERE owner = ? and garage = ?", {pedid, zone}, function(rs)
|
||||
if rs ~= nil and rs[1] ~= nil then
|
||||
for k, v in pairs (rs) do
|
||||
table.insert(veh, {
|
||||
vehicle = v.vehicle,
|
||||
mods = v.mods,
|
||||
mods = v.mods,
|
||||
plate = v.plate,
|
||||
name = v.name
|
||||
})
|
||||
end
|
||||
Wait(100)
|
||||
cb(veh)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Wait(100)
|
||||
cb(vehicles)
|
||||
QBCore.Functions.CreateCallback('mh_garage:retrieveKeyVehicle', function(source, cb, zone)
|
||||
local _source = source
|
||||
local Player = QBCore.Functions.GetPlayer(_source)
|
||||
local pedid = Player.PlayerData.citizenid
|
||||
local veh = {}
|
||||
|
||||
MySQL.query("SELECT pv.* FROM player_vehicles pv JOIN vehicle_keys vk ON pv.plate = vk.plate WHERE vk.owner = ? AND vk.count > 0", {playerId}, function(vehicles)
|
||||
if vehicles and #vehicles > 0 then
|
||||
for _, vehicle in pairs(vehicles) do
|
||||
table.insert(veh, {
|
||||
vehicle = vehicle.vehicle,
|
||||
mods = vehicle.mods,
|
||||
plate = vehicle.plate,
|
||||
name = vehicle.name
|
||||
})
|
||||
end
|
||||
Wait(100)
|
||||
cb(veh)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('mh_garage:verwaltung', function(source, cb)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue