SA-MP Forums Archive
Array index,first one is 0 or 1? - 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: Array index,first one is 0 or 1? (/showthread.php?tid=473779)



Array index,first one is 0 or 1? - Tagathron - 04.11.2013

Код:
new pArea [4][3] =
{
	{1323.5114,10.8203,158.5349},
	{1323.1530,10.8203,267.2626},
	{1342.7168,10.8203,357.8168},
	{1343.3971,10.8203,90.2510},
};
That way i get no errors,so i guess first array is indexed with [1] not [0] ?


Re: Array index,first one is 0 or 1? - Jefff - 04.11.2013

new pArena[0-3][0-2] = {
...


Re: Array index,first one is 0 or 1? - Tagathron - 04.11.2013

Код:
error 001: expected token: ";", but found "{"
error 010: invalid function or declaration
Код:
new pArea [4][3] =
{
	{1323.5114,10.8203,158.5349},
	{1323.1530,10.8203,267.2626},
	{1342.7168,10.8203,357.8168},
	{1343.3971,10.8203,90.2510}, // LINE 12
}; // LINE 13



Re: Array index,first one is 0 or 1? - Jefff - 04.11.2013

add Float tag to pArena and remove last ,


AW: Array index,first one is 0 or 1? - BigETI - 04.11.2013

Код:
array_name[amount]
array_name = Points to the data structure
amount = Amount of allocated cells (1 cell = 4 bytes = 32 bits)

Example:
pawn Код:
new my_arr[5];
Possibilities:
pawn Код:
my_arr[0] // First
my_arr[1] // Second
my_arr[2] // Third
my_arr[3] // Fourth
my_arr[4] // Fifth



Re: Array index,first one is 0 or 1? - Tagathron - 04.11.2013

Код:
new Float:pArea [3][2] =
{
	{1323.5114,10.8203,158.5349},
	{1323.1530,10.8203,267.2626},
	{1342.7168,10.8203,357.8168},
	{1343.3971,10.8203,90.2510}, // 12
}
Код:
(12) : error 001: expected token: ";", but found "{"



Re: Array index,first one is 0 or 1? - newbienoob - 04.11.2013

remove the comma at the last line(error line)


AW: Re: Array index,first one is 0 or 1? - BigETI - 04.11.2013

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
Код:
new Float:pArea [3][2] =
{
	{1323.5114,10.8203,158.5349},
	{1323.1530,10.8203,267.2626},
	{1342.7168,10.8203,357.8168},
	{1343.3971,10.8203,90.2510}, // 12
}
Код:
(12) : error 001: expected token: ";", but found "{"
Remove the last comma in line 12...

Also I see 4 rows and 2 columns. In PAWN you don't need to re-define the amount of cells, if you are already assigning the data after "=".

pawn Код:
static const Float:pArea[][] =
{
    {1323.5114, 10.8203, 158.5349},
    {1323.1530, 10.8203, 267.2626},
    {1342.7168, 10.8203, 357.8168},
    {1343.3971, 10.8203, 90.2510}
};