Erwin23p 34 Posted January 18, 2015 (edited) Hello, I'm trying to make a scenario where the missions are "random", example: You select in a computer (via addaction) "missions" and this addaction executes a .sqf called "Objectives.sqf" and this .sqf executes randomly a trigger that creates a mission. First thing is: Making the "Objectives.sqf" execute randomly missions, so for that goal I've searched and I found something that I don't really know what it means; I've modified some things and I think it means this: If (_missions > 1) then // If there is more than a mission then { objectiv = missionArray select (floor (random _missions)); // Pick one of the missions } else { objectiv = missionArray select 0; //hmm........ }; missionArray = missionArray - [objectiv]; // ......... if (_missions == 0) exitWith {titleCut ["All Enemy forces are defeated.. The End is here", "PLAIN DOWN", 1]}; // If there isn't any objective lefts, finish the mission "we win" _missions = ((count missionArray)-1) // missions -1 ???? objectiv = missionArray select (floor (random _missions)) // ...... switch (_objectiv) do // And these are my objectives, the only thing I've modified: { case ("m1"): { nul = [] execVM "m_kill_Moha.sqf"; cutText ["Kill the colonel","PLAIN DOWN",2]; }; case ("m2"): { nul = [] execVM "m_meet_informer.sqf"; cutText ["Meet the informer", "PLAIN DOWN", 2]; }; case ("m3"): { nul = [] execVM "m_resupply.sqf"; cutText ["Bring ammo", "PLAIN DOWN", 2]; }; }; How you can see, my comments are in orange, and I really don't know how to use the whole script. Init.sqf "respawn_west" setMarkerPosLocal [markerPos "respawn_west" select 0, markerPos "respawn_west" select 1, 10]; // This is for LHD respawn [] execVM "VCOMAI\init.sqf"; //SCRIPT [] execVM "scripts\zlt_fieldrepair.sqf"; //SCRIPT execVM "gvs\gvs_init.sqf"; //SCRIPT _igiload = execVM "IgiLoad\IgiLoadInit.sqf"; //SCRIPT if (local server) then { missionArray = ["m1","m2","m3"]; nul = [] execVM "Objectives.sqf"; }; Second problem: How to activate a trigger, using a script? Third problem: How can I make things spawn from a script? Like a FOB. Thanks for the help. Edited January 18, 2015 by elcabronazo Orthography & Grammar Share this post Link to post Share on other sites
jshock 513 Posted January 18, 2015 For your second question, you can create a trigger with a script (just look up "trigger script command Arma 3"), but TBH it's kinda pointless to "activate" a trigger via script, just execute whatever the trigger would in the script itself. Share this post Link to post Share on other sites
Erwin23p 34 Posted January 18, 2015 (edited) But the thing is: I've a create task module in editor, and a trigger waiting to be activated to create the task so what I want is a script that can activate the trigger, but I don't know how. thanks for trying to help me. :) Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
jshock 513 Posted January 19, 2015 (edited) Then create the task with the script (I would try BIS_fnc_setTask). https://community.bistudio.com/wiki/BIS_fnc_setTask Or have your trigger condition based on a global variable that gets set to true via your script. Edited January 19, 2015 by JShock Share this post Link to post Share on other sites
Erwin23p 34 Posted January 19, 2015 (edited) Then create the task with the script (I would try BIS_fnc_setTask).https://community.bistudio.com/wiki/BIS_fnc_setTask Or have your trigger condition based on a global variable that gets set to true via your script. thanks for the help. Ok, I'll do it by creating the mission from the script. I've seen that, but I don't know how to do it, I know I've to put something in the condition of the trigger, and then turn the variable true from the script. But how? Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
commanderx 17 Posted January 19, 2015 If you still would like to activate a trigger from a script make something like. - In your init.sqf write: your_activation_variable = 0; - Place the trigger - in the condition field write something like: your_activation_variable == 1; - in the script write to activate: your_activation_variable = 1; publicVariable "your_activation_variable"; After the script runs this line, your trigger should activate. Share this post Link to post Share on other sites
Erwin23p 34 Posted January 19, 2015 (edited) If you still would like to activate a trigger from a script make something like.- In your init.sqf write: your_activation_variable = 0; - Place the trigger - in the condition field write something like: your_activation_variable == 1; - in the script write to activate: your_activation_variable = 1; publicVariable "your_activation_variable"; After the script runs this line, your trigger should activate. Thanks a lot, when I arrive home I'll try it, So, in the variable, do I have to put an "_" in front or not? Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
commanderx 17 Posted January 19, 2015 No _ in front of the variable. It must be a global variable. variables with an _ in front of the name is only accessible within a script. EDIT: Before I forget, if you run this in a multiplayerenvironment there must be in the init.sqf if (isServer) then {your_activation_variable = 0;}; otherwise it will be confusing and every client who connects will set the your_activation_variable to 0. Share this post Link to post Share on other sites
Erwin23p 34 Posted January 19, 2015 (edited) No _ in front of the variable. It must be a global variable. variables with an _ in front of the name is only accessible within a script.EDIT: Before I forget, if you run this in a multiplayerenvironment there must be in the init.sqf if (isServer) then {your_activation_variable = 0;}; otherwise it will be confusing and every client who connects will set the your_activation_variable to 0. ok, so if I use a variable only in one script I can use "_variable", but if I have to use a variable in a script and in the game or another script no "_". Anything about the first script? Thanks again for the help Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
commanderx 17 Posted January 19, 2015 (edited) I put this in the init.sqf [] execVM "tasks\create_task.sqf"; in the create_tasks.sqf an array with filenames _mission_array = ["tasks\task1.sqf","tasks\task2.sqf","tasks\task3.sqf"] call BIS_fnc_selectRandom; [] execVM _mission_array; so it loads a random script where you can put your scripted mission. This is all from memory, hopefully this works as intended :D EDIT: and of course in front of the file if(!isServer) exitWith {}; Edited January 19, 2015 by CommanderX Share this post Link to post Share on other sites
Erwin23p 34 Posted January 19, 2015 (edited) I put this in the init.sqf[] execVM "tasks\create_task.sqf"; in the create_tasks.sqf an array with filenames _mission_array = ["tasks\task1.sqf","tasks\task2.sqf","tasks\task3.sqf"] call BIS_fnc_selectRandom; [] execVM _mission_array; so it loads a random script where you can put your scripted mission. This is all from memory, hopefully this works as intended :D EDIT: and of course in front of the file if(!isServer) exitWith {}; Thank I wasn't thinking it would be so easy, so when I can (have lot of school works) I'll try it. Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
Erwin23p 34 Posted January 19, 2015 (edited) I have tried it and it worked well, but when I finished the first (random) mission, it didn't show another one, so I think I need a script like: if (missions<1) then _mission_array = ["tasks\task1.sqf","tasks\task2.sqf","tasks\task3.s qf"] call BIS_fnc_selectRandom; or something like that, but I don't know how to do it, I'm pretty noob at scripting. :( And any help to spawn things from a script? Edited January 19, 2015 by elcabronazo Share this post Link to post Share on other sites
commanderx 17 Posted January 20, 2015 In your executed random mission file you need another []execVM "file.sqf"; Share this post Link to post Share on other sites
Erwin23p 34 Posted January 20, 2015 In your executed random mission file you need another []execVM "file.sqf"; How I didn't think about that before?:rolleyes: Ok, but I think it's better to create a trigger in the random mission, when this trigger's condition (condition like "!alive o1") is met, then []execVM "file.sqf" and mission completed.Is that good? Share this post Link to post Share on other sites
jshock 513 Posted January 20, 2015 Forget about a trigger use a waitUntil suspension in the mission script: waitUntil {sleep 5; !alive object;}; 0 = [] execVM "script.sqf"; Share this post Link to post Share on other sites