SA-MP Forums Archive
Infinite sized array? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Infinite sized array? (/showthread.php?tid=362566)



Infinite sized array? - maramizo - 24.07.2012

Well, we all know this:
pawn Код:
new arrayname[][1] =
{
     {blabla}
};
But, is there any chance that I can change it from that to:
pawn Код:
new arrayname[][1] =
{
     {blabla},
     {blabla}
};
Dynamically? Within the game without having to edit the code?


Re: Infinite sized array? - FUNExtreme - 24.07.2012

That is what [] allows you to do, yes


Re: Infinite sized array? - maramizo - 24.07.2012

But I cannot do either of the following:
pawn Код:
new myarray[][1] =
{
};
Nor:
pawn Код:
new myarray[][1] =
{
   {0}
};
//Later on
myarray[0][0] = blahblah //Returns that 1 is out of bounds.



Re: Infinite sized array? - FUNExtreme - 24.07.2012

Arrays start from 0. So new Array[] [1] = {7};

Then Array[0][0] is 7


Re: Infinite sized array? - maramizo - 24.07.2012

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Arrays start from 0. So Array[] [1] = {7};

Then Array[0][0] is 7
But then Array[1][0] doesn't exist, thus it's not infinite.
My aim is to make an infinite array which it's size could be set by a command or later on the script.


Re: Infinite sized array? - FUNExtreme - 24.07.2012

Something you don't give a value simply doesn't exist...

You can put Array[123][0] ≠ 2; and it should work. This is impossible with a predefined size

Though you'll have to test it. Maybe the compiler automaticly fills in the size when compiling.. Making it impossible


Re: Infinite sized array? - Vince - 24.07.2012

That is not possible.


Re: Infinite sized array? - maramizo - 24.07.2012

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Something you don't give a value simply doesn't exist...

You can put Array[123][0] ≠ 2; and it should work. This is impossible with a predefined size
So this:
pawn Код:
new arrayname[][1] =
{
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla},
     {blabla}
};
Is my only solution?


Re: Infinite sized array? - FUNExtreme - 24.07.2012

Actually.. Use foreach, it does what you want


Re: Infinite sized array? - leonardo1434 - 24.07.2012

pawn Код:
new myarray[1][2] =
{
   {0,1} // size 2.
};
new myarray2[2][1] =
{
   {0},  // 2 rows and 1 of size.
   {1}
};