AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] Need help re-creating sv_cheats "bot" command (https://forums.alliedmods.net/showthread.php?t=326518)

blacktr4sh 08-04-2020 03:08

[TF2] Need help re-creating sv_cheats "bot" command
 
Hello, I am trying to re-create most cheat commands so that they can be used without having to set sv_cheats to 1 and disabling achievements. Removing FCVAR_NOTIFY and FCVAR_REPLICATED from sv_cheats and toggling it will still disable achievements.

I am currently having trouble with the "bot" command. It uses "-team" or "-name" etc to determine the value for the argument and I am unsure on how to do that with SourcePawn.
So far I have this CommandListener:

If anyone can help or know an easier way, I would appreciate it. Thanks.

SSheriFF 08-04-2020 06:25

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
take a look at https://sm.alliedmods.net/new-api/console/GetCmdArg it might help you.

blacktr4sh 08-04-2020 15:11

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Quote:

Originally Posted by SSheriFF (Post 2712944)
take a look at https://sm.alliedmods.net/new-api/console/GetCmdArg it might help you.

Yes, I know of GetCmdArg but the issue is that it doesn't combine spaces. When using the command there could be multiple arguments that would be "-name Bot" or "-team blu".
GetCmdArg(1, sName, sizeof(sName)); will only get "-name". Thanks for trying to help.

SSheriFF 08-04-2020 15:24

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Quote:

Originally Posted by blacktr4sh (Post 2712995)
Yes, I know of GetCmdArg but the issue is that it doesn't combine spaces. When using the command there could be multiple arguments that would be "-name Bot" or "-team blu".
GetCmdArg(1, sName, sizeof(sName)); will only get "-name". Thanks for trying to help.

So use it like that: GetCmdArg(6, sName, sizeof(sName)); & GetCmdArg(2, sTeam, sizeof(sTeam)); each number constitutes the number of the argument after the command itself, so 1 is the first argument after the command, 2 is the second and so on...

blacktr4sh 08-04-2020 16:13

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Quote:

Originally Posted by SSheriFF (Post 2712998)
So use it like that: GetCmdArg(6, sName, sizeof(sName)); & GetCmdArg(2, sTeam, sizeof(sTeam)); each number constitutes the number of the argument after the command itself, so 1 is the first argument after the command, 2 is the second and so on...

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?

SSheriFF 08-04-2020 17:00

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Quote:

Originally Posted by blacktr4sh (Post 2713009)
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[] commandint 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<= ArgsNum;i++)
        {
            
GetCmdArg(isArg32);
            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(NameArgsName32);
            
iBot CreateFakeClient(sName);
           }
           if(
TeamArg!=0)
        {
            
GetCmdArg(TeamArgsTeam32);
            
TF2_ChangeClientTeam(iBotTF2_GetClientTeam(sTeam));
           }
           if(
ClassArg!=0)
        {
            
GetCmdArg(ClassArgsClass32);
            
//Do your stuff with the class using "sClass" as the class
           
}
    }
    return 
Plugin_Handled;



blacktr4sh 08-04-2020 17:20

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Quote:

Originally Posted by SSheriFF (Post 2713018)
PHP Code:

public Action OnCheatCommand(int client, const char[] commandint 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<= ArgsNum;i++)
        {
            
GetCmdArg(isArg32);
            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(NameArgsName32);
            
iBot CreateFakeClient(sName);
           }
           if(
TeamArg!=0)
        {
            
GetCmdArg(TeamArgsTeam32);
            
TF2_ChangeClientTeam(iBotTF2_GetClientTeam(sTeam));
           }
           if(
ClassArg!=0)
        {
            
GetCmdArg(ClassArgsClass32);
            
//Do your stuff with the class using "sClass" as the class
           
}
    }
    return 
Plugin_Handled;



Wow, thanks very much! I was also just experimenting with loops to try and get the values as well but you were quicker. I will test it out.

blacktr4sh 08-04-2020 18:27

Re: [TF2] Need help re-creating sv_cheats "bot" command
 
Btw, appearently an AI bot or puppet bot is a fake client but not the other way around? For example wasn't able to use bot_changeclass (removed FCVAR_CHEAT on the command) on the bot I created. "No bot with name Bot01".


All times are GMT -4. The time now is 16:39.

Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.