SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/08/2012, 12:36 PM   #1
Sinner
Gangsta
 
Sinner's Avatar
 
Join Date: Aug 2010
Location: On This Mortal Coil
Posts: 770
Reputation: 292
Default multidimensional array: alternative?

I'm making an include for something, and I need to address a multidimensional array within an enum. The following example will not work:

pawn Code:
// This, ofcourse, will not give any errors
#define ARRAY_SIZE 10
#define ENUM_SIZE 10

enum edata {
    E_DATA[ARRAY_SIZE]
}
new Enum[ENUM_SIZE][edata];

// This will not work, assuming "idx" is a valid index (Line 45)

Enum[idx][E_DATA[idx]] = someValue;

// This also gives some errors
Enum[idx][E_DATA][idx] = someValue;

Are there any alternatives for this? i'd like to keep the enum as this simplifies my problem. The errors are as followed:

Code:
C:~PATH~\~INCLUDE~.inc(45) : error 028: invalid subscript (not an array or too many subscripts): "E_DATA"
C:~PATH~\~INCLUDE~.inc(45) : warning 215: expression has no effect
C:~PATH~\~INCLUDE~.inc(45) : error 001: expected token: ";", but found "]"
C:~PATH~\~INCLUDE~.inc(45) : error 029: invalid expression, assumed zero
C:~PATH~\~INCLUDE~.inc(45) : fatal error 107: too many error messages on one line
__________________
Please use the search feature before asking a question.
Sinner is offline   Reply With Quote
Old 02/08/2012, 12:40 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: multidimensional array: alternative?

I think it's:
pawn Code:
Enum[idx][E_DATA][idx] = someValue;
Otherwise make a normal three dimensional array.
__________________
Vince is offline   Reply With Quote
Old 02/08/2012, 12:41 PM   #3
Sinner
Gangsta
 
Sinner's Avatar
 
Join Date: Aug 2010
Location: On This Mortal Coil
Posts: 770
Reputation: 292
Default Re: multidimensional array: alternative?

Quote:
Originally Posted by Vince View Post
I think it's:
pawn Code:
Enum[idx][E_DATA][idx] = someValue;
Otherwise make a normal three dimensional array.
My bad I didn't put it in the post. The errors for that case are as followed:

Code:
C:~PATH~/~INCLUDE~.inc(45) : warning 213: tag mismatch
C:~PATH~/~INCLUDE~.inc(45) : error 032: array index out of bounds (variable "Enum")
C:~PATH~/~INCLUDE~.inc(52) : error 008: must be a constant expression; assumed zero
C:~PATH~/~INCLUDE~.inc(52) : error 009: invalid array size (negative, zero or out of bounds)
C:~PATH~/~INCLUDE~.inc(52) : error 036: empty statement
C:~PATH~/~INCLUDE~.inc(52) : fatal error 107: too many error messages on one line
__________________
Please use the search feature before asking a question.
Sinner is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with multidimensional array Miguel Scripting Help 2 03/12/2011 03:19 PM
[Help] - Multidimensional Arrays xRyder Help Archive 5 19/02/2011 01:31 PM
Multidimensional array's Aleks7 Help Archive 0 07/10/2010 03:53 PM
Return multidimensional array Blekk Help Archive 2 22/01/2010 02:37 AM


All times are GMT. The time now is 07:27 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.