Restructuration du code
This commit is contained in:
parent
ed264f096f
commit
850d847096
1 changed files with 36 additions and 58 deletions
94
test.sp
94
test.sp
|
@ -24,22 +24,23 @@ public Plugin myinfo =
|
||||||
url = "https://git.gnous.eu/Rick/infolanBot"
|
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 OnClientAuthorized(int client, const char[] auth)
|
||||||
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
|
public void SuperTest(Event event, const char[] name, bool dontBroadcast)
|
||||||
{
|
{
|
||||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
PrintToServer("=============================");
|
|
||||||
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, sizeof(clientId));
|
bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, sizeof(clientId));
|
||||||
PrintToServer("Mon ID : %s", clientId);
|
if (allGood)
|
||||||
if (!strcmp(clientId, "BOT", false))
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if (!allGood)
|
|
||||||
{
|
|
||||||
PrintToServer("Erreur Fatale !");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
PrintToServer("== ID OK ==");
|
PrintToServer("== ID OK ==");
|
||||||
allGood = false;
|
allGood = false;
|
||||||
|
@ -49,18 +50,12 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
|
||||||
if (!strcmp(teamCT[i], clientId, false))
|
if (!strcmp(teamCT[i], clientId, false))
|
||||||
{
|
{
|
||||||
ChangeClientTeam(client, CS_TEAM_CT);
|
ChangeClientTeam(client, CS_TEAM_CT);
|
||||||
CS_SetClientClanTag(client, teamCT[0]);
|
|
||||||
allGood = true;
|
allGood = true;
|
||||||
PrintToServer("Team CT");
|
|
||||||
CS_RespawnPlayer(client);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(teamT[i], clientId, false))
|
else if (!strcmp(teamT[i], clientId, false))
|
||||||
{
|
{
|
||||||
ChangeClientTeam(client, CS_TEAM_T);
|
ChangeClientTeam(client, CS_TEAM_T);
|
||||||
CS_SetClientClanTag(client, teamT[0]);
|
|
||||||
PrintToServer("Team T");
|
|
||||||
allGood = true;
|
allGood = true;
|
||||||
CS_RespawnPlayer(client);
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +64,6 @@ public void SuperTest(Event event, const char[] name, bool dontBroadcast)
|
||||||
i = 0;
|
i = 0;
|
||||||
while (!allGood && i < sizeof(authorised))
|
while (!allGood && i < sizeof(authorised))
|
||||||
{
|
{
|
||||||
PrintToServer(authorised[i]);
|
|
||||||
if (!strcmp(authorised[i], clientId, false))
|
if (!strcmp(authorised[i], clientId, false))
|
||||||
{
|
{
|
||||||
allGood = true;
|
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 \
|
KickClient(client, "Vous n’êtes pas autorisé à suivre / jouer \
|
||||||
sur ce serveur");
|
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)
|
public Action SetTeam(int args)
|
||||||
{
|
{
|
||||||
char arg[128];
|
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));
|
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));
|
GetCmdArg(2, arg, sizeof(arg));
|
||||||
|
@ -110,7 +99,6 @@ public Action SetTeam(int args)
|
||||||
{
|
{
|
||||||
ServerCommand("mp_teamname_2 %s", arg)
|
ServerCommand("mp_teamname_2 %s", arg)
|
||||||
}
|
}
|
||||||
PrintToServer("L,équipe choisi est %d", team);
|
|
||||||
if (args == 7)
|
if (args == 7)
|
||||||
{
|
{
|
||||||
for(int i = 3; i <= args; i++)
|
for(int i = 3; i <= args; i++)
|
||||||
|
@ -124,7 +112,6 @@ public Action SetTeam(int args)
|
||||||
{
|
{
|
||||||
teamT[i - 3] = arg;
|
teamT[i - 3] = arg;
|
||||||
}
|
}
|
||||||
PrintToServer("%d c’est la demande %s", i - 2, arg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -135,8 +122,6 @@ public Action SetTeam(int args)
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {}
|
|
||||||
|
|
||||||
/* envoie information plugin */
|
/* envoie information plugin */
|
||||||
|
|
||||||
public void OnMapEnd()
|
public void OnMapEnd()
|
||||||
|
@ -145,6 +130,29 @@ public void OnMapEnd()
|
||||||
/* kick tout le monde */
|
/* 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)
|
public void OnSocketConnected(Handle socket, any arg)
|
||||||
{
|
{
|
||||||
char requestStr[150];
|
char requestStr[150];
|
||||||
|
@ -163,18 +171,7 @@ public void OnSocketConnected(Handle socket, any arg)
|
||||||
SocketSend(socket, requestStr, 150);
|
SocketSend(socket, requestStr, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SocketEnvoieVictoire(Handle socket, int t, int ct)
|
public void OnSocketReceive(Handle socket, const char[] datas, const int data, any arg) {}
|
||||||
{
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -187,22 +184,3 @@ public void OnSocketError(Handle socket, const int errorType, const int errorNum
|
||||||
CloseHandle(socket);
|
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));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue