-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
40 lines (35 loc) · 1.21 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterCommand('kickall', function(source, args, rawCommand)
kickPl()
end, true)
function kickPl ()
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
xPlayer.kick("🌙 FiveM: The server is restarting, come back later.")
sendToDiscord("https://discordapp.com/api/webhooks/xyz", "Weather", "Server restarting now.", 56108)
end
end
function sendToDiscord (canal, name, message, color)
local DiscordWebHook = canal
local embeds = {
{
["title"]= "Some text",
["type"]= "rich",
["color"] = color,
["description"]= message,
["footer"]= {
["text"]= "Footer",
["icon_url"]= "https://forum.fivem.net/uploads/default/original/3X/f/3/f39849c511fa123c3346b7afef26971f1f8a740d.png",
},
}
}
if message == nil or message == '' then return FALSE end
PerformHttpRequest(DiscordWebHook, function(err, text, headers) end, 'POST', json.encode({ username = name,embeds = embeds}), { ['Content-Type'] = 'application/json' })
end