When you end a loop, the code after won't load
#1

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.
Reply
#2

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

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

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

Anyway, it's solved.
Reply
#5

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!
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)