KokaKolaA3 394 Posted April 17, 2016 Hey, i really don't know where to start. I need a script which basicly doing the following things: If player has Helmet_A then he has the action "Switch Helmet to B" and becomes Helmet_B. (this have to work in MP too) If player has Helmat_B then he has the action "Switch Helmet to A" and becomes Helmet_A. Im a noob in scripting :P Thank You! Share this post Link to post Share on other sites
M1ke_SK 230 Posted April 17, 2016 add file initPlayerLocal.sqf to your mission and put this in that file //initPlayerLocal.sqf //if have helmet A if (headgear player in ["H_HelmetB_desert"]) then { player addAction["Switch Helmet to B", { removeHeadgear player; player addHeadgear "H_HelmetB_camo"; //helmet B player removeAction (_this select 2); }]; }; //if have helmet B if (headgear player in ["H_HelmetB_camo"]) then { player addAction["Switch Helmet to A", { removeHeadgear player; player addHeadgear "H_HelmetB_desert"; //helmet A player removeAction (_this select 2); }]; }; Not tested, just pseudo code to get you on point. 2 Share this post Link to post Share on other sites
KokaKolaA3 394 Posted April 17, 2016 (edited) add file initPlayerLocal.sqf to your mission and put this in that file //initPlayerLocal.sqf //if have helmet A if (headgear player in ["H_HelmetB_desert"]) then { player addAction["Switch Helmet to B", { removeHeadgear player; player addHeadgear "H_HelmetB_camo"; //helmet B player removeAction (_this select 2); }]; }; //if have helmet B if (headgear player in ["H_HelmetB_camo"]) then { player addAction["Switch Helmet to A", { removeHeadgear player; player addHeadgear "H_HelmetB_desert"; //helmet A player removeAction (_this select 2); }]; }; Not tested, just pseudo code to get you on point. You can switch to Helmet A, but not back to helmet B. But it works, thank you alot! Edit: It does work only once, so if you have the Helmet A, then switching to B, and pick up another Helmet A, you can't switch to Helmet B Edited April 17, 2016 by KokaKolaA3 Share this post Link to post Share on other sites
M1ke_SK 230 Posted April 17, 2016 You can modify it like this to select it back. //initPlayerLocal.sqf while { alive player } do { //if have helmet A if (headgear player in ["H_HelmetB_desert"]) then { player addAction["Switch Helmet to B", { removeHeadgear player; player addHeadgear "H_HelmetB_camo"; //helmet B player removeAction (_this select 2); }]; }; //wait until player have helmet B waitUntil { sleep 1; headgear player in ["H_HelmetB_camo"] }; //if have helmet B if (headgear player in ["H_HelmetB_camo"]) then { player addAction["Switch Helmet to A", { removeHeadgear player; player addHeadgear "H_HelmetB_desert"; //helmet A player removeAction (_this select 2); }]; }; //wait until player have helmet A waitUntil { sleep 1; headgear player in ["H_HelmetB_desert"] }; }; 1 Share this post Link to post Share on other sites
KokaKolaA3 394 Posted April 17, 2016 Thank You, i will try it later! 1 Share this post Link to post Share on other sites
barbolani 198 Posted April 18, 2016 put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!! 1 Share this post Link to post Share on other sites
M1ke_SK 230 Posted April 19, 2016 put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!! Good thinking. As I said earlier. This is pseudo code. Not tested or optimized. Share this post Link to post Share on other sites
Greenfist 1863 Posted April 19, 2016 put some sleep 1 in those waitUntils!!! I think there is no need to know what helmet has the player every 0.000000000001 seconds!!!! Sleep would be good in this situation, but waituntil runs the code only once a frame or less. 1 Share this post Link to post Share on other sites