From 1fb2552b3f33ec0b604c9ace0abf1eefb48326b5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 15 Apr 2026 21:00:01 +0200 Subject: [PATCH] Auto-sync 2026-04-15 21:00 --- [core]/mercyv-garage/client/main.lua | 44 ++++++++++++++++++++++++++++ [core]/mercyv-garage/nui/script.js | 5 ++++ [core]/mercyv-garage/server/main.lua | 25 ++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/[core]/mercyv-garage/client/main.lua b/[core]/mercyv-garage/client/main.lua index 76a35e1c..5a518d41 100644 --- a/[core]/mercyv-garage/client/main.lua +++ b/[core]/mercyv-garage/client/main.lua @@ -21,6 +21,7 @@ local GarageCam = nil -- Persist: Cache für eigene Fahrzeuge die draußen sind local MyOutsidePlates = {} local PersistVehicles = {} -- [normPlate] = {entity=veh, rawPlate="XYZ 123"} +local ActiveJobVehicles = {} -- [normPlate] = rawPlate, ausgeparkte Job-Fahrzeuge -- MyOutsidePlates: [normPlate] = rawPlate (Original aus DB) local function UpdateMyOutsidePlates(vehicles) @@ -413,6 +414,11 @@ RegisterNetEvent('mercyv-garage:receiveVehicles', function(vehicles, garageId) -- Fahrzeuge markieren die in der Nähe sind for _, v in ipairs(nuiVehicles) do v.nearby = nearbyPlates[normPlate(v.plate)] == true + -- Job-Fahrzeuge: "draußen" wenn in ActiveJobVehicles + if v.isJobVehicle then + v.stored = ActiveJobVehicles[normPlate(v.plate)] and 0 or 1 + v.nearby = nearbyPlates[normPlate(v.plate)] == true + end end SendNUIMessage({ @@ -553,6 +559,7 @@ function SpawnVehicle(data, closeGarageAfter) -- Job-Fahrzeug: allen Spielern mit gleichem Job Schlüssel geben if data.isJobVehicle and data.jobAccess then TriggerServerEvent('mercyv-garage:giveJobKeys', data.plate, data.jobAccess) + ActiveJobVehicles[normPlate(data.plate)] = data.plate end -- In Persist-Liste aufnehmen @@ -949,6 +956,43 @@ end) -- Einparken über Panel-Button (Fahrzeug in 30m Umkreis) -- ────────────────────────────────────────────────────────────── +-- Job-Fahrzeug einparken +RegisterNUICallback('parkJobVehicle', function(data, cb) + if not data.plate then cb({}); return end + + local targetPlate = normPlate(data.plate) + local ped = PlayerPedId() + local pedPos = GetEntityCoords(ped) + local foundVeh = nil + + for _, veh in ipairs(GetGamePool('CVehicle')) do + if DoesEntityExist(veh) then + if normPlate(GetVehicleNumberPlateText(veh)) == targetPlate then + local dist = #(pedPos - GetEntityCoords(veh)) + if dist <= 35.0 then + foundVeh = veh + break + end + end + end + end + + if not foundVeh then + Config.ClientNotification("Fahrzeug nicht in der Nähe.", "error") + cb({}); return + end + + TaskLeaveVehicle(ped, foundVeh, 0) + Citizen.Wait(1000) + DeleteEntity(foundVeh) + ActiveJobVehicles[targetPlate] = nil + RemoveVehicleKeys(data.plate, GetEntityModel(foundVeh), foundVeh) + + TriggerServerEvent('mercyv-garage:parkJobVehicle', data.plate) + CloseGarage() + cb({}) +end) + RegisterNUICallback('parkFromPanel', function(data, cb) if not CurrentGarage or not data.plate then cb({}); return end diff --git a/[core]/mercyv-garage/nui/script.js b/[core]/mercyv-garage/nui/script.js index 6a9f4e0e..d0cba3f9 100644 --- a/[core]/mercyv-garage/nui/script.js +++ b/[core]/mercyv-garage/nui/script.js @@ -68,6 +68,11 @@ const app = new Vue({ $.post(`https://${GetParentResourceName()}/parkFromPanel`, JSON.stringify({ plate: this.selectedVehicle.plate })); }, + parkJobVehicle() { + if (!this.selectedVehicle || !this.selectedVehicle.nearby) return; + $.post(`https://${GetParentResourceName()}/parkJobVehicle`, JSON.stringify({ plate: this.selectedVehicle.plate })); + }, + toggleFav(plate, current) { const newVal = current == 1 ? 0 : 1; $.post(`https://${GetParentResourceName()}/setFavorite`, JSON.stringify({ plate, value: newVal })); diff --git a/[core]/mercyv-garage/server/main.lua b/[core]/mercyv-garage/server/main.lua index 27ea1f0d..adbd7497 100644 --- a/[core]/mercyv-garage/server/main.lua +++ b/[core]/mercyv-garage/server/main.lua @@ -672,6 +672,31 @@ RegisterNetEvent('mercyv-garage:giveJobKeys', function(plate, jobName) plate, count, jobName)) end) +-- ────────────────────────────────────────────────────────────── +-- Job-Fahrzeug einparken +-- ────────────────────────────────────────────────────────────── + +RegisterNetEvent('mercyv-garage:parkJobVehicle', function(plate) + local src = source + local xp = ESX and ESX.GetPlayerFromId(src) + if not xp then return end + + local jobName = ActiveJobPlates[plate] + if not jobName then return end -- Kein aktives Job-Fahrzeug + + -- Nur Spieler mit dem passenden Job dürfen einparken + if xp.job and xp.job.name ~= jobName then + Config.ServerNotification(src, Config.Notify.NO_ACCESS, "error") + return + end + + -- Aus Tracking entfernen + ActiveJobPlates[plate] = nil + + Config.ServerNotification(src, Config.Notify.PARKED_IN, "success") + print(string.format('[mercyv-garage] Job-Fahrzeug %s eingeparkt von %s', plate, xp.identifier)) +end) + -- ────────────────────────────────────────────────────────────── -- Fahrzeug zerstört → zurück in Garage -- ──────────────────────────────────────────────────────────────