SA-MP Forums Archive
Multi-dimensional in enum - 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: Multi-dimensional in enum (/showthread.php?tid=407271)



Multi-dimensional in enum - printer - 13.01.2013

I've got this:
pawn Код:
enum fInfo
{
    fID,
    fName[32],
    fType,
    fDefaultSkin,
    Float:fDuty[3],
    fRank1[30],
    fRank2[30],
    fRank3[30],
    fRank4[30],
    fRank5[30],
    fRank6[30],
    fRank7[30],
    fRank8[30],
    fRank9[30],
    fRank10[30],
    fRank11[30],
    fRank12[30],
    fRank13[30],
    fRank14[30],
    fLeaderRank,
};
Now instead of all the ranks I'd wanna do fRank[30][15] but for some reason, it tells me that "}" is expected and there is "[", is there a way to do it to save lines?


Re: Multi-dimensional in enum - u3ber - 13.01.2013

just think of enums as placeholders for values. if i'm correct with what i think you're trying to do, it can be done in a FAR simpler way (no need for your mda). so what EXACTLY are you trying to do?


Re: Multi-dimensional in enum - printer - 13.01.2013

I am trying to make fRank usable in a way of like:
fRank[0] = rank name..
fRank[1] = rank name..
and blablabla instead of defining each varible million times with the string cells, I want to push the string cells and the array together.


Re: Multi-dimensional in enum - u3ber - 13.01.2013

Quote:
Originally Posted by printer
Посмотреть сообщение
I am trying to make fRank usable in a way of like:
fRank[0] = rank name..
fRank[1] = rank name..
and blablabla instead of defining each varible million times with the string cells, I want to push the string cells and the array together.
then represent them (ranks) as integer values, so you don't need to modify the meaning of the rank, just the number (and each number has a hypothetical meaning so -><-).


Re: Multi-dimensional in enum - printer - 13.01.2013

But I want it to be as a string so I can use it in /stats command and others.


Re: Multi-dimensional in enum - alenrobin - 14.09.2018

E-num is basically standing for "enumerated data type" which used in any kind of Programming language mostly in those platforms where it supports this format. The programmers face trouble in cases of using multidimensional in the enum. You may take a suggestion from hp printer assistant for proceeding further.


Re: Multi-dimensional in enum - JustNothing - 14.09.2018

https://sampforum.blast.hk/showthread.php?tid=373107


Re: Multi-dimensional in enum - Ciandlah - 14.09.2018

pawn Код:
enum fInfo
{
    fID,
    fName[32],
    fType,
    fDefaultSkin,
    Float:fDuty[3],
    fRank1[30],
    fRank2[30],
    fRank3[30],
    fRank4[30],
    fRank5[30],
    fRank6[30],
    fRank7[30],
    fRank8[30],
    fRank9[30],
    fRank10[30],
    fRank11[30],
    fRank12[30],
    fRank13[30],
    fRank14[30],
    fLeaderRank
};
Try this, you had an error in your code anyway


Re: Multi-dimensional in enum - Undef1ned - 15.09.2018

"I think" that it is not possible to do that in "enum's", since somehow it is going to throw you "error 001: expected token:"} ", but found" ["". Although you can do it this way.

PHP код:
new MyVariable[30][15];
new 
MyVariable2[MAX_PLAYERS][30][15]; 



Re: Multi-dimensional in enum - DRIFT_HUNTER - 15.09.2018

Short answer, it should not be possible to have array in enum at all.
Possible patch for your problem (i didnt test it but should work just fine)
pawn Код:
enum fInfo
{
    fID,
    fName[32],
    fType,
    fDefaultSkin,
    Float:fDuty[3],
    fLeaderRank,
};
new FactionInfo[MAX_FACTIONS][fInfo];
new fRank[MAX_FACTIONS][15][30];
#define FactionInfo[%0][fRank][%1] fRank[%0][%1]

//Example usage (empty string by nullifing first letter)
FactionInfo[FactionID][fRank][RankID][0] = '\0';