Variable being shadowed but not in same dialog?
#1

Everything after this dialog shows:

pawn Код:
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(8978) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(9160) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(9196) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(9260) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(9267) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\user\Desktop\Tierra Robada Roleplay\gamemodes\TRRP_MYSQL.pwn(9274) : warning 219: local variable "string" shadows a variable at a preceding level
EVEN if I change it to a different name it still complains later on in the script.

pawn Код:
else if(dialogid == DIALOG_GUNPARTS)
            {
                new string[128];
                if(response == 0)
                {
                    return 1;
                }
                switch(listitem)
                {
                    case 0:
                    {
     
                        PlayerMoney[playerid] = GetPlayerMoney(playerid);
                        if(PlayerMoney[playerid] < 300)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -300);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        SGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Small Grip, you now have a total of %d.", SGrip[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 1:
                    {
               
                        if(PlayerMoney[playerid] < 500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -500);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        MGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Medium Grip, you now have a total of %d.", MGrip[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 2:
                    {
             
                        if(PlayerMoney[playerid] < 750)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -750);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        LGrip[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Large Grip, you now have a total of %d.", LGrip[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);

                    }
                    case 3://Random Package.
                    {
                        if(PlayerMoney[playerid] < 1500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -1500);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        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(string, sizeof(string),"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, string);
                    }//actual case
                    case 4:
                    {
           
                        if(PlayerMoney[playerid] < 1000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, - 1000);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        SFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Small Frame, you now have a total of %d.", SFrame[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 5:
                    {
         
                        if(PlayerMoney[playerid] < 1500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -1500);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        MFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Medium Frame, you now have a total of %d.", MFrame[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 6:
                    {
             
                        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");
                        LFrame[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Large Frame, you now have a total of %d.", LFrame[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);

                    }
                    case 7://Random Package.
                    {
                        if(PlayerMoney[playerid] < 3000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -3000);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
           
                        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(string, sizeof(string),"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, string);
                    }//case
                case 8:
                    {
     
                        if(PlayerMoney[playerid] < 500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -500);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        SBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Small Barrel, you now have a total of %d.", SBarrel[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 9:
                    {
         
                        if(PlayerMoney[playerid] < 750)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -750);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        MBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Medium Barrel, you now have a total of %d.", MBarrel[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);
                    }
                    case 10:
                    {
     
                        if(PlayerMoney[playerid] < 1000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
                        GivePlayerMoney(playerid, -1000);
                        PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
                        LBarrel[playerid] ++;
                        MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");
                        format(string, sizeof(string), "You have purchased a Large Barrel, you now have a total of %d.", LBarrel[playerid]);
                        SendClientMessage(playerid, COLOUR_WHITE, string);

                    }
                    case 11://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(string, sizeof(string),"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, string);
                    }//case
                }//switch
            }//dialog
Reply
#2

pawn Код:
Change - new string[128]; TO --  new str[148];
Reply
#3

Код:
8978
9160
9196
9260
9267
9274
show these lines only
Reply
#4

Thanks, that fixed it, I wasn't aware a global var in Dialog would work on ALL dialogs.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)