Main/resources/[Developer]/[Max]/Duck_new_wartung/server.lua

66 lines
2.1 KiB
Lua
Raw Permalink Normal View History

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
2025-06-15 03:44:58 +02:00
QBCore = exports['qb-core']:GetCoreObject()
2025-06-13 20:44:36 +02:00
if not QBCore then
2025-06-15 03:44:58 +02:00
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
2025-06-13 20:44:36 +02:00
end
Wait(100)
2025-06-12 22:35:19 +02:00
end
end)
2025-06-12 22:22:51 +02:00
2025-06-15 03:44:58 +02:00
local function DiscordNachricht(nachricht)
if Config.DiscordWebhook == "" then
print("^1ERROR: Kein Discord-Webhook in config.lua!^7")
2025-06-13 20:44:36 +02:00
return
end
PerformHttpRequest(Config.DiscordWebhook, function(err, text, headers)
2025-06-15 03:44:58 +02:00
if err ~= 200 then
print("^1Discord-Fehler (Code "..err.."):^7", text)
2025-06-13 20:44:36 +02:00
end
2025-06-15 03:44:58 +02:00
end, 'POST', json.encode({content = nachricht}), { ['Content-Type'] = 'application/json' })
end
local function BenachrichtigeSpieler(nachricht, typ)
for _, playerId in pairs(QBCore.Functions.GetPlayers()) do
TriggerClientEvent('QBCore:Notify', playerId, nachricht, typ or "primary", 10000)
end
2025-06-12 22:18:10 +02:00
end
2025-06-15 03:44:58 +02:00
2025-06-12 22:18:10 +02:00
RegisterCommand('wartung', function(source)
2025-06-13 20:44:36 +02:00
local src = source
2025-06-15 03:44:58 +02:00
local Player = QBCore.Functions.GetPlayer(src)
if not Player or not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then
TriggerClientEvent('QBCore:Notify', src, "Keine Berechtigung!", "error")
2025-06-13 20:44:36 +02:00
return
2025-06-12 22:35:19 +02:00
end
2025-06-15 03:44:58 +02:00
BenachrichtigeSpieler("🔧 Wartungsarbeiten beginnen! Server wird neugestartet.", "error")
DiscordNachricht(Config.WartungStartNachricht)
TriggerClientEvent('QBCore:Notify', src, "Wartung gestartet!", "success")
print("^5[Wartung]^7 Gestartet von "..GetPlayerName(src))
end, false)
RegisterCommand('wartungoff', function(source)
local src = source
2025-06-12 22:22:51 +02:00
local Player = QBCore.Functions.GetPlayer(src)
2025-06-13 20:44:36 +02:00
2025-06-15 03:44:58 +02:00
if not Player or not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then
2025-06-13 20:44:36 +02:00
TriggerClientEvent('QBCore:Notify', src, "Keine Berechtigung!", "error")
2025-06-12 22:18:10 +02:00
return
end
2025-06-13 20:44:36 +02:00
2025-06-15 03:44:58 +02:00
BenachrichtigeSpieler("✅ Wartung abgeschlossen! Server ist wieder normal nutzbar.", "success")
DiscordNachricht(Config.WartungEndeNachricht)
TriggerClientEvent('QBCore:Notify', src, "Wartung beendet!", "success")
print("^5[Wartung]^7 Beendet von "..GetPlayerName(src))
2025-06-12 22:18:10 +02:00
end, false)