Finding right variables and randomly choosing one of them
#4

pawn Code:
new indexes[5], count;
static const item_names[][] =
{
    {"chair"},
    {"box"},
    {"tv"},
    {"couch"},
    {"bed"}
};

for(new i = 0, j = sizeof(item_names); i < j; i ++)
{
    if(!GetItemValue(playerid, item_names[i][0]))
    {
        continue;
    }

    indexes[count] = i;
    count ++;
}

GiveItem(playerid, item_names[indexes[random(count)]][0]);
Reply


Messages In This Thread
Finding right variables and randomly choosing one of them - by Aa12 - 24.03.2016, 22:03
Re: Finding right variables and randomly choosing one of them - by Pottus - 24.03.2016, 22:08
Re: Finding right variables and randomly choosing one of them - by Aa12 - 24.03.2016, 22:23
Re: Finding right variables and randomly choosing one of them - by SickAttack - 24.03.2016, 23:51
Re: Finding right variables and randomly choosing one of them - by Aa12 - 25.03.2016, 07:42

Forum Jump:


Users browsing this thread: 1 Guest(s)