Envoi serveur libre si dernière personne quitte serveur

This commit is contained in:
rick 2021-05-22 13:32:23 +02:00
parent e451d2c8d6
commit 861caa7245
Signed by: Rick
GPG key ID: 2B593F087240EE99

View file

@ -1,4 +1,5 @@
#include <sourcemod> #include <sourcemod>
#include <sdktools>
#include <cstrike> #include <cstrike>
#include "socket.inc" #include "socket.inc"
@ -7,8 +8,8 @@
#define MY_SOCKET_PORT 3000 #define MY_SOCKET_PORT 3000
#define STEAMID_LENGTH 128 #define STEAMID_LENGTH 128
char teamCT[6][150]; char teamCT[5][150];
char teamT[6][150]; char teamT[5][150];
char clientId[128]; char clientId[128];
int port = -1; 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 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) public OnSocketDisconnected(Handle socket, any arg)
{ {
CloseHandle(socket); CloseHandle(socket);