Something breaks the 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: Something breaks the loop. (
/showthread.php?tid=479051)
Something breaks the loop. -
kristo - 02.12.2013
It's actually a very simple for(new i; i < ...; i++) loop but something inside is breaking it in a very strange location. As you can see, I did some debugging and the results are here:
http://i.imgur.com/HgJL1Dz.png. The SQL plugin used here is Dan's but I think this doesn't matter much. Any help would be appreciated.
PHP код:
printf("rows: %i", rows);
for (new i; i < sizeof(rows); i++)
{
print("1");
sql_get_field_assoc(r, "aeg", result, 24);
print("2");
sql_get_field_assoc(r, "kestvus", kkestvus, 16);
print("3");
format(result, sizeof(result), "%i - %s - %s", sql_get_field_assoc_int(r, "helistaja"), result, kkestvus);
print("4");
format(string, sizeof(string), "%s%s\n", string, result);
print("5");
sql_next_row(r);
print("6");
}
ShowPlayerDialog(playerid, DIALOG_KONELOGI, DIALOG_STYLE_LIST, COL_WHITE"Telefon", string, "Vali", "Tagasi");
Re: Something breaks the loop. -
Konstantinos - 02.12.2013
rows is an integer, not an array to use
sizeof. No matter what its value, it will always return one; hence it's called only once (the loop).
Change to:
pawn Код:
for (new i; i < rows; i++)
Re: Something breaks the loop. -
kristo - 02.12.2013
Ahh, damn... I really didn't notice that. I have made so many stupid mistakes recently