Randomly select in the roster by age and sex

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
leahcim06
Posts: 2
Joined: July 19th, 2022, 3:10 am

Randomly select in the roster by age and sex

Post 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
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Randomly select in the roster by age and sex

Post 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());

    // ...
Post Reply