loop variables - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: loop variables (
/showthread.php?tid=391663)
loop variables -
Larry123 - 11.11.2012
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)
Re: loop variables -
Larry123 - 11.11.2012
Hmm what do you mean?
Like this?
Код:
new a = 14;
while(a > 0)
{
PlayerInfo[playerid][ContactNumber][a + 1] = PlayerInfo[playerid][ContactNumber][a];
a--;
}
Re: loop variables -
Larry123 - 11.11.2012
Nope
![Cheesy](images/smilies/biggrin.png)
But thanks anyway, now i know where is the problem and trying to fix it:P
Re: loop variables -
Abhishek. - 11.11.2012
try useing it with a for loop
for(new a=1;a<=14;a++)
{
PlayerInfo[playerid][ContactNumber][a]=PlayerInfo[playerid][ContactNumber][a-1];
}