Jump to content
AdirB

"Naked" part of random?

Recommended Posts

Hello,

I've got this code that gives a random clothes to every east sided unit in map.

if(Isserver)then
{
	UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"];
{
        if((side _x) == east)then
{
	  removeVest _x;
	  removeHeadgear _x;
	  removeUniform _x;
                _x unassignItem "NVGoggles";
                _x removeItem "NVGoggles";
	  _x forceAddUniform (UniformArray select (random(round(count UniformArray))))
};
} 
foreach allunits;
};

It's all working fine, but I noticed that the units could be naked.

I think it's a part of the random rounds, is it possible to disable it?

Share this post


Link to post
Share on other sites

Is it possible there's a particular unit that can't be reclothed? Find the naked ones and get their classname. Forceuniform might be failing on that type for whatever reason

 

Are all four of your new uniforms seen in equal numbers around your east guys? If one is missing, it might be a problem with that one.

 

You should write to debug the uniform you've chosen through each iteration of the script. Something odd might show itself there.

Share this post


Link to post
Share on other sites

try using floor instead of round:

 

 

_x forceAddUniform (UniformArray select (random(round(count UniformArray))))

Share this post


Link to post
Share on other sites

try using floor instead of round:

That could produce: random 4 -> 3.999 -> select 4 , which would fail also.

 

Try:

_x forceAddUniform (UniformArray select (floor(random(count UniformArray))))

Share this post


Link to post
Share on other sites

Or  BIS_fnc_selectRandom

UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"] call BIS_fnc_selectRandom;

_x forceAddUniform UniformArray;

For what the global variable?

 

Share this post


Link to post
Share on other sites


if(Isserver)then

{

    UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"];

{

if((side _x) == east)then

{

     removeVest _x;

     removeHeadgear _x;

     removeUniform _x;

_x unassignItem "NVGoggles";

_x removeItem "NVGoggles";

     _x forceAddUniform (UniformArray select (random(round(count UniformArray)))) //missing semicolon here

};

}

foreach allunits;

};

Share this post


Link to post
Share on other sites

Or  BIS_fnc_selectRandom

UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"] call BIS_fnc_selectRandom;

_x forceAddUniform UniformArray;

For what the global variable?

 

 

just use this, the problem is because count is going to return one more than there are array entries as count starts at 1 while select starts at 0

Share this post


Link to post
Share on other sites

just use this, the problem is because count is going to return one more than there are array entries as count starts at 1 while select starts at 0

Have you looked at what is inside bis_fnc_selectrandom?

 

_this select (floor random (count _this));

no problem with count here

Share this post


Link to post
Share on other sites

I wish we had a command like randomArray.

Share this post


Link to post
Share on other sites

Is it possible there's a particular unit that can't be reclothed? Find the naked ones and get their classname. Forceuniform might be failing on that type for whatever reason

 

Are all four of your new uniforms seen in equal numbers around your east guys? If one is missing, it might be a problem with that one.

 

You should write to debug the uniform you've chosen through each iteration of the script. Something odd might show itself there.

 

 

try using floor instead of round:

 

 

Or  BIS_fnc_selectRandom

UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"] call BIS_fnc_selectRandom;

_x forceAddUniform UniformArray;

For what the global variable?

 

 

 

if(Isserver)then
{
    UniformArray = ["U_C_Poloshirt_blue", "U_C_Poloshirt_redwhite", "U_C_Poloshirt_salmon", "U_BG_Guerilla3_1"];
{
if((side _x) == east)then
{
     removeVest _x;
     removeHeadgear _x;
     removeUniform _x;
_x unassignItem "NVGoggles";
_x removeItem "NVGoggles";
     _x forceAddUniform (UniformArray select (random(round(count UniformArray)))) //missing semicolon here
};
} 
foreach allunits;
};

 

 

just use this, the problem is because count is going to return one more than there are array entries as count starts at 1 while select starts at 0

 

 

Have you looked at what is inside bis_fnc_selectrandom?

 

_this select (floor random (count _this));

no problem with count here

 

 

I wish we had a command like randomArray.

Thank you all for your solution! :) adding floor instead round solved the problem

 

 

That could produce: random 4 -> 3.999 -> select 4 , which would fail also.

 

Try:

_x forceAddUniform (UniformArray select (floor(random(count UniformArray))))

Thank you :)

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

×