diff --git a/resources/[carscripts]/nordi_car_admin/config.lua b/resources/[carscripts]/nordi_car_admin/config.lua deleted file mode 100644 index ed35fd997..000000000 --- a/resources/[carscripts]/nordi_car_admin/config.lua +++ /dev/null @@ -1,48 +0,0 @@ -Config = {} - --- Erlaubte Jobs für das Vehicle Admin System -Config.AllowedJobs = { - ['police'] = true, - ['admin'] = true, - ['mechanic'] = true, - ['ambulance'] = true, - ['cardealer'] = true, - -- Füge hier weitere Jobs hinzu -} - --- Debug-Modus -Config.Debug = false - --- Log-Einstellungen -Config.Log = { - Enabled = true, - Webhook = "https://discord.com/api/webhooks/1366812966049288192/9ZjJC9_gLX6Fk-acf0YSW_haGWpCqG9zRGWaj0wCKLZefp8FX-GwNZBP77H6K93KfIw3", -- Verwende den gleichen Webhook wie im Garagensystem - Colors = { - green = 56108, - grey = 8421504, - red = 16711680, - orange = 16744192, - blue = 2061822, - purple = 11750815, - }, - SystemName = "Evolution_State_life Log [Fahrzeugadmin]", - UserAvatar = '', - SystemAvatar = '', -} - --- Standard-Garagen falls keine in QBCore definiert sind -Config.DefaultGarages = { - ['legion'] = { label = 'Legion Square Garage' }, - ['pillboxgarage'] = { label = 'Pillbox Garage' }, - ['spanishave'] = { label = 'Spanish Avenue Garage' }, - ['caears24'] = { label = 'Caears 24 Garage' }, - ['littleseoul'] = { label = 'Little Seoul Garage' }, - ['rockfordgarage'] = { label = 'Rockford Garage' }, - ['lamesamotel'] = { label = 'Lamesa Motel Garage' }, - ['airportp'] = { label = 'Airport Parking' }, - ['depot'] = { label = 'Depot' }, - ['impound'] = { label = 'Impound Lot' }, - ['pdgarage'] = { label = 'Police Garage' }, - ['emsgarage'] = { label = 'EMS Garage' }, - ['mechgarage'] = { label = 'Mechanic Garage' } -} diff --git a/resources/[carscripts]/nordi_car_admin/server.lua b/resources/[carscripts]/nordi_car_admin/server.lua index 4526c34cc..7fd57f516 100644 --- a/resources/[carscripts]/nordi_car_admin/server.lua +++ b/resources/[carscripts]/nordi_car_admin/server.lua @@ -1,18 +1,60 @@ local QBCore = exports['qb-core']:GetCoreObject() --- Lade die Garagen aus dem Hauptsystem -Citizen.CreateThread(function() - Wait(1000) -- Warte kurz, damit das Hauptsystem geladen ist +-- Interne Konfiguration für das Fahrzeugadmin-System +local AdminConfig = { + -- Erlaubte Jobs für das Vehicle Admin System + AllowedJobs = { + ['police'] = true, + ['admin'] = true, + ['mechanic'] = true, + ['ambulance'] = true, + ['cardealer'] = true, + }, - -- Versuche, die Garagen aus dem Hauptsystem zu laden - if _G.Config and _G.Config.Zonen then - Config.Zonen = _G.Config.Zonen - print("[Fahrzeugadmin] Garagen aus dem Hauptsystem geladen: " .. #Config.Zonen .. " Garagen gefunden.") - else - print("[Fahrzeugadmin] Konnte keine Garagen aus dem Hauptsystem laden, verwende Standard-Garagen.") - end -end) + -- Debug-Modus + Debug = false, + + -- Log-Einstellungen + Log = { + Enabled = true, + Webhook = "https://discord.com/api/webhooks/1366812966049288192/9ZjJC9_gLX6Fk-acf0YSW_haGWpCqG9zRGWaj0wCKLZefp8FX-GwNZBP77H6K93KfIw3", -- Verwende den gleichen Webhook wie im Garagensystem + Colors = { + green = 56108, + grey = 8421504, + red = 16711680, + orange = 16744192, + blue = 2061822, + purple = 11750815, + }, + SystemName = "Evolution_State_life Log [Fahrzeugadmin]", + }, + + -- Standard-Garagen falls keine in QBCore definiert sind + DefaultGarages = { + ['legion'] = { label = 'Legion Square Garage' }, + ['pillboxgarage'] = { label = 'Pillbox Garage' }, + ['spanishave'] = { label = 'Spanish Avenue Garage' }, + ['caears24'] = { label = 'Caears 24 Garage' }, + ['littleseoul'] = { label = 'Little Seoul Garage' }, + ['rockfordgarage'] = { label = 'Rockford Garage' }, + ['lamesamotel'] = { label = 'Lamesa Motel Garage' }, + ['airportp'] = { label = 'Airport Parking' }, + ['depot'] = { label = 'Depot' }, + ['impound'] = { label = 'Impound Lot' }, + ['pdgarage'] = { label = 'Police Garage' }, + ['emsgarage'] = { label = 'EMS Garage' }, + ['mechgarage'] = { label = 'Mechanic Garage' } + } +} +-- Versuche, die Garagen aus dem externen Config zu laden +local ExternalGarages = {} +if _G.Config and _G.Config.Zonen then + ExternalGarages = _G.Config.Zonen + print("[Fahrzeugadmin] Garagen aus dem Hauptsystem geladen: " .. #ExternalGarages .. " Garagen gefunden.") +else + print("[Fahrzeugadmin] Konnte keine Garagen aus dem Hauptsystem laden, verwende Standard-Garagen.") +end -- Job Permission Check local function HasPermission(source) @@ -26,7 +68,7 @@ local function HasPermission(source) -- Check if player has allowed job local playerJob = Player.PlayerData.job.name - return Config.AllowedJobs[playerJob] == true + return AdminConfig.AllowedJobs[playerJob] == true end -- Get all players from database @@ -99,9 +141,9 @@ QBCore.Functions.CreateCallback('vehicleadmin:getGarages', function(source, cb) local garages = {} - -- Verwende die externen Garagen aus dem Garagensystem - if Config.Zonen then - for k, v in pairs(Config.Zonen) do + -- Verwende die externen Garagen, wenn verfügbar + if next(ExternalGarages) ~= nil then + for k, v in pairs(ExternalGarages) do table.insert(garages, { name = v.name, label = v.name -- Ihr könnt hier auch eine Label-Property hinzufügen @@ -109,7 +151,7 @@ QBCore.Functions.CreateCallback('vehicleadmin:getGarages', function(source, cb) end else -- Fallback auf Standard-Garagen - for garageName, garageData in pairs(Config.DefaultGarages) do + for garageName, garageData in pairs(AdminConfig.DefaultGarages) do table.insert(garages, { name = garageName, label = garageData.label or garageName @@ -186,7 +228,7 @@ RegisterNetEvent('vehicleadmin:moveToGarage', function(plate, garage) )) -- Log für Discord - if Config.Log and Config.Log.Enabled then + if AdminConfig.Log and AdminConfig.Log.Enabled then sendToDiscord("Fahrzeugadmin", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.label .. ") hat Fahrzeug " .. plate .. " in Garage " .. garage .. " gestellt.", "blue") end end @@ -243,7 +285,7 @@ RegisterNetEvent('vehicleadmin:deleteFromMap', function(plate) )) -- Log für Discord - if Config.Log and Config.Log.Enabled then + if AdminConfig.Log and AdminConfig.Log.Enabled then sendToDiscord("Fahrzeugadmin", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.label .. ") hat Fahrzeug " .. plate .. " von der Map gelöscht.", "orange") end end @@ -311,7 +353,10 @@ RegisterNetEvent('vehicleadmin:repairVehicle', function(plate) SetVehicleUndriveable(veh, false) SetVehicleEngineOn(veh, true, true) SetVehicleFuelLevel(veh, 100.0) - exports["lc_fuel"]:SetFuel(veh, 100) + -- Versuche, den Kraftstoff über das lc_fuel-Export zu setzen, falls verfügbar + pcall(function() + exports["lc_fuel"]:SetFuel(veh, 100) + end) break end end @@ -327,7 +372,7 @@ RegisterNetEvent('vehicleadmin:repairVehicle', function(plate) )) -- Log für Discord - if Config.Log and Config.Log.Enabled then + if AdminConfig.Log and AdminConfig.Log.Enabled then sendToDiscord("Fahrzeugadmin", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.label .. ") hat Fahrzeug " .. plate .. " repariert.", "green") end end @@ -358,26 +403,25 @@ end) -- Discord Log Funktion function sendToDiscord(title, message, color) - if not Config.Log or not Config.Log.Enabled or not Config.Log.Webhook then return end + if not AdminConfig.Log or not AdminConfig.Log.Enabled or not AdminConfig.Log.Webhook then return end local embed = { { ["title"] = message, ["type"] = "rich", - ["color"] = Config.Log.Colors[color] or Config.Log.Colors.blue, + ["color"] = AdminConfig.Log.Colors[color] or AdminConfig.Log.Colors.blue, ["footer"] = { - ["text"] = Config.Log.SystemName or "Fahrzeugadmin", + ["text"] = AdminConfig.Log.SystemName or "Fahrzeugadmin", }, } } - PerformHttpRequest(Config.Log.Webhook, function(err, text, headers) + PerformHttpRequest(AdminConfig.Log.Webhook, function(err, text, headers) if err and err ~= 204 and err ~= 200 then print("Fehler beim Discord Webhook [" .. tostring(err) .. "]: " .. tostring(text)) end end, 'POST', json.encode({ username = title .. " - System", - avatar_url = Config.Log.SystemAvatar, embeds = embed }), { ['Content-Type'] = 'application/json' }) end @@ -467,3 +511,14 @@ QBCore.Commands.Add('dealeradmin', 'Öffne Autohändler Fahrzeug Menu', {}, fals TriggerClientEvent('vehicleadmin:openMenu', src) end) + +-- Versuche, die Garagen aus dem externen Config zu laden (erneut) +Citizen.CreateThread(function() + Wait(5000) -- Warte länger, damit das Hauptsystem sicher geladen ist + + -- Versuche, die Garagen aus dem Hauptsystem zu laden + if _G.Config and _G.Config.Zonen then + ExternalGarages = _G.Config.Zonen + print("[Fahrzeugadmin] Garagen aus dem Hauptsystem nachgeladen: " .. #ExternalGarages .. " Garagen gefunden.") + end +end)