Help with fread. -
Ricop522 - 14.08.2011
I want to read the:
pawn Код:
if(dialogid == DIALOG_MDCNOME3)
{
format(string, sizeof(string), "LSPD/Suspects/%s.ini", strlen(inputtext));
//Read
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "-", string, "Ok", "Fechar");
}
I try to use while, but I don't get some results..
I want to read just 20 lines.
Thanks for your help.
Re: Help with fread. - [BEP]AcerPilot - 14.08.2011
Use:
pawn Код:
if(dialogid == DIALOG_MDCNOME3)
{
new count = 0, string[128];
format(SkillBase, sizeof(SkillBase), "LSPD/Suspects/%s.ini", strlen(inputtext));
while(fread(SkillBase, string))
{
// do what you want here
count ++;
if(count == 20)
{
break;
}
}
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "-", string, "Ok", "Fechar");
}
Hope you understood.
@Vocк podia ter postado na PT/BR hehe
Re: Help with fread. -
Ricop522 - 14.08.2011
I appreciate your help.
But I want to show the twenty lines.
Thanks,
Re: Help with fread. - [BEP]AcerPilot - 14.08.2011
Ah I see. You can concatenate all the 20 lines in one master string and show it. As you're advanced in PAWN I won't document the code:
pawn Код:
if(dialogid == DIALOG_MDCNOME3)
{
new count = 0, masterstring[256 /*maybe tmpstring > 128*/], tmpstring[128], line[128];
format(SkillBase, sizeof(SkillBase), "LSPD/Suspects/%s.ini", strlen(inputtext));
while(fread(SkillBase, line))
{
format(tmpstring, sizeof(tmpstring), "%s\r\n", line);
strins(masterstring, tmpstring, strlen(masterstring));
count ++;
if(count == 20)
{
break;
}
}
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "-", string, "Ok", "Fechar");
}
Re: Help with fread. -
Ricop522 - 14.08.2011
Thanks, I'll see.
Re: Help with fread. - [BEP]AcerPilot - 14.08.2011
You are formatting SkillBase as a string (%s) but the value you are passing is a integer. Substitute strlen(inputtext) with inputtext.
Re: Help with fread. -
Ricop522 - 14.08.2011
So, I tryed to check, but doesn't show the dielog
pawn Код:
if(dialogid == DIALOG_MDCNOME3)
{
new count = 0, masterstring[1024], tmpstring[128], line[128];
format(SkillBase, sizeof(SkillBase), "LSPD/Suspects/%s.ini", inputtext);
new File:arquivo = fopen(SkillBase, io_read);
while(fread(arquivo, line))
{
count ++;
format(tmpstring, sizeof(tmpstring), "%s\n", line);
strins(masterstring, tmpstring, strlen(tmpstring));
if(count == 20) break;
}
ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, "-", masterstring, "Ok", "Fechar");
SCM(playerid, -1, masterstring);
return 1;
}
Re: Help with fread. -
Lorenc_ - 14.08.2011
pawn Код:
if(dialogid == DIALOG_MDCNOME3)
{
new count = 0, masterstring[1024], tmpstring[128], line[128];
format(SkillBase, sizeof(SkillBase), "LSPD/Suspects/%s.ini", inputtext);
new File:arquivo = fopen(SkillBase, io_read);
while(fread(arquivo, line))
{
count ++;
format(tmpstring, sizeof(tmpstring), "%s%s\n", tmpstring, line);
strins(masterstring, tmpstring, strlen(tmpstring));
if(count == 20) break;
}
ShowPlayerDialog(playerid, -1, DIALOG_STYLE_MSGBOX, "-", masterstring, "Ok", "Fechar");
SCM(playerid, -1, masterstring);
return 1;
}
Try that.
Edit: Change the goddamn Dialog ID, set it to 'NULL (0)'