SA-MP Forums Archive
Dialog with loop. - 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: Dialog with loop. (/showthread.php?tid=359285)



Dialog with loop. - vent - 13.07.2012

****


Re: Dialog with loop. - AndreT - 13.07.2012

That's not how it is supposed to be done. What you currently do is try to show the player 5 dialogs, but you only want to show ONE dialog.

You first need to create a buffer that will store the dialog content, then format it with the loop's help and then display the dialog (once).

pawn Код:
new buffer[512], string[128];
for(new i = 0; i != 5; i++)
{
    format(string, sizeof(string), "%s - %s\n", Uuendused[i][uuendus], Uuendused[i][staatus]);
    strcat(buffer, string); // append the formatted string to the buffer
}
// Proceed with ShowPlayerDialog
Some people like to do it like this:
pawn Код:
format(buffer, sizeof(buffer), %s%s - %s\n", buffer, Uuendused[i][uuendus], Uuendused[i][staatus]);
But this is not a very fast solution once your strings grow bigger!

Good luck!


Re: Dialog with loop. - vent - 13.07.2012

****