Envoi serveur libre si dernière personne quitte serveur
This commit is contained in:
parent
e451d2c8d6
commit
861caa7245
1 changed files with 14 additions and 2 deletions
16
infolan.sp
16
infolan.sp
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue