thedubl 43 Posted September 21, 2015 Hello, I have been starting to get things in order for a side search and destroy task to run. So, I have been reading the wiki, but I have run into an issue with a simple trigger test to learn how to script one. What am I doing wrong with the trigger? Once I get that working I can start to figure the trigger !alive or destroyed object bit. Thanks, dubl init: null=[] execVM "scripts\seekanddestory.sqf"; /**************************************************************************--get all the city locations and stuff in an array().--randomly get city position--create marker--create object from object pool (define the object pool)--create trigger and group the object.--write to a array (example: blacklisted[]...been there and done that) and store it so we do not create one there again.-- when object destroyed ( ! alive activation or destroyed) remove marker and remove trigger call script again to create next search and destroy.*************************************************************************///array position pool not using this for now...//_arrPos = [[10638,12254],[9227,15857],[7151,15857],[4881,14418],[3738,13613]]call BIS_fnc_selectRandom;_objectPool = ["Box_NATO_AmmoVeh_F","Box_NATO_WpsLaunch_F","O_Truck_03_device_F"] call BIS_fnc_selectRandom;//test position so I do not have to go looking for stuff._test=getPos player;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _test];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";_markerstr setMarkerText "DESTROY";//creates ammo box to destroy_box = createVehicle [_objectPool,_test,[], 0, "NONE"]//create a trigger for the ammo box..fire it off when ! alive in the condition//first activate when present to learn this first._trg = createTrigger ["EmptyDetector", _test];_trg setTriggerArea [500, 500, 0, false];_trg setTriggerActivation ["WEST", "PRESENT", true];_trg setTriggerStatements ["this", "hint ' player'", "hint 'no player near'"]; Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2015 Your trigger looks fine but the line before it is missing a ; at the end should be _box = createVehicle [_objectPool,_test,[], 0, "NONE"]; due to this error it's possible the trigger code isn't being run. Share this post Link to post Share on other sites
thedubl 43 Posted September 22, 2015 Thanks, that was it! Share this post Link to post Share on other sites
thedubl 43 Posted September 22, 2015 Now when I set the the vehicle name a check when it is !alive it does not seem to work. Any ideas? /**************************************************************************--get all the city locations and stuff in an array().--randomly get city position--create marker--create object from object pool (define the object pool)--create trigger and group the object.--write to a array (example: blacklisted[]...been there and done that) and store it so we do not create one there again.-- when object destroyed ( ! alive activiation or destoryed) remove marker and remove trigger call script agian to create next serach and destroy.*************************************************************************///array position pool not using this for now...//_arrPos = [[10638,12254],[9227,15857],[7151,15857],[4881,14418],[3738,13613]]call BIS_fnc_selectRandom;_objectPool = ["Box_NATO_AmmoVeh_F","Box_NATO_WpsLaunch_F","O_Truck_03_device_F"] call BIS_fnc_selectRandom;//test position so I do not have to go looking for stuff._test=getPos player;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _test];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";_markerstr setMarkerText "DESTROY";//creates ammo box to destroy_box = createVehicle [_objectPool,_test,[], 0, "NONE"];//create a trigger for the ammo box..fire it off when ! alive in the condition//set the name_box setVehicleVarName "obj";//**TESTING**display the name to see that it workedhint vehicleVarName _box;_act = "(!alive obj)";_trg = createTrigger ["EmptyDetector", _test];_trg setTriggerArea [500, 500, 0, false];_trg setTriggerActivation ["any", "PRESENT", true];_trg setTriggerStatements [_act, "null=[] execVM 'scripts\seekanddestory.sqf'", ""]; Share this post Link to post Share on other sites
jshock 513 Posted September 22, 2015 Wouldn't this work?: _trg setTriggerStatements [format ["!alive %1",_box], "null=[] execVM 'scripts\seekanddestory.sqf'", ""]; Share this post Link to post Share on other sites
thedubl 43 Posted September 22, 2015 I tried all the highlighted below and still when the object is blown up... nothing. Not sure what I am doing incorrect. It has been suggested and I have read to use "!alive name of obj". The name of the object is being set to "seekobj". So I do not see a problem. Thanks for any assistance. dubl _objectPool = ["Box_NATO_AmmoVeh_F","Box_NATO_WpsLaunch_F","O_Truck_03_device_F"] call BIS_fnc_selectRandom;//test position so I do not have to go looking for stuff._test=getPos player;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _test];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";_markerstr setMarkerText "DESTROY";//creates ammo box to destroy_obj= createVehicle [_objectPool,_test,[], 0, "NONE"]; //set the name _obj setVehicleVarName "seekobj";_trg = createTrigger ["EmptyDetector", _test];_trg setTriggerArea [500, 500, 0, false];_trg setTriggerActivation ["any", "PRESENT", true]; I first tried this..._trg setTriggerStatements [format ["!alive %1",_obj], "null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""]; I tried this next by setting the name to seekobj_trg setTriggerStatements ["!alive seekobj", "null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""]; Share this post Link to post Share on other sites
DeathF0X 198 Posted September 22, 2015 i read somewhere that scripted triggers only work with globals vars, had the same problem. Workaround: _crate2 = createVehicle [_crate_class, _pos2, [], 0, "CAN_COLLIDE"]; .... waitUntil { (!alive _crate1) AND (!alive _crate2) AND (!alive _crate3) OR (mission_abort) }; ... 1 Share this post Link to post Share on other sites
thedubl 43 Posted September 22, 2015 Skullfox, Well... that does work and thanks. I find it interesting that the trigger has trouble with the variable. I can certianly do keep that, but I am still wondering if anyone has found a solution for the trigger. I also have a question about arrays. If I define a public array in my script and push a value to the array once the script is called again will the previously pushed value still be in the array? If not, how can I create an array to store values so that I can check to arrary contents later. arr= [1,2,3]; publicVariable "arr"; thanks, dubl _objectPool = ["Box_NATO_AmmoVeh_F","Box_NATO_WpsLaunch_F","O_Truck_03_device_F"] call BIS_fnc_selectRandom;//test position so I do not have to go looking for stuff._test=getPos player;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _test];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";_markerstr setMarkerText "DESTROY";//creates ammo box to destroy_obj= createVehicle [_objectPool,_test,[], 0, "NONE"];waitUntil { (!alive _obj)};deleteMarker "marker";null=[] execVM "scripts\seekanddestory.sqf"; Share this post Link to post Share on other sites
DeathF0X 198 Posted September 22, 2015 Yes as long as you keep the array in sync with the client|server. init.sqf crates = ["Box_FIA_Support_F","Box_XXX_Suport_F"]; mission.sqf, extra chance to get a special box crates pushBack "Box_FFFF_Suport_F"; _crateClass = crates call BIS_fnc_selectRandom; _obj = createVehicle [_crateClass, getMarkerPos "myHiddenCrate", [], 0, "CAN_COLLIDE"]; BUT if you modify the array local and start the script on the local player then the array is in desync. Addaction is a local command, if you modify the array from the script: player addAction ["ASD", "oohh.sqf"]; oohh.sqf crates pushBack "FFFFF_FFF"; Other : crates = ["Box_FIA_Support_F","Box_XXX_Suport_F",Box_FFFF_Suport_F]; You : crates = ["Box_FIA_Support_F","Box_XXX_Suport_F",Box_FFFF_Suport_F,"FFFFF_FFF"]; as you posted publicVariable is the solution. crates pushBack "FFFFF_FFF"; publicVariable "crates"; You can reverse engineer my old project. Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2015 I'm sure it's possible to pas a local variable to a trigger statement but I can't remember how. You could always store the variable in the trigger memory space and retrieve it later. _trg setvariable [str _trg,_obj]; _trg setTriggerStatements [ "!alive (thistrigger getvariable str thistrigger)","null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""]; I think that should work until someone comes up with the correct answer. Share this post Link to post Share on other sites
thedubl 43 Posted September 22, 2015 Thanks f2K sel, I threw it in note pad so I would not forget to try it tonight. Here is what I currently have. I am not sure if I the "in" array while loop bit will work, but seems like should in my head. dubl Untested: /**************************************************************************Seek and Destroythedubl 9-21-2015Setup: Place in the initnull=[] execVM "scripts\seekanddestory.sqf";*************************************************************************///messages to playerstitleText ["We are receving new INTEL stand by...", "PLAIN"];sleep 120;titleText ["Your map has been updated with an new coordinates to search for unknown materials. Search and destroy.", "PLAIN"];sleep 5;//array position pool not using this forwhile {true}do{_arrPos = [[10638,12254],[9227,15857],[7151,15857],[4881,14418],[3738,13613]]call BIS_fnc_selectRandom;_arrPos in blacklist [];};//push the value to the arrayblacklist pushback _arrPos//lets grab a random object to seek_objectPool = ["Box_NATO_AmmoVeh_F","Box_NATO_WpsLaunch_F","O_Truck_03_device_F"] call BIS_fnc_selectRandom;//**test** position so I do not have to go looking for stuff.//_test=getPos player;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _arrPos];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";//creates ammo box to destroy_obj= createVehicle [_objectPool,_arrPos,[], 0, "NONE"];/***************************************************************************this block is not working due the variables and trigger not playing nicetogether.***************************************************************************///create a trigger for the ammo box..fire it off when ! alive in the condition//set the name//_obj setVehicleVarName "seekobj";//**TESTING**display the name to see that it worked//hint vehicleVarName _obj;//_trg = createTrigger ["EmptyDetector", _test];//_trg setTriggerArea [500, 500, 0, false];//_trg setTriggerActivation ["any", "PRESENT", true];//_trg setvariable [str _trg,_obj];//_trg setTriggerStatements [ "!alive (thistrigger getvariable str thistrigger)","null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""];//_trg setTriggerStatements [format ["!alive %1",seekobj], "null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""];//_trg setTriggerStatements ["!alive seekobj", "null=[] execVM 'scripts\seekanddestory.sqf';deleteMarker 'marker';", ""];/***************************************************************************End of trigger***************************************************************************//***************************************************************************Waituntil the object is destoryed and run again. Using this as workaround***************************************************************************/waitUntil { (!alive _obj)};deleteMarker "marker";//get sleep time before running again_randTime = [60,120,300,600]call BIS_fnc_selectRandom;titleText ["Great Job!", "PLAIN"];sleep _randTime;null=[] execVM "scripts\seekanddestory.sqf"; Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2015 I think you will need these lines for format to work although I think it's kind of pointless as setting the name means you can use the name directly "alive seekobj" without the format issues. I think it's real use is for when the name would be dynamic. missionNamespace setVariable ["seekobj", _obj, true];// set usable name call compile format ["_trg setTriggerStatements ['!alive %1', 'null=[] execVM ""scripts\seekanddestory.sqf"";deleteMarker ""marker"";', '']", _obj]; Your loop will loop but it never exits so the script will just keep looping. Share this post Link to post Share on other sites
thedubl 43 Posted September 25, 2015 When a marker is created via a script does it display on all clients? dubl Share this post Link to post Share on other sites
jshock 513 Posted September 25, 2015 It should yes, as long as you use "createMarker" and not "createMarkerLocal" or other "local" commands related to the marker scripting group. Share this post Link to post Share on other sites
thedubl 43 Posted September 25, 2015 Thanks, the init is called for each player on mission start, correct? If I want the script to be on call on the start of the mission on the server I would use the initserver, correct? If I had titletexts in the script but want them to be displayed across on clients... how would I achieve that? In my searches I keep coming back to remoteExec, yeah? Share this post Link to post Share on other sites
jshock 513 Posted September 25, 2015 initServer would be a good, and for titleText you can use BIS_fnc_MP to broadcast: [["Text Here","PLAIN",1],"titleText",true,false,false] call BIS_fnc_MP; Or the new remoteExec: ["Text Here","PLAIN",1] remoteExec ["titleText",0,false]; Share this post Link to post Share on other sites
thedubl 43 Posted September 25, 2015 ok. I will give the suggested a shot and update. I am hoping I can get this thing working by the end of the weekend. thanks jshock! Share this post Link to post Share on other sites
thedubl 43 Posted September 25, 2015 This did not work unfortunately I will try the the remote next. [["We are receving new INTEL stand by...","PLAIN",1],"titleText",true,false,false] call BIS_fnc_MP; Nothing comes up at all but the markers and objects are being created Neither did the ["We are receving new INTEL stand by...","PLAIN",1] remoteExec ["titleText",0,false]; work. initserver.sqf null=[] execVM "scripts\seekanddestroy.sqf"; /**************************************************************************Seek and Destroythedubl 9-21-2015Setup: Place in the init//PUBLIC VAR for stepping the array poolindex = 0;publicVariable "index";//SEEK SCRIPTnull=[] execVM "scripts\seekanddestroy.sqf";*************************************************************************/_lastpos =[] call compile "index";//just a double check it is not nullif (isNil "_lastpos") then {_lastpos = 0;};//for testing//hint format [" value: %1",_lastpos];if(_lastpos == 0) then {sleep 60;};//messages to players["We are receving new INTEL stand by...","PLAIN"] remoteExec ["titleText",0,false];sleep 5;//[["Your map has been updated with an unknown marker. Search and destroy enemy weapons cache.","PLAIN",1],"titleText",true,false,false] call BIS_fnc_MP;["Your map has been updated with an marker. Search and destroy enemy weapons cache.","PLAIN"] remoteExec ["titleText",0,false];sleep 5;//array position pool_arrPos = [[9227,15857],[7151,15857],[4881,14418],[3738,13613],[10638,12254],[3757.93,13796.1],[3711.4,12284.9],[4108.23,11758.3],[5028.74,11284.3],[8955.5,12086.4],[10673.8,12237.9],[10882,13464.1],[11714.7,13711.4],[11140.7,14597.4],[12493.9,14337],[12883,15062.7],[12324.2,15768.8],[14360.5,18949.5],[16385.8,17228.1],[16681.8,16143.9],[18126.3,15268.8],[18773.4,16595.3],[20990.1,17088.9],[25709.8,21383.9],[27050.5,23255.8],[21398.5,16344],[19456.9,13246.4],[16853.9,12623],[20236.6,11630.2]]; //select the pos from the array_pos = _arrpos select _lastpos;//for testing/*hint format [" value: %1",_pos];sleep 1;*///lets grab a random object to seek_objectPool = ["Box_NATO_AmmoVeh_F"] call BIS_fnc_selectRandom; // take these out for now ... "Land_SatellitePhone_F","B_CargoNet_01_ammo_F"//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _pos];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkerText "DESTROY";_markerstr setMarkerColor "ColorUNKNOWN";//creates ammo box to destroy_obj= createVehicle [_objectPool,_pos,[], 0, "NONE"];_retVal = _lastpos +1; //increment by 1/***************************************************************************Waituntil the object is destroyed and run again.***************************************************************************/waitUntil { (!alive _obj)};//reset the public varindex = _retval;publicVariable "index";deleteMarker "marker";//get sleep time before running again_randTime = [60,120,300,600]call BIS_fnc_selectRandom;//[["Great Job!","PLAIN",1],"titleText",true,false,false] call BIS_fnc_MP;["Great Job!","PLAIN"] remoteExec ["titleText",0,false];sleep _randTime;null=[index] execVM "scripts\seekanddestroy.sqf"; The above titletexts live within that script. If I place it in the init it works however every time a player joins it is called, which is not what i wanted. Maybe I am going about this all wrong. dubl Share this post Link to post Share on other sites
thedubl 43 Posted September 26, 2015 This is the error for the remote. Error when remotely executing 'titletext' - wrong number of arguments (3) passed, must be either 0, 1 or 2 ["Your map has been updated with an marker. Search and destroy enemy weapons cache.","PLAIN",1] remoteExec ["titleText",0,false]; Looks fine to me. dubl Share this post Link to post Share on other sites
thedubl 43 Posted September 26, 2015 Hint works. Maybe there is just an issue with titletext. "We have incoming INTEL stand by..." remoteExec ["hint", -2]; dubl Share this post Link to post Share on other sites
jshock 513 Posted September 26, 2015 Well, it's saying there are 3 arguments, expecting none, 1 or 2, so try: ["Your map has been updated with an marker. Search and destroy enemy weapons cache.","PLAIN",1] remoteExec ["titleText",0]; Share this post Link to post Share on other sites
thedubl 43 Posted September 27, 2015 Ok, I will give that a go. Sorry, I was not realizing what it was saying. Question about public variables. Can I have multiple public variables in the serverinit? I ask because it does not seem to like having more than one. Thanks for the help. dubl Share this post Link to post Share on other sites
thedubl 43 Posted September 28, 2015 In the end I did not use the trigger and although the titletext worked, I decided to keep the messaging out of the middle of the screen so I stayed with the hint. It is simple but, it works and I thank everyone who responded. /**************************************************************************Seek and Destroythedubl 9-21-2015Setup: Place in the init//PUBLIC VARindex = 0;publicVariable "index";//SEEK SCRIPTnull=[] execVM "scripts\seekanddestroyV2.sqf";*************************************************************************/_lastpos =[] call compile "index";//just a double check it is not nullif (isNil "_lastpos") then {_lastpos = 0;};//for testing//hint format [" value: %1",_lastpos];if(_lastpos == 0) then {sleep 120;};//messages to players"We have incoming INTEL stand by..." remoteExec ["hint", -2];sleep 5;//**Note...last kill//[9002.08,12053.1]//array position pool_arrPos = [[9227,15857],[17432.6,13127.9],[3757.93,13796.1],[20754.7,7264.11],[3711.4,12284.9],[23635.4,21078.1],[4108.23,11758.3],[26714.3,24604.1],[5028.74,11284.3],[14193.9,21198.4],[8955.5,12086.4],[3664.67,12827.4],[10673.8,12237.9],[4564.34,15411.8],[10882,13464.1],[9199.39,21689.2],[4564.34,15411.8],[18369.2,15485.6],[11714.7,13711.4],[16826.4,1266.5],[11140.7,14597.4],[12842.6,16681.4],[12493.9,14337],[14291,18865.3],[12883,15062.7],[9002.08,12053.1],[12324.2,15768.8],[14360.5,18949.5],[16385.8,17228.1],[16681.8,16143.9],[18126.3,15268.8],[18773.4,16595.3],[20990.1,17088.9],[25709.8,21383.9],[27050.5,23255.8],[21398.5,16344],[19456.9,13246.4],[16853.9,12623],[20236.6,11630.2]];//select the pos from the array_pos = _arrpos select _lastpos;//for testing/*hint format [" value: %1",_pos];sleep 1;*///Officer array index positions_arrkill = [1,3,5,7,9,11,13,15,17,19,21,23,25];//check on what to do...if(_lastpos in _arrkill)then{"Your map has been updated. Take out the enemy officer." remoteExec ["hint", -2];sleep 5;_markerstr = createMarker ["marker", _pos];_markerstr setMarkerShape "ICON";_markerstr setMarkerSize [1,1];_markerstr setMarkertype "hd_destroy";_markerstr setMarkerText "Kill the Officer";_markerstr setMarkerColor "ColorRed";//creates Officer_grp = createGroup east;_obj = _grp createUnit ["O_officer_F", _pos, [], 0, "FORM"] ;_s1 = _grp createUnit ["O_Soldier_LAT_F", _pos, [], 0, "FORM"] ;_s2 = _grp createUnit ["O_soldier_M_F", _pos, [], 0, "FORM"] ;_s3 = _grp createUnit ["O_soldier_M_F", _pos, [], 0, "FORM"] ;_s4 = _grp createUnit ["O_soldier_SL_F", _pos, [], 0, "FORM"] ;_retVal = _lastpos +1; //increment by 1/***************************************************************************Waituntil the object is destroyed and run again.***************************************************************************/waitUntil {(!alive _obj) };//reset the public varindex = _retval;publicVariable "index";deleteMarker "marker";//get sleep time before running again_randTime = [120,300]call BIS_fnc_selectRandom;"One less to give orders! Let's continue to cut off the head of the snake." remoteExec ["hint", -2];sleep _randTime;null=[index] execVM "scripts\seekanddestroyv2.sqf";}else{"Your map has been updated with an unknown marker. Search and destroy enemy weapons cache." remoteExec ["hint", -2];sleep 5;//lets grab a random object to seek_objectPool = ["Box_NATO_AmmoVeh_F","Box_IND_Wps_F","Box_IND_WpsSpecial_F"] call BIS_fnc_selectRandom;//creates my marker based the ramdomly select position._markerstr = createMarker ["marker", _pos];_markerstr setMarkerShape "ELLIPSE";_markerstr setMarkerSize [50,50];_markerstr setMarkertype "mil_unknown";_markerstr setMarkerText "S&D WEAPONS CACHE";_markerstr setMarkerColor "ColorUNKNOWN";//creates ammo box to destroy_obj= createVehicle [_objectPool,_pos,[], 0, "NONE"];_obj1= createVehicle [_objectPool,_pos,[], 0, "NONE"];_obj2= createVehicle [_objectPool,_pos,[], 0, "NONE"];_obj3= createVehicle [_objectPool,_pos,[], 0, "NONE"];/***************************************************************************Waituntil the object is destroyed and run again.***************************************************************************/_retVal = _lastpos +1; //increment by 1waitUntil { ((!alive _obj) && (!alive _obj1) && (!alive _obj2) && (!alive _obj3)) };//reset the public varindex = _retval;publicVariable "index";deleteMarker "marker";//get sleep time before running again_randTime = [60,120,300,600]call BIS_fnc_selectRandom;"Great Job! HQ will update if additional INTEL is obtained." remoteExec ["hint", -2];sleep _randTime;null=[index] execVM "scripts\seekanddestroyv2.sqf";}; dubl Share this post Link to post Share on other sites