Wierd bug.
#10

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
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;
}
And what should I do if I would want to have a certain percentage chance to get a certain gift?
That's why I was using new rand = random(20);
So I could do, "if(rand < 5) { //do code }" which would mean that it would be 10% chance to get the gift.
Reply


Messages In This Thread
Wierd bug. - by danielpalade - 04.07.2016, 02:38
Re: Wierd bug. - by SickAttack - 04.07.2016, 04:21
Re: Wierd bug. - by TwinkiDaBoss - 04.07.2016, 04:59
Re: Wierd bug. - by Dayrion - 04.07.2016, 12:01
Re: Wierd bug. - by danielpalade - 04.07.2016, 15:20
Re: Wierd bug. - by SickAttack - 04.07.2016, 16:34
Re: Wierd bug. - by danielpalade - 04.07.2016, 19:42
Re: Wierd bug. - by SickAttack - 04.07.2016, 20:23
Re: Wierd bug. - by SickAttack - 04.07.2016, 22:57
Re: Wierd bug. - by danielpalade - 04.07.2016, 23:20

Forum Jump:


Users browsing this thread: 1 Guest(s)