SA-MP Forums Archive
three multi-dimensional: is it possibile? - 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)
+--- Thread: three multi-dimensional: is it possibile? (/showthread.php?tid=610660)



three multi-dimensional: is it possibile? - DarK_FeneR - 26.06.2016

Hey guys, I'm working on a fishing sistem... Will this multi-dimensional can works?
pawn Код:
enum SFScale
{
    Name[62],
    cmMin,
    cmMax,
    Value
}
new ScaleFishStats[4][][SFScale] =
{
    {
        {"Acciuga", 13, 20, 1},
        {"Sparaglione", 13, 24, 1},
        {"Sardina", 20, 27, 1},
        {"Gт", 25, 30, 1},
        {"Pagello mafrone", 25, 36, 1},
        {"Sarago Testa Nera", 22, 45, 1},
        {"Sarago maggiore", 22, 45, 2},
        {"Anguilla", 35, 50, 2},
        {"Mormora", 30, 55, 2},
        {"Pagello fragolino", 25, 60, 1},
        {"Suro", 25, 60, 1},
        {"Sarago Pizzuto", 30, 60, 1},
        {"Sgombro", 30, 60, 1},
        {"Passera Pianuzza", 50, 60, 1},
        {"Occhialone", 30, 70, 2},
        {"Sogliola", 35, 70, 2},
        {"Orata", 35, 70, 2},
        {"Pagro mediterraneo", 35, 91, 1},
        {"Palamita", 50, 91, 2}
    },
    {
        {"Cefalo", 50, 100, 2},
        {"Spigola", 50, 103, 2},
        {"Cernia", 60, 120, 3},
        {"Tonnetto", 80, 122, 2},
        {"Merluzzo", 45, 140, 2}
    }, //Error line 59
    {
        {"Cernia di Fondale", 80, 210, 3},
        {"Tonno obeso", 180, 250, 3},
        {"Albacora", 150, 235, 3}
    },
    {
        {"Tonno rosso", 200, 450, 3},
        {"Pesce spada", 300, 455, 3}
    }
};
pawn Код:
forward RandomFishID(fishpole, &fishid, &lenght);
public RandomFishID(fishpole, &fishid, &lenght)
{
    switch(fishpole)
    {
        case 0: fishid = random(MAX_FISH_TYPE0);
        case 1: fishid = random(MAX_FISH_TYPE1);
        case 2: fishid = random(MAX_FISH_TYPE2);
        case 3: fishid = random(MAX_FISH_TYPE3);
    }

    lenght = random(ScaleFishStats[fishid][fishpole][cmMax] - ScaleFishStats[fishid][fishpole][cmMin]) + cmMin; //Error line 331
    return 1;
}
it gives me this error on compiling:
Код:
C:\Users\Vincenzo\Desktop\Test.pwn(59) : error 052: multi-dimensional arrays must be fully initialized
C:\Users\Vincenzo\Desktop\Test.pwn(331) : warning 213: tag mismatch
C:\Users\Vincenzo\Desktop\Test.pwn(331) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: three multi-dimensional: is it possibile? - Konstantinos - 26.06.2016

Do not initialize the array because if the rows do not match will give the error and to avoid it, you'd have to make them empty which looks awful.

pawn Код:
new ScaleFishStats[4][][SFScale] =
{
    {
        {"Acciuga", 13, 20, 1},
        {"Sparaglione", 13, 24, 1},
        {"Sardina", 20, 27, 1},
        {"Gт", 25, 30, 1},
        {"Pagello mafrone", 25, 36, 1},
        {"Sarago Testa Nera", 22, 45, 1},
        {"Sarago maggiore", 22, 45, 2},
        {"Anguilla", 35, 50, 2},
        {"Mormora", 30, 55, 2},
        {"Pagello fragolino", 25, 60, 1},
        {"Suro", 25, 60, 1},
        {"Sarago Pizzuto", 30, 60, 1},
        {"Sgombro", 30, 60, 1},
        {"Passera Pianuzza", 50, 60, 1},
        {"Occhialone", 30, 70, 2},
        {"Sogliola", 35, 70, 2},
        {"Orata", 35, 70, 2},
        {"Pagro mediterraneo", 35, 91, 1},
        {"Palamita", 50, 91, 2}
    },
    {
        {"Cefalo", 50, 100, 2},
        {"Spigola", 50, 103, 2},
        {"Cernia", 60, 120, 3},
        {"Tonnetto", 80, 122, 2},
        {"Merluzzo", 45, 140, 2},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    }, //Error line 59
    {
        {"Cernia di Fondale", 80, 210, 3},
        {"Tonno obeso", 180, 250, 3},
        {"Albacora", 150, 235, 3},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    },
    {
        {"Tonno rosso", 200, 450, 3},
        {"Pesce spada", 300, 455, 3},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    }
};



Re: three multi-dimensional: is it possibile? - DarK_FeneR - 26.06.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Do not initialize the array because if the rows do not match will give the error and to avoid it, you'd have to make them empty which looks awful.

pawn Код:
new ScaleFishStats[4][][SFScale] =
{
    {
        {"Acciuga", 13, 20, 1},
        {"Sparaglione", 13, 24, 1},
        {"Sardina", 20, 27, 1},
        {"Gт", 25, 30, 1},
        {"Pagello mafrone", 25, 36, 1},
        {"Sarago Testa Nera", 22, 45, 1},
        {"Sarago maggiore", 22, 45, 2},
        {"Anguilla", 35, 50, 2},
        {"Mormora", 30, 55, 2},
        {"Pagello fragolino", 25, 60, 1},
        {"Suro", 25, 60, 1},
        {"Sarago Pizzuto", 30, 60, 1},
        {"Sgombro", 30, 60, 1},
        {"Passera Pianuzza", 50, 60, 1},
        {"Occhialone", 30, 70, 2},
        {"Sogliola", 35, 70, 2},
        {"Orata", 35, 70, 2},
        {"Pagro mediterraneo", 35, 91, 1},
        {"Palamita", 50, 91, 2}
    },
    {
        {"Cefalo", 50, 100, 2},
        {"Spigola", 50, 103, 2},
        {"Cernia", 60, 120, 3},
        {"Tonnetto", 80, 122, 2},
        {"Merluzzo", 45, 140, 2},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    }, //Error line 59
    {
        {"Cernia di Fondale", 80, 210, 3},
        {"Tonno obeso", 180, 250, 3},
        {"Albacora", 150, 235, 3},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    },
    {
        {"Tonno rosso", 200, 450, 3},
        {"Pesce spada", 300, 455, 3},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0},
        {"", 0, 0, 0}
    }
};
i done defines for this
#define MAX_FISH_TYPE0 19
#define MAX_FISH_TYPE1 5
#define MAX_FISH_TYPE2 3
#define MAX_FISH_TYPE3 2

But my question is: gives it to me this error message because I can't do this?


Re: three multi-dimensional: is it possibile? - Konstantinos - 26.06.2016

Код:
lenght = random(ScaleFishStats[fishid][fishpole][cmMax] - ScaleFishStats[fishid][fishpole][cmMin]) + ScaleFishStats[fishid][fishpole][cmMin];
You wrote "+ cmMin" instead which cannot be used like that.


Re: three multi-dimensional: is it possibile? - DarK_FeneR - 26.06.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
lenght = random(ScaleFishStats[fishid][fishpole][cmMax] - ScaleFishStats[fishid][fishpole][cmMin]) + ScaleFishStats[fishid][fishpole][cmMin];
You wrote "+ cmMin" instead which cannot be used like that.
Oh shit. Sorry, I just understand what you mean LOL sorry! For it and to fill the array. I didn't understand, sorry. All fixed, thx! Rep +