for() doesnt work (mysql_tquery)
#1

Код:
public OnGameModeInit()
{
mysql_tquery(mysql, "SELECT * FROM houses", "LoadHouse");
return 1;
}

forward LoadHouse();
public LoadHouse()
{
for(new i=1; i<47; i++)
{
printf("%i", i);
}
return 1;
}
what I get printed :
Код:
0
1
2
3
and so on...
Problem is that numbers should start with 1, not with 0... No matter what value I give to "new i" it always starts with zero
Reply
#2

Lol.
Код:
for(new i=0;i<47;i++) {
Reply
#3

Quote:
Originally Posted by Aa12
Посмотреть сообщение
Код:
public OnGameModeInit()
{
mysql_tquery(mysql, "SELECT * FROM houses", "LoadHouse");
return 1;
}

forward LoadHouse();
public LoadHouse()
{
for(new i=1; i<47; i++)
{
printf("%i", i);
}
return 1;
}
what I get printed :
Код:
0
1
2
3
and so on...
Problem is that numbers should start with 1, not with 0... No matter what value I give to "new i" it always starts with zero
Pretty weird.
Maybe try with this 'C' style thing:

pawn Код:
public LoadHouse() {
  new i = 1;
  for(i; i < 47; i++)  printf("%d", i);  
}
Reply
#4

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Lol.
Код:
for(new i=0;i<47;i++) {
I dont think you understood my problem


Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
Pretty weird.
Maybe try with this 'C' style thing:

pawn Код:
public LoadHouse() {
  new i = 1;
  for(i; i < 47; i++)  printf("%d", i);  
}
Doesnt work, also I get warning
warning 215: expression has no effect
Reply
#5

Код:
for (new i = 1; i < MAX_I_VALUES_HERE; i++)
{
    if (!i) continue;
    printf('Looping %i', i);
}
Done
Reply
#6

Quote:
Originally Posted by amirm3hdi
Посмотреть сообщение
Код:
for (new i = 1; i < MAX_I_VALUES_HERE; i++)
{
    if (!i) continue;
    printf('Looping %i', i);
}
Done
Skipping i when it's 0 does not make sense.

Quote:

No matter what value I give to "new i" it always starts with zero

What, if i = 10..
Reply
#7

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
Skipping i when it's 0 does not make sense.


What, if i = 10..
You mean even that code doesn't work?
Reply
#8

Quote:
Originally Posted by amirm3hdi
Посмотреть сообщение
You mean even that code doesn't work?
I mean your solution does not solve the problem in question.

All your code does is just skip anything in the loop when iterator (i) is equal to 0 (because negation of 0 is 1, so does !i).

The problem is that even for:
for(new i = 5; i < 47; i++)

it will give: 0, 1, 2, 3...

Well, at least that's what this thread is about.
Reply
#9

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
I mean your solution does not solve the problem in question.

All your code does is just skip anything in the loop when iterator (i) is equal to 0 (because negation of 0 is 1, so does !i).

The problem is that even for:
for(new i = 5; i < 47; i++)

it will give: 0, 1, 2, 3...

Well, at least that's what this thread is about.
Well, my solution gives you what you want.. not counting 0,
if you wanna do "new i = 5" then you must do "if (i < 5) continue;"...

Check your recent changes, maybe something messes this up...
I've never seen such problem tho.

You tried while() ?
Reply
#10

Okay guys, so I don't know what happened but now it works, lol. I didn't change anything in the code, but I just tried it again(launch server.exe) couple of times and it worked... Sorry for wasting you time

Thanks for trying to help anyways!

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
Skipping i when it's 0 does not make sense.


What, if i = 10..
Before it worked, I set i=8, it still started from zero
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)