SA-MP Forums Archive
How to put in enum number of arrays + strings? - 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: How to put in enum number of arrays + strings? (/showthread.php?tid=569301)



How to put in enum number of arrays + strings? - maximthepain - 29.03.2015

I would like to ask, I'm trying to make 6 wanted reasons for wanted level.
Instead of doing:
Код:
enum pInfo
{
    WantedReason1[24],
    WantedReason2[24],
    WantedReason3[24],
    WantedReason4[24],
    WantedReason5[24],
    WantedReason6[24],
};
I want:
Код:
enum pInfo
{
    WantedReason[6][24],
};
So later on I can do this for example:
Код:
for(new i = 0; i < 5; i++)
{
    INI_String("WantedReason",PlayerInfo[playerid][WantedReason][i], 24);
}
How can i do this to work? When i complie it like that, its working untill the variable in the enum WantedReason and everything after the variable is in error. so im asuming this is incorrect way to do it.


Re: How to put in enum number of arrays + strings? - CalvinC - 29.03.2015

You cannot have a 2D array in your enumerator like that, but you could declare it outside your enumerator.


Re: How to put in enum number of arrays + strings? - maximthepain - 29.03.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
You cannot have a 2D array in your enumerator like that, but you could declare it outside your enumerator.
can you show me how?
But it has to feet PlayerInfo[playerid] :/


Re: How to put in enum number of arrays + strings? - Evocator - 29.03.2015

for(new i = 0; i != 6; i++) ... this will loop 6x
for(new i = 0; i != 5; i++) ... this will loop 5x

If you have 6 starts then you should loop 6x and not 5.


Re: How to put in enum number of arrays + strings? - CalvinC - 29.03.2015

pawn Код:
new WantedReason[MAX_PLAYERS][6][24];
I don't think it's possible to do in an enumerator, but there's no difference.


Re: How to put in enum number of arrays + strings? - maximthepain - 29.03.2015

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
for(new i = 0; i != 6; i++) ... this will loop 6x
for(new i = 0; i != 5; i++) ... this will loop 5x

If you have 6 starts then you should loop 6x and not 5.
Wanted can be 6 stars so its 0,1,2,3,4,5 5x. its more like i need to do [5] instead of 6

Well I guess i will go with new WantedReason[MAX_PLAYERS][6][24]; thanks..


Re: How to put in enum number of arrays + strings? - Tanky - 29.03.2015

You cannot do that in an enum because pawn doesn't support 4-dimensional arrays.
PlayerInfo[playerid][WantedReason][x][y] is a 4-dimensional array.


Re: How to put in enum number of arrays + strings? - maximthepain - 29.03.2015

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Can you even count?

0, 1, 2, 3, 4, 5 are 6 numbers and not 5 lol.
Probably counting the arrows here could help more: http://gyazo.com/f3f7c4fa4212cbfb3e391810c4054d12
6x.. right i said 6 stars and ment to write 0,1,2,3,4,5 x6 .. dude dont insult me just help with the problem..which dont even relat to the counting.. thanks


Re: How to put in enum number of arrays + strings? - Evocator - 29.03.2015

I did not even intended to insult you, i just wanted to get you on the right track and avoid flaws in your code: http://gyazo.com/d8658fb8d7a0e46908f41a69d565130a