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

48 lines
1.3 KiB
Lua
Raw Normal View History

2025-06-12 22:35:19 +02:00
local QBCore = nil
CreateThread(function()
while QBCore == nil do
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
Wait(200)
end
end)
2025-06-12 22:22:51 +02:00
2025-06-12 22:18:10 +02:00
local function DiscordNachricht()
if Config.DiscordWebhook == "" then return end
PerformHttpRequest(Config.DiscordWebhook, function() end, 'POST', json.encode({
content = Config.WartungsNachricht
}), { ['Content-Type'] = 'application/json' })
end
RegisterCommand('wartung', function(source)
2025-06-12 22:35:19 +02:00
while not QBCore do
Wait(100)
end
2025-06-12 22:18:10 +02:00
local src = source
2025-06-12 22:22:51 +02:00
local Player = QBCore.Functions.GetPlayer(src)
2025-06-12 22:18:10 +02:00
2025-06-12 22:35:19 +02:00
if not Player then
print(("^1Error: Player not found (source: %s)^7"):format(src))
return
end
if not QBCore.Functions.HasPermission(src, Config.ErlaubteRolle) then
2025-06-12 22:18:10 +02:00
TriggerClientEvent('QBCore:Notify', src, 'Keine Berechtigung!', 'error')
return
end
2025-06-12 22:35:19 +02:00
for k, v in pairs(QBCore.Functions.GetPlayers()) do
2025-06-12 22:18:10 +02:00
TriggerClientEvent('QBCore:Notify', v, 'Wartungsarbeiten beginnen!', 'error')
end
2025-06-12 22:22:51 +02:00
2025-06-12 22:18:10 +02:00
DiscordNachricht()
TriggerClientEvent('QBCore:Notify', src, 'Wartung angekündigt!', 'success')
2025-06-12 22:35:19 +02:00
print(("^5[Wartung]^7 Wartung wurde von %s gestartet"):format(GetPlayerName(src)))
2025-06-12 22:18:10 +02:00
end, false)