revv 15 Posted April 6, 2016 Hello all, as the title says I am trying to find the best method for detecting when I have destroyed a vehicle? In particular I am want this for an ammo crate called ammocrat1 for now but I would be wanting to reuse the code if possible for other entities such as a car or something later on too.It is for a server and is task related, I am also using a normal explosive to destroy the crate and I notice that after detonation the crate smokes for a few seconds then sinks into the terrain. Does this mean it is actually deleted/dead/destroyed? I have tried both of the following to detect and trigger the next task but to no avail.cache_A.sqf // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 10, "NONE"]; // Create trigger for crate _trg = createTrigger ["EmptyDetector", getPos ammocrate1, true]; _trg setTriggerArea [5, 5, 0, false]; _trg setTriggerStatements [ "this", "!alive ammocrate1;", "task_1 setTaskState 'SUCCEEDED'; player setCurrentTask task_2; task_1 = true; publicVariable "task_1"; hint "Operation Success!";" ]; and // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 10, "NONE"]; // Create trigger for crate if(isNull ammocrate1) then {hint "Operation Success!";}; I know the second is just a hint but it wont show either and I figure if I cant get a hint to show then it's not detecting the dead crate and wont spawn a trigger anywayNeither seem to work, any ideas?SOLVED:by simply placing a trigger on map with radius set to 0 then putting this in the following fields:CONDITION !alive ammocrate1 ON ACT hint "Operation Successful!"; task_1 setTaskState "Succeeded"; player removeSimpleTask task_1; 0 = [] execVM "scripts\initMissions.sqf"; Share this post Link to post Share on other sites
jshock 513 Posted April 6, 2016 Since your're keen on your trigger: _trg setTriggerStatements [ "!alive ammocrate1",//condition "task_1 setTaskState 'SUCCEEDED'; player setCurrentTask task_2; task_1 = true; publicVariable 'task_1'; hint 'Operation Success!';",//on activation ""//on deactivation ]; You got your stuff mixed up as to where it belongs: https://community.bistudio.com/wiki/setTriggerStatements And you still had some double quotes where there should be single quotes. All this would be caught by the -showScriptErrors startup parameter, recommend you turn that on: https://community.bistudio.com/wiki/ArmA:_Startup_Parameters My waitUntil expression in the other thread should work, not too sure why it didn't, unless just the task wasn't marked as completed, therefore something is wrong with your task system, which is another issue entirely. Share this post Link to post Share on other sites
revv 15 Posted April 6, 2016 Since your're keen on your trigger: _trg setTriggerStatements [ "!alive ammocrate1",//condition "task_1 setTaskState 'SUCCEEDED'; player setCurrentTask task_2; task_1 = true; publicVariable 'task_1'; hint 'Operation Success!';",//on activation ""//on deactivation ]; You got your stuff mixed up as to where it belongs: https://community.bistudio.com/wiki/setTriggerStatements And you still had some double quotes where there should be single quotes. All this would be caught by the -showScriptErrors startup parameter, recommend you turn that on: https://community.bistudio.com/wiki/ArmA:_Startup_Parameters My waitUntil expression in the other thread should work, not too sure why it didn't, unless just the task wasn't marked as completed, therefore something is wrong with your task system, which is another issue entirely. Okay well I will surely use your suggestion if I can get it working, here is my task system (which you've probably seen in other recent threads) init.sqf // Tasks fnc_miss_array = []; fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_1.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_2.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_3.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_4.sqf"); as of now just for testing purposes I have an addAction on a box to get a mission. In the init field of box in editor: this allowDamage false; this addAction["<t color='#ff9900'>Get Mission</t>", "scripts\initMissions.sqf"]; that obviously runs the initMissions.sqf which is as follows: [] call (selectRandom fnc_miss_array); which runs the selector in the init.sqf Each mission.sqf is the same right now just with different text in the description fields. mission_1.sqf "scripts\cache_A.sqf" remoteExec ["execVM",2]; switch (side player) do { case WEST: // BLUFOR briefing goes here { player createDiaryRecord ["Diary", ["*CHANGE ME*", "*debug 1*"]]; //Task1 - COMMENT task_1 = player createSimpleTask ["Mission 1"]; task_1 setSimpleTaskDescription ["This is mission 1 description","Find Cache","Search"]; task_1 setSimpleTaskDestination (getMarkerPos "cache_A"); task_1 setTaskState "Assigned"; taskhint ["Mission-1 Task-1", [1, 1, 1, 1], "taskNew"]; player setCurrentTask task_1; //Task2 - COMMENT task_2 = player createSimpleTask ["Exfil"]; task_2 setSimpleTaskDescription ["Leave area.","Exfiltrate","Exfil"]; task_2 setSimpleTaskDestination (getMarkerPos "cache_3"); task_2 setTaskState "created"; }; case EAST: // OPFOR briefing goes here { }; case RESISTANCE: // RESISTANCE/INDEPENDENT briefing goes here { }; case CIVILIAN: // CIVILIAN briefing goes here { }; }; and then the cache_A.sqf // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 10, "NONE"]; // Create trigger for crate if(isNull ammocrate1) then {hint "Operation Success!";}; _trg = createTrigger ["EmptyDetector", getPos ammocrate1, true]; _trg setTriggerArea [5, 5, 0, false]; _trg setTriggerStatements [ "this", "!alive ammocrate1;", "task_1 setTaskState 'SUCCEEDED'; player setCurrentTask task_2; task_1 = true; publicVariable "task_1";" ]; I have cache_1 to cache_3 markers and a cache_A marker on the map. I did try your method but which ever one I can get working I'm going to use so I'm trying different things out :) EDIT: typo ini.sqf - init.sqf Share this post Link to post Share on other sites
revv 15 Posted April 6, 2016 Since your're keen on your trigger: _trg setTriggerStatements [ "!alive ammocrate1",//condition "task_1 setTaskState 'SUCCEEDED'; player setCurrentTask task_2; task_1 = true; publicVariable 'task_1'; hint 'Operation Success!';",//on activation ""//on deactivation ]; You got your stuff mixed up as to where it belongs: https://community.bistudio.com/wiki/setTriggerStatements And you still had some double quotes where there should be single quotes. All this would be caught by the -showScriptErrors startup parameter, recommend you turn that on: https://community.bistudio.com/wiki/ArmA:_Startup_Parameters My waitUntil expression in the other thread should work, not too sure why it didn't, unless just the task wasn't marked as completed, therefore something is wrong with your task system, which is another issue entirely. In fact I think it is working and you are probably right about the task although Im not sure where I went wrong Share this post Link to post Share on other sites
revv 15 Posted April 6, 2016 So after some tweaking I still cant get this to complete the task correctly.Script sequence is as follows:init.sqf (just the part relating to the missions) // Tasks fnc_miss_array = []; fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_1.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_2.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_3.sqf"); fnc_miss_array pushBack (compileFinal preprocessFileLineNumbers "scripts\mission_4.sqf"); I have a box (temporary) with an addAction to get a missionBox init field: this allowDamage false; this addAction["<t color='#ff9900'>Get Mission</t>", "scripts\initMissions.sqf"]; that runs the initMissions.sqf which is: [] call (selectRandom fnc_miss_array); That picks a random mission from the array in the init.sqfThe scripts listed in the array are all identical except some text for debugging, so they all run the tasks and a file called cache_A.sqfThe mission_1.sqf "scripts\cache_A.sqf" remoteExec ["execVM",2]; switch (side player) do { case WEST: // BLUFOR briefing goes here { player createDiaryRecord ["Diary", ["*CHANGE ME*", "*debug 1*"]]; //Task1 - COMMENT task_1 = player createSimpleTask ["Mission 1"]; task_1 setSimpleTaskDescription ["This is mission 1 long description","Find Cache","Search"]; task_1 setSimpleTaskDestination (getMarkerPos "cache_A"); task_1 setTaskState "ASSIGNED"; ["TaskAssigned"] call BIS_fnc_showNotification; player setCurrentTask task_1; }; case EAST: // OPFOR briefing goes here { }; case RESISTANCE: // RESISTANCE/INDEPENDENT briefing goes here { }; case CIVILIAN: // CIVILIAN briefing goes here { }; }; So from here when I start the mission I can go to the box, use the action on it to get a random mission and the ammo crate spawns at a random marker but when I destroy the ammo crate nothing else happens.I'm assuming I forgot something with the tasks here but here is the final script called cache_A.sqf // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "mrk_1",["mrk_1","mrk_1"], 0, "NONE"]; // Set Task State for crate _handle = [] spawn { waitUntil {!alive ammocrate1; sleep 0.5}; [task_1, "SUCCEEDED", true] call bis_fnc_tasksetstate; ["TaskSucceeded"] call BIS_fnc_showNotification; hint "Operation Success!"; }; Can anyone help please? Share this post Link to post Share on other sites
jshock 513 Posted April 6, 2016 Try: https://community.bistudio.com/wiki/BIS_fnc_setTask To do all the necessary creation and assignment of the task, use the return in taskSetState as you have it above. It may be boiling down to a locality issue here. Also, typo on my part (not sure if it matters), but go ahead and add a ';' after sleep 0.5 in the waitUntil block. Share this post Link to post Share on other sites
revv 15 Posted April 6, 2016 Well I couldn't get any script to do it so I have set up a trigger in the editor with radius set to 0 and set to NONE and NONE and just put in the condition field !alive ammocrate1 and in the activation field is just a hint for now but its working and its working REPEATEDLY in the correct way too lol. About to test it all on a server with a friend to make sure everything is syncing correctly now, wish me luck and thanks for your help mate! Share this post Link to post Share on other sites