For Cycles Ending?
#1

Hey guys, me again, pretty nobbish question?...

The thing is..
i have a code like this

Код:
for(new I;I<10;I++)
{
    if(IsPlayerInRangeOfPoint(playerid,5.0,Thing[I][X],Thing[I][Y],Thing[I][Z]);
    {
      if(Somethihg)
      {
          Some stuff here
      }
      else return SendClientmessage(playerid,COLOR,TExt);
     }
     else return  SendClientmessage(playerid,COLOR,TExt);
}
return 1;
Now, the thing is, i want to send a message IF the cycle ends without finding any match, i have tried checking if I = 10 but it bugs, so... i really dont kjnow what else to do, any ideas?
Reply
#2

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,5.0,Thing[I][X],Thing[I][Y],Thing[I][Z]) return SendClientMessage(playerid,/*COLOR*/,/*Text*/);
Reply
#3

This should work:

pawn Код:
new inarea = false;
for(new I;I<10;I++)
{
    if(IsPlayerInRangeOfPoint(playerid,5.0,Thing[I][X],Thing[I][Y],Thing[I][Z]);
    {
      if(Somethihg)
      {
          Some stuff here
      }
      else return SendClientmessage(playerid,COLOR,TExt);
      inarea = true;
     }
     else return  SendClientmessage(playerid,COLOR,TExt);
}
if(!inarea) SendClientMessage(...);
return 1;
Reply
#4

Quote:
Originally Posted by Bessensap
Посмотреть сообщение
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,5.0,Thing[I][X],Thing[I][Y],Thing[I][Z]) return SendClientMessage(playerid,/*COLOR*/,/*Text*/);
Thanks, but that wouldt work, it would return that message each time it was false (9 to 10 times since the cycle runs 10 times)

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
This should work:

pawn Код:
new inarea = false;
for(new I;I<10;I++)
{
    if(IsPlayerInRangeOfPoint(playerid,5.0,Thing[I][X],Thing[I][Y],Thing[I][Z]);
    {
      if(Somethihg)
      {
          Some stuff here
      }
      else return SendClientmessage(playerid,COLOR,TExt);
      inarea = true;
     }
     else return  SendClientmessage(playerid,COLOR,TExt);
}
if(!inarea) SendClientMessage(...);
return 1;
Thanks, it did work...
Reply


Forum Jump:


Users browsing this thread: