Jump to content
pappagoat

Random Date help?!

Recommended Posts

I'm looking for help. I am trying to create random date BUT with only certain months depending on which year is selected. So far I cannot get the last part to work:

 

Basic Random Date (WORKS):

 

_year = selectrandom [1970];
_month = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12];
_day = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28];

setDate [_year, _month, _day, 15, 45];

 

 

Attempting month range depending on year (struggling):

 

_year = selectrandom [1967, 1968];
if (_year == 1967) then {_month = selectrandom [04, 05, 06, 07, 08, 09, 10, 11, 12];};
if (_year == 1968) then {_month = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12];};
_day = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28];

setDate [_year, _month, _day, 15, 45];

 

 

Any ideas?

Share this post


Link to post
Share on other sites
_year = selectrandom [1967, 1968];
_month = selectRandom ( if (_year == 1967) then { [04, 05, 06, 07, 08, 09, 10, 11, 12] } else { [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12] } );
_day = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28];
setDate [_year, _month, _day, 15, 45];

 

  • Like 1

Share this post


Link to post
Share on other sites
On 12/31/2018 at 9:36 AM, M1ke_SK said:

_year = selectrandom [1967, 1968];
_month = selectRandom ( if (_year == 1967) then { [04, 05, 06, 07, 08, 09, 10, 11, 12] } else { [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12] } );
_day = selectrandom [01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28];
setDate [_year, _month, _day, 15, 45];

 

Works perfectly, thank you!

Share this post


Link to post
Share on other sites

@pappagoat,

_year = selectRandom [1967, 1968];
_months = if (_year == 1967) then {[4, 12]} else {[1, 12]};

setDate [
    _year,
    _months call BIS_fnc_randomInt,
    [1, 28] call BIS_fnc_randomInt,
    15,
    45
];

 

  • Like 1

Share this post


Link to post
Share on other sites

I've used month selection for a couple things but having errors with this, not sure why:

 

if (_month == [04, 05, 06, 07, 08, 09]) then {{deletevehicle _x} forEach (crew slick4)+[slick4];};

Share this post


Link to post
Share on other sites
34 minutes ago, pappagoat said:

if (_month == [04, 05, 06, 07, 08, 09]) then {{deletevehicle _x} forEach (crew slick4)+[slick4];};

change "==" to "in".

if (_month in [04, 05, 06, 07, 08, 09]) then {{deletevehicle _x} forEach (crew slick4)+[slick4];};

 

  • Like 1

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

×