update(commande team): avertissement si pas assez ou trop d’arguments & log

check issue #7
This commit is contained in:
rick 2021-06-03 14:56:12 +02:00
parent 5bfc39ef9c
commit b29d437882
Signed by: Rick
GPG key ID: 2B593F087240EE99

View file

@ -127,6 +127,12 @@ public void SetTeamPlayer(Event event, const char[] name, bool dontBroadcast)
*/ */
public Action SetTeam(int args) public Action SetTeam(int args)
{ {
char tmp[2058];
GetCmdArgString(tmp, 2058);
LogMessage("Commande !team reçu: %s", tmp);
if (args != 7)
LogMessage("!team: pas assez ou trop darguments données.");
char arg[128]; char arg[128];
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);
@ -136,9 +142,8 @@ public Action SetTeam(int args)
else else
ServerCommand("mp_teamname_2 %s", arg) ServerCommand("mp_teamname_2 %s", arg)
if (args == 7) /* on garde 7 pour éviter de mettre + de 5 personnes / équipe */
{ for(int i = 3; i <= 7 && 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)
@ -146,11 +151,6 @@ public Action SetTeam(int args)
else else
teamT[i - 3] = arg; teamT[i - 3] = arg;
} }
}
else
{
PrintToServer("Erreur, pas assez dargs");
}
return Plugin_Handled; return Plugin_Handled;
} }