Restructuration du code

This commit is contained in:
rick 2021-05-18 15:43:05 +02:00
parent ed264f096f
commit 850d847096
Signed by: Rick
GPG key ID: 2B593F087240EE99

94
test.sp
View file

@ -24,22 +24,23 @@ public Plugin myinfo =
url = "https://git.gnous.eu/Rick/infolanBot"
};
public void OnPluginStart()
{
HookEvent("cs_win_panel_match", ServeurLibre);
HookEvent("player_activate", SuperTest);
RegServerCmd("!team", SetTeam);
PrintToServer("Hello world!");
PrintToServer("%d", sizeof(authorised));
}
//public void OnClientAuthorized(int client, const char[] auth)
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
{
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
if (allGood)
{
PrintToServer("== ID OK ==");
allGood = false;
@ -49,18 +50,12 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
if (!strcmp(teamCT[i], clientId, false))
{
ChangeClientTeam(client, CS_TEAM_CT);
CS_SetClientClanTag(client, teamCT[0]);
allGood = true;
PrintToServer("Team CT");
CS_RespawnPlayer(client);
}
else if (!strcmp(teamT[i], clientId, false))
{
ChangeClientTeam(client, CS_TEAM_T);
CS_SetClientClanTag(client, teamT[0]);
PrintToServer("Team T");
allGood = true;
CS_RespawnPlayer(client);
}
i++;
}
@ -69,7 +64,6 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
i = 0;
while (!allGood && i < sizeof(authorised))
{
PrintToServer(authorised[i]);
if (!strcmp(authorised[i], clientId, false))
{
allGood = true;
@ -82,8 +76,6 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
KickClient(client, "Vous nêtes pas autorisé à suivre / jouer \
sur ce serveur");
}
// check si casteur ou admin
// sinon ban
}
}
}
@ -96,9 +88,6 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
public Action SetTeam(int args)
{
char arg[128];
char full[256];
GetCmdArgString(full, sizeof(full));
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));
@ -110,7 +99,6 @@ public Action SetTeam(int args)
{
ServerCommand("mp_teamname_2 %s", arg)
}
PrintToServer("L,équipe choisi est %d", team);
if (args == 7)
{
for(int i = 3; i <= args; i++)
@ -124,7 +112,6 @@ public Action SetTeam(int args)
{
teamT[i - 3] = arg;
}
PrintToServer("%d cest la demande %s", i - 2, arg);
}
}
else
@ -135,8 +122,6 @@ public Action SetTeam(int args)
return Plugin_Handled;
}
public void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {}
/* envoie information plugin */
public void OnMapEnd()
@ -145,6 +130,29 @@ public void OnMapEnd()
/* kick tout le monde */
}
public void ServeurLibre(Event event, const char[] name, bool dontBroadcast)
{
// 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);
}
public void SocketUpdateScore(Handle socket, int t, int ct) {}
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 void OnSocketConnected(Handle socket, any arg)
{
char requestStr[150];
@ -163,18 +171,7 @@ 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 void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {}
public OnSocketDisconnected(Handle socket, any arg)
{
@ -187,22 +184,3 @@ public void OnSocketError(Handle socket, const int errorType, const int errorNum
CloseHandle(socket);
}
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);
}
public void OnPluginStart()
{
HookEvent("cs_win_panel_match", EnvoiInfo);
HookEvent("player_activate", SuperTest);
RegServerCmd("!team", SetTeam);
PrintToServer("Hello world!");
PrintToServer("%d", sizeof(authorised));
}