razzored 37 Posted November 11, 2020 Jello. Im working on something, where i need an addaction likeThis addAction ["Get random effect","scripts\randomizer.sqf",[],1,false,true,"","_this distance _target < 2"]; // this being example. Where the script "randomizer.sqf" then has a list of scripts/scripts paths and runs 1 random of them as a remote server execution (Ie if they spawn something, it has to spawn so everyone sees it, in dedicated environment, though i suppose for that, i just need to put if (isServer) then {Long script that does stuff}; inside the "end scripts" chosen by the randomizer..) So the thing i need help with is the "randomizer" or selection script itself. So far what ive come up with is something along the lines of (NOTE, Scripts are all located in mission folder) _Rscripts = ["scripts\script1.sqf","scripts\script2.sqf","scripts\script3.sqf","scripts\script1.sqf","scripts\script4.sqf"]; _Rselector = _Rscripts select floor random count _Rscripts; _handle = [] execVM "_Rselector"; Cheers. Share this post Link to post Share on other sites
gc8 970 Posted November 11, 2020 (edited) Not sure what's the problem but you can use https://community.bistudio.com/wiki/selectRandom for selecting one script name from the array oh and take quotes of from "_Rselector" Edited November 11, 2020 by gc8 quotes 1 Share this post Link to post Share on other sites
razzored 37 Posted November 11, 2020 So like dis _Rscripts = ["scripts\script1.sqf","scripts\script2.sqf","scripts\script3.sqf","scripts\script1.sqf","scripts\script4.sqf"]; _Rselector = _Rscripts select floor random count _Rscripts; _handle = [] execVM _Rselector // I also removed ; since i dont actually think its required here. OR _Rscripts = selectRandom ["scripts\script1.sqf","scripts\script2.sqf","scripts\script3.sqf","scripts\script1.sqf","scripts\script4.sqf"]; _handle = [] execVM _Rscripts // I also removed ; since i dont actually think its required here. // This is a very syntax based question, i am not at a pc with arma 3 installed right now, so i am not able to test it for another couple of hours, so im just hoping to to pinpoint the most likely to give good results, until i can actually test ^_^ Share this post Link to post Share on other sites
gc8 970 Posted November 11, 2020 7 minutes ago, razzored said: _handle = [] execVM _Rselector // I also removed ; since i dont actually think its required here. it is required if you have more script lines after that 2 Share this post Link to post Share on other sites
razzored 37 Posted November 11, 2020 Which i dont atm 👉😎👉 Share this post Link to post Share on other sites
Joe98 90 Posted November 16, 2020 Another way: Write 5 scripts. Create 5 triggers. Each trigger runs one of the scripts. The 5 triggers are placed in an out of the way place on the other side of the map. The five triggers are named from zero to four. trig0 trig1 trig2 trig3 trig4 Place a 6th trigger on the map in the centre of the action. When this trigger is fired, it selects one of the five triggers at random and fires that trigger. . 1 Share this post Link to post Share on other sites
razzored 37 Posted November 16, 2020 Thanks for the info, the script method has been exactly what i needed, especially since there are 40+ scripts in place.. that's a lot of triggers ^^ I do however appreciate the pitch none the less and could use it for something else one day, or someone else might swing by and find it to be just what they need 😄 1 Share this post Link to post Share on other sites
Smart Games 76 Posted November 16, 2020 17 hours ago, Joe98 said: Another way: Write 5 scripts. Create 5 triggers. Each trigger runs one of the scripts. The 5 triggers are placed in an out of the way place on the other side of the map. The five triggers are named from zero to four. trig0 trig1 trig2 trig3 trig4 Place a 6th trigger on the map in the centre of the action. When this trigger is fired, it selects one of the five triggers at random and fires that trigger. If he wants to use his Scripts again, this is hell a lot of work. I would do it like this: 1) Create some Sqf-files (1 file =1 function) 2) Add all your files to CfgFunctions (in the "Description.ext" file) class CfgFunctions { class JF { class Scripts { class function_1 {file = "MyPath\function1.sqf"}; class function_2 {file = "MyPath\function2.sqf"}; class function_3 {file = "MyPath\function3.sqf"}; }; }; }; --> your functions are compiled to: JF_fnc_function_1, JF_fnc_function_2, JF_fnc_function_3 3) Create some sort of Array (for Example in the initServer.sqf) and add the functions private _Functions = [JF_fnc_function_1, JF_fnc_function_2, JF_fnc_function_3]; missionNamespace setVariable ["JF_Functions", _Functions]; 4) Add a random function to an unit (for example the player) private _functions = []; private ["_function"]; _functions = missionNamespace getVariable "JF_Functions"; _function = selectRandom _functions; player addAction ["Some Function", _function]; 2 1 Share this post Link to post Share on other sites
Von Quest 1161 Posted November 17, 2020 _rNum = selectRandom [1,2,3,4,5]; if ( _rNum == 1 ) then { execVM "script1.sqf"; }; if ( _rNum == 2 ) then { execVM "script2.sqf"; }; if ( _rNum == 3 ) then { execVM "script3.sqf"; }; if ( _rNum == 4 ) then { execVM "script4.sqf"; }; if ( _rNum == 5 ) then { execVM "script5.sqf"; }; etc. If you want to stack the probably of a script (example #1), you can do: _rNum = selectRandom [1,1,1,1,2,3,4,5]; And so on. 1 1 Share this post Link to post Share on other sites
Smart Games 76 Posted November 17, 2020 27 minutes ago, Von Quest said: if ( _rNum == 1 ) then { execVM "script1.sqf"; }; if ( _rNum == 2 ) then { execVM "script2.sqf"; }; if ( _rNum == 3 ) then { execVM "script3.sqf"; }; if ( _rNum == 4 ) then { execVM "script4.sqf"; }; if ( _rNum == 5 ) then { execVM "script5.sqf"; }; etc. Use switch do instead 1 1 Share this post Link to post Share on other sites
razzored 37 Posted November 17, 2020 If we keep this up, we will have a compiled list of every possible way to select random arrays of scripts in the real virtuality engine before 2021 🙂 2 Share this post Link to post Share on other sites
Von Quest 1161 Posted November 17, 2020 Another option is min/max for the random number if you have a large range : _rNum = [1,40] call BIS_fnc_randomInt; Share this post Link to post Share on other sites
pierremgi 4737 Posted November 17, 2020 see also selectRandomWeighted 😊 Share this post Link to post Share on other sites
razzored 37 Posted November 19, 2020 Why does Arma have so many different commands to call a random string from an array. Share this post Link to post Share on other sites
Von Quest 1161 Posted November 19, 2020 Precision, Flexibility, and Age. And I assume you mean commands, as variables are created by the coder/user as you invent the variable/word and spelling at your discretion. _one = 1; _num = 1; _blah = 1; _two = 1; _bgsAvH = 1; All local variables on the left side of the equals sign, are all 1. You make them up. They are just data holders. _num + _blah = 2 ArmA Scripting Commands (for other new players) : https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 1 Share this post Link to post Share on other sites
razzored 37 Posted November 20, 2020 yeah, Ooga forgot wordy words. Luckily Vooga from Bonga tribe remembers. Share this post Link to post Share on other sites
razzored 37 Posted November 20, 2020 Also @Von Quest why did you pull the plug on Fuse? tried it out some time ago, was quite sad that it does not explode on a dedicated server and that... development stopped. Share this post Link to post Share on other sites
Von Quest 1161 Posted November 20, 2020 Just paused for now. Will be continuing it this winter I think. Share this post Link to post Share on other sites