/report Bug
#1

On This Code:
pawn Код:
dcmd_report(playerid,params[])
{
    new reported;
    new tmp[256];
    new tmp2[256];
    new Index;
    tmp = strtok(params,Index);
    tmp2 = strtok(params,Index);
    if(!strlen(params)) return
    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /report [PlayerID] [Reason]") &&
    SendClientMessage(playerid, orange, "Attention: Not report anyone without Reason!");
    reported = strval(tmp);

    if(IsPlayerConnected(reported) && reported != INVALID_PLAYER_ID)
     {
        if(AccInfo[reported][Level] == ServerInfo[MaxAdminLevel])
        return SendClientMessage(playerid,red,"ERROR: You cannot report this Administrator");
        if(playerid == reported)
        return SendClientMessage(playerid,red,"ERROR: You Cannot report Yourself");
        if(strlen(params) > 7)
        {
            new reportedname[MAX_PLAYER_NAME], reporter[MAX_PLAYER_NAME], str[128];
            new hour,minute,second;
            gettime(hour,minute,second);
            GetPlayerName(reported, reportedname, sizeof(reportedname));
            GetPlayerName(playerid, reporter, sizeof(reporter));
            format(str, sizeof(str), "REPORT: %s(Id:%d) Reported %s(Id:%d) Reason: %s |Time: %d:%d:%d|", reporter,playerid, reportedname, reported, params[strlen(tmp)+1], hour,minute,second);
            MessageToAdmins(COLOR_WHITE,str);
            SaveIn("ReportLog",str);
            format(str, sizeof(str), "(%d:%d:%d): %s(Id:%d) Reported %s(Id:%d) Reason: %s", hour,minute,second, reporter,playerid, reportedname, reported, params[strlen(tmp)+1]);
            for(new i = 1; i < MAX_REPORTS-1; i++) Reports[i] = Reports[i+1];
            Reports[MAX_REPORTS-1] = str;
            return SendClientMessage(playerid,yellow, "|- Your report has been sent to Online Administrators and saved in File! -|");
        }
        else return SendClientMessage(playerid,red,"ERROR: Invalid Reason!");
    }
    else return ErrorMessages(playerid, 2);
}
The Problem Is When Typing /report Without ID It Shows That The Player Reported The Player Whose ID Is 0,Please Fix For Me This Problem.
Reply
#2

you should use sscanf, it's much easier; lol.

there are barely players left using strtok or anything like that, therefor there's nearly nobody who can help you as they don't know how it works because they use sscanf.

strtok is only used in old scripts.

you can find sscanf here:
https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#3

This CMD is from LuxAdmin So,its hard for me to make sscanf,can you do it for me and you get +REP?
Reply
#4

Quote:
Originally Posted by Youssef214
Посмотреть сообщение
This CMD is from LuxAdmin So,its hard for me to make sscanf,can you do it for me and you get +REP?
if it's from luxadmin then I'm pretty sure the command should work just fine.

did you edit it or anything?
Reply
#5

no i didn't edit it
Reply
#6

any help?
Reply
#7

pawn Код:
dcmd_report(playerid,params[])
{
    new tmp[128], idx = 0;
    strcat(tmp,strtok(params,idx),5);
    if(!('0' <= tmp[0] <= '9'))
    {
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /report [PlayerID] [Reason]");
        return SendClientMessage(playerid, orange, "Attention: Not report anyone without Reason!");
    }

    new reported = strval(tmp);

    if(IsPlayerConnected(reported))
    {
        if(playerid == reported) return SendClientMessage(playerid,red,"ERROR: You Cannot report Yourself");
        if(AccInfo[reported][Level] == ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot report this Administrator");
        strcat((tmp[0]='\0',tmp),strtok(params,idx)); // reason
        if(strlen(tmp) > 7)
        {
            new reportedname[MAX_PLAYER_NAME], reporter[MAX_PLAYER_NAME], str[128];
            new hour,minute,second;
            gettime(hour,minute,second);
            GetPlayerName(reported, reportedname, sizeof(reportedname));
            GetPlayerName(playerid, reporter, sizeof(reporter));
            format(str, sizeof(str), "REPORT: %s(Id:%d) Reported %s(Id:%d) Reason: %s |Time: %d:%d:%d|", reporter,playerid, reportedname, reported, tmp, hour,minute,second);
            MessageToAdmins(COLOR_WHITE,str);
            SaveIn("ReportLog",str);
            format(str, sizeof(str), "(%d:%d:%d): %s(Id:%d) Reported %s(Id:%d) Reason: %s", hour,minute,second, reporter,playerid, reportedname, reported, tmp);
            for(new i = 1; i < MAX_REPORTS; i++)
                Reports[i - 1] = Reports[i];

            Reports[MAX_REPORTS-1] = str;
            SendClientMessage(playerid,yellow, "|- Your report has been sent to Online Administrators and saved in File! -|");
        }
        else SendClientMessage(playerid,red,"ERROR: Invalid Reason!");
    }
    else ErrorMessages(playerid, 2);
    return 1;
}
Reply
#8

Thanks That Helped!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)