Why does this dialog lag before opening?
#4

Quote:
Originally Posted by Dokins
Посмотреть сообщение
pawn Код:
//code//
It just is weird, I think to do with loops maybe, basically what happens is that I have to define the string in every single section as opposed to just in each case, it's like it's I don't know...
I optimized your code A-bit, but I am not sure if this could is going to work, I used break; to break the loop so It would stop running when you have chosen that specific item and used varname = "Text Here"; instead of format(varname, sizeof(varname), "Text Here");

pawn Код:
else if(dialogid == DIALOG_RANDOMS)
{
    if(response == 0)
        return ShowPlayerDialog(playerid, DIALOG_PARTLIST, DIALOG_STYLE_LIST, "Part Selection", "{FF0000}Grips\n{FF0000}Frames\n{FF0000}Barrels\n{FF0000}Random Packages",  "Select", "Cancel");
   
    switch(listitem)
    {
        case 0://Random Package.
        {
            new str[128];

            if(PlayerMoney[playerid] < 1500)
                return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");

            GivePlayerMoney(playerid, -1500);

            new rand[3];
            new randStr[3][25];

            for(new i = 0; i < sizeof(rand); i++)
            {
                rand[i] = random(3);
                switch(rand[i])
                {
                    case 0:
                    {
                        randStr[i] = "Small Grip";
                        SGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");

                    }
                    case 1:
                    {
                        randStr[i] = "Medium Grip";
                        MGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
                    }
                    case 2:
                    {
                        randStr[i] = "Large Grip";
                        LGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
                    }
                }
                break;
            }
                format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr[0], randStr[1], randStr[2]);
                SendClientMessage(playerid, COLOUR_WHITE, str);
        }
        case 1://Random Package.
        {
            if(PlayerMoney[playerid] < 3000)
                return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");

            GivePlayerMoney(playerid, -3000);

            new rand1[3];
            new randStr1[3][25];

            for(new i = 0; i < sizeof(rand1); i++)
            {
                rand1[i] = random(3);
                switch(rand1[i])
                {
                    case 0:
                    {
                        randStr1[i] = "Small Frame";
                        SFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");

                    }
                    case 1:
                    {
                        randStr1[i] = "Medium Frame";
                        MFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
                    }
                    case 2:
                    {
                        randStr1[i] = "Large Frame";
                        LFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
                    }
                }
                break;
            }
                format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr1[0], randStr1[1], randStr1[2]);
                SendClientMessage(playerid, COLOUR_WHITE, str);
        }
        case 2://Random Package.
        {
            if(PlayerMoney[playerid] < 2000)
                return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");

            GivePlayerMoney(playerid, -2000);

            PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");

            new rand2[3];
            new randStr2[3][25];

            for(new i = 0; i < sizeof(rand2); i++)
            {
                rand2[i] = random(3);
                switch(rand2[i])
                {
                    case 0:
                    {
                        randStr2[i] = "Small Barrel";
                        SBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");

                    }
                    case 1:
                    {
                        randStr2[i] = "Medium Barrel");
                        MBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
                    }
                    case 2:
                    {
                        randStr2[i] = "Large Barrel");
                        LBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");
                    }
                }
                break;
            }
            format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr2[0], randStr2[1], randStr2[2]);
            SendClientMessage(playerid, COLOUR_WHITE, str);
        }
    }
}
Reply


Messages In This Thread
Why does this dialog lag before opening? - by Dokins - 18.12.2013, 18:19
Re: Why does this dialog lag before opening? - by Patrick - 18.12.2013, 18:21
Re: Why does this dialog lag before opening? - by Dokins - 18.12.2013, 18:26
Re: Why does this dialog lag before opening? - by Patrick - 18.12.2013, 18:48
Re: Why does this dialog lag before opening? - by Dokins - 18.12.2013, 19:03
Re: Why does this dialog lag before opening? - by Dokins - 18.12.2013, 19:08
Re: Why does this dialog lag before opening? - by Tayab - 18.12.2013, 19:11
Re: Why does this dialog lag before opening? - by Dokins - 18.12.2013, 19:14
Re: Why does this dialog lag before opening? - by Dokins - 18.12.2013, 19:53
Re: Why does this dialog lag before opening? - by Dokins - 19.12.2013, 00:18

Forum Jump:


Users browsing this thread: 1 Guest(s)