Selection équipes & commandes pour les assigner
This commit is contained in:
parent
6b0d10ceac
commit
ed264f096f
1 changed files with 72 additions and 21 deletions
91
test.sp
91
test.sp
|
@ -1,5 +1,7 @@
|
|||
#include <sourcemod>
|
||||
#include <string>
|
||||
#include <clients>
|
||||
#include <cstrike>
|
||||
#include <sdktools>
|
||||
#include "socket.inc"
|
||||
|
||||
#define MY_SOCKET_IP "localhost"
|
||||
|
@ -8,6 +10,8 @@
|
|||
|
||||
char teamCT[6][150];
|
||||
char teamT[6][150];
|
||||
char authorised[20][128];
|
||||
char clientId[128];
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
|
@ -16,45 +20,68 @@ public Plugin myinfo =
|
|||
description = "Bot communiquant avec le bot discord \
|
||||
https://github.com/Lunki51/cs-picker afin d’automatiser \
|
||||
l’InfoLan 2021",
|
||||
version = "1.0",
|
||||
version = "1.3",
|
||||
url = "https://git.gnous.eu/Rick/infolanBot"
|
||||
};
|
||||
|
||||
/* bool = GetClientAuthId()
|
||||
|
||||
public void OnClientConnected(int client)
|
||||
//public void OnClientAuthorized(int client, const char[] auth)
|
||||
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
char clientId[65];
|
||||
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId,
|
||||
sizeof(clientId), true);
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
PrintToServer("=============================");
|
||||
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, sizeof(clientId));
|
||||
PrintToServer("Mon ID : %s", clientId);
|
||||
if (!strcmp(clientId, "BOT", false))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (!allGood)
|
||||
{
|
||||
PrintToServer("Erreur Fatale !");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintToServer("== ID OK ==");
|
||||
allGood = false;
|
||||
int i = 1;
|
||||
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]);
|
||||
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]);
|
||||
PrintToServer("Team T");
|
||||
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++;
|
||||
}
|
||||
if (!allGood)
|
||||
{
|
||||
KickClient(client, "Vous n’êtes pas autorisé à suivre / jouer \
|
||||
sur ce serveur !");
|
||||
sur ce serveur");
|
||||
}
|
||||
// check si casteur ou admin
|
||||
// sinon ban
|
||||
}
|
||||
|
@ -74,19 +101,28 @@ public Action SetTeam(int args)
|
|||
PrintToServer("Je reçois %d arguments qui sont : %s", args, full);
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
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);
|
||||
if (args == 7)
|
||||
{
|
||||
for(int i = 2; i <= args; i++)
|
||||
for(int i = 3; i <= args; i++)
|
||||
{
|
||||
GetCmdArg(i, arg, sizeof(arg));
|
||||
if (team == 1)
|
||||
{
|
||||
teamCT[i - 2] = arg;
|
||||
teamCT[i - 3] = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
teamT[i - 2] = arg;
|
||||
teamT[i - 3] = arg;
|
||||
}
|
||||
PrintToServer("%d c’est 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()
|
||||
{
|
||||
PrintToServer("======= FIN ======");
|
||||
/* kick tout le monde */
|
||||
}
|
||||
|
||||
|
@ -126,6 +163,19 @@ public void OnSocketConnected(Handle socket, any arg)
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
//kick tout le monde
|
||||
// requete post pour match fini et serveur libre
|
||||
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()
|
||||
{
|
||||
/*cs_win_panel_match*/
|
||||
|
||||
HookEvent("cs_win_panel_match", EnvoiInfo);
|
||||
HookEvent("player_activate", SuperTest);
|
||||
|
||||
RegServerCmd("!team", SetTeam);
|
||||
|
||||
PrintToServer("Hello world!");
|
||||
PrintToServer("==== REQUETE ENVOYÉE ====");
|
||||
PrintToServer("%d", sizeof(authorised));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue