From 5a8db4a0100cb2bda312ff1fe24edf21934427de Mon Sep 17 00:00:00 2001 From: rick Date: Sat, 22 May 2021 15:04:18 +0200 Subject: [PATCH] =?UTF-8?q?Message=20envoy=C3=A9=20quand=20tous=20les=20jo?= =?UTF-8?q?ueurs=20sont=20partis=20+=20reset=20tableaux=20=C3=A9quipes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infolan.sp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/infolan.sp b/infolan.sp index b684327..5458646 100644 --- a/infolan.sp +++ b/infolan.sp @@ -13,6 +13,7 @@ char teamT[5][150]; char clientId[128]; int port = -1; +bool needReset; /* pour éviter le kick lors des connexions post veille */ public Plugin myinfo = { @@ -21,7 +22,7 @@ public Plugin myinfo = description = "Bot communiquant avec le bot discord \ https://github.com/Lunki51/cs-picker afin d’automatiser \ l’InfoLan 2021", - version = "1.1", + version = "1.4", url = "https://git.gnous.eu/Rick/infolanBot" }; @@ -68,6 +69,7 @@ public void SetTeamPlayer(Event event, const char[] name, bool dontBroadcast) { ChangeClientTeam(client, CS_TEAM_CT); allGood = true; + needReset = true; } else if (!strcmp(teamT[i], clientId, false)) { @@ -81,6 +83,8 @@ public void SetTeamPlayer(Event event, const char[] name, bool dontBroadcast) KickClient(client, "Vous n’êtes pas autorisé à suivre / jouer \ sur ce serveur"); } + else + CS_RespawnPlayer(client); } } } @@ -111,6 +115,7 @@ public Action SetTeam(int args) else teamT[i - 3] = arg; } + needReset = false; } else { @@ -126,12 +131,16 @@ public void OnMapEnd() { // TODO kick tout le monde PrintToServer("======= FIN ======"); - ServeurLibre(); /* kick tout le monde */ } public void ServeurLibre() { + for (int i = 0; i < sizeof(teamCT); i++) + { + teamCT[i] = ""; + teamT[i] = ""; + } // requete post pour match fini et serveur libre Handle socket = SocketCreate(SOCKET_TCP, OnSocketError); SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT); @@ -200,10 +209,9 @@ public void OnClientDisconnect(int client) { int nbClient = GetTeamClientCount(CS_TEAM_SPECTATOR) + GetTeamClientCount(CS_TEAM_CT) + GetTeamClientCount(CS_TEAM_T); - if (nbClient == 1) + if (nbClient == 1 && needReset) { - Handle socket = SocketCreate(SOCKET_TCP, OnSocketError); - SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT); + ServeurLibre(); } }