Jump to content
Sign in to follow this  
BeerHunter

Rank scripting beginner here. Why doesn't this work?

Recommended Posts

I do have a fair bit of programming experience using Basic and C++ but this scripting language is like nothing I've ever seen before.:p

So I've started to delve into it remembering that moving from Basic to C++ was a mass of confusion as well.:rolleyes:

Anyway , I've put the following code in the initialization line:

removeAllWeapons this;this addMagazine"30Rnd_9x19_MP5";this addWeapon "MP5A5"; while{a<3}do {this addMagazine "30Rnd_9x19_MP5";a=a+1};

I end up with an MP5 with 1 magazine. Why isn't the "do" loop executing? Far as I can tell the syntax is correct...but then..:cool:

Is it possible that the initialization isn't capable of handling complex commands such as loops and that these should be in a seperate script that gets called? :confused:

Another thing..I've noticed that when typing the command in the editor it displays suggested possible scripting calls (right term??).

Is there a way to grab these and insert them rather than having to type the entire string into the initialization box?

Share this post


Link to post
Share on other sites

because the code doesn't know what a is and so won't it won't run the while part of the code, try this

removeAllWeapons this;this addMagazine"30Rnd_9x19_MP5";this addWeapon "MP5A5"; a=0;while{a<3}do {this addMagazine "30Rnd_9x19_MP5";a=a+1};

Share this post


Link to post
Share on other sites

removeAllWeapons this; {this addMagazine "30Rnd_9x19_MP5"} forEach [1,2,3,4]; this addWeapon "MP5A5";

Hitting TAB while it's suggesting a scripting command will autocomplete the word. You can also type a command, click in it and press F1 to bring up context sensitive help.

Also: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2

Share this post


Link to post
Share on other sites

Also, putting showscripterrors in the command line is a good idea for people who are scripting. There'll be basically a dos-style box that appears indicating there's been a problem.

Errors will also be reported in the arma.rpt (its location depends on what OS you have) which is handy.

Share this post


Link to post
Share on other sites
because the code doesn't know what a is and so won't it won't run the while part of the code

DOH!! I was sure I read somewhere that all variables are initialized with a value of 1 and since they are neither defined nor declared , assumed it would automatically start at 1 each time the script fired. Now I know better and wont be making that same mistake again. Txs

And kylania , txs for that tip.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×