SA-MP Forums Archive
Why does this dialog lag before opening? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why does this dialog lag before opening? (/showthread.php?tid=481997)



Why does this dialog lag before opening? - Dokins - 18.12.2013

pawn Код:
CMD:buyparts(playerid,params[])
{
    new string[64];
    if(IsPlayerInRangeOfPoint(playerid, 5.0, -2230.5210,2560.3955,1.8223))
     {
        format(string, sizeof(string), "Illegal Gun Part Purchasing.");
        ShowPlayerDialog(playerid, DIALOG_PARTLIST, DIALOG_STYLE_LIST, string, "{FF0000}Grips\n{FF0000}Frames\n{FF0000}Barrels\n{FF0000}Random Packages", "Select", "Cancel");
    }
    return 1;
}

It does it, all the time and I've absolutely no idea. But the /buy dialog doesn't lag. Can someone please advise me?


Re: Why does this dialog lag before opening? - Patrick - 18.12.2013

Show us the DIALOG_PARTLIST under OnDialogResponse


Re: Why does this dialog lag before opening? - Dokins - 18.12.2013

pawn Код:
else if(dialogid == DIALOG_PARTLIST)
            {
                printf("CALLED DIALOG_PARTLIST");
            if(response == 0)
                {
                    return 1;
                }
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid, DIALOG_GRIPS, DIALOG_STYLE_LIST, "Available Grips", "Small Grip {FF0000}($300)\nMedium Grip {FF0000}($500)\nLarge Grip{FF0000}($750)", "Buy", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid, DIALOG_FRAMES, DIALOG_STYLE_LIST, "Available Frames", "Small Frame {FF0000}($1,000)\nMedium Frame {FF0000}($1,500)\nLarge Frame {FF0000}($2,000)", "Buy", "Cancel");
                    }
                    case 2:
                    {
                        ShowPlayerDialog(playerid, DIALOG_BARRELS, DIALOG_STYLE_LIST, "Available Barrels", "Small Barrel {FF0000}($500)\nMedium Barrel {FF0000}($750)\nLarge Barrel{FF0000}($1,000)", "Buy", "Cancel");
                    }
                    case 3:
                    {
                        ShowPlayerDialog(playerid, DIALOG_RANDOMS, DIALOG_STYLE_LIST, "Available Random Packages", "Random Grip Package (3) {FF0000}($1,500)\nRandom Frame Package (3){FF0000}($3,000)\nRandom Barrel Package (3) {FF0000}($2,000)", "Buy", "Cancel");
                    }
                }
            }
Thank you, already.

EDIT:

I really think it's something to do with this dialog:

pawn Код:
else if(dialogid == DIALOG_RANDOMS)
            {
            if(response == 0)
                {
                    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:
                                {
                                    format(randStr[i], 25, "Small Grip");
                                    SGrip[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");

                                }
                            case 1:
                                {
                                    format(randStr[i], 25, "Medium Grip");
                                    MGrip[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
                                }
                            case 2:
                                {
                                    format(randStr[i], 25, "Large Grip");
                                    LGrip[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
                                }//case 2
                            }//switch
                        }//fornew
                            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);
                    }//actual case
                    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:
                                {
                                    format(randStr1[i], 25, "Small Frame");
                                    SFrame[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");

                                }
                            case 1:
                                {
                                    format(randStr1[i], 25, "Medium Frame");
                                    MFrame[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
                                }
                            case 2:
                                {
                                    format(randStr1[i], 25, "Large Frame");
                                    LFrame[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
                                }//case 2
                            }//switch
                        }//switch
                            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
                    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:
                                {
                                    format(randStr2[i], 25, "Small Barrel");
                                    SBarrel[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");

                                }
                            case 1:
                                {
                                    format(randStr2[i], 25, "Medium Barrel");
                                    MBarrel[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
                                }
                            case 2:
                                {
                                    format(randStr2[i], 25, "Large Barrel");
                                    LBarrel[playerid] ++;
                                    MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");
                                }//case 2
                            }//switch

                        }//for
                            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);
                    }//case
                }//switch
            }//dialog
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...


Re: Why does this dialog lag before opening? - Patrick - 18.12.2013

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);
        }
    }
}



Re: Why does this dialog lag before opening? - Dokins - 18.12.2013

I appreciate this, I will update you on the outcome. Much appreciated. Rep +.


Re: Why does this dialog lag before opening? - Dokins - 18.12.2013

Sorry for double post, It didn't work, I'm afraid. It didn't display all the strings, as in the parts in "this"


Re: Why does this dialog lag before opening? - Tayab - 18.12.2013

pawn Код:
randStr[i] = "Small Grip";
I doubt this will work, because for putting strings in a variable, you have to format it. I am not sure.

This is the only way I see to define all the strings.
pawn Код:
format(randStr[i],sizeof(randStr[i]),"Small Grip");



Re: Why does this dialog lag before opening? - Dokins - 18.12.2013

I reverted back to the way it was.


Re: Why does this dialog lag before opening? - Dokins - 18.12.2013

Anyone?


Re: Why does this dialog lag before opening? - Dokins - 19.12.2013

Still unresolved.