Forum Jump :

Author Message


Posts: 27
Rank:


Level: Member

Country: au
Location: No idea
Occupation: Woolworths Trolley Boy
Age:
In-game name:

 
#1 Posted at 2017-02-22 12:48        
     
G'day, Im currently having trouble with hiding objects randomly, I've created an array which contains a randomSelect, further on from that selection I am trying to complete a command [] exec "spawn1.sqs", this spawn1.sqs contains the command for hiding the object which is working correctly however I'm experiencing numerous errors and I'm quite new to scripting. what I have written probably does not even get close to what I want to achieve but never the less, here's what I've got.


_array1 = selectRandom ["0","1"]; 
 _array1 = true;
if (_array1 select 0) then { [] exec "spawn1.sqs"};
if (_array1 select 1) then { [] exec "spawn2.sqs"};

so basically if _array1 selects 0 or 1 (hope fully randomly), i want it to trigger a command to execute spawn1 or 2.sqs(to hide an object)
anyways that's about it cheers.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#2 Posted at 2017-02-22 16:09        
     
"0" "1" are strings, not numeric values. It's useless to define something by selectRandom, then overwrite it by true.
in your code, _array1 is a string, then a boolean... but never an array! So select doesn't make sense here.

you just have to write:
[] exec (selectRandom ["spawn1.sqs","spawn2.sqs"]);

And you should write your code in sqf. sqs is an old language, totally obsolete for Arma.

To hide an object randomly:
- in editor
if (isServer) then {this hideObjectGlobal selectRandom [false,true]}; // in init field
- in script, name the object:
myObject hideObjectGlobal selectRandom [false,true];

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#3 Posted at 2017-02-22 17:00        
     
Also don't use exec, use execVM. exec is for running the outdated sqs language that Pierre mentioned.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 27
Rank:


Level: Member

Country: au
Location: No idea
Occupation: Woolworths Trolley Boy
Age:
In-game name:

 
#4 Posted at 2017-02-23 08:21        
     
Thanks Pierre MGI for the short and sharp explanation on arrays and the correction of the script. 654wak654 will do on the utilisation of SQFs and execVM, cheers fellas.