Jump to content
offbtdrummr

How to make a Supply Crate drop using AddAction

Recommended Posts

I want to create a Supply Crate that drops near to your position, by using the addAction class. If it is possible to use a marker to place a relative LZ that would be great. So, you would use the addAction to place the marker, to designate the LZ for the supply drop. My current code should have it dropping on top of your current position, but it is not working. Can I get some help?

 

Here is the code Im using to drop the crate, titled "B_SupplyCrate":

 

_chuteType = "B_Parachute_02_F"; //parachute for blufor, for opfor and greenfor replace the 'B' with 'O' or 'G' respectively

    _crateType =  "B_supplyCrate_F"; //ammocrate class for blufor, feel free to change to whichever box you desire
    _smokeType =  "SmokeShellRed";  //smoke shell color you want to use
    _lightType =  "Chemlight_blue";  //chemlightcolor you want used
    _HQ = [West,"HQ"];  // do not touch this!
       
        if(isServer)then
{
_wpPos=B_Sniper select 0;
 
_chute = createVehicle [_chuteType, [100, 100, 200], [], 0, 'FLY'];
_chute setPos [getPos _wpPos select 0, getPos _wpPos select 1, 100];
_crate = createVehicle [_crateType, position _chute, [], 0, 'NONE'];
_crate attachTo [_chute, [0, 0, -1.3]];
_crate allowdamage false;
_light = createVehicle [_lightType, position _chute, [], 0, 'NONE'];
_light attachTo [_chute, [0, 0, 0]];
 
// clear crate - leaves medkits in place. add clearItemCargoGlobal _crate; to remove medkits
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
clearItemCargoGlobal _crate;
 
// fill crate with our junk
_crate addMagazineCargoGlobal ["7Rnd_408_Mag", 15];
_crate addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 40];
_crate addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag_Tracer", 40];
_crate addMagazineCargoGlobal ["20Rnd_762x51_Mag", 30];
_crate addMagazineCargoGlobal ["200Rnd_65x39_cased_Box_Tracer", 10];
_crate addMagazineCargoGlobal ["30Rnd_65x39_caseless_green", 40];
_crate addMagazineCargoGlobal ["150Rnd_762x51_Box", 10];
_crate addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag", 40];
_crate addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 2];
_crate addMagazineCargoGlobal ["HandGrenade", 6];
_crate addMagazineCargoGlobal ["SmokeShell", 6];
_crate addMagazineCargoGlobal ["SmokeShellGreen", 6];
_crate addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 6];
_crate addMagazineCargoGlobal ["RPG32_HE_F", 2];
_crate addMagazineCargoGlobal ["RPG32_F", 2];
_crate addMagazineCargoGlobal ["NLAW_F", 3];
_crate addMagazineCargoGlobal ["Titan_AT", 2];
_crate addMagazineCargoGlobal ["Titan_AA", 1];
 
// lets people know stuff happened
_HQ sideChat "ammo crate has been dropped.";
waitUntil {position _crate select 2 < 1 || isNull _chute};
detach _crate;
_crate setPos [position _crate select 0, position _crate select 1, 0];
_smoke = _smokeType createVehicle [getPos _crate select 0, getPos _crate select 1,5];
 
// let ground forces know they can resupply
_HQ sideChat "Be advised: ammo crate has touched down!";
sleep 3;
_HQ sideChat "I say again, ammo crate has touched down!";
};

 

To call in the crate, I use another code in a different .sqf, Which has the line of code:

 

B_Sniper addAction ["<t color=#FF0000'>Supply Crate (1 Point)</t>","B_SupplyCrate.sqf];

 

 
quick note: B_Sniper is the name of the unit that the crate should spawn over, and he is the unit who can call in the commands.

Share this post


Link to post
Share on other sites

think you forgot this part of the script :)

/*
      ::: ::: :::             ::: :::             :::
     :+: :+:   :+:           :+:   :+:           :+:
    +:+ +:+     +:+         +:+     +:+         +:+
   +#+ +#+       +#+       +#+       +#+       +#+
  +#+ +#+         +#+     +#+         +#+     +#+
 #+# #+#           #+#   #+#           #+#   #+#
### ###             ### ###             ### ###
 
 Helicopter ammo box drop script (aw_drop.sqf) was written by Jester [AW] of AhoyWorld.co.uk
 You may add or alter this code to your liking as long as you leave the authors name in place.
 set _reloadtime = 30 to however many seconds you want before it is available to use again.
 place "this addAction ["<t color='#0000f6'>Ammo Drop</t>", "aw_drop.sqf",[1],0,false,true,""," driver  _target == _this"];", "aw_drop.sqf"];" in the helicopter/plane init field.
 change the loadouts to the crate to your likings.
*/

In response to your question, change the top line to:

 

_wpPos = _this select 0;

 

 

Be advised it doesn't look like there is anything in the code you provided to prevent it from being spammed/duplicated.

Share this post


Link to post
Share on other sites

Here specially for you;

// ammo drop ondemand via addaction by davidoss for offbtdrummr
/* 

initPlayerLocal.sqf

	if ((typeOf player) == "B_sniper_F") then  {

		dropcrate = player addAction ["<t color='#FF707E'>Call ressuply drop</t>", "B_SupplyCrate.sqf",[],6,false,true,"",""];

	};

----------------------------------------------------------------------------------------------------------------------------------------
onPlayerRespawn.sqf
	
waituntil {alive player};

	if ((typeOf player) == "B_sniper_F") then  {

		dropcrate = player addAction ["<t color='#FF707E'>Call ressuply drop</t>", "B_SupplyCrate.sqf",[],6,false,true,"",""];

	};

*/

private ["_caller", "_trigPos", "_parachute", "_supplyLight", "_supplySmoke"];

_caller = _this select 0;

if (!isnil {fobbox}) then {
	deleteVehicle fobbox;
	fobbox = nil;
	PublicVariable "fobbox";
};

_trigPos = getPos _caller;
_parachute = createVehicle ["B_Parachute_02_F", [(_trigPos select 0), (_trigPos select 1), ((_trigPos select 2)+300)], [], 0, 'FLY'];
fobbox = createVehicle ["B_supplyCrate_F", position _parachute, [], 0, 'NONE'];
PublicVariable "fobbox";
fobbox attachTo [_parachute,[0,0,-1.5]];
playSound3D ["A3\Sounds_F\ambient\battlefield\battlefield_jet1.wss", _caller, false, getPosASL _caller, 1, 1, 0];
sleep 3;
PAPABEAR = [West,"HQ"];
PAPABEAR sideChat "Ammo crate has been dropped.";
_supplyLight = "NVG_TargetW" createVehicle (position fobbox);
_supplyLight attachTo [fobbox, [0,0,0.5]];
clearWeaponCargoGlobal fobbox;
clearMagazineCargoGlobal fobbox;
clearItemCargoGlobal fobbox;
clearBackpackCargoGlobal fobbox;
fobbox addItemCargoGlobal ["acc_flashlight", 10];
fobbox addItemCargoGlobal ["acc_pointer_IR", 10];
fobbox addItemCargoGlobal ["Binocular", 10];
fobbox addItemCargoGlobal ["bipod_01_F_blk" ,10];
fobbox addItemCargoGlobal ["bipod_01_F_mtp" ,10];
fobbox addItemCargoGlobal ["bipod_01_F_snd", 10];
fobbox addItemCargoGlobal ["bipod_02_F_blk", 10];
fobbox addItemCargoGlobal ["bipod_02_F_hex", 10];
fobbox addItemCargoGlobal ["bipod_02_F_tan", 10];
fobbox addItemCargoGlobal ["bipod_03_F_blk", 10];
fobbox addItemCargoGlobal ["bipod_03_F_oli", 10];
fobbox addItemCargoGlobal ["B_UavTerminal", 10];
fobbox addItemCargoGlobal ["FirstAidKit", 10];
fobbox addItemCargoGlobal ["ItemCompass", 10];
fobbox addItemCargoGlobal ["ItemGPS", 10];
fobbox addItemCargoGlobal ["ItemMap", 10];
fobbox addItemCargoGlobal ["ItemRadio", 10];
fobbox addItemCargoGlobal ["ItemWatch", 10];
fobbox addItemCargoGlobal ["Laserdesignator", 10];
fobbox addItemCargoGlobal ["Medikit", 10];
fobbox addItemCargoGlobal ["MineDetector", 10];
fobbox addItemCargoGlobal ["muzzle_snds_338_black", 10];
fobbox addItemCargoGlobal ["muzzle_snds_338_green", 10];
fobbox addItemCargoGlobal ["muzzle_snds_338_sand", 10];
fobbox addItemCargoGlobal ["muzzle_snds_93mmg", 10];
fobbox addItemCargoGlobal ["muzzle_snds_93mmg_tan", 10];
fobbox addItemCargoGlobal ["muzzle_snds_acp", 10];
fobbox addItemCargoGlobal ["muzzle_snds_B", 10];
fobbox addItemCargoGlobal ["muzzle_snds_H", 10];
fobbox addItemCargoGlobal ["muzzle_snds_H_MG", 10];
fobbox addItemCargoGlobal ["muzzle_snds_H_SW", 10];
fobbox addItemCargoGlobal ["muzzle_snds_L", 10];
fobbox addItemCargoGlobal ["muzzle_snds_M", 10];
fobbox addItemCargoGlobal ["NVGoggles", 10];
fobbox addItemCargoGlobal ["optic_Aco", 10];
fobbox addItemCargoGlobal ["optic_ACO_grn", 10];
fobbox addItemCargoGlobal ["optic_ACO_grn_smg", 10];
fobbox addItemCargoGlobal ["optic_Aco_smg", 10];
fobbox addItemCargoGlobal ["optic_AMS", 10];
fobbox addItemCargoGlobal ["optic_AMS_khk", 10];
fobbox addItemCargoGlobal ["optic_AMS_snd", 10];
fobbox addItemCargoGlobal ["optic_Arco", 10];
fobbox addItemCargoGlobal ["optic_DMS", 10];
fobbox addItemCargoGlobal ["optic_Hamr", 10];
fobbox addItemCargoGlobal ["optic_Holosight", 10];
fobbox addItemCargoGlobal ["optic_Holosight_smg", 10];
fobbox addItemCargoGlobal ["optic_KHS_blk", 10];
fobbox addItemCargoGlobal ["optic_KHS_hex", 10];
fobbox addItemCargoGlobal ["optic_KHS_old", 10];
fobbox addItemCargoGlobal ["optic_KHS_tan", 10];
fobbox addItemCargoGlobal ["optic_LRPS", 10];
fobbox addItemCargoGlobal ["optic_MRCO", 10];
fobbox addItemCargoGlobal ["optic_MRD", 10];
fobbox addItemCargoGlobal ["optic_Nightstalker", 10];
fobbox addItemCargoGlobal ["optic_NVS", 10];
fobbox addItemCargoGlobal ["optic_SOS", 10];
fobbox addItemCargoGlobal ["optic_tws", 10];
fobbox addItemCargoGlobal ["optic_tws_mg", 10];
fobbox addItemCargoGlobal ["optic_Yorris", 10];
fobbox addItemCargoGlobal ["Rangefinder", 10];
fobbox addItemCargoGlobal ["ToolKit", 10];
fobbox addMagazineCargoGlobal ["100Rnd_65x39_caseless_mag", 100];
fobbox addMagazineCargoGlobal ["100Rnd_65x39_caseless_mag_Tracer", 100];
fobbox addMagazineCargoGlobal ["10Rnd_127x54_Mag", 100];
fobbox addMagazineCargoGlobal ["10Rnd_338_Mag", 100];
fobbox addMagazineCargoGlobal ["10Rnd_762x51_Mag", 100];
fobbox addMagazineCargoGlobal ["10Rnd_762x54_Mag", 100];
fobbox addMagazineCargoGlobal ["10Rnd_93x64_DMR_05_Mag", 100];
fobbox addMagazineCargoGlobal ["11Rnd_45ACP_Mag", 100];
fobbox addMagazineCargoGlobal ["130Rnd_338_Mag", 100];
fobbox addMagazineCargoGlobal ["150Rnd_762x51_Box", 100];
fobbox addMagazineCargoGlobal ["150Rnd_762x51_Box_Tracer", 100];
fobbox addMagazineCargoGlobal ["150Rnd_762x54_Box", 100];
fobbox addMagazineCargoGlobal ["150Rnd_762x54_Box_Tracer", 100];
fobbox addMagazineCargoGlobal ["150Rnd_93x64_Mag", 100];
fobbox addMagazineCargoGlobal ["16Rnd_9x21_Mag", 100];
fobbox addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokeBlue_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokeGreen_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokeOrange_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokePurple_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokeRed_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_SmokeYellow_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["1Rnd_Smoke_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["200Rnd_65x39_cased_Box", 100];
fobbox addMagazineCargoGlobal ["200Rnd_65x39_cased_Box_Tracer", 100];
fobbox addMagazineCargoGlobal ["20Rnd_556x45_UW_mag", 100];
fobbox addMagazineCargoGlobal ["20Rnd_762x51_Mag", 100];
fobbox addMagazineCargoGlobal ["30Rnd_45ACP_Mag_SMG_01", 100];
fobbox addMagazineCargoGlobal ["30Rnd_45ACP_Mag_SMG_01_Tracer_Green", 100];
fobbox addMagazineCargoGlobal ["30Rnd_45ACP_Mag_SMG_01_Tracer_Red", 100];
fobbox addMagazineCargoGlobal ["30Rnd_45ACP_Mag_SMG_01_Tracer_Yellow", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag_green", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag_red", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag_Tracer_Green", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag_Tracer_Red", 100];
fobbox addMagazineCargoGlobal ["30Rnd_556x45_Stanag_Tracer_Yellow", 100];
fobbox addMagazineCargoGlobal ["30Rnd_65x39_caseless_green", 100];
fobbox addMagazineCargoGlobal ["30Rnd_65x39_caseless_green_mag_Tracer", 100];
fobbox addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag", 100];
fobbox addMagazineCargoGlobal ["30Rnd_65x39_caseless_mag_Tracer", 100];
fobbox addMagazineCargoGlobal ["30Rnd_9x21_Mag", 100];
fobbox addMagazineCargoGlobal ["3Rnd_HE_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokeBlue_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokeGreen_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokeOrange_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokePurple_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokeRed_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_SmokeYellow_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_Smoke_Grenade_shell", 100];
fobbox addMagazineCargoGlobal ["3Rnd_UGL_FlareCIR_F", 100];
fobbox addMagazineCargoGlobal ["3Rnd_UGL_FlareGreen_F", 100];
fobbox addMagazineCargoGlobal ["3Rnd_UGL_FlareRed_F", 100];
fobbox addMagazineCargoGlobal ["3Rnd_UGL_FlareWhite_F", 100];
fobbox addMagazineCargoGlobal ["3Rnd_UGL_FlareYellow_F", 100];
fobbox addMagazineCargoGlobal ["5Rnd_127x108_APDS_Mag", 100];
fobbox addMagazineCargoGlobal ["5Rnd_127x108_Mag", 100];
fobbox addMagazineCargoGlobal ["6Rnd_45ACP_Cylinder", 100];
fobbox addMagazineCargoGlobal ["7Rnd_408_Mag", 100];
fobbox addMagazineCargoGlobal ["9Rnd_45ACP_Mag", 100];
fobbox addMagazineCargoGlobal ["APERSBoundingMine_Range_Mag", 100];
fobbox addMagazineCargoGlobal ["APERSMine_Range_Mag", 100];
fobbox addMagazineCargoGlobal ["APERSTripMine_Wire_Mag", 100];
fobbox addMagazineCargoGlobal ["ATMine_Range_Mag", 100];
fobbox addMagazineCargoGlobal ["B_IR_Grenade", 100];
fobbox addMagazineCargoGlobal ["Chemlight_blue", 100];
fobbox addMagazineCargoGlobal ["Chemlight_green", 100];
fobbox addMagazineCargoGlobal ["Chemlight_red", 100];
fobbox addMagazineCargoGlobal ["Chemlight_yellow", 100];
fobbox addMagazineCargoGlobal ["ClaymoreDirectionalMine_Remote_Mag", 100];
fobbox addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 100];
fobbox addMagazineCargoGlobal ["FlareGreen_F", 100];
fobbox addMagazineCargoGlobal ["FlareRed_F", 100];
fobbox addMagazineCargoGlobal ["FlareWhite_F", 100];
fobbox addMagazineCargoGlobal ["FlareYellow_F", 100];
fobbox addMagazineCargoGlobal ["HandGrenade", 100];
fobbox addMagazineCargoGlobal ["Laserbatteries", 100];
fobbox addMagazineCargoGlobal ["MiniGrenade", 100];
fobbox addMagazineCargoGlobal ["NLAW_F", 100];
fobbox addMagazineCargoGlobal ["RPG32_F", 100];
fobbox addMagazineCargoGlobal ["RPG32_HE_F", 100];
fobbox addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 100];
fobbox addMagazineCargoGlobal ["SLAMDirectionalMine_Wire_Mag", 100];
fobbox addMagazineCargoGlobal ["SmokeShell", 100];
fobbox addMagazineCargoGlobal ["SmokeShellBlue", 100];
fobbox addMagazineCargoGlobal ["SmokeShellGreen", 100];
fobbox addMagazineCargoGlobal ["SmokeShellOrange", 100];
fobbox addMagazineCargoGlobal ["SmokeShellPurple", 100];
fobbox addMagazineCargoGlobal ["SmokeShellRed", 100];
fobbox addMagazineCargoGlobal ["SmokeShellYellow", 100];
fobbox addMagazineCargoGlobal ["Titan_AA", 100];
fobbox addMagazineCargoGlobal ["Titan_AP", 100];
fobbox addMagazineCargoGlobal ["Titan_AT", 100];
fobbox addMagazineCargoGlobal ["UGL_FlareCIR_F", 100];
fobbox addMagazineCargoGlobal ["UGL_FlareGreen_F", 100];
fobbox addMagazineCargoGlobal ["UGL_FlareRed_F", 100];
fobbox addMagazineCargoGlobal ["UGL_FlareWhite_F", 100];
fobbox addMagazineCargoGlobal ["UGL_FlareYellow_F", 100];
["AmmoboxInit",[fobbox,true,{(_target distance _this) < 5}]] spawn BIS_fnc_arsenal;
waitUntil {position fobbox select 2 < 1};
PAPABEAR sideChat "Be advised: ammo crate has touched down!";
_supplySmoke = "SmokeShellGreen" createVehicle (position fobbox);
_supplySmoke attachTo [fobbox, [0,0,0.5]];

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

×