Jump to content
Purzel

randomized script selection..?

Recommended Posts

Hi there,

what I need is the following:
A randomized script-selection executed on server which works in MP (JiP compatible!)

 

like this:

if IsServer (get randomX 1-3) , {if randomX = 1 -> script1.sqf, if randomX = 2 -> script2.sqf, if randomX = 3 -> script3.sqf}

(I know, this is not a working code, its just an example)

I need this to start 1 of 3 different scripts random to get different waypoints/vehicles/units/groups/etc activated by trigger or missions begin.
(e.g. a target should be start on one of three different routes with different vehicles (depending on choosen script: e.g. coming via helicopter/vehicle oder plane)

 

I only need the correct code-line...

Thanks and Greetz
Purzel

Share this post


Link to post
Share on other sites
_scripts = ["script1.sqf","script2.sqf","script4.sqf"];
_weights = [0.5,0.25,0.25];
_script = [_scripts,_weights] call BIS_fnc_selectRandomWeighted;

Probably the most underrated function when it comes to this.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

This will exec 'script_<random>.sqf':

_nums = [1,2,3,4,5];

_null = [] execVM format ["script_%1", (selectRandom _nums)];

or just put all the script in an array and exec random, similar to prev. post:

_scripts = ["gen_wp", "go_here", "go_there", "do_something"];

_null = [] execVM format ["%1.sqf", (selectRandom _scripts)];

Share this post


Link to post
Share on other sites


execVM selectRandom ["script1.sqf", "script2.sqf", "script3.sqf"...."scriptN.sqf"]

Share this post


Link to post
Share on other sites

To make it JIP-compatible run the randomization once (and serversidedly, e.g. in initServer.sqf) and stash the result in a variable.

Share this post


Link to post
Share on other sites

At first:
THANKS to ALL!

Wouldnt it be JIP-compatible, if I just use KK´s script:

execVM selectRandom ["script1.sqf", "script2.sqf", "script3.sqf"...."scriptN.sqf"]

because only the server would call the script and place the units depending on the choosen script?
So all waypoints etc. will just start as given in the script only on server??

Share this post


Link to post
Share on other sites

At first:

THANKS to ALL!

Wouldnt it be JIP-compatible, if I just use KK´s script:

execVM selectRandom ["script1.sqf", "script2.sqf", "script3.sqf"...."scriptN.sqf"]

because only the server would call the script and place the units depending on the choosen script?

So all waypoints etc. will just start as given in the script only on server??

 

No idea what you mean, but if you want to make sure the same script is executed on every client and JIP you can run this on the server only:

 

if (isServer) then {selectRandom ["script1.sqf", "script2.sqf", "script3.sqf"] remoteExec ["execVM", 0, true]}

Share this post


Link to post
Share on other sites

Thanks - that is what I needed...
works like charms!

Big THX!!!!

:D :D :D :D :) :) :) :)

Share this post


Link to post
Share on other sites

Another solution:  Place a box on the map and name it  box1

 

Arrange it so that it always starts at one of 10 places at random.

 

Each of those 10 places has a trigger.  When the box appears in a trigger it causes that trigger to fire.

 

When a trigger fires it runs a script.  Obviously you would have 10 scripts.

 

So, from the player's point of view, one of 10 scripts will be selected at random.

 

.

.

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

×