Vice City Multiplayer
VC:MP 0.4 (Beta) => Script Discussion => Topic started by: sseebbyy on September 16, 2014, 06:25:30 pm
-
I'm working on a project, and I need double array to can decrease the number of lines used for it.
(I need it to run the globan function)
What I call a "double array" ? This:
myarray[0][0];
myarray[1][0];
myarray[0][0] is not the same with myarray[1][0];.
Is it possible ?
-
You mean like a multidimensional array? Like in the following example:
arr <- [
["sub array 0", true, 54, 0.45],
["sub array 2", false, 213.6, 32],
["sub array 3", false, 9897, 45.425],
["sub array 4", true, 321.2353, 32]
];
foreach (sub in arr)
{
print(format("\n%s elements are the following:\n", sub[0]));
print(format("\telement 1 is of type %s with the value %s\n", typeof sub[1], sub[1].tostring()));
print(format("\telement 2 is of type %s with the value %s\n", typeof sub[2], sub[2].tostring()));
print(format("\telement 3 is of type %s with the value %s\n", typeof sub[3], sub[3].tostring()));
}
Output should be:
sub array 0 elements are the following:
element 1 is of type bool with the value true
element 2 is of type integer with the value 54
element 3 is of type float with the value 0.45
sub array 2 elements are the following:
element 1 is of type bool with the value false
element 2 is of type float with the value 213.6
element 3 is of type integer with the value 32
sub array 3 elements are the following:
element 1 is of type bool with the value false
element 2 is of type integer with the value 9897
element 3 is of type float with the value 45.425
sub array 4 elements are the following:
element 1 is of type bool with the value true
element 2 is of type float with the value 321.235
element 3 is of type integer with the value 32
-
Thank you for reply, but it is not what I need.
Knucis and Gudio were right, and I was noob.
The code is this:
(I use it in a class, so is the example)
t = array(sizeofarray,null);
for(local i = 0; i < t.len(); i++)
{
t[i] = array(sizeofsecondarray,null);
}
I used "local i = 1" instead of "local i = 0" because I was thinking about something related to my project. (that you may find out after I public the script)
I knew that arrays starts with 0, but like I said, I was thinking about something else used few lines under.
Thank you very much, Gudio and Knucis ! :/
Topic locked.