Page 1 of 1

Randomly select in the roster by age and sex

Posted: August 2nd, 2022, 2:54 am
by leahcim06
Hi,

I would like to ask if there is any way where i can randomly select the member by age and sex?

Thanks,
Leahcim

Re: Randomly select in the roster by age and sex

Posted: August 2nd, 2022, 9:14 am
by Gregory Martin
See a recent post about this: viewtopic.php?f=1&t=5115

There are a variety of random-related functions in CSPro, including: https://www.csprousers.org/help/CSPro/r ... ction.html

One option is to loop through your roster and fill a list object with the occurrences of each applicable member. Then you can select the random member using:
list eligible_members;

// ... fill this

if eligible_members.length() > 0 then

    numeric
selected_member = random(1, eligible_members.length());

    // ...