Infinite sized array?
#1

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

That is what [] allows you to do, yes
Reply
#3

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

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

Then Array[0][0] is 7
Reply
#5

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

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

That is not possible.
Reply
#8

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

Actually.. Use foreach, it does what you want
Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)