Retriving my Memory Of Scripting. [Need help :)]
#1

I didn't script for a long time, so this is my current issue i probably solved a long time ago:

new MapNames[][4] =
{
{"<- ID Map Name ->Location",0,0,0},
{"Map Two",1,1,1}
};



SetPlayerPos(MapNames[DefaultMap][2],MapNames[DefaultMap][3],MapNames[DefaultMap][4]);


Seems to give me errors i do kinda remember.

(192) : error 018: initialization data exceeds declared size
(227) : error 032: array index out of bounds (variable "MapNames")
Reply
#2

Ah. My Mistake. I just got another way. Instead of [][4]
[][]. I made this mistake earlier and found it :P Suprisingly no one else did that?
Reply
#3

Hmm. seems ive been wrong and found the true error: i will have to create another variable for this, unfortinunantly
Reply
#4

There are two different array sizes in the array inside the array: the name is another array with a size of about 20 cells, but the three numbers only have one cell.
But you don't have to use a second variable, it's better to use an enum here, for example:
pawn Код:
enum Map
{
    mapName[32],
    mapNum1, // TODO: change variable names
    mapNum2,
    mapNum3
}

new MapNames[][Map]
{
    { "Name of map #1", 0, 0, 0 },
    { "Name of map #2", 1, 1, 1 }
};
And, array indices start with 0, so there is no index 4 here:
pawn Код:
SetPlayerPos(MapNames[DefaultMap][2],MapNames[DefaultMap][3],MapNames[DefaultMap][4]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)