04.07.2016, 22:57
I'd suggest you use the snippet I posted. But since you're a bit stubborn, I'll post another method (not as efficient as the snippet, but it would get the job done):
pawn Код:
CMD:getgift(playerid, params[])
{
// Get available gifts
new available_gifts[3], count;
if(boxVariables[1][boxLic]) // If not 0, thus 1
{
available_gifts[count] = 1;
count ++;
}
else if(boxVariables[1][boxMoney]) // If not 0, thus 1
{
available_gifts[count] = 2;
count ++;
}
else if(boxVariables[1][boxFireWorks]) // If not 0, thus 1
{
available_gifts[count] = 3;
count ++;
}
// Select random available gift
switch(available_gifts(random(count)))
{
case 1:
{
// boxLic
}
case 2:
{
// boxMoney
}
case 3:
{
// boxFireWorks
}
default:
{
// No gifts are available
}
}
return 1;
}