SA-MP Forums Archive
Retriving my Memory Of Scripting. [Need help :)] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Retriving my Memory Of Scripting. [Need help :)] (/showthread.php?tid=251119)



Retriving my Memory Of Scripting. [Need help :)] - DeadAhead - 25.04.2011

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")


Re: Retriving my Memory Of Scripting. [Need help :)] - DeadAhead - 25.04.2011

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?


Re: Retriving my Memory Of Scripting. [Need help :)] - DeadAhead - 25.04.2011

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


AW: Retriving my Memory Of Scripting. [Need help :)] - Fabsch - 25.04.2011

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