need help with fread.
#1

Thanks For Everyone Who Helped ! got work this now
Reply
#2

You'll need to use "while":
pawn Код:
while(fread(example, string))
{
  new string235[256];
  format(string235, 256, "%s\r\n", string);
  //Other code
}
fclose(example);
Reply
#3

pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0) {
    new string[64]; // Create the string to store the read text in
    new File:example = fopen("text.txt", io_read); // Open the file
    fread(example, string); // Fread from the file and store what's read in 'string'
    while(fread(example, string))
    {
    new string235[256];
    format(string235,sizeof string235,"%s\r\n",string);
    ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Text",string235,"Okei","Cancel");
    }
    fclose(example);
   
    return 1;
    }
something like that ?
Reply
#4

I guess so.. I'm not fully functional in fread ^^. Oh and: Show the dialog AFTER the "while {....}" loop has been done, else it'll most probably bug up.
Reply
#5

thanks working but i want to add whole text history to the Dialog but now it shows the last one writed text.


atm code

pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0) {
    new string[64]; // Create the string to store the read text in
    new File:example = fopen("text.txt", io_read); // Open the file
    fread(example, string); // Fread from the file and store what's read in 'string'
    new string235[256];
    while(fread(example, string))
    {
    format(string235,sizeof string235,"%s\r\n",string);
    }
    ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Chat Logs",string235,"Okei","Cancel");
    fclose(example);
    return 1;
    }
Reply
#6

have tryd much times to fix this but i cant understand what i have to do to get whole text from text.txt to dialog
Reply
#7

pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0)
{
    new string[128];
    new string235[512];
    new File:example = fopen("text.txt", io_read);
    while(fread(example, string))
    {
        strcat(string235, string, sizeof(string235));
    }
    fclose(example);
    ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Chat Logs",string235,"Okei","Cancel");
    return 1;
}
Reply
#8

thanks got fixed now the problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)