Question about array - Multidimensional
#1

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

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

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

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

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

You can do:


PHP код:
new QuadName[MAX_TEAMS][MAX_QUADS_PER_TEAM][48];
new 
QuadOwner[MAX_TEAMS][MAX_QUADS_PER_TEAM][48]; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)