This is efficient?
#5

Quote:
Originally Posted by iLearner
Посмотреть сообщение
PHP код:
print("search again.");
    return 
FindBusiness(playerid); 
This code will always be executed. to avoid it try it like this:

PHP код:
FindBusiness(playerid)
{
    new 
random(ValidBusiness); // Total business
    
    
if(BusinessData[i][bizExists] && BusinessData[i][bizType] >= && BusinessData[i][bizType] <= 4  && GetPlayerVirtualWorld(playerid) == BusinessData[i][bizExteriorVW] && GetPlayerInterior(playerid) == BusinessData[i][bizExterior])
    {
        if (
BusinessData[i][bizDeliver][0] != 0.0 && BusinessData[i][bizDeliver][1] != 0.0 && BusinessData[i][bizDeliver][2] != 0.0)
        {
            print(
"found!");
            return 
i;
        }
    }
    else
    {
      print(
"search again.");
      return 
FindBusiness(playerid);       
    }
    

But... if you're going through valid bussiness only then it should always find it.
Both are same and it won't get executed if the if statement get false. And if that become true it will return i and recursion part won't get executed.
Reply


Messages In This Thread
This is efficient? - by StreK - 02.05.2017, 06:47
Re: This is efficient? - by iLearner - 02.05.2017, 06:53
Respuesta: Re: This is efficient? - by StreK - 02.05.2017, 06:56
Re: This is efficient? - by iLearner - 02.05.2017, 06:57
Re: This is efficient? - by SyS - 02.05.2017, 06:58
Re: This is efficient? - by DRIFT_HUNTER - 02.05.2017, 07:31
Re: This is efficient? - by Duco - 02.05.2017, 09:13
Re: This is efficient? - by Logic_ - 02.05.2017, 10:20
Re: This is efficient? - by Vince - 02.05.2017, 15:17
Respuesta: Re: This is efficient? - by StreK - 02.05.2017, 22:50

Forum Jump:


Users browsing this thread: 1 Guest(s)