SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/03/2013, 10:03 AM   #1
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Sizeof 2D Array

Hello there,

I have this array:

pawn Code:
enum _robinfos{
    rName[64],
    rPay,
    Float:rX,
    Float:rY,
    Float:rZ,
    rID
}

new RobInfos[6][100][_robinfos];

And when I want to get size of RobInfos[1] I do this
pawn Code:
sizeof(RobInfos[1])
but from some reason I get this error
Code:
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 001: expected token: "]", but found "-integer value-"
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : warning 215: expression has no effect

4 Errors.
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 001: expected token: ";", but found "]"
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 029: invalid expression, assumed zero
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : fatal error 107: too many error messages on one line
can anyone tell me what am I doing wrong here...
__________________
CoaPsyFactor is offline   Reply With Quote
Old 19/03/2013, 10:19 AM   #2
Stylock
Huge Clucker
 
Stylock's Avatar
 
Join Date: Dec 2010
Posts: 342
Reputation: 137
Default Re: Sizeof 2D Array

Read what the compiler says:
Code:
error 001: expected token: "]", but found "-integer value-"
Stylock is offline   Reply With Quote
Old 19/03/2013, 07:18 PM   #3
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Re: Sizeof 2D Array

and? if you see the code there is no open [ left, its sizeof(RobInfos[1]); that means size of sub arrays in one array
__________________
CoaPsyFactor is offline   Reply With Quote
Old 19/03/2013, 07:20 PM   #4
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 3,134
Reputation: 639
Default Re: Sizeof 2D Array

Remove the value.
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 20/03/2013, 12:08 AM   #5
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Re: Sizeof 2D Array

Well I can't, I have RobInfo[6][100][_some_enum], and I need to get all records from RobInfo[6] but if I change RobInfo[6][100][_some_enum] to RobInfo[6][][_some_enum] it crashes compiler.
__________________
CoaPsyFactor is offline   Reply With Quote
Old 20/03/2013, 01:28 AM   #6
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,554
Reputation: 130
Default Re: Sizeof 2D Array

What part of the array do you actually want the size of? This is btw an 3D array, not 2D
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 20/03/2013, 03:38 AM   #7
mastermax7777
Huge Clucker
 
Join Date: Oct 2012
Posts: 428
Reputation: -46
Default Re: Sizeof 2D Array

try this...
sizeof(RobInfos[])
mastermax7777 is offline   Reply With Quote
Old 20/03/2013, 04:20 AM   #8
CJay9209
Huge Clucker
 
Join Date: Jan 2013
Location: Canada
Posts: 218
Reputation: 24
Default Re: Sizeof 2D Array

yeah as i remember my 3d arrays always had trouble using the sizeof() function for some reason.

then again i was trying to get the sizeof a string contained in a singe enum at the end of the array so slightly different issue. I think that what ur trying to do is maybe not possible as ur not fully indexing the 3d array and it needs all 3 variables to be specified but thats only my stab in the dark - anyone please feel free to correct me lol.
__________________
My stuff:
CJay9209 is offline   Reply With Quote
Old 20/03/2013, 07:00 AM   #9
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,554
Reputation: 130
Default Re: Sizeof 2D Array

Quote:
Originally Posted by mastermax7777 View Post
try this...
sizeof(RobInfos[])
That would get the size of the 2nd dimension. What he (apparently) wants to do is getting the size of the string inside the enum. My best shot would be either
pawn Code:
sizeof( RobInfos[][] )
or
pawn Code:
sizeof( RobInfos[][][] )
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 20/03/2013, 07:34 AM   #10
mastermax7777
Huge Clucker
 
Join Date: Oct 2012
Posts: 428
Reputation: -46
Default Re: Sizeof 2D Array

Quote:
Originally Posted by LarzI View Post
That would get the size of the 2nd dimension. What he (apparently) wants to do is getting the size of the string inside the enum. My best shot would be either
pawn Code:
sizeof( RobInfos[][] )
or
pawn Code:
sizeof( RobInfos[][][] )
[][][] is not valid, thats 4. he probably wants what i posted before
mastermax7777 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
[FIXED] Char-array with sizeof() as size MP2 Scripting Help 7 19/03/2013 05:00 AM
sizeof char-array MP2 Scripting Help 9 17/03/2013 07:39 PM
sizeof array RedFusion Scripting Help 2 07/12/2012 04:21 PM
sizeof second dimension of array? SEnergy Scripting Help 2 29/07/2012 12:15 PM
sizeof 2D array zgintasz Scripting Help 8 05/07/2012 09:35 AM


All times are GMT. The time now is 12:26 AM.


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