relations between arrays using ID.. loops.. acceptable?
#5

Quote:
Originally Posted by TheStreetsRP
Посмотреть сообщение
NEW QUESTION:

I also from time to time need to find the highest slot in an array that's "empty" (all zeros).. To do this I've been looping, again.. As such.

Код:
for(new i=0;i<MAX_PROPERTIEs;i++) {
    if(HomeInfo[i][homeID] == 0) { // I'm able to check for homeID being zero because this value is assigned by DB.
        newArrID = i;
        break;
    }
}
That is OK too. Consider that you're finding the FIRST available slot, and not the highest one, for that you need to do the loop "reversed".

Код:
for(new i=MAX_PROPERTIES;i>0;i--) {
    if(HomeInfo[i][homeID] == 0) { // I'm able to check for homeID being zero because this value is assigned by DB.
        newArrID = i;
        break;
    }
}
You are probably the kind of person that is too tidy with performance, but really, computer code runs fast unless it's a very complex mathematical algorithm or you're running heavy code constantly in a timer with low intervals. It's just for you to do benchmarking tests and see the results!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)