SA-MP Forums Archive
OnRconCommand - Not all commands are working - - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnRconCommand - Not all commands are working - (/showthread.php?tid=508341)



OnRconCommand - Not all commands are working - - Kyance - 21.04.2014

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.


Re: OnRconCommand - Not all commands are working - - Kyance - 23.04.2014

bump


AW: OnRconCommand - Not all commands are working - - Nero_3D - 24.04.2014

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