Author Topic: How to make a "double array" ?  (Read 3143 times)

0 Members and 1 Guest are viewing this topic.

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
How to make a "double array" ?
« 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:
Code: [Select]
myarray[0][0];
myarray[1][0];

myarray[0][0] is not the same with myarray[1][0];.
Is it possible ?

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline S.L.C

  • Street Thug
  • *
  • Posts: 42
  • Sorry if you weren't impressed!
    • View Profile
Re: How to make a "double array" ?
« Reply #1 on: September 16, 2014, 06:49:15 pm »
You mean like a multidimensional array? Like in the following example:

Code: [Select]
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:
Code: [Select]
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
« Last Edit: September 16, 2014, 06:52:11 pm by S.L.C »

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: How to make a "double array" ?
« Reply #2 on: September 17, 2014, 12:01:12 am »
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)

Code: [Select]
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.

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.