while loop failing to check statement
#1

In the following code, the while loop fails to assign a value to a variable.

Код:
enum IN
{
rNum,
rVar
};
new lCheck[MAX_PLAYERS][IN];

lCheck[player][rNum] = 0;
while(lCheck[player][rNum] == 0)lCheck[player][rNum] = random(50);
The value of rNum will always be zero. I don't know if this is an issue for me only. The way I got around this is by doing the following.

Код:
new rRock = 0;
while(rRock == 0)rRock = random(50);
lCheck[player][rNum] = rRock;
I know it isn't the end of the world but why would this happen?
Reply
#2

pawn Код:
while(rRock == 0)rRock = random(50);
This could randomly pick 0, try this:

pawn Код:
while(rRock == 0)rRock = random(50) + 1;
And your issue is common elsewhere, like when you save score it requires you set a variable then save it.
Reply
#3

Very foolish of me. I could have just done this:
Код:
 lCheck[player][rNum] = random(50)+1;
Much obliged Weponz.
Reply
#4

EDIT: You fixed it while i was writing my post. Testers feel free to delete it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)