Question about array - Multidimensional -
Magic_Time - 13.09.2014
Hey everyone, I was scripting a squad system today, but I'm stuck at this point:
PHP код:
enum qInfo
{
qOwner[MAX_QUADS_PER_TEAM],
qOwnerConnectedID[MAX_QUADS_PER_TEAM],
qName[MAX_QUADS_PER_TEAM],
qTeam[MAX_QUADS_PER_TEAM],
qValid[MAX_QUADS_PER_TEAM],
};
new QuadInfo[MAX_TEAMS][qInfo];
Here's an example of what I would like to do:
PHP код:
new team = gTeam[playerid];
strcpy(QuadInfo[team][qOwner][squad], Name(playerid));
However it won't work, it keeps giving me this error:
PHP код:
error 032: array index out of bounds (variable "QuadInfo")
I know that qName[MAX_QUADS_PER_TEAMS] should be a string, but it just won't work.
I tried:
PHP код:
qOwner[MAX_QUADS_PER_TEAM][48]
It doesn't work, any suggestions?
Re: Question about array - Multidimensional -
Jack_Leslie - 14.09.2014
Well I can see that you have:
pawn Код:
QuadInfo[gTeam[playerid]][qOwner][squad]
Beacuse team = gteam
But then you have:
pawn Код:
QuadInfo[MAX_TEAMS][qInfo]
So that's the first thing I can see wrong. You need to use the MAX_TEAMS definition, not gTeam[playerid].
Respuesta: Re: Question about array - Multidimensional -
Magic_Time - 14.09.2014
Quote:
Originally Posted by Jack_Leslie
Well I can see that you have:
pawn Код:
QuadInfo[gTeam[playerid]][qOwner][squad]
Beacuse team = gteam
But then you have:
pawn Код:
QuadInfo[MAX_TEAMS][qInfo]
So that's the first thing I can see wrong. You need to use the MAX_TEAMS definition, not gTeam[playerid].
|
That's not what I want:
Here's an example:
PHP код:
QuadInfo[0][qOwner][0] = "Jack";
//So basically, team 0, quad slot 0's owner is Jack.
QuadInfo[0][qOwner][1] = "Tim";
//So basically, team 0, quad slot 1's owner is Tim.
Re: Question about array - Multidimensional -
Sasino97 - 14.09.2014
Try to change this in the enum
pawn Код:
qOwner[MAX_QUADS_PER_TEAM][MAX_PLAYER_NAME]
Logically it seems ok, but I don't know if pawn can handle it, try anyway.
Re: Question about array - Multidimensional -
Pottus - 14.09.2014
Quote:
Originally Posted by Sasino97
Try to change this in the enum
pawn Код:
qOwner[MAX_QUADS_PER_TEAM][MAX_PLAYER_NAME]
Logically it seems ok, but I don't know if pawn can handle it, try anyway.
|
You can't have multidimensional arrays in an enum.
Respuesta: Question about array - Multidimensional -
ThePhenix - 14.09.2014
You can do:
PHP код:
new QuadName[MAX_TEAMS][MAX_QUADS_PER_TEAM][48];
new QuadOwner[MAX_TEAMS][MAX_QUADS_PER_TEAM][48];