How do I make a dialog MSGBOX which shows multiple lines from fread?
#1

So I have a command that I'm trying to make which takes lines from fread() and I want to make it so that each line found shows up in its own separate line in a dialog.

Here is what I have so far but the problem with it right now is it only shows the last line... I want the dialog box to show ALL the results in its own line... if that makes any sense.


Код:
CMD:viewfeedback(playerid, params[])
{
	new File:handle = fopen("feedback.txt", io_read);

	if(handle)
	{
		new line[128];
		new i = 1;
		while(fread(handle, line)) 
		{
			new dialoglines[250], dialogstring[1000];
			format(dialoglines, sizeof(dialoglines), "[%i] %s\n", i, line);
			strcat(dialogstring, dialoglines);
			ShowPlayerDialog(playerid, 89273, DIALOG_STYLE_MSGBOX, "View Feedback", dialogstring, "Close", "");
			i++;
		}
		fclose(handle);

	}
	else SendClientMessage (playerid, -1, "error");
	return 1;

}
Reply
#2

try one one of these codes
Код:
new File:Warns = fopen("filename.txt",io_read);
if(!Warns) return 0;
new str[128],warndstr[500],len;
while((len = fread(Warns,str)))
{
str[len - 1] = 0;
strcat(warnstr,str);
}
fclose(Warns);
if(warnstr[0] != EOS)
{
// ShowPlayerDialog(...);
}
or

Код:
while((len = fread(Warns,str)))
{
str[len - 2] = 0;
SendClientMessage(playerid,-1,str);
}
fclose(Warns);
Reply
#3

Nvm got it, I just had the dialog showing in the loop by accident lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)