20.12.2016, 07:21
Just checked the loop part and no, it's not an infinite loop. It's just clear mathematical logic. (0 < rows) is equal to (rows > 0). Here, when the number of rows retrieved are greater than zero, the loop runs until the 'rows' variable becomes zero or less. That's why you can see "rows--" statement under the loop. For instance, you can consider this:
pawn Код:
new rows = db_num_rows(result); //Suppose that rows is now 3. (rows = 3)
while (0 < rows) //(0 is of course less than 3, so the loop runs until 0 < 0 occurs.)
{
db_get_field_assoc(result, "userid", tmp1, sizeof(tmp1));
new pid = GetPlayerID(GetNameFromUserID(strval(tmp1)));
if (IsPlayerConnected(pid)) { SetPlayerColor(pid, color); pcolor[pid] = color; }
db_next_row(result);
rows--; //The value of rows keeps on decreasing.
}