65 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local QBCore = nil
 | 
						|
CreateThread(function()
 | 
						|
    while not QBCore do
 | 
						|
        QBCore = exports['qb-core']:GetCoreObject()
 | 
						|
        if not QBCore then
 | 
						|
            TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
 | 
						|
        end
 | 
						|
        Wait(100)
 | 
						|
    end
 | 
						|
end)
 | 
						|
 | 
						|
 | 
						|
local function DiscordNachricht(nachricht)
 | 
						|
    if Config.DiscordWebhook == "" then
 | 
						|
        print("^1ERROR: Kein Discord-Webhook in config.lua!^7")
 | 
						|
        return
 | 
						|
    end
 | 
						|
 | 
						|
    PerformHttpRequest(Config.DiscordWebhook, function(err, text, headers)
 | 
						|
        if err ~= 200 then
 | 
						|
            print("^1Discord-Fehler (Code "..err.."):^7", text)
 | 
						|
        end
 | 
						|
    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
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
RegisterCommand('wartung', function(source)
 | 
						|
    local src = source
 | 
						|
    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")
 | 
						|
        return
 | 
						|
    end
 | 
						|
 | 
						|
    
 | 
						|
    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
 | 
						|
    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")
 | 
						|
        return
 | 
						|
    end
 | 
						|
 | 
						|
    
 | 
						|
    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))
 | 
						|
end, false)
 |