sortof an array inside an array?
#1

hi,

so, I was wondering if I can make something like:

pawn Код:
enum cpData
{
    Float:CP_X[ 20 ],
    Float:CP_Y[ 20 ],
    Float:CP_Z[ 20 ]
}
new Float:RaceCheckpoints[ 1 ][ cpData ] =
{
    { 10.001, 51.5123, 25.12312 }
};
it works fine, but how should I do it? I mean, CP_X[ 0 ] should be 10.001; CP_Y[ 0 ] should be 51.5123; and CP_Z[ 0 ] should be 25.12312;

then it should go on, on the same row, till CP_X/Y/Z[ 19 ];

for example.

{ 123, 456, 789, 123, 2345, 12315, 1234, 12352315, 35, 345, 123, 153125, 321431, 34132, 12341 ...> all the way to 19; }

like that in the array.

the problem is that it gives:

Код:
warning 227: more initiallers than enum fields
warning 213: tag mismatch
warning 227: more initiallers than enum fields
warning 213: tag mismatch
error 018: initialization data exceeds declared size
I'm not sure how to do this, excluding the fact of using CP1_X/Y/Z CP2_X/Y/Z etc, which I don't want to do unless there's no other option, because it looks terrible.
Reply
#2

You have 3D array, and are initialising 2D array. It'd look like
pawn Код:
enum cpData
{
    Float:CP_X[ 2 ],
    Float:CP_Y[ 2 ],
    Float:CP_Z[ 2 ]
}
new Float:RaceCheckpoints[ 1 ][ cpData ] =
{
    { { 10.001, 12.0 }, { 51.5123, 52.0 }, { 25.12312, 26.0 } }
};
However pawncc shipped with server, doesn't support multidimensional initialising. You'd need to use Zeex's compiler (search the forum for it, somewhere in tools subforum)
Reply
#3

oh I see.

Thanks

I didn't really find a compiler, but is this the one you mean?

https://sampforum.blast.hk/showthread.php?tid=473595

also, how should I use it?

should I use it like this?

pawn Код:
RaceCheckpoints[ raceid ][ CP_X ][ 0 ]
but idk because that would get all the variables of CP_X in the first array part, right? while it should get the first coordinate from the first array part.
Reply
#4

Yup, that's how you use it. RaceCheckpoints[ raceid ][ CP_X ][ 0 ] means that you want exactly first value from the CP_X array, inside RaceCheckpoints at raceid index.

http://forum.sa-mp.com/showpost.php?...6&postcount=17 - here's the latest build. You have to substitute in your pawno folder pawncc.exe and all other files with those which you download.
Reply
#5

well, I downloaded that one, but now it gives:

Код:
D:\Program Files\NextGen Streetracers\pawno\include\sscanf2.inc(31) : fatal error 111: user error: Please include <a_npc> or <a_samp> first.


Compilation aborted.

Pawn compiler 3.2.3664.samp	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
I tried using #include <a_samp> but it still gives this error..
Reply
#6

Is it higher in code than #include <sscanf2>? If not, put it there. Otherwise, go to https://sampforum.blast.hk/showthread.php?tid=120356 , download latest dll and inc. If the problem persists, stuff is weird
Reply
#7

well, I tried both, but it still gives this error :/
Reply
#8

My apologies, I had outdated sscanf.inc. Go into your sscanf2.inc and remove those lines:
pawn Код:
#elseif !defined _inc_a_samp
    #error Please include <a_npc> or <a_samp> first.
Reply
#9

Код:
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(467) : error 021: symbol already defined: "Player@YSII_Cg"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(471) : error 021: symbol already defined: "Bot@YSII_Cg"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(811) : error 021: symbol already defined: "Itter_RandomInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(849) : error 021: symbol already defined: "Itter_FreeInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(878) : error 021: symbol already defined: "Itter_AddInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(912) : error 021: symbol already defined: "Itter_RemoveInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(935) : error 021: symbol already defined: "Itter_SafeRemoveInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(969) : error 021: symbol already defined: "Itter_ContainsInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(988) : error 021: symbol already defined: "Itter_ClearInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(1013) : error 021: symbol already defined: "Itter_InitInternal"
D:\Program Files\NextGen Streetracers\pawno\include\foreach.inc(1039) : error 021: symbol already defined: "Itter_PrevInternal"
D:\Program Files\NextGen Streetracers\pawno\include\HiStreet\HS_Variables.inc(181) : warning 213: tag mismatch
D:\Program Files\NextGen Streetracers\pawno\include\HiStreet\HS_Variables.inc(181) : warning 213: tag mismatch
D:\Program Files\NextGen Streetracers\pawno\include\HiStreet\HS_Variables.inc(181) : warning 213: tag mismatch
D:\Program Files\NextGen Streetracers\pawno\include\getvehiclename.inc(23) : error 021: symbol already defined: "VehicleFriendlyNames"
D:\Program Files\NextGen Streetracers\pawno\include\getvehiclename.inc(55) : error 021: symbol already defined: "GetVehicleNameByID"
D:\Program Files\NextGen Streetracers\pawno\include\getvehiclename.inc(71) : error 021: symbol already defined: "GetVehicleModelFromName"
D:\Program Files\NextGen Streetracers\pawno\include\getvehiclename.inc(82) : error 021: symbol already defined: "GetVehicleNameByModel"
D:\Program Files\NextGen Streetracers\gamemodes\NGStreet.pwn(39) : error 021: symbol already defined: "Itter_OnGameModeInit"
D:\Program Files\NextGen Streetracers\gamemodes\NGStreet.pwn(202) : error 021: symbol already defined: "Itter_OnPlayerConnect"
D:\Program Files\NextGen Streetracers\gamemodes\NGStreet.pwn(249) : error 021: symbol already defined: "Itter_OnPlayerDisconnect"
Pawn compiler 3.2.3664.samp	 	 	Copyright © 1997-2006, ITB CompuPhase


18 Errors.
that didn't turn out very well
Reply
#10

Ha, that makes me wonder why would even my compiler work with the same YSI files. Ok, revert that change, and in your main file, after #include <a_samp> add
pawn Код:
#define _inc_a_samp
If that raises another metric shitton of errors, then I dun goof'd. You'd have to download server pack again, and replace back pawncc and that dll file :c Sorry about that, didn't anticipate that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)