From 1c093e3c392fb5d616f806ef4eea9c564fb3f1ef Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 20 May 2021 01:08:11 +0200 Subject: [PATCH] Requete fonctionnelle pour la fin de match --- test.sp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test.sp b/test.sp index 3c9d6f9..7c1eee7 100644 --- a/test.sp +++ b/test.sp @@ -138,7 +138,6 @@ public void ServeurLibre(Event event, const char[] name, bool dontBroadcast) public void UpdateScoreBoard(Event event, const char[] name, bool dontBroadcast) { // request post avec les scores des 2 équipes - PrintToServer("Coucou, je souis là"); Handle socket = SocketCreate(SOCKET_TCP, OnSocketError); SocketConnect(socket, SocketUpdateScore, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT); } @@ -162,32 +161,35 @@ public Action TestSocketA(int args) public void SocketUpdateScore(Handle socket, any arg) { - char requestStr[2048]; + char requestStr[1024]; + char json[64]; + FormatEx(json, sizeof(json), "{\"port\": %d, \"ct\": %d, \"t\": %d}", + port, CS_GetTeamScore(CS_TEAM_CT), CS_GetTeamScore(CS_TEAM_T)); FormatEx( requestStr, sizeof(requestStr), "POST /api/csgo/updatescore HTTP/1.1\r\n\ Content-Type: application/json\r\n\ - Content-Length: 32\r\n\r\n\ - {\"port\": %d, \"ct\": %d, \"t\": %d}", - port, CS_GetTeamScore(CS_TEAM_CT), CS_GetTeamScore(CS_TEAM_T) + Content-Length: %d\r\n\r\n%s", strlen(json), json ); - SocketSend(socket, requestStr, 2048); + SocketSend(socket, requestStr, sizeof(requestStr)); SocketDisconnect(socket); CloseHandle(socket); } public void SocketEnvoieVictoire(Handle socket, any arg) { - char requestStr[512]; + char requestStr[1024]; + char json[64]; + FormatEx(json, sizeof(json), "{\"serverport\": %d, \"available\": true}", port); FormatEx( requestStr, sizeof(requestStr), - "POST /api/csgo/matchend HTTP/1.0\r\n\ - Content-type: text/json\r\n\ - {\"serverport\": 512, \"available\": true}", port + "POST /api/csgo/matchend HTTP/1.1\r\n\ + Content-Type: application/json\r\n\ + Content-Length: %d\r\n\r\n%s", strlen(json), json ); - SocketSend(socket, requestStr, 512); + SocketSend(socket, requestStr, sizeof(requestStr)); SocketDisconnect(socket); CloseHandle(socket); }