Jump to content
pliskin124

Randomized Array of Clothing

Recommended Posts

Greetings,

 

I recently created this script in an attempt to equip the player with a random set of clothing from a dresser from an addaction.

The cut text works fine, but it never applies the clothing and I'm getting an "error line 7" (the _unit forceAddUniform _clothing; section). I tried replacing _unit_ with player but I still get the same error. Any help would be appreciated, thanks.

 

 

_clothing = _array select floor random count _array;
_array = ["TRYK_U_B_Denim_T_WH","TRYK_U_B_Denim_T_BG_WH","TRYK_U_B_Denim_T_BK","TRYK_U_B_BLK_T_WH","TRYK_U_B_RED_T_BR","TRYK_U_B_BLK_T_BK","TRYK_U_B_BLK_T_BG_WH","TRYK_U_B_RED_T_BG_BR","TRYK_U_B_BLK_T_BG_BK","TRYK_shirts_DENIM_BK","TRYK_shirts_DENIM_BL","TRYK_shirts_DENIM_BWH","TRYK_shirts_DENIM_od","TRYK_shirts_DENIM_R","TRYK_shirts_DENIM_RED2","TRYK_shirts_DENIM_WH","TRYK_shirts_DENIM_WHB","TRYK_shirts_DENIM_ylb","TRYK_shirts_DENIM_od_Sleeve","TRYK_shirts_DENIM_ylb_Sleeve","TRYK_shirts_DENIM_BK_Sleeve","TRYK_shirts_DENIM_BL_Sleeve","TRYK_shirts_DENIM_BWH_Sleeve","TRYK_shirts_DENIM_R_Sleeve","TRYK_shirts_DENIM_RED2_Sleeve","TRYK_shirts_DENIM_WH_Sleeve","TRYK_shirts_DENIM_WHB_Sleeve"];
cutText ["","BLACK OUT"];
sleep 1;
cutText ["","BLACK IN"];
_unit forceAddUniform _clothing;

Share this post


Link to post
Share on other sites

You must define array FIRST (_array must be before _clothing) and THEN select random clothing from it.

Better use selectRandom command.

 

_array = ["class1", "class2", "class3"];
_clothing = selectRandom _array;

_unit forceAddUniform _clothing;

 

Share this post


Link to post
Share on other sites

Alternatively you can use:

_clothing = ["class1", 0.5, "class2", 0.25, "class3", 0.25] call BIS_fnc_selectRandomWeighted;
_unit forceAddUniform _clothing;

if you want certain uniforms being selected more often.

Above example will result in 50% "class1" and 25% "class2"+"class3" uniforms.

 

Cheers

Share this post


Link to post
Share on other sites
19 hours ago, M1ke_SK said:

You must define array FIRST (_array must be before _clothing) and THEN select random clothing from it.

Better use selectRandom command.

 


_array = ["class1", "class2", "class3"];
_clothing = selectRandom _array;

_unit forceAddUniform _clothing;

 

 

This worked great, thanks.

 

(Change _unit to player for anyone new to Arma scripting who comes across this.)

Share this post


Link to post
Share on other sites
21 hours ago, Grumpy Old Man said:

Alternatively you can use:


_clothing = ["class1", 0.5, "class2", 0.25, "class3", 0.25] call BIS_fnc_selectRandomWeighted;
_unit forceAddUniform _clothing;

if you want certain uniforms being selected more often.

Above example will result in 50% "class1" and 25% "class2"+"class3" uniforms.

 

Cheers

 
 
 
 

Aren't you amazing, this is better than what I have been doing lol which was this:

[selectRandom [if (random 100 >25) then {"O_Heli_Attack_02_F"} else {"O_Heli_Attack_02_black_F"},
if (random 100 >25) then {"O_Heli_Light_02_F"} else {"O_Heli_Light_02_v2_F"}],
_spawnLoc, ["H_PILOT","H_PILOT"],["DRIVER","GUNNER"]] call SER_fnc_spawnVehicleSquads;

Just to be sure though the better way would be this?

[ ["O_Heli_Attack_02_F",0.75,"O_Heli_Attack_02_black_F",0.25,"O_Heli_Light_02_F",0.25"O_Heli_Light_02_v2_F"0.75]call BIS_fnc_selectRandomWeighted,
 _spawnLoc,["H_PILOT","H_PILOT"],["DRIVER","GUNNER"]  ]call SER_fnc_spawnVehicleSquads;

 

Share this post


Link to post
Share on other sites
1 hour ago, Grumpy Old Man said:

Besides these comma errors it sure would be.

 

Cheers

 

Oh will fix that,

Cheers

Share this post


Link to post
Share on other sites

what's the performance differences on the two?

bis_fnc_selectRandomWeighted and just selectRandom ?

Especially with a larger array. :dontgetit:

Share this post


Link to post
Share on other sites
1 hour ago, Midnighters said:

what's the performance differences on the two?

bis_fnc_selectRandomWeighted and just selectRandom ?

Especially with a larger array. :dontgetit:

 

I believe bis_fnc_selectRandomWeighted does more processing since it does not just choose randomly, it has to give some values more chances than others.

Share this post


Link to post
Share on other sites
14 hours ago, Midnighters said:

what's the performance differences on the two?

bis_fnc_selectRandomWeighted and just selectRandom ?

Especially with a larger array. :dontgetit:

I thing thats the wrong question because they have a different purpose.

if u need a weighted random then u use that and if u need it without weighting then u use selectRandom.

But I m with BlackKnightBK. selectRandom should be faster because it has the simpler task.

Share this post


Link to post
Share on other sites
6 hours ago, sarogahtyp said:

I thing thats the wrong question because they have a different purpose.

if u need a weighted random then u use that and if u need it without weighting then u use selectRandom.

But I m with BlackKnightBK. selectRandom should be faster because it has the simpler task.

Right, I understand there is a distinct difference between the two. However, by others above both (selectRandom) and (bis_fnc_selectRandomWeighted) were used.

(in this context) 

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

×