Update // Duck Wartung
This commit is contained in:
		
							parent
							
								
									4206f525f0
								
							
						
					
					
						commit
						294c36c060
					
				
					 2 changed files with 42 additions and 37 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| Config = { | ||||
|     DiscordWebhook = "https://discord.com/api/webhooks/1383151445532086442/02u3NBPWov8pfKj8B-F-lyr-BH54hPgdCgROUqe6aZmVxLDChYCSSbyGkC7YPUtUYWzi", | ||||
|     WartungsNachricht = "🔧 Wartungsarbeiten 🔧\nDer Server wird jetzt gewartet! >> Connect solange nicht Möglich!", | ||||
|     DiscordWebhook = "HIER_WEBHOOK_EINFÜGEN", | ||||
|     WartungStartNachricht = "🔧 **Wartungsarbeiten** 🔧\nDer Server wird jetzt gewartet! >> Connect solange nicht Möglich", | ||||
|     WartungEndeNachricht = "✅ **Wartung abgeschlossen** ✅\nDer Server ist wieder verfügbar! Viel Spaß >> Danke für euer verständnis!", | ||||
|     ErlaubteRolle = "admin"  | ||||
| } | ||||
|  |  | |||
|  | @ -1,61 +1,65 @@ | |||
| -- Initialisiere QBCore (kompatibel mit allen QB-Versionen) | ||||
| local QBCore = nil | ||||
| CreateThread(function() | ||||
|     while not QBCore do | ||||
|         QBCore = exports['qb-core']:GetCoreObject() -- Funktioniert mit QB v2/v4 | ||||
|         QBCore = exports['qb-core']:GetCoreObject() | ||||
|         if not QBCore then | ||||
|             TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) -- Fallback für ältere QB-Versionen | ||||
|             TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) | ||||
|         end | ||||
|         Wait(100) | ||||
|     end | ||||
|     print("[Wartung] QBCore erfolgreich initialisiert!") -- Debug | ||||
| end) | ||||
|  | ||||
| -- Discord-Webhook-Funktion | ||||
| local function DiscordNachricht() | ||||
|     if Config.DiscordWebhook == "" or Config.DiscordWebhook == "HIER_WEBHOOK_EINFÜGEN" then | ||||
|         print("^1ERROR: Kein Discord-Webhook in config.lua gesetzt!^7") | ||||
|  | ||||
| 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("^2Discord-Nachricht erfolgreich gesendet!^7") | ||||
|         else | ||||
|             print("^1Fehler beim Senden an Discord (Code "..err.."):^7", text) | ||||
|         if err ~= 200 then | ||||
|             print("^1Discord-Fehler (Code "..err.."):^7", text) | ||||
|         end | ||||
|     end, 'POST', json.encode({content = Config.WartungsNachricht}), { ['Content-Type'] = 'application/json' }) | ||||
|     end, 'POST', json.encode({content = nachricht}), { ['Content-Type'] = 'application/json' }) | ||||
| end | ||||
|  | ||||
| -- Hauptbefehl | ||||
|  | ||||
| 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 | ||||
|     if not QBCore then | ||||
|         print("^1ERROR: QBCore nicht initialisiert!^7") | ||||
|         TriggerClientEvent('QBCore:Notify', src, "Systemfehler: QBCore nicht bereit.", "error") | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     local Player = QBCore.Functions.GetPlayer(src) | ||||
|     if not Player then | ||||
|         print("^1ERROR: Spieler-ID "..src.." nicht gefunden!^7") | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     -- Berechtigungsprüfung | ||||
|     if not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then | ||||
|      | ||||
|     if not Player or not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then | ||||
|         TriggerClientEvent('QBCore:Notify', src, "Keine Berechtigung!", "error") | ||||
|         print("^3WARNUNG: "..GetPlayerName(src).." versuchte, Wartung zu starten!^7") | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     -- Benachrichtige alle Spieler | ||||
|     for _, playerId in pairs(QBCore.Functions.GetPlayers()) do | ||||
|         TriggerClientEvent('QBCore:Notify', playerId, "Wartungsarbeiten beginnen!", "error", 10000) | ||||
|      | ||||
|     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 | ||||
|  | ||||
|     -- Discord & Logging | ||||
|     DiscordNachricht() | ||||
|     TriggerClientEvent('QBCore:Notify', src, "Wartung gestartet!", "success") | ||||
|     print("^5[Wartung]^7 Gestartet von "..GetPlayerName(src).." (ID: "..src..")") | ||||
|      | ||||
|     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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Max
						Max