loop variables
#1

Hello

I have this code:

Код:
new a = 0;
while(a < 14)
{
	PlayerInfo[playerid][ContactNumber][a + 1] = PlayerInfo[playerid][ContactNumber][a];
	a++;
}
That code should do this:

ContactNumber[1] to ContactNumber[0]
ContactNumber[2] to ContactNumber[1]
ContactNumber[3] to ContactNumber[2]
etc.

But right now it`s doing like this:

ContactNumber[1] to ContactNumber[0]
ContactNumber[2] to ContactNumber[0]
ContactNumber[3] to ContactNumber[0]
Etc.


How can i resolve this problem?? (Look the bold things, there is the problem)
Reply
#2

Hmm what do you mean?

Like this?

Код:
new a = 14;
while(a > 0)
{
	PlayerInfo[playerid][ContactNumber][a + 1] = PlayerInfo[playerid][ContactNumber][a];
	a--;
}
Reply
#3

Nope But thanks anyway, now i know where is the problem and trying to fix it:P
Reply
#4

try useing it with a for loop
for(new a=1;a<=14;a++)
{
PlayerInfo[playerid][ContactNumber][a]=PlayerInfo[playerid][ContactNumber][a-1];
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)