About using loops
#3

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
if(pickupid == Pickip[0]) till Pickup[149] ?
Checking for each item would be slightly faster but you would need lot more text which would make your file unused big

A switch wont work, switch only work with constant values

Just use a loop like you already did and add a return 1 in it because an item can only be found once
Or add a break (which stops the loop) if some other code should be executed in the callback

pawn Код:
public OnPlayerPickUpPickup(playerid,pickupid)
{
    Loop(i, sizeof Pickup)
    {
        if(pickupid == Pickup[i])
        {
            //code
            return 1;
        }
    }
    Loop(i, sizeof EntrancePickup)
    {
        if(pickupid == EntrancePickup[i])
        {
            //code
            return 1;
        }
    }
    return 1;
}
Reply


Messages In This Thread
About using loops - by BuLLeT[LTU] - 15.02.2011, 21:09
Re: About using loops - by Krx17 - 15.02.2011, 21:26
AW: About using loops - by Nero_3D - 15.02.2011, 22:14
Re: About using loops - by BuLLeT[LTU] - 16.02.2011, 07:07

Forum Jump:


Users browsing this thread: 2 Guest(s)