SA-MP Forums Archive
Loop spams - 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)
+--- Thread: Loop spams (/showthread.php?tid=436147)



Loop spams - JaKe Elite - 10.05.2013

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).


Re: Loop spams - RajatPawar - 10.05.2013

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;
}



Re: Loop spams - Lordzy - 10.05.2013

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.


Re: Loop spams - JaKe Elite - 10.05.2013

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.


Re: Loop spams - Lordzy - 10.05.2013

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.