Message envoyé quand tous les joueurs sont partis + reset tableaux équipes
This commit is contained in:
parent
861caa7245
commit
5a8db4a010
1 changed files with 13 additions and 5 deletions
18
infolan.sp
18
infolan.sp
|
@ -13,6 +13,7 @@ char teamT[5][150];
|
||||||
char clientId[128];
|
char clientId[128];
|
||||||
|
|
||||||
int port = -1;
|
int port = -1;
|
||||||
|
bool needReset; /* pour éviter le kick lors des connexions post veille */
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
|
@ -21,7 +22,7 @@ public Plugin myinfo =
|
||||||
description = "Bot communiquant avec le bot discord \
|
description = "Bot communiquant avec le bot discord \
|
||||||
https://github.com/Lunki51/cs-picker afin d’automatiser \
|
https://github.com/Lunki51/cs-picker afin d’automatiser \
|
||||||
l’InfoLan 2021",
|
l’InfoLan 2021",
|
||||||
version = "1.1",
|
version = "1.4",
|
||||||
url = "https://git.gnous.eu/Rick/infolanBot"
|
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);
|
ChangeClientTeam(client, CS_TEAM_CT);
|
||||||
allGood = true;
|
allGood = true;
|
||||||
|
needReset = true;
|
||||||
}
|
}
|
||||||
else if (!strcmp(teamT[i], clientId, false))
|
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 \
|
KickClient(client, "Vous n’êtes pas autorisé à suivre / jouer \
|
||||||
sur ce serveur");
|
sur ce serveur");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
CS_RespawnPlayer(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,7 @@ public Action SetTeam(int args)
|
||||||
else
|
else
|
||||||
teamT[i - 3] = arg;
|
teamT[i - 3] = arg;
|
||||||
}
|
}
|
||||||
|
needReset = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -126,12 +131,16 @@ public void OnMapEnd()
|
||||||
{
|
{
|
||||||
// TODO kick tout le monde
|
// TODO kick tout le monde
|
||||||
PrintToServer("======= FIN ======");
|
PrintToServer("======= FIN ======");
|
||||||
ServeurLibre();
|
|
||||||
/* kick tout le monde */
|
/* kick tout le monde */
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ServeurLibre()
|
public void ServeurLibre()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < sizeof(teamCT); i++)
|
||||||
|
{
|
||||||
|
teamCT[i] = "";
|
||||||
|
teamT[i] = "";
|
||||||
|
}
|
||||||
// requete post pour match fini et serveur libre
|
// requete post pour match fini et serveur libre
|
||||||
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
|
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
|
||||||
SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
|
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)
|
int nbClient = GetTeamClientCount(CS_TEAM_SPECTATOR)
|
||||||
+ GetTeamClientCount(CS_TEAM_CT) + GetTeamClientCount(CS_TEAM_T);
|
+ GetTeamClientCount(CS_TEAM_CT) + GetTeamClientCount(CS_TEAM_T);
|
||||||
if (nbClient == 1)
|
if (nbClient == 1 && needReset)
|
||||||
{
|
{
|
||||||
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
|
ServeurLibre();
|
||||||
SocketConnect(socket, SocketEnvoieVictoire, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue