If whole array?
#1

Hi guys.

I have a array with e.g. 10 different objects and I want to detect if is player near one of them.

I used cycle for:
Код:
for(new i = 0; i < sizeof(myObjArray); i++)
{
     if(IsPlayerNearObject(playerid, myObjArray[i]))
    {
      ...
    }
}
but it doesn't work. I tried a lot of other ways, but just one of them worked, this one ->

Код:
if(IsPlayerNearObject(playerid, myObjArray[0]) || 
IsPlayerNearObject(playerid, myObjArray[1]) ||
IsPlayerNearObject(playerid, myObjArray[2]) ||
IsPlayerNearObject(playerid, myObjArray[3]) ||
IsPlayerNearObject(playerid, myObjArray[4]) ||
IsPlayerNearObject(playerid, myObjArray[5]) ||
IsPlayerNearObject(playerid, myObjArray[6]) ||
IsPlayerNearObject(playerid, myObjArray[7]) ||
IsPlayerNearObject(playerid, myObjArray[8]) ||
IsPlayerNearObject(playerid, myObjArray[9]))
{
...
}
and It's not very good solution.

Do you have any suggestions?
Thank you.
Reply


Messages In This Thread
If whole array? - by Professional_Programmer - 27.03.2015, 00:31
Re: If whole array? - by Jefff - 27.03.2015, 00:34
Re: If whole array? - by Professional_Programmer - 27.03.2015, 00:42
Re: If whole array? - by Jefff - 27.03.2015, 02:50
Re: If whole array? - by Professional_Programmer - 27.03.2015, 04:12
Re: If whole array? - by Misiur - 27.03.2015, 10:35
Re: If whole array? - by Jefff - 27.03.2015, 14:52
Re: If whole array? - by Professional_Programmer - 27.03.2015, 16:53

Forum Jump:


Users browsing this thread: 1 Guest(s)