TAW_Yonose 11 Posted October 25, 2014 How do i make this script to work with INDEP units? if (!isServer && hasInterface ) exitWith {}; // filter for only East units, // {if (side _x = east) then // You could filter using alternative methods, eg IsKindof "Man" etc. In this instance filter for all units not on players side. {if (side _x != playerSide) then // Remove NV GOGGLES based on Side {if (_x IsKindof "Man") then { if ("NVGoggles_OPFOR" in assignedItems _x) then {_x unlinkitem "NVGoggles_OPFOR";_x removeitem "NVGoggles_OPFOR";}; if ("NVGoggles_INDEP" in assignedItems _x) then {_x unlinkitem "NVGoggles_INDEP";_x removeitem "NVGoggles_INDEP";}; if ("NVGoggles" in assignedItems _x) then {_x unlinkitem "NVGoggles";_x removeitem "NVGoggles";}; }; //Now add Flashlight only if it"s night.. _GiveFlashlight = sunOrMoon; if (_GiveFlashlight < 1) then { _x unassignItem "acc_pointer_IR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x assignItem "acc_flashlight"; _x enableGunLights "ForceOn"; }; }; } forEach allUnits; I already tried to change this to guerrila // {if (side _x = east) then It works with Opfor.. but i dont know what to change expect what i already tried Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted October 25, 2014 if (side _x isEqualTo independent) then {...} Just in case: For comparision, use "isEqualTo" or ==, not = Btw, have a look here: https://community.bistudio.com/wiki/Side Share this post Link to post Share on other sites
TAW_Yonose 11 Posted October 25, 2014 am i supposed to add? I have no knowledge about scripts, i dident make this of course :P then {...} ---------- Post added at 11:27 ---------- Previous post was at 11:23 ---------- Blufor are user side and INDEP are the enemy side by the way, if that will make any difference. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted October 25, 2014 Alright, I was just gonna ask, because you've got a pretty strange way of indenting your code. So, if I understand you (and the code) correctly, you simply change this line: {if (side _x != playerSide) then to this: {if (side _x isEqualTo independent) then Blufor are user side and INDEP are the enemy side by the way, if that will make any difference. Doesn't make any difference in this case. Share this post Link to post Share on other sites
TAW_Yonose 11 Posted October 25, 2014 Still nothing :/ Beerkan sent me the code.. here is the link of the thread, look 5th post http://forums.bistudio.com/showthread.php?184207-Adding-flashlight-to-enemy Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted October 25, 2014 (edited) If you're executing this code in your mission editor, leave out the very first line. Works for me (at night of course). Edited October 25, 2014 by waltenberg Share this post Link to post Share on other sites
Beerkan 71 Posted October 25, 2014 Alright, I was just gonna ask, because you've got a pretty strange way of indenting your code.....I indent my code so that each opening "{" is parallel to it's closing "}" and everything in between is related to the routine. This has been tested and working, and is meant to be run from the init.sqf. Remember it checks if the Sun is not present and based on that, removes NVGoggles. For independant use:- if (!isServer && hasInterface ) exitWith {}; // filter for only East units, // {if (side _x = east) then // {if (side _x == independent) then // {if (side _x != playerSide) then // You could filter using alternative methods, eg IsKindof "Man" etc. In this instance filter for all units not on players side. {if (side _x == independent) then // Remove NV GOGGLES based on Side {if (_x IsKindof "Man") then { if ("NVGoggles_OPFOR" in assignedItems _x) then {_x unlinkitem "NVGoggles_OPFOR";_x removeitem "NVGoggles_OPFOR";}; if ("NVGoggles_INDEP" in assignedItems _x) then {_x unlinkitem "NVGoggles_INDEP";_x removeitem "NVGoggles_INDEP";}; if ("NVGoggles" in assignedItems _x) then {_x unlinkitem "NVGoggles";_x removeitem "NVGoggles";}; }; //Now add Flashlight only if it"s night.. _GiveFlashlight = sunOrMoon; if (_GiveFlashlight < 1) then { _x unassignItem "acc_pointer_IR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x assignItem "acc_flashlight"; _x enableGunLights "ForceOn"; _x setskill ["spotDistance",(0 + random 0.2)];// Reduce for night time _x setskill ["spotTime",(0 + random 0.2)]; }; }; } forEach allUnits; Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted October 25, 2014 We can talk about indention another day. I know your code is working, I've tested it myself. Share this post Link to post Share on other sites
Beerkan 71 Posted October 26, 2014 We can talk about indention another day. I know your code is working, I've tested it myself.No need to apologise friend. Beerkan's code is ALWAYS tested. Share this post Link to post Share on other sites
TAW_Yonose 11 Posted October 29, 2014 Ehhmm alright.. Still not working for me here.. what am i doing wrong. Here is the script as you posted. (i removed the distance spotting since i dont want it) if (!isServer && hasInterface ) exitWith {}; // filter for only East units, // {if (side _x = east) then // {if (side _x == independent) then // {if (side _x != playerSide) then // You could filter using alternative methods, eg IsKindof "Man" etc. In this instance filter for all units not on players side. {if (side _x == independent) then // Remove NV GOGGLES based on Side {if (_x IsKindof "Man") then { if ("NVGoggles_OPFOR" in assignedItems _x) then {_x unlinkitem "NVGoggles_OPFOR";_x removeitem "NVGoggles_OPFOR";}; if ("NVGoggles_INDEP" in assignedItems _x) then {_x unlinkitem "NVGoggles_INDEP";_x removeitem "NVGoggles_INDEP";}; if ("NVGoggles" in assignedItems _x) then {_x unlinkitem "NVGoggles";_x removeitem "NVGoggles";}; }; //Now add Flashlight only if it"s night.. _GiveFlashlight = sunOrMoon; if (_GiveFlashlight < 1) then { _x unassignItem "acc_pointer_IR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x assignItem "acc_flashlight"; _x enableGunLights "ForceOn"; }; }; } forEach allUnits; And in my Init i got this, i have all the /// to make it easy to find what i need. And yes the path is "Scripts\addflash.sqf" i double checked that. //////////////////////////////////////////// /////////////// Add Scripts //////////////// //////////////////////////////////////////// [] execVM "Scripts\addflash.sqf"; //////////////////////////////////////////// The INDEP unit im testing on have a F2000 (camo) and still a IR Laser Point Share this post Link to post Share on other sites
Wolfenswan 1 Posted October 29, 2014 If you are testing it locally then the script will exit because isServer is true and you do have an interface. Try commenting the very first line for testing purposes. Beekan's code looks solid otherwise but if you're completely out of luck try mine. However, it's more general, as it affects all units in the mission minus player units. { private ["_unit"]; _unit = _x; // Only run where the unit is local, it isn't a player and doesn't have a flashlight if (local _unit && !isplayer _unit && !("acc_flashlight" in primaryWeaponItems _unit)) then { // Remove laser if equipped if ("acc_pointer_IR" in primaryWeaponItems _unit) then {_x removePrimaryWeaponItem "acc_pointer_IR"}; _unit addPrimaryWeaponItem "acc_flashlight"; // Add flashlight // Removes NVGs from unit { if (_x in assigneditems _unit) exitWith {_unit unlinkItem _x}; } forEach ["NVGoggles_OPFOR","NVGoggles_INDEP","NVGoggles"]; }; // Forces flashlights on // _unit enablegunlights "forceOn"; } forEach allUnits; Share this post Link to post Share on other sites
Von Quest 1163 Posted October 30, 2014 Oh, neat lil script. Gotta try that out when I get home. Was on my script 'bucket list' to do. Cool. :cool: Share this post Link to post Share on other sites
TAW_Yonose 11 Posted November 1, 2014 Forget it, for some reason it works now without doing anything.. i just restarted the game.. hmm Share this post Link to post Share on other sites