Jump to content
  • 0

Custom loot box trigger


FredEvoX

Question

What can I do with my custom box sqf so i can add a trigger where if the player gets close to the box, it will activate it. EX: Walk up to crate, starts timer, profit. Here is my sqf.

 

//* Breaks Server If To Much Is Added To The Crate   *\\
//*    Anything More Can Cause Server To Crash       *\\
//* Max Weapons = 100 * Max Mags = 520 * Max Bag = 1 *\\
//****************************************************\\
if (isServer) then {
 
//FPA
_vehicle_103768 = objNull;
if (true) then
{
  _this = createVehicle ["USSpecialWeaponsBox", [7532.94,14141.7,0.460999], [], 0, "CAN_COLLIDE"];
  _vehicle_103768 = _this;
  _this setDir -182.5;
  _vehicle_103768 setVariable ["ObjectID","1",true];
  _vehicle_103768 setVariable ["permaLoot",true];
  _vehicle_103768 addEventHandler ["HandleDamage", {false}];
  
  //Clear Cargo
  clearweaponcargoGlobal _this;
  clearmagazinecargoGlobal _this;
  
  uiSleep 1800;
  
  //Add Cargo
  _this addWeaponCargoGlobal ["M110_TWS_EP1",2];
  _this addWeaponCargoGlobal ["BAF_AS50_scoped_DZ",2];
  _this addWeaponCargoGlobal ["M32_EP1",1];
 
  _this addmagazineCargoGlobal ["10Rnd_127x99_m107",10];
  _this addmagazineCargoGlobal ["5Rnd_127x99_as50",10]; 
  _this addmagazineCargoGlobal ["ItemRuby",8]; 
  _this addmagazineCargoGlobal ["ItemSapphire",8];
  _this addmagazineCargoGlobal ["ItemPainkiller",5];  
  _this addmagazineCargoGlobal ["ItemEmerald",10];
  _this addmagazineCargoGlobal ["ItemBloodbag",5];
  _this addmagazineCargoGlobal ["ItemMorphine",5];
  _this addmagazineCargoGlobal ["m240_nest_kit",1];
  _this addmagazineCargoGlobal ["6Rnd_HE_M203",3];
 
  _this addbackpackCargoGlobal ["DZ_largeGunBag_EP1",1];
  _this setPos [7532.94,14141.7,0.460999];
  
  _this titleText ["Fred's Doubloons Have Spawned!", "PLAIN"];
};
 
};

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

So I implemented a sensor, but it activates for anyone who wants to go near the crate (once per person though), so in theory the box would spawn repeatedly for every player that goes near the box, also the file path doesnt work for some reason.

	class Item4
		{
            position[]={7527.9478,0.15632951,14141.764};
            a=10;
			b=10;
			activationBy="WEST";
			repeating=0;
			interruptable=1;
			age="UNKNOWN";
			name="crate";
			expCond="(player distance crate) < 10;";
			expActiv="TitleText[""The Box Will Spawn In 30 Minutes"",""PLAIN DOWN""]; ExecVM ""\z\addons\dayz_server\crates\crates.sqf"";";
			class Effects{};
        };
Link to comment
Share on other sites

  • 0

If you only want the loot to spawn when players enter a radius around the loot crate you can add this statement after you spawn the box, but before you add items to the container.

 

waitUntil{{isPlayer _x && _x distance _vehicle_103768 < 30  } count playableunits > 0};

 

Anything after this statement will only be executed when a player is within 30 meters of the object and it only executes once.  Adjust the radius as needed.

 

You should also remove the sleep statement as it is no longer required.

 

I use this technique in all my missions to broadcast a global message that the mission is complete and to remove the markers on the map.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...