From 861caa72455493b3d3d1715862b0eee759684f2f Mon Sep 17 00:00:00 2001 From: rick Date: Sat, 22 May 2021 13:32:23 +0200 Subject: [PATCH] =?UTF-8?q?Envoi=20serveur=20libre=20si=20derni=C3=A8re=20?= =?UTF-8?q?personne=20quitte=20serveur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infolan.sp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/infolan.sp b/infolan.sp index 8e68759..b684327 100644 --- a/infolan.sp +++ b/infolan.sp @@ -1,4 +1,5 @@ #include +#include #include #include "socket.inc" @@ -7,8 +8,8 @@ #define MY_SOCKET_PORT 3000 #define STEAMID_LENGTH 128 -char teamCT[6][150]; -char teamT[6][150]; +char teamCT[5][150]; +char teamT[5][150]; char clientId[128]; int port = -1; @@ -195,6 +196,17 @@ public void SocketEnvoieVictoire(Handle socket, any arg) public void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {} +public void OnClientDisconnect(int client) +{ + int nbClient = GetTeamClientCount(CS_TEAM_SPECTATOR) + + GetTeamClientCount(CS_TEAM_CT) + GetTeamClientCount(CS_TEAM_T); + if (nbClient == 1) + { + Handle socket = SocketCreate(SOCKET_TCP, OnSocketError); + SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT); + } +} + public OnSocketDisconnected(Handle socket, any arg) { CloseHandle(socket);