Raised This Month: $12 Target: $400
 3% 

Solved [TF2] Need help re-creating sv_cheats "bot" command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blacktr4sh
Junior Member
Join Date: Apr 2020
Old 08-04-2020 , 03:08   [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #1

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.

Last edited by blacktr4sh; 08-04-2020 at 17:37.
blacktr4sh is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 08-04-2020 , 06:25   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #2

take a look at https://sm.alliedmods.net/new-api/console/GetCmdArg it might help you.
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
blacktr4sh
Junior Member
Join Date: Apr 2020
Old 08-04-2020 , 15:11   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #3

Quote:
Originally Posted by SSheriFF View Post
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.

Last edited by blacktr4sh; 08-04-2020 at 15:14.
blacktr4sh is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 08-04-2020 , 15:24   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #4

Quote:
Originally Posted by blacktr4sh View Post
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...
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:

Last edited by SSheriFF; 08-04-2020 at 16:05.
SSheriFF is offline
blacktr4sh
Junior Member
Join Date: Apr 2020
Old 08-04-2020 , 16:13   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #5

Quote:
Originally Posted by SSheriFF View Post
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?

Last edited by blacktr4sh; 08-04-2020 at 16:26.
blacktr4sh is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 08-04-2020 , 17:00   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #6

Quote:
Originally Posted by blacktr4sh View Post
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;

__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
blacktr4sh
Junior Member
Join Date: Apr 2020
Old 08-04-2020 , 17:20   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #7

Quote:
Originally Posted by SSheriFF View Post
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 is offline
blacktr4sh
Junior Member
Join Date: Apr 2020
Old 08-04-2020 , 18:27   Re: [TF2] Need help re-creating sv_cheats "bot" command
Reply With Quote #8

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".

Last edited by blacktr4sh; 08-04-2020 at 18:28.
blacktr4sh is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode