Whats Wrong With This?
#1

Hello,
I have a little problem here with the code /reports.
Here's my code.

pawn Код:
// New's
new reportcount = 0;
new reports[5][50];
new reportstring[100];
new reportstring1[100];
new reportstring2[100];
new reportstring3[100];
new reportstring4[100];
// Command
CMD:reports(playerid, params[])
{
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": You Are Not Authorized To Use This Command!");
    if(!strlen(reports[0])) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": There Have Been 0 Player Reports So Far!");
    for(new s; s < 5; s++)
    {
        if(strlen(reports[s]) != 0)
        {
            format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s][0]);
            SendClientMessage(playerid, -1, reportstring);
            format(reportstring1, sizeof(reportstring1), "REPORT: %s", reports[s][1]);
            SendClientMessage(playerid, -1, reportstring1);
            format(reportstring2, sizeof(reportstring2), "REPORT: %s", reports[s][2]);
            SendClientMessage(playerid, -1, reportstring2);
            format(reportstring3, sizeof(reportstring3), "REPORT: %s", reports[s][3]);
            SendClientMessage(playerid, -1, reportstring3);
            format(reportstring4, sizeof(reportstring4), "REPORT: %s", reports[s][4]);
            SendClientMessage(playerid, -1, reportstring4);
        }
    }
    return 1;
}
Whenever someone does /reports it spams something like ' aceeed: Littlehelper '
Help will be appreciated.
Thanks.
Reply
#2

Try changing your code with
pawn Код:
// New's
new reportcount = 0;
new reports[5][50];
new reportstring[128];
// Command
CMD:reports(playerid, params[])
{
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": You Are Not Authorized To Use This Command!");
    if(!strlen(reports[0])) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": There Have Been 0 Player Reports So Far!");

    for(new s; s < 5; s++)
        if(strlen(reports[s]) != 0)
            format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s]);

    return 1;
}
Reply
#3

using reports[s][0] will pick the string at the starting point [0]. to print the whole string, just remove the 2-dimensional [0]. the [s] is already done by the loop, you dont need to access all reports if just one string is existing:
pawn Код:
for(new s; s < 5; s++)
    {
        if(strlen(reports[s]) != 0)
        {
            format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s]);
            SendClientMessage(playerid, -1, reportstring);
        }
    }
oh, you can get rid of the other reportstring1, 2 etc...

edit: ah, its already postet above, iam 1 minute late lol
Reply
#4

I get it,
thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)