CheckpointID: 1 CheckpointID: 2
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;
}
}
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;
}
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++;
}
Here is the problem. Instead of returning the checkpoint id.
It will continue looping until it reached 29. |
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;
}
}