Selection équipes & commandes pour les assigner

This commit is contained in:
rick 2021-05-18 15:11:19 +02:00
parent 6b0d10ceac
commit ed264f096f
Signed by: Rick
GPG key ID: 2B593F087240EE99

91
test.sp
View file

@ -1,5 +1,7 @@
#include <sourcemod> #include <sourcemod>
#include <string> #include <clients>
#include <cstrike>
#include <sdktools>
#include "socket.inc" #include "socket.inc"
#define MY_SOCKET_IP "localhost" #define MY_SOCKET_IP "localhost"
@ -8,6 +10,8 @@
char teamCT[6][150]; char teamCT[6][150];
char teamT[6][150]; char teamT[6][150];
char authorised[20][128];
char clientId[128];
public Plugin myinfo = public Plugin myinfo =
{ {
@ -16,45 +20,68 @@ public Plugin myinfo =
description = "Bot communiquant avec le bot discord \ description = "Bot communiquant avec le bot discord \
https://github.com/Lunki51/cs-picker afin dautomatiser \ https://github.com/Lunki51/cs-picker afin dautomatiser \
lInfoLan 2021", lInfoLan 2021",
version = "1.0", version = "1.3",
url = "https://git.gnous.eu/Rick/infolanBot" url = "https://git.gnous.eu/Rick/infolanBot"
}; };
/* bool = GetClientAuthId() //public void OnClientAuthorized(int client, const char[] auth)
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
public void OnClientConnected(int client)
{ {
char clientId[65]; int client = GetClientOfUserId(event.GetInt("userid"));
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, PrintToServer("=============================");
sizeof(clientId), true); bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, sizeof(clientId));
PrintToServer("Mon ID : %s", clientId);
if (!strcmp(clientId, "BOT", false))
{
return ;
}
if (!allGood) if (!allGood)
{ {
PrintToServer("Erreur Fatale !"); PrintToServer("Erreur Fatale !");
} }
else else
{ {
PrintToServer("== ID OK ==");
allGood = false; allGood = false;
int i = 1; int i = 1;
while (!allGood && i < sizeof(teamCT)) while (!allGood && i < sizeof(teamCT))
{ {
if (teamCT[i] == clientId) if (!strcmp(teamCT[i], clientId, false))
{ {
CS_SwitchTeam(client, 3); ChangeClientTeam(client, CS_TEAM_CT);
CS_SetClientClanTag(client, teamCT[0]); CS_SetClientClanTag(client, teamCT[0]);
allGood = true; allGood = true;
PrintToServer("Team CT");
CS_RespawnPlayer(client);
} }
else if (teamT[i] == clientId) else if (!strcmp(teamT[i], clientId, false))
{ {
CS_SwitchTeam(client, 2); ChangeClientTeam(client, CS_TEAM_T);
CS_SetClientClanTag(client, teamT[0]); CS_SetClientClanTag(client, teamT[0]);
PrintToServer("Team T");
allGood = true; allGood = true;
CS_RespawnPlayer(client);
}
i++;
}
if (!allGood)
{
i = 0;
while (!allGood && i < sizeof(authorised))
{
PrintToServer(authorised[i]);
if (!strcmp(authorised[i], clientId, false))
{
allGood = true;
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
} }
i++; i++;
} }
if (!allGood) if (!allGood)
{ {
KickClient(client, "Vous nêtes pas autorisé à suivre / jouer \ KickClient(client, "Vous nêtes pas autorisé à suivre / jouer \
sur ce serveur !"); sur ce serveur");
}
// check si casteur ou admin // check si casteur ou admin
// sinon ban // sinon ban
} }
@ -74,19 +101,28 @@ public Action SetTeam(int args)
PrintToServer("Je reçois %d arguments qui sont : %s", args, full); PrintToServer("Je reçois %d arguments qui sont : %s", args, full);
GetCmdArg(1, arg, sizeof(arg)); GetCmdArg(1, arg, sizeof(arg));
int team = (!strcmp(arg, "ct", false) ? 1 : 2); int team = (!strcmp(arg, "ct", false) ? 1 : 2);
GetCmdArg(2, arg, sizeof(arg));
if (team == 1)
{
ServerCommand("mp_teamname_1 %s", arg)
}
else
{
ServerCommand("mp_teamname_2 %s", arg)
}
PrintToServer("L,équipe choisi est %d", team); PrintToServer("L,équipe choisi est %d", team);
if (args == 7) if (args == 7)
{ {
for(int i = 2; i <= args; i++) for(int i = 3; i <= args; i++)
{ {
GetCmdArg(i, arg, sizeof(arg)); GetCmdArg(i, arg, sizeof(arg));
if (team == 1) if (team == 1)
{ {
teamCT[i - 2] = arg; teamCT[i - 3] = arg;
} }
else else
{ {
teamT[i - 2] = arg; teamT[i - 3] = arg;
} }
PrintToServer("%d cest la demande %s", i - 2, arg); PrintToServer("%d cest la demande %s", i - 2, arg);
} }
@ -105,6 +141,7 @@ public void OnSocketReceive(Handle socket, const char[] datas, const int data, a
public void OnMapEnd() public void OnMapEnd()
{ {
PrintToServer("======= FIN ======");
/* kick tout le monde */ /* kick tout le monde */
} }
@ -126,6 +163,19 @@ public void OnSocketConnected(Handle socket, any arg)
SocketSend(socket, requestStr, 150); SocketSend(socket, requestStr, 150);
} }
public void SocketEnvoieVictoire(Handle socket, int t, int ct)
{
char requestStr[512];
FormatEx(
requestStr,
sizeof(requestStr),
"POST /api/csgo/matchend HTTP/1.0\r\n\
Host: Serveur\r\n\
Content-type: text/json\r\n\
{\"serverport\": XXXXXX, \"available\": \"true\"}"
)
}
public OnSocketDisconnected(Handle socket, any arg) public OnSocketDisconnected(Handle socket, any arg)
{ {
CloseHandle(socket); CloseHandle(socket);
@ -139,19 +189,20 @@ public void OnSocketError(Handle socket, const int errorType, const int errorNum
public void EnvoiInfo(Event event, const char[] name, bool dontBroadcast) public void EnvoiInfo(Event event, const char[] name, bool dontBroadcast)
{ {
//kick tout le monde
// requete post pour match fini et serveur libre
Handle socket = SocketCreate(SOCKET_TCP, OnSocketError); Handle socket = SocketCreate(SOCKET_TCP, OnSocketError);
SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT); //SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, MY_SOCKET_IP, MY_SOCKET_PORT);
} }
public void OnPluginStart() public void OnPluginStart()
{ {
/*cs_win_panel_match*/
HookEvent("cs_win_panel_match", EnvoiInfo); HookEvent("cs_win_panel_match", EnvoiInfo);
HookEvent("player_activate", SuperTest);
RegServerCmd("!team", SetTeam); RegServerCmd("!team", SetTeam);
PrintToServer("Hello world!"); PrintToServer("Hello world!");
PrintToServer("==== REQUETE ENVOYÉE ===="); PrintToServer("%d", sizeof(authorised));
} }