forked from Simnation/Main
ed
This commit is contained in:
parent
ee2f25eb25
commit
5d20163e0b
2 changed files with 80 additions and 73 deletions
|
@ -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' }
|
|
||||||
}
|
|
|
@ -1,18 +1,60 @@
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
-- Lade die Garagen aus dem Hauptsystem
|
-- Interne Konfiguration für das Fahrzeugadmin-System
|
||||||
Citizen.CreateThread(function()
|
local AdminConfig = {
|
||||||
Wait(1000) -- Warte kurz, damit das Hauptsystem geladen ist
|
-- 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
|
-- 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
|
if _G.Config and _G.Config.Zonen then
|
||||||
Config.Zonen = _G.Config.Zonen
|
ExternalGarages = _G.Config.Zonen
|
||||||
print("[Fahrzeugadmin] Garagen aus dem Hauptsystem geladen: " .. #Config.Zonen .. " Garagen gefunden.")
|
print("[Fahrzeugadmin] Garagen aus dem Hauptsystem geladen: " .. #ExternalGarages .. " Garagen gefunden.")
|
||||||
else
|
else
|
||||||
print("[Fahrzeugadmin] Konnte keine Garagen aus dem Hauptsystem laden, verwende Standard-Garagen.")
|
print("[Fahrzeugadmin] Konnte keine Garagen aus dem Hauptsystem laden, verwende Standard-Garagen.")
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
-- Job Permission Check
|
-- Job Permission Check
|
||||||
local function HasPermission(source)
|
local function HasPermission(source)
|
||||||
|
@ -26,7 +68,7 @@ local function HasPermission(source)
|
||||||
|
|
||||||
-- Check if player has allowed job
|
-- Check if player has allowed job
|
||||||
local playerJob = Player.PlayerData.job.name
|
local playerJob = Player.PlayerData.job.name
|
||||||
return Config.AllowedJobs[playerJob] == true
|
return AdminConfig.AllowedJobs[playerJob] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get all players from database
|
-- Get all players from database
|
||||||
|
@ -99,9 +141,9 @@ QBCore.Functions.CreateCallback('vehicleadmin:getGarages', function(source, cb)
|
||||||
|
|
||||||
local garages = {}
|
local garages = {}
|
||||||
|
|
||||||
-- Verwende die externen Garagen aus dem Garagensystem
|
-- Verwende die externen Garagen, wenn verfügbar
|
||||||
if Config.Zonen then
|
if next(ExternalGarages) ~= nil then
|
||||||
for k, v in pairs(Config.Zonen) do
|
for k, v in pairs(ExternalGarages) do
|
||||||
table.insert(garages, {
|
table.insert(garages, {
|
||||||
name = v.name,
|
name = v.name,
|
||||||
label = v.name -- Ihr könnt hier auch eine Label-Property hinzufügen
|
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
|
end
|
||||||
else
|
else
|
||||||
-- Fallback auf Standard-Garagen
|
-- Fallback auf Standard-Garagen
|
||||||
for garageName, garageData in pairs(Config.DefaultGarages) do
|
for garageName, garageData in pairs(AdminConfig.DefaultGarages) do
|
||||||
table.insert(garages, {
|
table.insert(garages, {
|
||||||
name = garageName,
|
name = garageName,
|
||||||
label = garageData.label or garageName
|
label = garageData.label or garageName
|
||||||
|
@ -186,7 +228,7 @@ RegisterNetEvent('vehicleadmin:moveToGarage', function(plate, garage)
|
||||||
))
|
))
|
||||||
|
|
||||||
-- Log für Discord
|
-- 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")
|
sendToDiscord("Fahrzeugadmin", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.label .. ") hat Fahrzeug " .. plate .. " in Garage " .. garage .. " gestellt.", "blue")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -243,7 +285,7 @@ RegisterNetEvent('vehicleadmin:deleteFromMap', function(plate)
|
||||||
))
|
))
|
||||||
|
|
||||||
-- Log für Discord
|
-- 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")
|
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
|
||||||
end
|
end
|
||||||
|
@ -311,7 +353,10 @@ RegisterNetEvent('vehicleadmin:repairVehicle', function(plate)
|
||||||
SetVehicleUndriveable(veh, false)
|
SetVehicleUndriveable(veh, false)
|
||||||
SetVehicleEngineOn(veh, true, true)
|
SetVehicleEngineOn(veh, true, true)
|
||||||
SetVehicleFuelLevel(veh, 100.0)
|
SetVehicleFuelLevel(veh, 100.0)
|
||||||
|
-- Versuche, den Kraftstoff über das lc_fuel-Export zu setzen, falls verfügbar
|
||||||
|
pcall(function()
|
||||||
exports["lc_fuel"]:SetFuel(veh, 100)
|
exports["lc_fuel"]:SetFuel(veh, 100)
|
||||||
|
end)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -327,7 +372,7 @@ RegisterNetEvent('vehicleadmin:repairVehicle', function(plate)
|
||||||
))
|
))
|
||||||
|
|
||||||
-- Log für Discord
|
-- 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")
|
sendToDiscord("Fahrzeugadmin", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " (" .. Player.PlayerData.job.label .. ") hat Fahrzeug " .. plate .. " repariert.", "green")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -358,26 +403,25 @@ end)
|
||||||
|
|
||||||
-- Discord Log Funktion
|
-- Discord Log Funktion
|
||||||
function sendToDiscord(title, message, color)
|
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 = {
|
local embed = {
|
||||||
{
|
{
|
||||||
["title"] = message,
|
["title"] = message,
|
||||||
["type"] = "rich",
|
["type"] = "rich",
|
||||||
["color"] = Config.Log.Colors[color] or Config.Log.Colors.blue,
|
["color"] = AdminConfig.Log.Colors[color] or AdminConfig.Log.Colors.blue,
|
||||||
["footer"] = {
|
["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
|
if err and err ~= 204 and err ~= 200 then
|
||||||
print("Fehler beim Discord Webhook [" .. tostring(err) .. "]: " .. tostring(text))
|
print("Fehler beim Discord Webhook [" .. tostring(err) .. "]: " .. tostring(text))
|
||||||
end
|
end
|
||||||
end, 'POST', json.encode({
|
end, 'POST', json.encode({
|
||||||
username = title .. " - System",
|
username = title .. " - System",
|
||||||
avatar_url = Config.Log.SystemAvatar,
|
|
||||||
embeds = embed
|
embeds = embed
|
||||||
}), { ['Content-Type'] = 'application/json' })
|
}), { ['Content-Type'] = 'application/json' })
|
||||||
end
|
end
|
||||||
|
@ -467,3 +511,14 @@ QBCore.Commands.Add('dealeradmin', 'Öffne Autohändler Fahrzeug Menu', {}, fals
|
||||||
|
|
||||||
TriggerClientEvent('vehicleadmin:openMenu', src)
|
TriggerClientEvent('vehicleadmin:openMenu', src)
|
||||||
end)
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue