Loop spams
#1

The loop spams

like returning

Код:
CheckpointID: 1
CheckpointID: 2
until it reached up to 29. (Maximum is 30).

Causing the checkpointid to be messed up or not working.
I want it to remain to 1 or return it as the checkpoint id.

I'm using custom checkpoint streamer (don't tell me to use incognito. i'm creating a custom one).

pawn Код:
for(new j = 0; j < 30; j++)
{
    if(IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == false)
    {
        //code here
        printf("CheckpointID: %i", j);
        continue;
    }
    else if(!IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == true)
    {
        //code here
        continue;
    }
}
I don't want to show the code in "//code here" because that one is private and i'm sure it's nothing to do with this. (Since it only CallLocalFunction and variable).
Reply
#2

I don't know about you saying "returning one checkpoint" but something like this?
pawn Код:
for(new j = 0; j < 30; j++)
{
    if(IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == false)
    {
        //code here
       return printf("CheckpointID: %i", j);
    }
    else break;
}
Reply
#3

pawn Код:
new Count;
for(new j = 0; j < 30; j++)
{
    if(Count >= 30) break;
    if(IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == false)
    {
        //code here
        printf("CheckpointID: %i", j);
        continue;
    }
    else if(!IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == true)
    {
        //code here
        continue;
    }
   Count++;
}
It'll stop the loop once if after getting looped 30 times. Sorry if this isn't what you mean, honestly; I didn't well understood your post.
Reply
#4

I'm not sure if these will work.
By i meant of that i mean.

The loop will loop all 30 custom checkpoints (colored checkpoints).

Here is the problem. Instead of returning the checkpoint id.
It will continue looping until it reached 29.

Let me try if these codes work.
Reply
#5

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
Here is the problem. Instead of returning the checkpoint id.
It will continue looping until it reached 29.
pawn Код:
for(new j = 0; j < 30; j++)
{
    if(IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == false)
    {
        //code here
        printf("CheckpointID: %i", j);
        break; //Returns the checkpoint ID and breaks the loop.
    }
    else if(!IsPlayerInRangeOfPoint(i, 1.0, cpData[j][cpX], cpData[j][cpY], cpData[j][cpZ]) && entered[i][j] == true)
    {
        //code here
        continue;
    }
}
As you've told, this might return the checkpoint and won't continue the loop, in fact it'll just break the loop if its returning the checkpoint ID, else it will continue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)