Multi-dimensional in enum
#1

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?
Reply
#2

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?
Reply
#3

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.
Reply
#4

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 -><-).
Reply
#5

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

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.
Reply
#7

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

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
Reply
#9

"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]; 
Reply
#10

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';
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)