Array index out of bounds (variable "Pay")
#1

It says:
Код:
new.pwn(24639 -- 24640) : error 032: array index out of bounds (variable "Pay")
new.pwn(24676) : error 032: array index out of bounds (variable "Pay")
new.pwn(24677) : error 032: array index out of bounds (variable "Pay")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPh
Where I add: [pawn] Factions[i][Rank8Pay] = Pay[7];
Factions[i][Rank9Pay] = Pay[8];
Factions[i][Rank10Pay] = Pay[9];[/code]

pawn Код:
stock LoadFactions()
    {
        new
            Str[1024],
            fID,
            fName[128],
            fRankOne[50],
            fRankTwo[50],
            fRankThree[50],
            fRankFour[50],
            fRankFive[50],
            fRankSix[50],
            fRankSeven[50],
            fRankEight[50],
            fRankNine[50],
            fRankTen[50],
            Skin[10],
            Bank,
            Pay[8],
            PosX[4],
            PosY[4],
            PosZ[4],
            PosA[4],
            Int[4],
            VW[4],
            SpawnSet[4],
            name1[25],
            name2[25],
            name3[25],
            Type;

        mysql_query("SELECT * FROM `factions`");
        mysql_store_result();

        new
            i = 1;

        if(mysql_num_rows() > 0) {
            while(mysql_fetch_row(Str)) {
                sscanf(Str, "p<|>is[128]s[50]s[50]s[50]s[50]s[50]s[50]s[50]s[50]s[50]s[50]iiiiiiiiiiiiiiiiiiiiiis[24]ffffiiis[24]ffffiiis[24]ffffiii",
                fID, fName, fRankOne, fRankTwo, fRankThree, fRankFour, fRankFive, fRankSix, fRankSeven, fRankEight, fRankNine, fRankTen, Skin[0], Skin[1], Skin[2], Skin[3], Skin[4], Skin[5], Skin[6], Skin[7], Skin[8], Skin[9], Bank, Pay[0], Pay[1], Pay[2], Pay[3], Pay[4], Pay[5], Pay[6], Pay[7], Pay[8], Pay[9],
                SpawnSet[1], name1, PosX[1], PosY[1], PosZ[1], PosA[1], Int[1], VW[1], SpawnSet[2], name2, PosX[2], PosY[2], PosZ[2], PosA[2], Int[2], VW[2], SpawnSet[3], name3, PosX[3], PosY[3], PosZ[3], PosA[3], Int[3], VW[3], Type);

                format(Factions[i][FactionName], 128, "%s", fName);
                format(Factions[i][RankOne], 50, "%s", fRankOne);
                format(Factions[i][RankTwo], 50, "%s", fRankTwo);
                format(Factions[i][RankThree], 50, "%s", fRankThree);
                format(Factions[i][RankFour], 50, "%s", fRankFour);
                format(Factions[i][RankFive], 50, "%s", fRankFive);
                format(Factions[i][RankSix], 50, "%s", fRankSix);
                format(Factions[i][RankSeven], 50, "%s", fRankSeven);
                format(Factions[i][RankEight], 50, "%s", fRankEight);
                format(Factions[i][RankNine], 50, "%s", fRankNine);
                format(Factions[i][RankTen], 50, "%s", fRankTen);
               
                Factions[i][FactionSkin][0] = Skin[0];
                Factions[i][FactionSkin][1] = Skin[1];
                Factions[i][FactionSkin][2] = Skin[2];
                Factions[i][FactionSkin][3] = Skin[3];
                Factions[i][FactionSkin][4] = Skin[4];
                Factions[i][FactionSkin][5] = Skin[5];
                Factions[i][FactionSkin][6] = Skin[6];
                Factions[i][FactionSkin][7] = Skin[7];
                Factions[i][FactionSkin][8] = Skin[8];
                Factions[i][FactionSkin][9] = Skin[9];
               
                Factions[i][FactionBank] = Bank;
               
                Factions[i][Rank1Pay][0] = Pay[0];
                Factions[i][Rank2Pay][1] = Pay[1];
                Factions[i][Rank3Pay][2] = Pay[2];
                Factions[i][Rank4Pay][3] = Pay[3];
                Factions[i][Rank5Pay][4] = Pay[4];
                Factions[i][Rank6Pay][5] = Pay[5];
                Factions[i][Rank7Pay][6] = Pay[6];
                Factions[i][Rank8Pay][7] = Pay[7];
                Factions[i][Rank9Pay][8] = Pay[8];
                Factions[i][Rank10Pay][9] = Pay[9];
               

                Factions[i][fType] = Type;

                format(Factions[i][f1SpawnName], 24, "%s", name1);
                Factions[i][fSpawnSet][1] = SpawnSet[1];
                Factions[i][fSpawnPosX][1] = PosX[1];
                Factions[i][fSpawnPosY][1] = PosY[1];
                Factions[i][fSpawnPosZ][1] = PosZ[1];
                Factions[i][fSpawnPosA][1] = PosA[1];
                Factions[i][fSpawnInt][1] = Int[1];
                Factions[i][fSpawnWorld][1] = VW[1];

                format(Factions[i][f2SpawnName], 24, "%s", name2);
                Factions[i][fSpawnSet][2] = SpawnSet[2];
                Factions[i][fSpawnPosX][2] = PosX[2];
                Factions[i][fSpawnPosY][2] = PosY[2];
                Factions[i][fSpawnPosZ][2] = PosZ[2];
                Factions[i][fSpawnPosA][2] = PosA[2];
                Factions[i][fSpawnInt][2] = Int[2];
                Factions[i][fSpawnWorld][2] = VW[2];

                format(Factions[i][f3SpawnName], 24, "%s", name3);
                Factions[i][fSpawnSet][3] = SpawnSet[3];
                Factions[i][fSpawnPosX][3] = PosX[3];
                Factions[i][fSpawnPosY][3] = PosY[3];
                Factions[i][fSpawnPosZ][3] = PosZ[3];
                Factions[i][fSpawnPosA][3] = PosA[3];
                Factions[i][fSpawnInt][3] = Int[3];
                Factions[i][fSpawnWorld][3] = VW[3];

                ToggledF[i] = 0;
                i++;
                fTotal++;
            }
        }
        mysql_free_result();
        printf("--- %i factions loaded from the MySQL Database. ---", fTotal);
        return 1;
    }
Reply
#2

pawn Код:
Pay[8],
means 0-7 and you got
pawn Код:
Factions[i][Rank7Pay] = Pay[8];
Factions[i][Rank7Pay] = Pay[9];
Reply
#3

So what am I suppose to do?
Reply
#4

Quote:
Originally Posted by EmilLykke
Посмотреть сообщение
So what am I suppose to do?
Change the size of
pawn Код:
Pay[8]
To

pawn Код:
Pay[10]
Reply
#5

It comes up with errors at the sscanf lines and it says that Pay is out of bounds.
Reply
#6

So change both Pay[8] and Pay[9] to 10?

I would like help..

Please add me on skype. "Emil.Lykke"
Reply
#7

Fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)