diff --git a/test.sp b/test.sp index d6b9833..0960260 100644 --- a/test.sp +++ b/test.sp @@ -1,8 +1,13 @@ #include +#include #include "socket.inc" #define MY_SOCKET_IP "localhost" #define MY_SOCKET_PORT 3500 +#define STEAMID_LENGTH 128 + +char teamCT[6][150]; +char teamT[6][150]; public Plugin myinfo = { @@ -15,16 +20,80 @@ public Plugin myinfo = url = "https://git.gnous.eu/Rick/infolanBot" }; -public Action TestCommand(int args) +/* bool = GetClientAuthId() + +public void OnClientConnected(int client) +{ + char clientId[65]; + bool allGood = GetClientAuthId(client, AuthId_SteamID64, clientId, + sizeof(clientId), true); + if (!allGood) + { + PrintToServer("Erreur Fatale !"); + } + else + { + allGood = false; + int i = 1; + while (!allGood && i < sizeof(teamCT)) + { + if (teamCT[i] == clientId) + { + CS_SwitchTeam(client, 3); + CS_SetClientClanTag(client, teamCT[0]); + allGood = true; + } + else if (teamT[i] == clientId) + { + CS_SwitchTeam(client, 2); + CS_SetClientClanTag(client, teamT[0]); + allGood = true; + } + i++; + } + if (!allGood) + { + KickClient(client, "Vous n’êtes pas autorisé à suivre / jouer \ + sur ce serveur !"); + // check si casteur ou admin + // sinon ban + } + } +} + +/* + * !team + * + * + */ +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); - for(int i = 1; i < args; i++) + GetCmdArg(1, arg, sizeof(arg)); + int team = (!strcmp(arg, "ct", false) ? 1 : 2); + PrintToServer("L,équipe choisi est %d", team); + if (args == 7) { - GetCmdArg(i, arg, sizeof(arg)); - PrintToServer("%d c’est la demande %s", i, arg); + for(int i = 2; i <= args; i++) + { + GetCmdArg(i, arg, sizeof(arg)); + if (team == 1) + { + teamCT[i - 2] = arg; + } + else + { + teamT[i - 2] = arg; + } + PrintToServer("%d c’est la demande %s", i - 2, arg); + } + } + else + { + PrintToServer("Erreur, pas assez d’args"); } return Plugin_Handled; @@ -37,7 +106,6 @@ public void OnSocketReceive(Handle socket, const char[] datas, const int data, a public void OnMapEnd() { /* kick tout le monde */ - PrintToServer("This is zi end ================"); } public void OnSocketConnected(Handle socket, any arg) @@ -82,7 +150,7 @@ public void OnPluginStart() HookEvent("cs_win_panel_match", EnvoiInfo); - RegServerCmd("!test", TestCommand); + RegServerCmd("!team", SetTeam); PrintToServer("Hello world!"); PrintToServer("==== REQUETE ENVOYÉE ====");