diff --git a/lua/relay/sv_config.lua b/lua/relay/sv_config.lua index 5c9ee70..c51f93e 100644 --- a/lua/relay/sv_config.lua +++ b/lua/relay/sv_config.lua @@ -11,6 +11,8 @@ Discord = { ["srvStarted"] = true, + ["srvShutdown"] = true, + ["hideBots"] = false, ["language"] = "ru", diff --git a/lua/relay/sv_msgGet.lua b/lua/relay/sv_msgGet.lua index 815f56e..b39277d 100644 --- a/lua/relay/sv_msgGet.lua +++ b/lua/relay/sv_msgGet.lua @@ -122,3 +122,8 @@ timer.Simple( 3, function() socket:open() Discord.isSocketReloaded = false end ) + +-- request (lag when changelevel) +hook.Add("ShutDown", "!!discord_srvShutdown_socketdown", function() + socket:closeNow() +end) \ No newline at end of file diff --git a/lua/relay/sv_msgSend.lua b/lua/relay/sv_msgSend.lua index a692fcd..d4c9b2c 100644 --- a/lua/relay/sv_msgSend.lua +++ b/lua/relay/sv_msgSend.lua @@ -179,17 +179,32 @@ gameevent.Listen( "player_disconnect" ) hook.Add("player_disconnect", "!!discord_onDisconnect", plyDisconnect) if Discord.srvStarted then -hook.Add("Initialize", "!!discord_srvStarted", function() - local form = { - ["username"] = Discord.hookname, - ["embeds"] = {{ - ["title"] = DiscordString.serverStarted, - ["description"] = DiscordString.currentMapAlt .. game.GetMap(), - ["color"] = 5793266 - }} - } - - Discord.send(form) - hook.Remove("Initialize", "!!discord_srvStarted") -end) + hook.Add("Initialize", "!!discord_srvStarted", function() + local form = { + ["username"] = Discord.hookname, + ["embeds"] = {{ + ["title"] = DiscordString.serverStarted, + ["description"] = DiscordString.currentMapAlt .. game.GetMap(), + ["color"] = 5793266 + }} + } + + Discord.send(form) + hook.Remove("Initialize", "!!discord_srvStarted") + end) end +if Discord.srvShutdown then + hook.Add("ShutDown", "!!discord_srvShutdown", function() + local form = { + ["username"] = Discord.hookname, + ["embeds"] = {{ + ["title"] = DiscordString.serverShutdown, + ["description"] = '', + ["color"] = 16730698 + }} + } + + Discord.send(form) + hook.Remove("Initialize", "!!discord_srvShutdown") + end) +end \ No newline at end of file diff --git a/lua/relay/translations/en.lua b/lua/relay/translations/en.lua index 7b88ec1..43287fc 100644 --- a/lua/relay/translations/en.lua +++ b/lua/relay/translations/en.lua @@ -11,5 +11,6 @@ DiscordString = { ["connected"] = " connected", ["disconnected"] = " disconnected", ["serverStarted"] = "Server Started!", + ["serverShutdown"] = "The server has shut down", ["currentMapAlt"] = "Current Map - " } diff --git a/lua/relay/translations/ru.lua b/lua/relay/translations/ru.lua index 90c7506..7149ee0 100644 --- a/lua/relay/translations/ru.lua +++ b/lua/relay/translations/ru.lua @@ -11,5 +11,6 @@ DiscordString = { ["connected"] = " подключился", ["disconnected"] = " отключился", ["serverStarted"] = "Сервер запущен!", + ["serverShutdown"] = "Сервер выключился", ["currentMapAlt"] = "Карта сейчас - " }