Auto-sync 2026-04-15 21:00
This commit is contained in:
parent
03c9a79002
commit
1fb2552b3f
@ -21,6 +21,7 @@ local GarageCam = nil
|
|||||||
-- Persist: Cache für eigene Fahrzeuge die draußen sind
|
-- Persist: Cache für eigene Fahrzeuge die draußen sind
|
||||||
local MyOutsidePlates = {}
|
local MyOutsidePlates = {}
|
||||||
local PersistVehicles = {} -- [normPlate] = {entity=veh, rawPlate="XYZ 123"}
|
local PersistVehicles = {} -- [normPlate] = {entity=veh, rawPlate="XYZ 123"}
|
||||||
|
local ActiveJobVehicles = {} -- [normPlate] = rawPlate, ausgeparkte Job-Fahrzeuge
|
||||||
|
|
||||||
-- MyOutsidePlates: [normPlate] = rawPlate (Original aus DB)
|
-- MyOutsidePlates: [normPlate] = rawPlate (Original aus DB)
|
||||||
local function UpdateMyOutsidePlates(vehicles)
|
local function UpdateMyOutsidePlates(vehicles)
|
||||||
@ -413,6 +414,11 @@ RegisterNetEvent('mercyv-garage:receiveVehicles', function(vehicles, garageId)
|
|||||||
-- Fahrzeuge markieren die in der Nähe sind
|
-- Fahrzeuge markieren die in der Nähe sind
|
||||||
for _, v in ipairs(nuiVehicles) do
|
for _, v in ipairs(nuiVehicles) do
|
||||||
v.nearby = nearbyPlates[normPlate(v.plate)] == true
|
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
|
end
|
||||||
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
@ -553,6 +559,7 @@ function SpawnVehicle(data, closeGarageAfter)
|
|||||||
-- Job-Fahrzeug: allen Spielern mit gleichem Job Schlüssel geben
|
-- Job-Fahrzeug: allen Spielern mit gleichem Job Schlüssel geben
|
||||||
if data.isJobVehicle and data.jobAccess then
|
if data.isJobVehicle and data.jobAccess then
|
||||||
TriggerServerEvent('mercyv-garage:giveJobKeys', data.plate, data.jobAccess)
|
TriggerServerEvent('mercyv-garage:giveJobKeys', data.plate, data.jobAccess)
|
||||||
|
ActiveJobVehicles[normPlate(data.plate)] = data.plate
|
||||||
end
|
end
|
||||||
|
|
||||||
-- In Persist-Liste aufnehmen
|
-- In Persist-Liste aufnehmen
|
||||||
@ -949,6 +956,43 @@ end)
|
|||||||
-- Einparken über Panel-Button (Fahrzeug in 30m Umkreis)
|
-- 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)
|
RegisterNUICallback('parkFromPanel', function(data, cb)
|
||||||
if not CurrentGarage or not data.plate then cb({}); return end
|
if not CurrentGarage or not data.plate then cb({}); return end
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,11 @@ const app = new Vue({
|
|||||||
$.post(`https://${GetParentResourceName()}/parkFromPanel`, JSON.stringify({ plate: this.selectedVehicle.plate }));
|
$.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) {
|
toggleFav(plate, current) {
|
||||||
const newVal = current == 1 ? 0 : 1;
|
const newVal = current == 1 ? 0 : 1;
|
||||||
$.post(`https://${GetParentResourceName()}/setFavorite`, JSON.stringify({ plate, value: newVal }));
|
$.post(`https://${GetParentResourceName()}/setFavorite`, JSON.stringify({ plate, value: newVal }));
|
||||||
|
|||||||
@ -672,6 +672,31 @@ RegisterNetEvent('mercyv-garage:giveJobKeys', function(plate, jobName)
|
|||||||
plate, count, jobName))
|
plate, count, jobName))
|
||||||
end)
|
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
|
-- Fahrzeug zerstört → zurück in Garage
|
||||||
-- ──────────────────────────────────────────────────────────────
|
-- ──────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user