Emryse 2 Posted July 27, 2014 Hey there all, I've been doing a few hours worth of searching for some very clear, specific, and example-provisioned case to answer this question. Context: I'm making a multiplayer mission where the following code is placed into any playable unit's initialization field: this addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; null = [this, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; this addweapon ""Laserdesignator""; Works great, until the player dies. Then - when they respawn, there's no code in the init field for them. Could someone please assist in explaining how to properly event handle this situation, and show what the proper code structure / syntax for this would be? I would surely appreciate it! Thanks, Emryse P.S.: Even better - is there a way I can create code that drives every playable unit to have my init field code populated from get-go, so that I don't have to place it in the init field of a specific playable unit in the first place? Share this post Link to post Share on other sites
bangabob 45 Posted July 27, 2014 1st Question. Use a killed or Respawn event handler to add the script when the unit dies 2nd Question. Put your code into a script. Script.sqf this addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; null = [this, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; this addweapon ""Laserdesignator""; In your Init.sqf use { null=[]execVM "script.sqf"; }foreach playableUnits Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted July 27, 2014 in your mission directory, create the sqf file 'onPlayerRespawn.sqf'' Within that file, player addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; null = [this, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; player addweapon ""Laserdesignator""; That code will then be applied to a player on respawn. Share this post Link to post Share on other sites
Emryse 2 Posted July 28, 2014 Guys, thanks so much for the help - I wish I could say I've had success. Unfortunately, I've not been able to make either of these work. 1. I followed your instructions verbatim. Using the combo of a script.sqf with the exact copy/paste code, plus adding the additional code to the init.sqf did not auto-populate that code into each playable unit. 2.) I created a file called: "respawn.sqf". In it, I place the following code: player addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; null = [player, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; player addweapon ""Laserdesignator""; In the init.sqf, I added the following code: player addEventHandler ["respawn", {null=[] execVM "respawn.sqf"}] Here's the funny thing: with this - when I exported / tried in multiplayer, upon respawn, these options did not appear as menu items in my new guy, but when I walked over to my old dead guy, the options then appeared as if they were attached to him. Wierd. I guess I shouldn't be trusted with this stuff... Maybe just to be clear about what I'm trying to do: I have a number of scripts that I want to have available for every playable unit to use at all times, whether initial spawn or respawn throughout game. These are: - a laser missile guided strike : that's this code: player addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; - Close Air Support : that's this code: null = [player, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; - Naval Gun Ship support - SATCOM support (a script that lets you look top-down like a satellite view - the BIS Virtual Arsenal with complete and total access to everything Here's my init.sqf file as it currently sits: /// VIRTUAL ARSENAL TIE TO SUPPLY CRATE TYPE START /// { _x allowDamage false; _x addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; } forEach nearestObjects [getpos player,["B_supplyCrate_F"],15000]; /// VIRTUAL ARSENAL END /// /// SATCOM START /// _variable = [] execVM "pxs_satcom_a3\init_satellite.sqf"; sleep 0.2; //action [player, true] call PXS_switcher; /// SATCOM END /// /// LAUNCHMISSILE LIMIT NUMBER OF USES START /// misActive = false; ASnumMIS = 6; //number of times missile can be called misSupLimit = ""; ASMIS = 0; exit1 = false; /// LAUNCHMISSILE END /// /// CAS START /// [] execVM "JWC_CASFS\initCAS.sqf"; /// CAS END /// /// NGS STARTS HERE /// [] execVM "NGS\init.sqf"; [] call compile preprocessFile "NGS\func.sqf"; if (isNil "theVariable") then {theVariable = false; publicvariable "theVariable";}; /// NGS ENDS HERE /// /// ADD PLAYER INIT VALUES AFTER RESPAWN /// player addEventHandler ["respawn", {null=[] execVM "respawn.sqf"}] /// END/// null=[]execVM "script.sqf"; }foreach playableUnits Here's my description.ext: //RESPAWN respawn = "BASE"; respawndelay = "3"; //SATCOM #include "pxs_satcom_a3\init_interface.hpp" //LAUNCHMISSILE //JWC_CAS #include "JWC_CASFS\casDefine.hpp" #include "JWC_CASFS\casMenu.hpp" class CfgSounds { class cantDo { name="cantDo"; sound[]={"JWC_CASFS\cantDo.ogg",1.0,1.0}; titles[]={}; }; }; //NGS #include "NGS\defines.hpp" #include "NGS\dialogs.hpp" ---------- Post added at 14:48 ---------- Previous post was at 14:45 ---------- I should add that, with the above files as I currently have them set up, and if I place this code this addAction[""<t color='#FC0000'>Request Greyhound Strike Package</t>"",""launchMissile.sqf"",[this, missilestart,""M_Scalpel_AT"",200]]; null = [this, 3000, true, 6] execVM ""JWC_CASFS\addAction.sqf""; this addweapon ""Laserdesignator""; in the init value of the player unit, it all works, the first time I load up the map. But on respawn, none of it works anymore, other than the BIS Virtual Arsenal. ---------- Post added at 14:49 ---------- Previous post was at 14:48 ---------- Another note; and maybe this is the struggle for all editors - I'm trying to figure out the right order of script and place in these files, so that one script doesn't break or write over another. That gets really hard - seems unpredictable what's going to happen sometimes. Share this post Link to post Share on other sites