SA-MP Forums Archive
/report Bug - 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: /report Bug (/showthread.php?tid=511483)



/report Bug - Youssef214 - 05.05.2014

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.


Re: /report Bug - Smileys - 05.05.2014

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


Re: /report Bug - Youssef214 - 05.05.2014

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


Re: /report Bug - Smileys - 05.05.2014

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?


Re: /report Bug - Youssef214 - 05.05.2014

no i didn't edit it


Re: /report Bug - Youssef214 - 05.05.2014

any help?


Re: /report Bug - Jefff - 05.05.2014

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;
}



Re: /report Bug - Youssef214 - 06.05.2014

Thanks That Helped!