for() doesnt work (mysql_tquery) -
Aa12 - 23.01.2016
Код:
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
Re: for() doesnt work (mysql_tquery) -
Prokill911 - 23.01.2016
Lol.
Код:
for(new i=0;i<47;i++) {
Re: for() doesnt work (mysql_tquery) -
LetsOWN[PL] - 23.01.2016
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);
}
Re: for() doesnt work (mysql_tquery) -
Aa12 - 23.01.2016
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
Re: for() doesnt work (mysql_tquery) -
amirm3hdi - 23.01.2016
Код:
for (new i = 1; i < MAX_I_VALUES_HERE; i++)
{
if (!i) continue;
printf('Looping %i', i);
}
Done
Re: for() doesnt work (mysql_tquery) -
LetsOWN[PL] - 23.01.2016
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..
Re: for() doesnt work (mysql_tquery) -
amirm3hdi - 23.01.2016
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?
Re: for() doesnt work (mysql_tquery) -
LetsOWN[PL] - 23.01.2016
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.
Re: for() doesnt work (mysql_tquery) -
amirm3hdi - 23.01.2016
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() ?
Re: for() doesnt work (mysql_tquery) -
Aa12 - 23.01.2016
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