forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
cf848bbc6f
commit
40b090bfb8
1 changed files with 77 additions and 74 deletions
|
@ -94,11 +94,27 @@ local function SetVehicleMods(vehicle, mods)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prüfe ob Fahrzeug einem Spieler gehört
|
-- Prüfe ob Fahrzeug einem Spieler gehört (vereinfachte Version)
|
||||||
local function DoesVehicleBelongToPlayer(plate)
|
local function DoesVehicleBelongToPlayer(plate)
|
||||||
-- Verwende jg-advanced-garage Export
|
-- Da der Export nicht existiert, prüfen wir über QB-Core
|
||||||
local vehicleData = exports['jg-advancedgarages']:GetVehicleByPlate(plate)
|
local Player = QBCore.Functions.GetPlayerData()
|
||||||
return vehicleData ~= nil
|
if not Player or not Player.citizenid then return false end
|
||||||
|
|
||||||
|
-- Hier könntest du eine eigene Logik implementieren oder
|
||||||
|
-- einfach alle Fahrzeuge tracken die nicht NPC Fahrzeuge sind
|
||||||
|
local vehicle = GetVehicleByPlate(plate)
|
||||||
|
if vehicle then
|
||||||
|
-- Prüfe ob es ein NPC Fahrzeug ist
|
||||||
|
local driver = GetPedInVehicleSeat(vehicle, -1)
|
||||||
|
if driver and IsPedAPlayer(driver) then
|
||||||
|
return true
|
||||||
|
elseif not driver then
|
||||||
|
-- Kein Fahrer = wahrscheinlich Spielerfahrzeug
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hauptloop für Fahrzeugtracking
|
-- Hauptloop für Fahrzeugtracking
|
||||||
|
@ -120,10 +136,6 @@ CreateThread(function()
|
||||||
|
|
||||||
-- Prüfe ob Fahrzeug einem Spieler gehört
|
-- Prüfe ob Fahrzeug einem Spieler gehört
|
||||||
if DoesVehicleBelongToPlayer(plate) then
|
if DoesVehicleBelongToPlayer(plate) then
|
||||||
-- Prüfe ob Fahrzeug nicht zu nah an einer Garage ist
|
|
||||||
local nearGarage = exports['jg-advancedgarages']:IsNearGarage(vehicleCoords, Config.MinGarageDistance)
|
|
||||||
|
|
||||||
if not nearGarage then
|
|
||||||
-- Speichere Fahrzeugdaten
|
-- Speichere Fahrzeugdaten
|
||||||
local vehicleData = {
|
local vehicleData = {
|
||||||
plate = plate,
|
plate = plate,
|
||||||
|
@ -150,7 +162,6 @@ CreateThread(function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Spawne gespeicherte Fahrzeuge
|
-- Spawne gespeicherte Fahrzeuge
|
||||||
|
@ -162,10 +173,6 @@ RegisterNetEvent('vehicle-persistence:client:spawnSavedVehicles', function(vehic
|
||||||
-- Prüfe ob Fahrzeug bereits existiert
|
-- Prüfe ob Fahrzeug bereits existiert
|
||||||
local existingVehicle = GetVehicleByPlate(vehicleData.plate)
|
local existingVehicle = GetVehicleByPlate(vehicleData.plate)
|
||||||
if not existingVehicle then
|
if not existingVehicle then
|
||||||
-- Prüfe ob Position nicht in einer Garage ist
|
|
||||||
local nearGarage = exports['jg-advancedgarages']:IsNearGarage(vector3(position.x, position.y, position.z), Config.MinGarageDistance)
|
|
||||||
|
|
||||||
if not nearGarage then
|
|
||||||
-- Spawne Fahrzeug
|
-- Spawne Fahrzeug
|
||||||
local modelHash = GetHashKey(vehicleData.model)
|
local modelHash = GetHashKey(vehicleData.model)
|
||||||
|
|
||||||
|
@ -205,10 +212,6 @@ RegisterNetEvent('vehicle-persistence:client:spawnSavedVehicles', function(vehic
|
||||||
end
|
end
|
||||||
|
|
||||||
SetModelAsNoLongerNeeded(modelHash)
|
SetModelAsNoLongerNeeded(modelHash)
|
||||||
else
|
|
||||||
-- Entferne aus Datenbank da es zu nah an einer Garage ist
|
|
||||||
TriggerServerEvent('vehicle-persistence:server:removeVehicle', vehicleData.plate)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue