Help with loading logs in a dialog
#1

Hey guys i have been working on making a /bugreports command. the commands is meant to show a dialog with the bug reports from the .txt. file, the problem i have is that it shows the dialog and only shows the last report, could anyone help me get more reports showing please. i will rep the one whos help works for me.

here is the code so far
pawn Код:
#include <a_samp>
#include <zcmd>

new File:bugs;
#define DIALOG_BUGS 2008
#define COLOR_YELLOW        0xFFFF00AA // Server Message & Numbers & Names
#define C_White     "{FFFFFF}" //Text

CMD:bug(playerid,params[])
{
    new string[192], name[MAX_PLAYER_NAME];
    if(isnull(params))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: "C_White"/bug [Description of the bug]");
        return 1;
    }
    GetPlayerName(playerid, name, sizeof(name));
    bugs = fopen("Bugs.txt", io_append);
    format(string,sizeof(string),"Reporter: %s | Bug:%s\r\n", name, params);
    fwrite(bugs, string);
    fclose(bugs);
    SendClientMessage(playerid, COLOR_YELLOW, "Server: "C_White"Your bug report sent.");
    return 1;
}

CMD:bugreports(playerid, params[])
{
    new str[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str, "Close", "");
    }
    fclose(bugs);
    return 1;
}
i also try to write it another way and can not figure out how to load it at all on this one
pawn Код:
//Y_INI Version
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>

CMD:bug(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /bug [Description of the bug]");
    BugLog("Bugs.ini", params);
    SendClientMessage(playerid, -1, "Server: Bug report sent.");
    return 1;
}

CMD:bugreports(playerid, params[])
{
    return 1;
}

stock BugLog(file[] , text[])
{
    new File:Bugs=fopen(file,io_append);
    fwrite(Bugs,text);
    fwrite(Bugs,"\r\n");
    fclose(Bugs);
    return 1;
}
If you could help on either on that will be great.

Thanks in advance
Reply
#2

pawn Код:
CMD:bugreports(playerid, params[])
{
    new str[500], str2[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        format(str, sizeof(str), "%s%s", str2, str);
    }
    fclose(bugs);
    ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str, "Close", "");
    return 1;
}
Try this.

I've edited the code. I haven't tested, but this may work. I'm not to sure.
Reply
#3

Код:
C:\Documents and Settings\****\Desktop\NR DM\filterscripts\Bugs.PWN(32) : warning 213: tag mismatch
pawn Код:
CMD:bugreports(playerid, params[])
{
    new str[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        format(str, sizeof str, "%s%s", str, bugs);// Warning on this line!!
    }
    fclose(bugs);
    ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str, "Close", "");
    return 1;
}
Reply
#4

pawn Код:
CMD:bugreports(playerid, params[])
{
    new str[500], str2[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        format(str2, sizeof(str2), "%s%s", str2, str);
    }
    fclose(bugs);
    ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str2, "Close", "");
    return 1;
}
I do apologize, try this instead. (I have edited my last reply after seeing this error).

Take note, I've edited it again.
Reply
#5

Код:
CMD:bugreports(playerid, params[])
{
    new str[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        format(str, sizeof str, "%s%s\n", str, str);// Warning on this line!!
    }
    fclose(bugs);
    ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str, "Close", "");
    return 1;
}
Reply
#6

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Код:
CMD:bugreports(playerid, params[])
{
    new str[500];
    bugs = fopen("Reported_Bugs.txt", io_read);
    while(fread(bugs, str, sizeof str, false))
    {
        format(str, sizeof str, "%s%s\n", str, str);// Warning on this line!!
    }
    fclose(bugs);
    ShowPlayerDialog(playerid, DIALOG_BUGS, DIALOG_STYLE_MSGBOX, "Bug Reports", str, "Close", "");
    return 1;
}
This wouldn't work since you are repeating the same string twice.
Reply
#7

Yea, nevermind, that will work with format, I mean using same string many times but not working with fread and format.
Reply
#8

it works thank you for that ive + rep you.
Reply


Forum Jump:


Users browsing this thread: