diff --git a/Discord_UNLOZE/scripting/live_chat_stoat.sp b/Discord_UNLOZE/scripting/live_chat_stoat.sp index 3b11d47..266b2a2 100644 --- a/Discord_UNLOZE/scripting/live_chat_stoat.sp +++ b/Discord_UNLOZE/scripting/live_chat_stoat.sp @@ -9,6 +9,9 @@ #define API_URL "" #define BOT_TOKEN "" + +int i_port = 0; + public Plugin myinfo = { name = "livechat stoat", @@ -26,7 +29,6 @@ public void OnMapStart() public Action SendMapNotificationToStoat(Handle timer) { - int i_port = GetConVarInt(FindConVar("hostport")); if (i_port == 27015) { char sText[1024]; @@ -59,6 +61,7 @@ void SendToMapNotifications_endpoint(const char[] msg) { public void OnPluginStart() { + i_port = GetConVarInt(FindConVar("hostport")); AddCommandListener(CommandListener_SmChat_stoat, "say"); RegServerCmd("sm_printtoallchat_stoat", Command_PrintToAllChat_stoat, "Stoat Integration"); @@ -95,8 +98,15 @@ public Action CommandListener_SmChat_stoat(int client, const char[] sCommand, in } //LogMessage("sText: %s. sText[0]: %c", sText, sText[0]); - - SendToStoat(sUsername, sText, ""); + + if (i_port == 27015) + { + SendToStoat(sUsername, sText, ""); + } + else if (i_port == 27017) + { + SendToStoat(sUsername, sText, ""); + } return Plugin_Continue; } @@ -119,7 +129,34 @@ void SendToStoat(const char[] name, const char[] msg, const char[] channel_id) { delete data; } -void OnHTTPResponse(HTTPResponse response, any value) { +void OnHTTPResponse(HTTPResponse response, any value, const char[] error) { + /* + if (strlen(error) > 0) + { + LogError("HTTP request failed: %s", error); + return; + } + + int status = response.Status; + + if (status != HTTPStatus_OK && status != HTTPStatus_Created) + { + LogError("Unexpected HTTP status: %d", status); + + // Optionally log the response body to see what the server returned + JSONObject body = view_as(response.Data); + if (body != null) + { + char bodyStr[1024]; + body.ToString(bodyStr, sizeof(bodyStr)); + LogError("Response body: %s", bodyStr); + } + } + else + { + LogMessage("Message sent successfully, status: %d", status); + } + */ } public Action Command_PrintToAllChat_stoat(int args) @@ -163,6 +200,21 @@ public void GetDiscordToStoat(const char[] username, const char[] message, int t //type = 4. admin logs ze ban evasion //type = 5. Calladmin //type = 6. admin chat ze + + if (i_port == 27017) + { + if (type == 1) + { + SendToStoat(username, message, ""); + } + else if (type == 2) + { + SendToStoat(username, message, ""); + } + + return; + } + if (type == 1) { SendToStoat(username, message, "");