GrKl30 10 Posted April 28, 2014 Hello all, I am learning to script for Arma3 by creating my first Arma scripts. Here is what I would like to do in my 'spawn.sqf' script: 1: If previous mission is completed (if (taskComplete)) -1A: send a hint for confirmation -1B: in this case delete the marker and mark the task as succeeded 2: If server: -2A: find randomly a new task (city) and assign the 'cityPos' (position) variable to it -2B: create a new trigger and configure it so that when activated it launches: "format["[true] execVM ""spawn.sqf"""]" 3: All (players & server): -3A: create a new task and configure it -3B: create a marker on the map and configure it So in my mission, I set the first trigger manually to launch on activation: "this = [false] execVM "spawn.sqf"" this works properly, all runs fine on clients & on the server my problem is with the triggers created from the script (2B), it is launched correctly on the server, but it seems to me that the clients do not execute the 'spawn.sqf' script as requested. I placed a few hints in it, and can thus confirm it Is this normal? If so, what should I do so that the script is correctly launched on clients + servers? here is the 'spawn.sqf': taskComplete = _this select 0; sleep 1; //wait load.sqf to load hint format ["taskComplete?: %1",taskComplete]; sleep 5; if (taskComplete) then { hint "task completed!"; task setTaskState "Succeeded"; sleep 5; player removeSimpleTask task; deleteMarker "marker"; sleep 2; }; if (isServer) then { // find new city cityName = city call BIS_fnc_selectRandom; publicVariable "cityName"; city = city - [cityName]; if (cityName == "Agia Marina") then { cityPos = getMarkerPos "AgiaMarina"; publicVariable "cityPos"; }; if (cityName == "Girna") then { cityPos = getMarkerPos "Girna"; publicVariable "cityPos"; }; //create the trigger and winning conditions trigger = createTrigger["EmptyDetector", cityPos]; trigger setTriggerArea[300,300,0,false]; trigger setTriggerActivation["EAST","NOT PRESENT",false]; trigger setTriggerStatements["this", "nul = [true] execVM ""spawn.sqf"";", ""]; }; sleep 1; //create a task task = player createSimpleTask ["task"]; task setSimpleTaskDestination cityPos; task setSimpleTaskDescription [format ["You must kill all enemies in %1",cityName],format ["Free %1",cityName],format ["Free %1",cityName]]; task setTaskState "Created"; //add a marker on the map marker = createMarker ["marker", (cityPos)]; marker setMarkerShape "ELLIPSE"; marker setMarkerSize [300, 300]; "marker" setMarkerColor "ColorRed"; hint format ["cityName is: %1\ncityPos is: %2",cityName,cityPos]; /* sleep 10; // this part works... so code written above seems good to me hint "task completed!"; task setTaskState "Succeeded"; deleteMarker "marker"; */ Thank you for any help possible Share this post Link to post Share on other sites
Lala14 135 Posted April 28, 2014 Hello all,I am learning to script for Arma3 by creating my first Arma scripts. Here is what I would like to do in my 'spawn.sqf' script: 1: If previous mission is completed (if (taskComplete)) -1A: send a hint for confirmation -1B: in this case delete the marker and mark the task as succeeded 2: If server: -2A: find randomly a new task (city) and assign the 'cityPos' (position) variable to it -2B: create a new trigger and configure it so that when activated it launches: "format["[true] execVM ""spawn.sqf"""]" 3: All (players & server): -3A: create a new task and configure it -3B: create a marker on the map and configure it So in my mission, I set the first trigger manually to launch on activation: "this = [false] execVM "spawn.sqf"" this works properly, all runs fine on clients & on the server my problem is with the triggers created from the script (2B), it is launched correctly on the server, but it seems to me that the clients do not execute the 'spawn.sqf' script as requested. I placed a few hints in it, and can thus confirm it Is this normal? If so, what should I do so that the script is correctly launched on clients + servers? here is the 'spawn.sqf': taskComplete = _this select 0; sleep 1; //wait load.sqf to load hint format ["taskComplete?: %1",taskComplete]; sleep 5; if (taskComplete) then { hint "task completed!"; task setTaskState "Succeeded"; sleep 5; player removeSimpleTask task; deleteMarker "marker"; sleep 2; }; if (isServer) then { // find new city cityName = city call BIS_fnc_selectRandom; publicVariable "cityName"; city = city - [cityName]; if (cityName == "Agia Marina") then { cityPos = getMarkerPos "AgiaMarina"; publicVariable "cityPos"; }; if (cityName == "Girna") then { cityPos = getMarkerPos "Girna"; publicVariable "cityPos"; }; //create the trigger and winning conditions trigger = createTrigger["EmptyDetector", cityPos]; trigger setTriggerArea[300,300,0,false]; trigger setTriggerActivation["EAST","NOT PRESENT",false]; trigger setTriggerStatements["this", "nul = [true] execVM ""spawn.sqf"";", ""]; }; sleep 1; //create a task task = player createSimpleTask ["task"]; task setSimpleTaskDestination cityPos; task setSimpleTaskDescription [format ["You must kill all enemies in %1",cityName],format ["Free %1",cityName],format ["Free %1",cityName]]; task setTaskState "Created"; //add a marker on the map marker = createMarker ["marker", (cityPos)]; marker setMarkerShape "ELLIPSE"; marker setMarkerSize [300, 300]; "marker" setMarkerColor "ColorRed"; hint format ["cityName is: %1\ncityPos is: %2",cityName,cityPos]; /* sleep 10; // this part works... so code written above seems good to me hint "task completed!"; task setTaskState "Succeeded"; deleteMarker "marker"; */ Thank you for any help possible Well if this is being called by either game logic or init.sqf then I see no issue but if you think that this is the issue then I would try instead this [[[false], "spawn.sqf"],"BIS_fnc_execVM",true,true] spawn BIS_fnc_MP; this is to call the script on every client and the server. Share this post Link to post Share on other sites
GrKl30 10 Posted April 28, 2014 (edited) Thx Lala for helping, currently I just replaced: trigger setTriggerStatements["this", "nul = [1] execVM ""spawn.sqf"";", ""]; by: trigger setTriggerStatements["this", "[[[1], "spawn.sqf"],BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;, ""]; was this what you ment? I am not able to make this work currently, but I think this is because your propose to 'spawn' with 'BIS_fnc_MP'. If I am correct I must then preprocess the 'spawn.sqf' script. But having never preprocessed scripts, I do not quite understand how and were this should be done. Could you help on this too? Edited April 28, 2014 by GrKl30 Share this post Link to post Share on other sites
Lala14 135 Posted April 28, 2014 Thx Lala for helping,currently I just replaced: trigger setTriggerStatements["this", "nul = [1] execVM ""spawn.sqf"";", ""]; by: trigger setTriggerStatements["this", "[[[1], "spawn.sqf"],BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;, ""]; was this what you ment? I am not able to make this work currently, but I think this is because your propose to 'spawn' with 'BIS_fnc_MP'. If I am correct I must then preprocess the 'spawn.sqf' script. But having never preprocessed scripts, I do not quite understand how and were this should be done. Could you help on this too? you would not need to preprocess this since its already loaded up when you launch the game, as for if thats not working then I'm not exactly to sure on what you can do, probably need someone else other than me to step in. anyway I don't think also you can execute a script with a number, maybe I'm wrong. Share this post Link to post Share on other sites
GrKl30 10 Posted April 30, 2014 Ok, Lala, actually I'm going to have to hug you ;-) this: [[[false], "spawn.sqf"],"BIS_fnc_execVM",true,true] spawn BIS_fnc_MP; indeed resolves my problem, I just was not supposed to add it in the "on Act." field of my trigger (as I written above), this does not work. I had to make my script launch that line from the server to apply it on all clients (and server, so I had to use if (!isServer) to prevent it running it too) so problem resolved, thanks a lot Lala14! Share this post Link to post Share on other sites
Magirot 14 Posted April 30, 2014 I just was not supposed to add it in the "on Act." field of my trigger (as I written above), this does not work. It might work, but you'd need to use ' or "" instead of " as quotation marks inside a string (otherwise it ends the string there), also you were missing two quotation marks in the earlier paste. trigger setTriggerStatements["this", "[[[1], "spawn.sqf"],BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;, ""]; -> trigger setTriggerStatements["this", "[[[1], 'spawn.sqf'], 'BIS_fnc_execVM', true, true] spawn BIS_fnc_MP;", ""]; Just thought to point this out, since it might help elsewhere. Share this post Link to post Share on other sites