diff --git a/Discord_UNLOZE/scripting/live_chat_stoat.sp b/Discord_UNLOZE/scripting/live_chat_stoat.sp index 101437a..3b11d47 100644 --- a/Discord_UNLOZE/scripting/live_chat_stoat.sp +++ b/Discord_UNLOZE/scripting/live_chat_stoat.sp @@ -14,10 +14,49 @@ public Plugin myinfo = name = "livechat stoat", author = "jenz", description = "", - version = "1.0.0", + version = "1.1.0", url = "www.unloze.com" } +public void OnMapStart() +{ + CreateTimer(5.0, SendMapNotificationToStoat); +} + + +public Action SendMapNotificationToStoat(Handle timer) +{ + int i_port = GetConVarInt(FindConVar("hostport")); + if (i_port == 27015) + { + char sText[1024]; + char sCurrentmap[64]; + GetCurrentMap(sCurrentmap, sizeof(sCurrentmap)); + int NumPlayers = GetClientCount(false); + char serverIp[32]; + ConVar ip_cvar = FindConVar("ip"); + ip_cvar.GetString(serverIp, sizeof(serverIp)); + + Format(sText, sizeof(sText), "Map changed to: %s\nPlayerCount: %i/65\nQuick Join: %s:%i", sCurrentmap, NumPlayers, serverIp, i_port); + SendToMapNotifications_endpoint(sText); + } + return Plugin_Handled; +} + +void SendToMapNotifications_endpoint(const char[] msg) { + HTTPRequest request = new HTTPRequest(""); + request.SetHeader("Content-Type", "application/json"); + + char content[1024]; + Format(content, sizeof(content), "**%s**", msg); + + JSONObject data = new JSONObject(); + data.SetString("content", content); + + request.Post(data, OnHTTPResponse); + delete data; +} + public void OnPluginStart() { AddCommandListener(CommandListener_SmChat_stoat, "say");