2025-06-13 20:44:36 +02:00
|
|
|
-- Initialisiere QBCore (kompatibel mit allen QB-Versionen)
|
2025-06-12 22:35:19 +02:00
|
|
|
local QBCore = nil
|
|
|
|
CreateThread(function()
|
2025-06-13 20:44:36 +02:00
|
|
|
while not QBCore do
|
|
|
|
QBCore = exports['qb-core']:GetCoreObject() -- Funktioniert mit QB v2/v4
|
|
|
|
if not QBCore then
|
|
|
|
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) -- Fallback für ältere QB-Versionen
|
|
|
|
end
|
|
|
|
Wait(100)
|
2025-06-12 22:35:19 +02:00
|
|
|
end
|
2025-06-13 20:44:36 +02:00
|
|
|
print("[Wartung] QBCore erfolgreich initialisiert!") -- Debug
|
2025-06-12 22:35:19 +02:00
|
|
|
end)
|
2025-06-12 22:22:51 +02:00
|
|
|
|
2025-06-13 20:44:36 +02:00
|
|
|
-- Discord-Webhook-Funktion
|
2025-06-12 22:18:10 +02:00
|
|
|
local function DiscordNachricht()
|
2025-06-13 20:44:36 +02:00
|
|
|
if Config.DiscordWebhook == "" or Config.DiscordWebhook == "HIER_WEBHOOK_EINFÜGEN" then
|
|
|
|
print("^1ERROR: Kein Discord-Webhook in config.lua gesetzt!^7")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
PerformHttpRequest(Config.DiscordWebhook, function(err, text, headers)
|
|
|
|
if err == 200 then
|
|
|
|
print("^2Discord-Nachricht erfolgreich gesendet!^7")
|
|
|
|
else
|
|
|
|
print("^1Fehler beim Senden an Discord (Code "..err.."):^7", text)
|
|
|
|
end
|
|
|
|
end, 'POST', json.encode({content = Config.WartungsNachricht}), { ['Content-Type'] = 'application/json' })
|
2025-06-12 22:18:10 +02:00
|
|
|
end
|
|
|
|
|
2025-06-13 20:44:36 +02:00
|
|
|
-- Hauptbefehl
|
2025-06-12 22:18:10 +02:00
|
|
|
RegisterCommand('wartung', function(source)
|
2025-06-13 20:44:36 +02:00
|
|
|
local src = source
|
|
|
|
if not QBCore then
|
|
|
|
print("^1ERROR: QBCore nicht initialisiert!^7")
|
|
|
|
TriggerClientEvent('QBCore:Notify', src, "Systemfehler: QBCore nicht bereit.", "error")
|
|
|
|
return
|
2025-06-12 22:35:19 +02:00
|
|
|
end
|
|
|
|
|
2025-06-12 22:22:51 +02:00
|
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
2025-06-12 22:35:19 +02:00
|
|
|
if not Player then
|
2025-06-13 20:44:36 +02:00
|
|
|
print("^1ERROR: Spieler-ID "..src.." nicht gefunden!^7")
|
2025-06-12 22:35:19 +02:00
|
|
|
return
|
|
|
|
end
|
2025-06-13 20:44:36 +02:00
|
|
|
|
|
|
|
-- Berechtigungsprüfung
|
2025-06-12 22:35:19 +02:00
|
|
|
if not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then
|
2025-06-13 20:44:36 +02:00
|
|
|
TriggerClientEvent('QBCore:Notify', src, "Keine Berechtigung!", "error")
|
|
|
|
print("^3WARNUNG: "..GetPlayerName(src).." versuchte, Wartung zu starten!^7")
|
2025-06-12 22:18:10 +02:00
|
|
|
return
|
|
|
|
end
|
2025-06-13 20:44:36 +02:00
|
|
|
|
|
|
|
-- Benachrichtige alle Spieler
|
|
|
|
for _, playerId in pairs(QBCore.Functions.GetPlayers()) do
|
|
|
|
TriggerClientEvent('QBCore:Notify', playerId, "Wartungsarbeiten beginnen!", "error", 10000)
|
2025-06-12 22:18:10 +02:00
|
|
|
end
|
2025-06-13 20:44:36 +02:00
|
|
|
|
|
|
|
-- Discord & Logging
|
2025-06-12 22:18:10 +02:00
|
|
|
DiscordNachricht()
|
2025-06-13 20:44:36 +02:00
|
|
|
TriggerClientEvent('QBCore:Notify', src, "Wartung gestartet!", "success")
|
|
|
|
print("^5[Wartung]^7 Gestartet von "..GetPlayerName(src).." (ID: "..src..")")
|
2025-06-12 22:18:10 +02:00
|
|
|
end, false)
|