SA-MP Forums Archive
Loop Not Work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Loop Not Work (/showthread.php?tid=96462)



Loop Not Work - _TeRmiNaToR_ - 08.09.2009

I made a object loop for create 20 objects but with this command created one object.

Код:
new LoopTimer;
LoopTimer = SetTimerEx("LoopTunnel", 100, true, "");
Код:
forward LoopTunnel();
public LoopTunnel()
{
	for(new Objects; Objects < 20; Objects++)
	{
	  new Float:X = -38;
		CreateObject(13666, X, 2492, 30, 0, 0, 0);
		Objects++;
		X += 5;
		if(Objects == 20)
		{
		  KillTimer(LoopTimer);
		  break;
		}
		else continue;
	}
}
Who is the error.


Re: Loop Not Work - snoob - 08.09.2009

Quote:
Originally Posted by _TeRmiNaToR_
I made a object loop for create 20 objects but with this command created one object.

Код:
new LoopTimer;
LoopTimer = SetTimerEx("LoopTunnel", 100, true, "");
Код:
forward LoopTunnel();
public LoopTunnel()
{
	for(new Objects; Objects < 20; Objects++)
	{
	  new Float:X = -38;
		CreateObject(13666, X, 2492, 30, 0, 0, 0);
		Objects++;
		X += 5;
		if(Objects == 20)
		{
		  KillTimer(LoopTimer);
		  break;
		}
		else continue;
	}
}
Who is the error.
Код:
forward LoopTunnel();
public LoopTunnel()
{
    new Float:X = -38;// create X before the loop

	for(new Objects; Objects < 20; Objects++)
	{
         
	  //new Float:X = -38; //you create and set X at each step of loop.
		CreateObject(13666, X, 2492, 30, 0, 0, 0);
		Objects++;
		X += 5;
		if(Objects == 20)
		{
		  KillTimer(LoopTimer);
		  break;
		}
		else continue;
	}
}



Re: Loop Not Work - _TeRmiNaToR_ - 09.09.2009


This time give me crash for invalid object id.
I use 0.3a RC-4-4


Re: Loop Not Work - Joe Staff - 09.09.2009

Then use a correct object ID, the problem with your function is that you're creating all 20 objects in the same spot, so you won't notice the difference.


Re: Loop Not Work - _TeRmiNaToR_ - 09.09.2009

Quote:
Originally Posted by Joe Staff
Then use a correct object ID, the problem with your function is that you're creating all 20 objects in the same spot, so you won't notice the difference.
What must I ?

_________________________________________________

When I add in ongamemodeinit are work.