Jump to content
Sign in to follow this  
TAW_Yonose

INDEP flashlight

Recommended Posts

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

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

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

If you're executing this code in your mission editor, leave out the very first line. Works for me (at night of course).

Edited by waltenberg

Share this post


Link to post
Share on other sites
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
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

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

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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×