[Help] "If" and "Else If" question
#1

Hello there, I am facing a simple problem but I do not know how to solve it, I have this sequence with decision commands, I wanted it even if the first if it returned a true value, it continues for the others, but it does not continue in the game if the first one value is true, it does not do others, someone knows why?


PHP код:
    if(itemtype[1] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT1");
        
RemoveItemFromInventory(playerid0);
        
DestroyItem(itemid[1]);
        
count count 1;
    }
    else if(
itemtype[2] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT2");
        
RemoveItemFromInventory(playerid1);
        
DestroyItem(itemid[2]);
        
count count 1;
    }
    else if(
itemtype[3] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT3");
        
RemoveItemFromInventory(playerid2);
        
DestroyItem(itemid[3]);
        
count count 1;
    }
    else if(
itemtype[4] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT4");
        
RemoveItemFromInventory(playerid3);
        
DestroyItem(itemid[4]);
        
count count 1;
    }
    else if(
itemtype[5] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT5");
        
RemoveItemFromInventory(playerid4);
        
DestroyItem(itemid[5]);
        
count count 1;
    }
    else if(
itemtype[6] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT6");
        
RemoveItemFromInventory(playerid5);
        
DestroyItem(itemid[6]);
        
count count 1;
    }
    else if(
itemtype[7] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT7");
        
RemoveItemFromInventory(playerid6);
        
DestroyItem(itemid[7]);
        
count count 1;
    }
    else if(
itemtype[8] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT8");
        
RemoveItemFromInventory(playerid7);
        
DestroyItem(itemid[8]);
        
count count 1;
    }
    else if(
itemtype[9] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT9");
        
RemoveItemFromInventory(playerid8);
        
DestroyItem(itemid[9]);
        
count count 1;
    }
    else if(
itemtype[10] == item_EnfeCruze)
    {
        if(
count == 3)
            return 
0;
        
SendClientMessage(playeridRED"DEPURADO SLOT10");
        
RemoveItemFromInventory(playerid9);
        
DestroyItem(itemid[10]);
        
count count 1;
    }
    else
    {
        
SendClientMessage(playeridRED"[ > ] Vocк nгo tem itens suficientes.");
    } 
Reply
#2

PHP код:
new count_tmpstr40 ];
for( new 
_item 1_item sizeofitemtype ); _item++ )
{
    if( 
itemtype_item ] == item_EnfeCruze )
    {
        if( 
count_ == )
        {
            break;
        }
        
count_++; 
        
RemoveItemFromInventoryplayerid_item );
        
DestroyItemitemtype_item ] );
        
formattmpstrsizeoftmpstr ), "DEPURADO SLOT%d"_item );
        
SendClientMessageplayeridREDtmpstr );
    }

Just iterate through itemtype.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)