# Thread: How to make Arrays (Sorry if wrong)

1. ## How to make Arrays (Sorry if wrong)

Well, now I want to show you how to make Arrays, even.. I am not sure if thats what we like to call them.
___________

Here we go.

First of all, we need to choose what it's gone be.

I will choose weapons for now. ( cuse most used and easy too )

First we start our line with:
self.wep = []
Okey, that is the first line in our thread.
Then we gone add "sub arrays" that we will add our things to.
List:
self.wep[0] = "ak47_mp";
Whats in read is just so you see what the difference here and the "main array" is.
then we make a long list of weps. ( or short )
self.wep[0] = "ak47_mp";
self.wep[1] = "ump45_mp";
self.wep[2] = "usp_mp";
self.wep[3] = "tavor_mp";
self.wep[4] = "tmp_mp";
self.wep[5] = "rpg_mp";
Now I have a list of 6 Arrays. (Yes the 0 counts as 1 too)

Then I make a Press action thread to just see that this works:
weproll()
{
self endon("death");
self endon("disconnect");

for(i=0; i<=5; i++)
{
self notifyOnPlayerCommand("N", "+actionslot 1");
self waittill("N");
self giveweapon(self.wep[i]);
self switchtoweapon(self.wep[i]);
}
}
As you see, I have marked more text.
The for(i=0; i<=5; i++) this will do so that the list will go up so we get our list to work as we want it to.

So when i = 0; menas that it will be Array 0.
And the i<=5; means that it will stop when it reach 5. (In this case it doesn't really mater that much but. We mostly like avoid lagg)
And the i++ means that we increase i that's 0 with 1 every time we press N.

Now I hope you learned how to make the Arrays.
You can also use this for threads and so on. (maps, models, visions, and more)

2. Nice tut. I have actually wondered how to make a menu like that easy. But now i know. I actually thought you needed more code but IW really helped us with all those unused functions...

3. Originally Posted by Nachos
Nice tut. I have actually wondered how to make a menu like that easy. But now i know. I actually thought you needed more code but IW really helped us with all those unused functions...
haha, well...

They use arrays too, just not so many

4. It's not called 'sub-arrays', the numbers inside the square braces are called the indexes. If you do not know how many items are in the array you can use the .size property/variable.

Code:
```someArray = [];
someArray[0] = "Hello!";
self iPrintLnBold(someArray.size); //This will display 1 on the screen because the 0 still counts!```
If you want to add more things to the array but don't know what number to use, you can do this:
Code:
```someArray = [];
someArray[someArray.size] = 1; //At this point, someArray.size equals to 0
someArray[someArray.size] = 2; //At this point, someArray.size equals to 1
//At this point, someArray.size equals to 2```

5. can you maybe show us a fully completed one?

because i don't really know were to put the

self.wep[0] = "ak47_mp";
self.wep[1] = "ump45_mp";
self.wep[2] = "usp_mp";
self.wep[3] = "tavor_mp";
self.wep[4] = "tmp_mp";
self.wep[5] = "rpg_mp";

6. Well no shit sherlock.

7. Takes a year for me to understand this^^ But nice turorial.

8. Originally Posted by TechnoX
Takes a year for me to understand this^^ But nice turorial.
If you need help to understand.
PM me and I can talk to you over:
Skype, MSN, Steam or TeamViewer

9. didn't know it had so much to do with php

10. Originally Posted by jorricks3
didn't know it had so much to do with php
Most programming languages have arrays.....

11. @Moto
/Move to tutorials (My bad sorry)

12. /moved to tutorials section