OnRconCommand - Not all commands are working -
#1

Only 2 of 5 commands work for me, what am i doing wrong? D:
pawn Код:
public OnRconCommand(cmd[])
{
    if(!strcmp(cmd, "cmds", true))
    {
        print("squads\ndisbandsquads\ndisbandsquad <squadid>");
        return 1;
    }
    else if(!strcmp(cmd, "squadlogging", true)) //WORKING
    {
        if(chatlogging)
        {
            chatlogging = 0;
            print("SQUADS: You've disabled squad information logging");
        }
        else
        {
            chatlogging = 1;
            print("SQUADS: You've enabled squad information logging");
        }
        return 1;
    }
    else if(!strcmp(cmd, "squads", true)) //WORKING
    {
        new
            amount[2],
            string[400],
            shortstr[90]
            //team = GetPlayerTeam(playerid)
        ;
        for(new x=0; x<MAX_SQUADS; x++)
        {
            if(squadinfo[x][active])
            {
                amount[0] ++;
                amount[1] ++;
                format(shortstr, sizeof(shortstr), "%s (id:%d, members:%d/%d)\n", squadinfo[x][sqname], x, squadinfo[x][sqmembers], squadinfo[x][sqmaxmembers]);
                if(amount[1] == 1)
                {
                    format(string, sizeof(string), "SQUADS: %s\n", shortstr);
                    //strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
                }
                if(amount[1] != 1)
                {
                    format(string, sizeof(string), "SQUADS: %s %s\n", string, shortstr);
                    //strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
                }
            }
            else
            {
                if(amount[1] == 1)
                {
                    format(string, sizeof(string), "SQUADS: %s\n", shortstr);
                    //strcat(string, "\n\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
                }
                if(amount[1] != 1)
                {
                    format(string, sizeof(string), "SQUADS: %s %s\n", string, shortstr);
                    //strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
                }
            }
            if(amount[0] == 4)
            {
                print(string);
                string = "";
                amount[0] = 0;
            }
        }
        if(amount[1] == 0) print("SQUADS: 0 active squads");
        if(amount[1] != 0) print(string);
       
        return 1;
    }
    else if(!strcmp(cmd, "disbandsquads", true))
    {
        new count = 0;
        foreach(Player, x)
        {
            if(squad[x][sid] != -1)
            {
                LeaveSquad(x, 5);
                count++;
            }
        }
        printf("NOTIFICATION: %d squads disbanded", count);
        return 1;
    }
    else if(!strcmp(cmd, "disbandsquad", true))
    {
        new targetsquad;
        //if(sscanf(cmd, "d", targetsquad)) return print("NOTIFICATION: /disbandsquad SquadID");
        if(isnull(cmd)) return print("NOTIFICATION: /disbandsquad SquadID");
        if(!squadinfo[targetsquad][active]) return printf("ERROR: squad '%d' does NOT exist", targetsquad);
        else
        {
            foreach(Player, x)
            {
                if(squad[x][sid] == targetsquad)
                {
                    LeaveSquad(x, 5);
                }
            }
        }
        return 1;
    }
    return 0;
}
Commands which work (incase you didn't notice)

"squads" and "squadlogging"
If it type the others, nothing happens.
Reply
#2

bump
Reply
#3

Add before and in each command a print statment and check the value of cmd (that is called debugging)
Also change the else if's into normal if statments, you don't need else if you are using return
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)