Jump to content
Robustcolor

50% chance of activating fnc

Recommended Posts

Hi, i'm using this code at the moment to try to get a 50% chance of activating the fnc when a player is near a specific marker. Problem is, it seems to always activate the fnc. How can i improve this code?

private _ambush = (0 + round (random 1));

for "_x" from 0 to _ambush do {
Just a ai spawn script here.
};

 

Share this post


Link to post
Share on other sites
private _seed = [1,101] call BIS_fnc_randomInt;
if (_seed >50) exitWith {false};
// rest of your code here

 

  • Like 1

Share this post


Link to post
Share on other sites
On 10/19/2019 at 8:17 PM, Robustcolor said:

Problem is, it seems to always activate the fnc. How can i improve this code?

The problem is your loop, it will always run, 50% it will run 1 time and 50% it will run 2 times. Make `from` 1 instead of 0

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

×