Wierd bug.
#1

I've made a giftbox command. Here it is:

Код:
CMD:getgift(playerid, params[])
{
    if(playerVariables[playerid][pPlayingHours] >= 3)
    {
        if(boxVariables[1][boxStatus] == 1)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, boxVariables[1][boxX], boxVariables[1][boxY], boxVariables[1][boxZ]))
            {
                format(szMessage, 256, "Poti folosi /getgift peste %d ore.", playerVariables[playerid][pGiftHours]);
                /*if(playerVariables[playerid][pGiftHours] == 0)
                {*/
					new string[256];
                    new gift = random(30);
					while(gift == 0 && boxVariables[1][boxVehicle] != 0) gift = random(30);
					while(gift > 0 || gift < 2 && boxVariables[1][boxPP] != 0) gift = random(30);
					while(gift > 1 && gift < 7 && boxVariables[1][boxMoney] != 0) gift = random(30);
					while(gift > 6 && gift < 12 && boxVariables[1][boxMats] != 0) gift = random(30);
					while(gift > 11 && gift < 17 && boxVariables[1][boxClearWarns] != 0 && playerVariables[playerid][pWarns] != 0) gift = random(30);
					while(gift > 13 && gift < 16 && boxVariables[1][boxClearFP] != 0 && playerVariables[playerid][pFP] != 0) gift = random(30);
					while(gift > 15 && gift < 21 && boxVariables[1][boxFireWorks] != 0) gift = random(30);
					while(gift > 20 && gift < 23 && boxVariables[1][boxHidden] != 0) gift = random(30);
					while(gift > 22 && gift < 27 && boxVariables[1][boxLic] != 0) gift = random(30);
					printf("%d", gift);
					if(gift == 0) //5%
					{
						format(string, sizeof(string), "GiftBox: %s a castigat un %s din giftbox. Felicitari!", GetName(playerid), VehicleNames[boxVariables[1][boxVehicle] - 400]);
						SendClientMessageToAll(COLOR_LIGHT, string);
					}
					if(gift > 0 && gift < 2) //5%
					{
						new pp = 10 + random(50);
						format(string, sizeof(string), "GiftBox: %s a castigat %d puncte premium din giftbox. Felicitari!", GetName(playerid), pp);
						SendClientMessageToAll(COLOR_LIGHT, string);
					}
					if(gift > 1 && gift < 7) //25%
					{
						new money = 200000 + random(1000000);
						format(string, sizeof(string), "* Ai castigat $%s din giftbox.", NumberFormat(money));
						SendClientMessage(playerid, COLOR_YELLOW, string);
					}					
					if(gift > 6 && gift < 12) //25%
					{
						new mats = 5000 + random(30000);
						format(string, sizeof(string), "* Ai castigat %s materiale din giftbox.", NumberFormat(mats));
						SendClientMessage(playerid, COLOR_YELLOW, string);
					}					
					if(gift > 11 && gift < 14) //10%
					{
						SendClientMessage(playerid, COLOR_YELLOW, "* Ai castigat clear warns la giftbox!");
					}					
					if(gift > 13 && gift < 16) //10%
					{
						SendClientMessage(playerid, COLOR_YELLOW, "* Ai castigat clear fp la giftbox!");
					}					
					if(gift > 15 && gift < 21) //25%
					{
						new fireworks = 10 + random(30);
						format(string, sizeof(string), "* Ai castigat %s artificii din giftbox.", NumberFormat(fireworks));
						SendClientMessage(playerid, COLOR_YELLOW, string);
					}					
					if(gift > 20 && gift < 23) //10%
					{
						SendClientMessage(playerid, COLOR_YELLOW, "* Ai castigat un hidden din giftbox!");
					}					
					if(gift > 22 && gift < 27) //20%
					{
						SendClientMessage(playerid, COLOR_YELLOW, "* Ai castigat toate licentele +500 la giftbox!");
					}
                    playerVariables[playerid][pGiftHours] = 3;
               /* }
                else SCM(playerid,COLOR_YELLOW, szMessage);*/
            }
            else
            {
                SCM(playerid,COLOR_WHITE, "You are not at giftbox location. Go to checkpoint.");
                SetPlayerCheckpoint(playerid, 1129.31531, -1448.38330, 15.43760, 5.0);
            }
        }
        else SCM(playerid,COLOR_YELLOW,"The gift is not active.");
    }
 
    else SCM(playerid,COLOR_WHITE, "Ai nevoie de 3 ore jucate pentru a folosi comanda /getgift.");
    return 1;
}
The only problem is, that the variable "gift" is always 0. Even tho I've put "random(30)".
How can I fix this?
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: 2 Guest(s)