Message envoyé quand tous les joueurs sont partis + reset tableaux équipes

This commit is contained in:
rick 2021-05-22 15:04:18 +02:00
parent 861caa7245
commit 5a8db4a010
Signed by: Rick
GPG key ID: 2B593F087240EE99

View file

@ -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 dautomatiser \
lInfoLan 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();
}
}