Help with this please ?
#1

I have an bug in this command or some.
if i accept an report or accept an help from community advisors the server crash and restarts.

pawn Код:
CMD:report(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2 && PlayerInfo[playerid][pAdmin] < 1338)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You can't submit reports as an administrator.");
        return 1;
    }
    if(PlayerInfo[playerid][pRMuted] != 0)
    {
        ShowPlayerDialog(playerid,7955,DIALOG_STYLE_MSGBOX,"Report blocked","You are blocked from submitting any reports!\n\nTips when reporting:\n- Report what you need, not who you need.\n- Be specific, report exactly what you need.\n- Do not make false reports.\n- Do not flame admins.\n- Report only for in-game items.\n- For shop orders use the /shoporder command","Close", "");
        return 1;
    }
    if(JustReported[playerid] > 0)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "Wait 25 seconds before sending another report!");
        return 1;
    }

    if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /report [text]");

    JustReported[playerid]=25;
    SendReportToQue(playerid, params);
    SendClientMessageEx(playerid, COLOR_YELLOW, "Your report message was sent to the Admins.");
    return 1;
}
pawn Код:
CMD:reports(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new reportdialog[1000], itemid = 0;
        for(new i = 0; i < MAX_REPORTS; i++)
        {
            if(Reports[i][BeingUsed] == 1 && itemid < 40)
            {
                ListItemReportId[playerid][itemid] = i;
                itemid++;
                format(reportdialog, sizeof(reportdialog), "%s%s(ID:%i) | RID:%i | Report: %s", reportdialog, GetPlayerNameEx(Reports[i][ReportFrom]), Reports[i][ReportFrom], i, (Reports[i][Report]), Reports[i][TimeToExpire]);
                format(reportdialog, sizeof(reportdialog), "%s\n", reportdialog);
            }
        }
        CancelReport[playerid] = itemid;
        format(reportdialog, sizeof(reportdialog), "%s\n", reportdialog);
        format(reportdialog, sizeof(reportdialog), "%sCancel Reports", reportdialog);
        ShowPlayerDialog(playerid, REPORTSMENU, DIALOG_STYLE_LIST, "Reports", reportdialog, "Accept", "Trash");
    }
    return 1;
}
pawn Код:
stock SendReportToQue(reportfrom, report[])
{
    new bool:breakingloop = false, newid = INVALID_REPORT_ID;

    for(new i=0;i<MAX_REPORTS;i++)
    {
        if(!breakingloop)
        {
            if(Reports[i][HasBeenUsed] == 0)
            {
                breakingloop = true;
                newid = i;
            }
        }
    }
pawn Код:
CMD:ar(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], reportid;
        if(sscanf(params, "d", reportid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ar [reportid]");

        if(reportid < 0 || reportid > 999) { SendClientMessageEx(playerid, COLOR_GREY, "   Report ID not below 0 or above 999!"); return 1; }
        if(Reports[reportid][BeingUsed] == 0)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "   That report ID is not being used!");
            return 1;
        }
        if(!IsPlayerConnected(Reports[reportid][ReportFrom]))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "   The reporter has disconnected !");
            Reports[reportid][ReportFrom] = 999;
            Reports[reportid][BeingUsed] = 0;
            return 1;
        }
        format(string, sizeof(string), "AdmCmd: %s has accepted the report from %s (ID: %i, RID: %i).", GetPlayerNameEx(playerid), GetPlayerNameEx(Reports[reportid][ReportFrom]),Reports[reportid][ReportFrom],reportid);
        ABroadCast(COLOR_ORANGE, string, 2);
        AddReportToken(playerid); // Report Tokens
        format(string, sizeof(string), "%s has accepted your report and is reviewing it, you can /reply to send messages to the admin reviewing your report.", GetPlayerNameEx(playerid));
        SendClientMessageEx(Reports[reportid][ReportFrom], COLOR_WHITE, string);
        PlayerInfo[playerid][pAcceptReport]++;
        Reports[reportid][ReplyTimerr] = SetTimerEx("ReplyTimer", 30000, 0, "d", reportid);
        Reports[reportid][CheckingReport] = playerid;
        Reports[reportid][BeingUsed] = 0;
        Reports[reportid][TimeToExpire] = 0;
        strmid(Reports[reportid][Report], "None", 0, 4, 4);
    }
    return 1;
}
pawn Код:
// AddReportToken Function (playerid)
public AddReportToken(playerid) {
    new
        sz_FileStr[32 + MAX_PLAYER_NAME],
        sz_playerName[MAX_PLAYER_NAME],
        i_timestamp[3],
        File: fPointer;

    GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
    getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);

    format(sz_FileStr, sizeof(sz_FileStr), "admins/rtokens/%s[%d'%d'%d]", sz_playerName, i_timestamp[1], i_timestamp[2], i_timestamp[0]);
    if(fexist(sz_FileStr))
    {
        fPointer = fopen(sz_FileStr, io_read);
        fread(fPointer, sz_playerName), fclose(fPointer);

        new
            i_tokenVal = strval(sz_playerName);

        format(sz_playerName, sizeof(sz_playerName), "%i", i_tokenVal + 1);
        fPointer = fopen(sz_FileStr, io_write);
        fwrite(fPointer, sz_playerName);
        fclose(fPointer);
    }
    else {
        fPointer = fopen(sz_FileStr, io_write);
        fwrite(fPointer, "1");
    }
    return fclose(fPointer);
}

// AddCAReportToken Function (playerid)
public AddCAReportToken(playerid) {

    new
        sz_FileStr[32 + MAX_PLAYER_NAME],
        sz_playerName[MAX_PLAYER_NAME],
        i_timestamp[3],
        File: fPointer;

    GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
    getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);

    format(sz_FileStr, sizeof(sz_FileStr), "admins/catokens/%s[%d'%d'%d]", sz_playerName, i_timestamp[1], i_timestamp[2], i_timestamp[0]);
    if(fexist(sz_FileStr))
    {
        fPointer = fopen(sz_FileStr, io_read);
        fread(fPointer, sz_playerName), fclose(fPointer);

        new
            i_tokenVal = strval(sz_playerName);

        format(sz_playerName, sizeof(sz_playerName), "%i", i_tokenVal + 1);
        fPointer = fopen(sz_FileStr, io_write);
        fwrite(fPointer, sz_playerName);
        fclose(fPointer);
    }
    else {
        fPointer = fopen(sz_FileStr, io_write);
        fwrite(fPointer, "1");
    }
    return fclose(fPointer);
}

// SeeReportToken (playerid, name[], month, day, year)
public SeeReportToken(playerid,name[],month,day,year)
{
    new string[128], rtoken;
    new strFromFile[128];
    format(string,sizeof(string),"admins/rtokens/%s[%d'%d'%d]",name,month,day,year);
    if(fexist(string))
    {
        new File: file = fopen(string, io_read);
        if(file)
        {
            fread(file, strFromFile);
            fclose(file);

            rtoken = strval(strFromFile);
            format(string,sizeof(string),"Admin has %d report tokens on [%d/%d/%d].",rtoken,month,day,year);
            SendClientMessageEx(playerid, COLOR_YELLOW, string);
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_YELLOW, "Admin does not have any logged report tokens for this date.");
        return 0;
    }
    return 1;
}

// SeeCAReportToken (playerid, name[], month, day, year)
public SeeCAReportToken(playerid,name[],month,day,year)
{
    new string[128], rtoken;
    new strFromFile[128];
    format(string,sizeof(string),"admins/catokens/%s[%d'%d'%d]",name,month,day,year);
    if(fexist(string))
    {
        new File: file = fopen(string, io_read);
        if(file)
        {
            fread(file, strFromFile);
            fclose(file);

            rtoken = strval(strFromFile);
            format(string,sizeof(string),"Advisor has %d report tokens on [%d/%d/%d].",rtoken,month,day,year);
            SendClientMessageEx(playerid, COLOR_YELLOW, string);
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_YELLOW, "Advisor does not have any logged report tokens for this date.");
        return 0;
    }
    return 1;
}
Is there an bug in one of these things

Please help.
or tell me to post another code that you wanna see

Greets:
Reply
#2

Wrong section, ask in here:

http://forum.sa-mp.com/forumdisplay.php?f=12
Reply
#3

Edit: shit, nvm.
Sorry for this post of me, I thought you posted this in the Dutch section while you were speaking English :P
Stupid me.
Reply
#4

Sorry for the wrong section.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)