revv 15 Posted April 5, 2016 Hello, I am trying to make an ammo crate spawn at a random marker position and Im having trouble. I want my missions to run on repeat as I have a selector picking a random mission from a list so I dont want to crate spawning at server start. This is what I have so far: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"); Then for the moment (while I decide how to execute the mission selector) I have an object with an addAction executing the initMissions.sqf: [] call (selectRandom fnc_miss_array); The mission_1.sqf: 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_1"); task_1 setTaskState "Assigned"; 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 { }; }; I tried putting: "scripts\cache_A.sqf" remoteExec ["execVM",2]; at the start of the mission_1.sqf but it doesn't work.To recap Im trying to get the ammo crate to spawn when the mission_1 tasks are assigned.EDIT: I should also mention this will be run on a server so it needs to be JIP friendly and the markers I have placed are: cache_1, cache_2, cache_3EDIT*: SOLVEDBy placing "scripts\cache_A.sqf" remoteExec ["execVM",2]; At the start of the initMissions.sqf it ran the cache_A.sqf and it spawned the crate! 1 Share this post Link to post Share on other sites
revv 15 Posted April 5, 2016 I also forgot to mention the actual ammo crate spawning method.I have a file called cache_A.sqf // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 5, "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!";" ]; I dont know if the trigger part works yet as the crate wont spawn. Share this post Link to post Share on other sites
SpaydCBR 11 Posted April 5, 2016 Hmm, well in your triggerStatements, I think you need to replace the inner double quotes (like at "SUCCEEDED") with single quotes, otherwise you keep closing and reopening the whole string! But I don't think that would stop the crate from spawning :( Share this post Link to post Share on other sites
revv 15 Posted April 5, 2016 Yeah not sure about that, I think I need a different method of spawning it but can't figure it out. Share this post Link to post Share on other sites
jshock 513 Posted April 5, 2016 Yeah not sure about that, I think I need a different method of spawning it but can't figure it out. Spayd is correct. But you could easily do this without a trigger: // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 5, "NONE"]; _handle = [] spawn { waitUntil {!alive ammocrate1; sleep 0.5}; task_1 setTaskState "SUCCEEDED"; player setCurrentTask task_2; task_1 = true; publicVariable "task_1"; hint "Operation Success!"; }; You were missing ']' at the end of your createVehicle line, that's probably why it didn't work, fixed in my example above. Share this post Link to post Share on other sites
revv 15 Posted April 6, 2016 Spayd is correct. But you could easily do this without a trigger: // Create weapon cache at random marker ammocrate1 = createVehicle ["B_supplyCrate_F",getMarkerPos "cache_1",["cache_2","cache_3"], 5, "NONE"]; _handle = [] spawn { waitUntil {!alive ammocrate1; sleep 0.5}; task_1 setTaskState "SUCCEEDED"; player setCurrentTask task_2; task_1 = true; publicVariable "task_1"; hint "Operation Success!"; }; You were missing ']' at the end of your createVehicle line, that's probably why it didn't work, fixed in my example above. OMG facepalm! (it was late last night lol) THAT WORKED, it now spawns the crate, however the triggering of the task completion is not working after I destroy it. Thanks for pointing out that bracket! 1 Share this post Link to post Share on other sites
dystopian 25 Posted June 25, 2016 Anyway you could help me out with getting this cache script working on my insurgency mission? Share this post Link to post Share on other sites
serena 151 Posted June 25, 2016 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"); Try // Function return array with compiled mission scripts. Arguments: [Mission filename template, Mission count] Fn_CompileMissions = { private _tpl = _this select 0; private _cnt = _this select 1; private _res = []; while {count _res < _cnt} do { _res pushBack compile preprocessFileLineNumbers format [_tpl, count _res + 1]}; _res }; fnc_miss_array = ["scripts\mission_%1.sqf", 4] call Fn_CompileMissions; Share this post Link to post Share on other sites
revv 15 Posted July 19, 2016 Hey guys and gals really sorry for the late reply I was offline for a while, I did eventually get this working pretty good and Serena's script looks much cleaner than mine but anyway here is what I ended up with if anyone was still needing help on this:initPlayerLocal.sqf params["_player","_jip","_killer","_victim"]; /* ----- PDW ----- */ call compilefinal preprocessFileLineNumbers "oo_pdw.sqf"; pdw = ["new","profile"] call OO_PDW; /* ----- End PDW ----- */ /* ----- If not first time join, restore gear else set initial loadout ----- */ private "_session"; _session = profileNamespace getVariable "DMP_FirstJoin"; if(!isNil "_session") then { ["clearInventory",_player] call pdw; ["loadPlayer",_player] call pdw; ["loadInventory",[(name _player),_player]] call pdw; [] call Bank_fnc_loadAccount; hint format["Welcome back %1",profileName]; } else { profileNamespace setVariable["DMP_FirstJoin",true]; saveProfileNamespace; null=[] execVM "scripts\kitBag.sqf"; _player setVariable["HG_myCash",35000]; [] call Bank_fnc_saveAccount; hint format["Welcome %1, first time setup has been successfully completed",profileName]; }; /* ---------- */ /* ----- Briefing ----- */ player createDiaryRecord ["Black Talons", ["Ronin", "Welcome to Black Talon's Ronin."]]; player createDiaryRecord ["Credits", ["Made by:", "Dampiirâ„¢<br />Website: http://black-talons.enjin.com/<br />Teamspeak: blacktalons.enjinvoice.com"]]; /* ---------- */ /* ----- JIP Stuff ----- */ if(_jip) then { [] execVM "scripts\JIPhandle.sqf"; }; /* ---------- */ /* ----- Spawn a thread to give cash to player every 5 minutes ----- */ [] spawn { while {true} do { uiSleep 300; [1000,0] call HG_fnc_addOrSubCash; hint format["%1 Paycheck! +$1000",profileName]; }; }; /* ---------- */ /* ----- Spawn a thread to save gear every 60 seconds ----- */ [] spawn { while {true} do { uiSleep 60; ["savePlayer",player] call pdw; ["saveInventory",[(name player),player]] call pdw; }; }; /* ---------- */ if (hasinterface) then { waitUntil {!isnull _player}; _player enableStamina false; player addEventHandler ["Respawn", {player enableStamina false}]; }; I posted this to show how it handles JIP players and I should mention this runs on a dedicated server so I don't know if it would work being hosted locally.So if a player is JIP it runs the:JIPhandle.sqf if(!isNil "missionStatus") then { switch(missionStatus) do { case 11: {execVM "scripts\mission_1.sqf"; hint "M1"}; case 12: {execVM "scripts\mission_2.sqf"; hint "M2"}; case 13: {execVM "scripts\mission_5.sqf"; hint "M3"}; case 14: {execVM "scripts\mission_4.sqf"; hint "M4"}; case 15: {execVM "scripts\mission_5.sqf"; hint "M5"}; default{hint "Mission Load Failed, Relog!"}; } }; Now for the meat and potatoes of the thread, spawning the object in: // Set mission status for JIP missionStatus = 11; // Code that actually sends this out to other players. publicVariable "missionStatus"; publicVariable "ammocrate1"; [WEST, ["tsk1"], ["Find and destroy the stolen weapon cache!", "Search and Destroy", "Destroy"], [objNull], 1, 2, true] call BIS_fnc_taskCreate; sleep 1; if(!isServer) exitWith{}; _mkr_array = ["tsk_1_1","tsk_1_2","tsk_1_3"]; _mkr_position = getmarkerpos (_mkr_array select floor (random (count _mkr_array))); // Create marker at the location _marker = createMarker ["cache_A", _mkr_position]; _marker setMarkerType "hd_destroy"; _marker setMarkerColor "ColorRed"; _marker setMarkerText "Find Cache"; sleep 1; // Create weapon cache near marker _ammocrate1 = createVehicle ["B_supplyCrate_F", getMarkerPos "cache_A", [], 20, "NONE"]; sleep 2; waitUntil {sleep 0.1; !alive _ammocrate1}; ["tsk1", "SUCCEEDED",true] spawn BIS_fnc_taskSetState; deleteMarker "cache_A"; sleep 1; [10000,0] remoteExecCall ["HG_fnc_addOrSubCash",-2,false]; ["tsk1", WEST] spawn BIS_fnc_deleteTask; sleep 3; "scripts\initMissions.sqf" remoteExec ["execVM",2]; You will notice on line 27 is the actual spawning of the object!Again sorry for the really late reply and hope this helps someone! Share this post Link to post Share on other sites
revv 15 Posted July 19, 2016 I might also add that it does not need the public variable "ammocrate1" near the top it was an old piece of code and I just forgot to remove it Share this post Link to post Share on other sites