error 032: array index out of bounds
#1

I get this error on these codes:

Код:
C:\Users\User\Desktop\VL-Roleplay\GTA RP Script Linux\gamemodes\RolePlay.pwn(5941) : error 032: array index out of bounds (variable "CopSkins")
C:\Users\User\Desktop\VL-Roleplay\GTA RP Script Linux\gamemodes\RolePlay.pwn(16274) : error 032: array index out of bounds (variable "CopSkins")
C:\Users\User\Desktop\VL-Roleplay\GTA RP Script Linux\gamemodes\RolePlay.pwn(16279) : error 032: array index out of bounds (variable "CopSkins")
C:\Users\User\Desktop\VL-Roleplay\GTA RP Script Linux\gamemodes\RolePlay.pwn(16283) : error 032: array index out of bounds (variable "CopSkins")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
new CopSkins[][] =
{
    {280},{281},{265},{266},{267},{282},{283},{288},{284},{285}
};

SetPlayerSkin(playerid, CopSkins[0][1]);

if(Player[playerid][SelectingClothes] == 1)
    {
        if(Player[playerid][SelectingClothesType] == 1)
        {
            new ViewingSkin = 0;
            if(clickedid == NSkin)
            {
                ViewingSkin++;
                SetPlayerSkin(playerid, CopSkins[ViewingSkin][1]);
            }
            if(clickedid == PSkin)
            {
                ViewingSkin--;
                SetPlayerSkin(playerid, CopSkins[ViewingSkin][1]);
            }
            if(clickedid == SSkin)
            {
                Player[playerid][DutyClothes] = CopSkins[ViewingSkin][1];
                SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
                SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
                SetPlayerInterior(playerid, Player[playerid][LastInt]);
                SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]);
                SetPlayerSkin(playerid, Player[playerid][LastSkin]);
                Player[playerid][SelectingClothesType] = 0;
                Player[playerid][SelectingClothes] = 0;
                SCM(playerid, ADMINBLUE, "Duty Clothes changed!");
                SavePlayerData(playerid);
            }
            if(clickedid == CSkin)
            {
                SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
                SetPlayerFacingAngle(playerid, Player[playerid][LastA]);
                SetPlayerInterior(playerid, Player[playerid][LastInt]);
                SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]);
                SetPlayerSkin(playerid, Player[playerid][LastSkin]);
                Player[playerid][SelectingClothesType] = 0;
                Player[playerid][SelectingClothes] = 0;
            }
        }
    }
Reply
#2

Which lines?
Reply
#3

I'm interested to know why some people (not just you) always create a two dimensional array where a single dimensional array would suffice. What exactly is wrong with this?

pawn Код:
new const CopSkins[] = { 280, 281, 265, 266, 267, 282, 283, 288, 284, 285 };
Then simply use like this:

pawn Код:
SetPlayerSkin(playerid, CopSkins[ViewingSkin]);
No useless second dimension.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'm interested to know why some people (not just you) always create a two dimensional array where a single dimensional array would suffice. What exactly is wrong with this?

pawn Код:
new const CopSkins[] = { 280, 281, 265, 266, 267, 282, 283, 288, 284, 285 };
Then simply use like this:

pawn Код:
SetPlayerSkin(playerid, CopSkins[ViewingSkin]);
No useless second dimension.
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)