sending map info to mapnotifications
This commit is contained in:
parent
005552248b
commit
4efd426893
@ -14,10 +14,49 @@ public Plugin myinfo =
|
|||||||
name = "livechat stoat",
|
name = "livechat stoat",
|
||||||
author = "jenz",
|
author = "jenz",
|
||||||
description = "",
|
description = "",
|
||||||
version = "1.0.0",
|
version = "1.1.0",
|
||||||
url = "www.unloze.com"
|
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()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
AddCommandListener(CommandListener_SmChat_stoat, "say");
|
AddCommandListener(CommandListener_SmChat_stoat, "say");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user