SA-MP Forums Archive
When you end a loop, the code after won't load - 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: When you end a loop, the code after won't load (/showthread.php?tid=215043)



When you end a loop, the code after won't load - Biesmen - 22.01.2011

Hello,

I am creating a code to spawn a vehicle if you logon.
But there's a problem which I never had before with the same script.

If I use this loop, the code after this loop won't do anything anymore.

This is the code I am using to load the vehicle:

pawn Код:
for(new i; i < MAX_VEHICLES + 1; i++)
        {
        if(strmatch(Owner, Name))
        {
            COwnerData[i][CarID] = CreateVehicle(COwnerData[i][ModelID], COwnerData[i][carX], COwnerData[i][carY], COwnerData[i][carZ], COwnerData[i][carRot], COwnerData[i][pC1], COwnerData[i][sC2], 30*10000);
            continue;
        }
        }
The continue; was my second option, which didn't work.

I also removed a brace, it worked. But then the vehicle will not spawn.


Re: When you end a loop, the code after won't load - wups - 22.01.2011

continue; does nothing in this loop. If you wan't to end the loop, when the right car is found, use break;


Re: When you end a loop, the code after won't load - _Tommy - 22.01.2011

As wups already said, remove the "continue". Also replace "MAX_VEHICLES + 1" with "MAX_VEHICLES".
Post here the results please.


Re: When you end a loop, the code after won't load - Biesmen - 22.01.2011

Then the code won't load, which is after the loop.

Anyway, it's solved.


Re: When you end a loop, the code after won't load - wups - 22.01.2011

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
Then the code won't load, which is after the loop.

Anyway, it's solved.
if return; would be used, the code wouldn't load!


Re: When you end a loop, the code after won't load - Biesmen - 22.01.2011

Quote:
Originally Posted by wups
Посмотреть сообщение
if return; would be used, the code wouldn't load!
Same with break as I tried it before.