sending map info to mapnotifications

This commit is contained in:
jenz 2026-02-22 23:35:39 +01:00
parent 005552248b
commit 4efd426893

View File

@ -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");