Jump to content
Sign in to follow this  
neonghillie

Can anyone salvage this script please?

Recommended Posts

Hello all!

I'm new to Arma scripting and was wondering if anyone could fix this mess for me. Its supposed to spawn a random amount of random items in a supply crate. Sorry for my noobyness and thanks in advance!

_rdmc = round ((random 1) 4);
_rdm = round ((random 1)5);
_box	=_this select 0;


for [rdmC] do
{	
if (_rdm = 1) then
{
	_box additemcargo ["itemMap",1];	
};

if(_rdm = 2) then
{
	_box additemcargo ["Binocular",1];
};

if(_rdm = 3) then
{
	_box additemcargo ["itemGPS",1];
};

if(_rdm = 4) then
{
	_box additemcargo ["itemFirstAidKit",1];
};

if (rdm = 5) then 
{	
	_box addweaponcargo ["arifle_MXM_Base_F",1];
	_box addmagazineCargo ["30Rnd_65x39_caseless_green_mag_Tracer ",1];
}
};

Share this post


Link to post
Share on other sites

Assuming you are calling it from the init of the crate:

null = [this] execVM "script.sqf"

for[rdmC] do

should be

for[[b][color=#ff0000]_[/color][/b]rdmC] do

Share this post


Link to post
Share on other sites

Believe You are using for command incorrectly. Base on what u have look at the switch command saves using all that if business. Or just remove the for bit and its brackets and u will get it to work.

Share this post


Link to post
Share on other sites

Still doesn't seem to be working. Do you think it may be a syntax error?

Thanks for your input!

/

_rdm = round ((random 1)5);

_box =_this select 0;

if (_rdm = 1) then

{

_box additemcargo ["itemMap",1];

};

if(_rdm = 2) then

{

_box additemcargo ["Binocular",1];

};

if(_rdm = 3) then

{

_box additemcargo ["itemGPS",1];

};

if(_rdm = 4) then

{

_box additemcargo ["itemFirstAidKit",1];

};

if (_rdm = 5) then

{

_box addweaponcargo ["arifle_MXM_Base_F",1];

_box addmagazineCargo ["30Rnd_65x39_caseless_green_mag_Tracer ",1]

};

Edited by neonghillie

Share this post


Link to post
Share on other sites

If(something==something) not if (something = something).

In ur script you are initializing/assigning a value to the variable. Not testing a condition

Share this post


Link to post
Share on other sites
_rdm = round ((random 1)5);

i assume its meant to be

_rdm = round (random 5)

if (_rdm = 1) then 

Here you are assign _rdm to 1, you want to compare it to 1 with the == syntax

so

 if(_rdm == 1) then

arifle_MXM_Base_F

This is a base class, you should not use it, use "arifle_MXM_F"

Wrong magazine. Should be "30Rnd_65x39_caseless_mag_Tracer" or "30Rnd_65x39_caseless_mag"

Also remember to try and understand what we're pointing out and if you need any help understanding what i just told you ,ask away this way to will never have to come back asking the same questions

Share this post


Link to post
Share on other sites

Thanks guys. I fixed the problems but the crate still appears to be empty. Any ideas?

/

_rdm = round ((random 1)5);

_box =_this select 0;

if (_rdm == 1) then

{

_box additemcargo ["itemMap",1];

};

if(_rdm == 2) then

{

_box additemcargo ["Binocular",1];

};

if(_rdm == 3) then

{

_box additemcargo ["itemGPS",1];

};

if(_rdm == 4) then

{

_box additemcargo ["itemFirstAidKit",1];

};

if (_rdm == 5) then

{

_box addweaponcargo ["arifle_MXM_Base_F",1];

_box addmagazineCargo ["30Rnd_65x39_caseless_mag_Tracer ",1];

};

\[code]

Share this post


Link to post
Share on other sites
Thanks guys. I fixed the problems but the crate still appears to be empty. Any ideas?

/

_rdm = round ((random 1)5);

_box =_this select 0;

if (_rdm == 1) then

{

_box additemcargo ["itemMap",1];

};

if(_rdm == 2) then

{

_box additemcargo ["Binocular",1];

};

if(_rdm == 3) then

{

_box additemcargo ["itemGPS",1];

};

if(_rdm == 4) then

{

_box additemcargo ["itemFirstAidKit",1];

};

if (_rdm == 5) then

{

_box addweaponcargo ["arifle_MXM_Base_F",1];

_box addmagazineCargo ["30Rnd_65x39_caseless_mag_Tracer ",1];

};

\[code]

Read my post again....

Share this post


Link to post
Share on other sites

hahahhaha thanks. Forgot to get rid of that parenthesis! your help is greatly appreciated. It works now.

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  

×