SA-MP Forums Archive
showing results from files into dialog - 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: showing results from files into dialog (/showthread.php?tid=499010)



showing results from files into dialog - newbienoob - 06.03.2014

I'm having a little problem with this code;
pawn Код:
if(fexist("names.txt"))
    {
        new File:pname = fopen("names.txt");
        new str[128];
        new string[400];
        while(fread(pname, string))
        {
            format(str,sizeof(str), "%s\n", string);
            printf("%s", str);
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Players", str, "Ok", "Cancel");
        }
        fclose(pname);
    }
And here's names.txt
Код:
player1
player2
player3
player4
It prints everything perfectly. But it only shows player4 in the dialog.


Re: showing results from files into dialog - ]Rafaellos[ - 06.03.2014

pawn Код:
format(str,sizeof(str), "%s%s\n", str, string);



Re: showing results from files into dialog - newbienoob - 06.03.2014

Nothing changes.


Re: showing results from files into dialog - ]Rafaellos[ - 06.03.2014

It should. Because you format str with every name but when you format again, it's deleting the previous names and format with the last name only.

EDIT: try it like so:

pawn Код:
while(fread(pname, string))
{
format(str,sizeof(str), "%s%s\n", str, string);
printf("%s", string);
}
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Players", str, "Ok", "Cancel");
Bad indentation, i am in school!


Re: showing results from files into dialog - newbienoob - 06.03.2014




Re: showing results from files into dialog - ]Rafaellos[ - 06.03.2014

Hmm, i'm not sure why is not working, I did something similar and it worked fine.

I will make few tests when I will be back home.


Re: showing results from files into dialog - newbienoob - 06.03.2014

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
It should. Because you format str with every name but when you format again, it's deleting the previous names and format with the last name only.

EDIT: try it like so:

pawn Код:
while(fread(pname, string))
{
format(str,sizeof(str), "%s%s\n", str, string);
printf("%s", string);
}
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Players", str, "Ok", "Cancel");
Bad indentation, i am in school!
That works. Thanks.