SA-MP Forums Archive
how to put many integers in one variable - 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: how to put many integers in one variable (/showthread.php?tid=600822)



how to put many integers in one variable - BlackHorse - 13.02.2016

When I was just creating a script in which i wanted to assign many integers in one variable, I just done like this:
Код:
new variable;
variable = 1,2,3;
But it came into :expression has no effect.

So, How can I put many integers in a variable.


Re: how to put many integers in one variable - K0P - 13.02.2016

A variable can have only 1 value.

You can use arrays like

variable[2][3]...


Re: how to put many integers in one variable - BiosMarcel - 13.02.2016

PHP код:
new variable[5];

//now u can put up to 5 integers into the variable

//you always have to start counting at 0, thats very important cause the index of all arrays starts at 0 and not at 1

variable[0] = 1;
variable[1] = 2;
variable[2] = 3;
variable[3] = 4;
variable[4] = 5;

//You can also create multidimensional arrays like that:

new variable[5][5];

// you can now put up to 5 x 5 variables in there (25)

variable[0][0] = 1;
variable[0][1] = 1;
variable[0][2] = 1;
variable[0][3] = 1;
variable[0][4] = 1;
variable[1][0] = 1;
variable[1][1] = 1;
variable[1][2] = 1;
variable[1][3] = 1;
variable[1][4] = 1;

//and so on ....