Get number of houses from array?
#4

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
why don't you just use row count? it is harder to count an array. you'll have to loop through all elements until it reaches an unused cell.
And mysql has to send request, wait for mysql server to select all rows, count them and than return result. Looping thru array is 1000x times faster (literally).


Just loop thru your houses and skip unused cells/rows. My simple trick is to check if houses entrance Z is 0 or if label/icon is invalid. Simple example:

pawn Код:
stock CountHouses()
{
    new count = 0;
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(HouseInfo[i][EntZ] != 0.0) count++;
    }
    return count;
}
While EntZ should be float and comparing floats is discouraged feel free to do it in pawn.
Reply


Messages In This Thread
Get number of houses from array? - by CloudLEL - 29.05.2016, 11:25
Re: Get number of houses from array? - by iKarim - 29.05.2016, 11:30
Re: Get number of houses from array? - by CloudLEL - 29.05.2016, 11:36
Re: Get number of houses from array? - by DRIFT_HUNTER - 29.05.2016, 11:52
Re: Get number of houses from array? - by Konstantinos - 29.05.2016, 11:59
Re: Get number of houses from array? - by DRIFT_HUNTER - 29.05.2016, 16:01
Re: Get number of houses from array? - by Vince - 29.05.2016, 16:23
Re: Get number of houses from array? - by AlexBlack - 29.05.2016, 16:25

Forum Jump:


Users browsing this thread: 1 Guest(s)