Auto-sync 2026-04-15 21:20
This commit is contained in:
parent
70d82f5670
commit
8892aeda36
@ -55,15 +55,11 @@ end, false)
|
|||||||
RegisterNUICallback('closeAdmin', function(data, cb)
|
RegisterNUICallback('closeAdmin', function(data, cb)
|
||||||
AdminOpen = false
|
AdminOpen = false
|
||||||
GarageIsOpen = false
|
GarageIsOpen = false
|
||||||
SetNuiFocus(false, false)
|
|
||||||
exports['hex_4_hud']:HideHud(false)
|
|
||||||
|
|
||||||
-- Garage-Kamera aufräumen falls sie noch läuft
|
-- NUI-Fokus freigeben und Steuerung zurückgeben
|
||||||
if GarageCam then
|
SetNuiFocus(false, false)
|
||||||
RenderScriptCams(false, true, 500, true, true)
|
SetNuiFocusKeepInput(false)
|
||||||
DestroyCam(GarageCam, false)
|
exports['hex_4_hud']:HideHud(false)
|
||||||
GarageCam = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Preview-Fahrzeug löschen falls vorhanden
|
-- Preview-Fahrzeug löschen falls vorhanden
|
||||||
if PreviewVeh and DoesEntityExist(PreviewVeh) then
|
if PreviewVeh and DoesEntityExist(PreviewVeh) then
|
||||||
@ -72,7 +68,6 @@ RegisterNUICallback('closeAdmin', function(data, cb)
|
|||||||
end
|
end
|
||||||
|
|
||||||
CurrentGarage = nil
|
CurrentGarage = nil
|
||||||
SendNUIMessage({ action = "CLOSE" })
|
|
||||||
cb({})
|
cb({})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@ -178,6 +178,52 @@ local function LoadGarages()
|
|||||||
GaragesData[row.id] = DBRowToGarage(row)
|
GaragesData[row.id] = DBRowToGarage(row)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Job-Fahrzeuge aus DB laden
|
||||||
|
MySQL.query.await([[CREATE TABLE IF NOT EXISTS `mercyv_job_vehicles` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`garage_id` VARCHAR(80) NOT NULL,
|
||||||
|
`model` VARCHAR(100) NOT NULL,
|
||||||
|
`label` VARCHAR(100) DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4]])
|
||||||
|
|
||||||
|
local jvResult = MySQL.query.await('SELECT * FROM mercyv_job_vehicles')
|
||||||
|
if jvResult then
|
||||||
|
for _, row in ipairs(jvResult) do
|
||||||
|
if not Config.JobVehicles then Config.JobVehicles = {} end
|
||||||
|
if not Config.JobVehicles[row.garage_id] then
|
||||||
|
Config.JobVehicles[row.garage_id] = {}
|
||||||
|
end
|
||||||
|
-- Prüfen ob schon in config (config hat Vorrang beim ersten Start)
|
||||||
|
local exists = false
|
||||||
|
for _, existing in ipairs(Config.JobVehicles[row.garage_id]) do
|
||||||
|
if existing.model == row.model then exists = true; break end
|
||||||
|
end
|
||||||
|
if not exists then
|
||||||
|
table.insert(Config.JobVehicles[row.garage_id], {
|
||||||
|
model = row.model,
|
||||||
|
label = row.label or row.model,
|
||||||
|
grade = 0,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Config.JobVehicles auch initial in DB schreiben (einmalig)
|
||||||
|
if Config.JobVehicles then
|
||||||
|
for garageId, vehicles in pairs(Config.JobVehicles) do
|
||||||
|
for _, v in ipairs(vehicles) do
|
||||||
|
local exists = MySQL.query.await(
|
||||||
|
'SELECT id FROM mercyv_job_vehicles WHERE garage_id = ? AND model = ?',
|
||||||
|
{ garageId, v.model })
|
||||||
|
if not exists or #exists == 0 then
|
||||||
|
MySQL.insert('INSERT INTO mercyv_job_vehicles (garage_id, model, label) VALUES (?, ?, ?)',
|
||||||
|
{ garageId, v.model, v.label or v.model })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local cnt = 0; for _ in pairs(GaragesData) do cnt=cnt+1 end
|
local cnt = 0; for _ in pairs(GaragesData) do cnt=cnt+1 end
|
||||||
print(string.format('[mercyv-garage] %d Garagen geladen.', cnt))
|
print(string.format('[mercyv-garage] %d Garagen geladen.', cnt))
|
||||||
end
|
end
|
||||||
@ -601,10 +647,16 @@ RegisterNetEvent('mercyv-garage:admin:saveGarage', function(data)
|
|||||||
showcar_x=data.showcar_x,showcar_y=data.showcar_y,showcar_z=data.showcar_z,showcar_heading=data.showcar_heading or 0,
|
showcar_x=data.showcar_x,showcar_y=data.showcar_y,showcar_z=data.showcar_z,showcar_heading=data.showcar_heading or 0,
|
||||||
cam_x=data.cam_x,cam_y=data.cam_y,cam_z=data.cam_z,cam_rot_z=data.cam_rot_z or -20,
|
cam_x=data.cam_x,cam_y=data.cam_y,cam_z=data.cam_z,cam_rot_z=data.cam_rot_z or -20,
|
||||||
})
|
})
|
||||||
-- Job-Fahrzeuge in Config aktualisieren
|
-- Job-Fahrzeuge persistieren (DB + Config)
|
||||||
if data.type == 'jobgarage' and data.job_vehicles then
|
if data.type == 'jobgarage' and data.job_vehicles then
|
||||||
if not Config.JobVehicles then Config.JobVehicles = {} end
|
if not Config.JobVehicles then Config.JobVehicles = {} end
|
||||||
Config.JobVehicles[data.access] = data.job_vehicles
|
Config.JobVehicles[data.access] = data.job_vehicles
|
||||||
|
-- In DB speichern
|
||||||
|
MySQL.update.await("DELETE FROM mercyv_job_vehicles WHERE garage_id = ?", { data.id })
|
||||||
|
for _, v in ipairs(data.job_vehicles) do
|
||||||
|
MySQL.insert("INSERT INTO mercyv_job_vehicles (garage_id, model, label) VALUES (?, ?, ?)",
|
||||||
|
{ data.id, v.model, v.label or v.model })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
BroadcastGarages()
|
BroadcastGarages()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user