Quote:
Originally Posted by Alpays
what is the difference between
new Float:TDMSpawn[][] =
{
{1,1,1,1},
{1,1,1,1)
}
and
new Float:TDMSpawn[2][4] =
{
{1,1,1,1},
{1,1,1,1)
}
|
The first one will have the compiler calculate the array size based on the initializer, thus it will technically becomes [2][4]. It is only possible if the initial values are declared, so you cant just have:
Code:
new Float:TDMSpawn[][];
The second will have fixed amount array size as you specified, which is [2][4]... giving [1][3] will result error because the array size mismatch and giving more like [3][5] will result a warning because the array must be fully initialized.
Since the array size is explicit, you can declare without initial value, so you can have:
Code:
new Float:TDMSpawn[2][4];
which will have all 0 for initial values.
Note that it is possible to have
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1}
}
In case you will be adding more tdm spawn rows in the initializer but dont want to accidentally change the column size
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1},
{1,1,1,1} // ok
}
Code:
new Float:TDMSpawn[][4] =
{
{1,1,1,1},
{1,1,1,1},
{1,1,1} // error
}
Check out the pawn-lang.pdf documentation