Quote:
Originally Posted by blacktr4sh
Hmm okay, but I think it might be too repetitive. The first argument isn't always "-team blue", it could also be "-name Bot" or "-class Scout", same with any other argument. So I would have to check every time I get the argument. Is there a simpler way you know of or is that the only way it could be done?
|
PHP Code:
public Action OnCheatCommand(int client, const char[] command, int argc)
{
if (StrEqual(command, "bot"))
{
int iBot;
char sName[32];
int NameArg = 0;
char sArg[32];
char sTeam[32];
int TeamArg = 0;
char sClass[32];
int ClassArg = 0;
int ArgsNum = GetCmdArgs();
for (int i = 1; i <= ArgsNum;i++)
{
GetCmdArg(i, sArg, 32);
if (strcmp(sArg, "-name") == 0)
NameArg = (i+1);
if (strcmp(sArg, "-team") == 0)
TeamArg = (i+1);
if (strcmp(sArg, "-class") == 0)
ClassArg = (i+1);
}
if(NameArg!=0)
{
GetCmdArg(NameArg, sName, 32);
iBot = CreateFakeClient(sName);
}
if(TeamArg!=0)
{
GetCmdArg(TeamArg, sTeam, 32);
TF2_ChangeClientTeam(iBot, TF2_GetClientTeam(sTeam));
}
if(ClassArg!=0)
{
GetCmdArg(ClassArg, sClass, 32);
//Do your stuff with the class using "sClass" as the class
}
}
return Plugin_Handled;
}
__________________