Jump to content
Sign in to follow this  
SIlenceFiction

Custom Gear In Supply Drop Script - Please Help

Recommended Posts

I am trying to write a supply drop script.

I want the script to create a supply box with predefined gear by me.

I've been looking up and I used the setVehicleInit command but it wouldn't work, the boxes are being created with the default gear.

So I'm reaching out to you as last resort since you helped me in my previous script (which I am very thankful for :cool:)

This is how the script is going for now (I have been testing after every stage, I know its nowhere near complete)

EDIT:

I got the script working thanks to Ranwer, but now I have different issues:

I am writing this script for use in mass multiplayer, I use the command "player" in the script, is it going to work in multiplayer?

I can't get the behavior of the heli (supply1) to work correctly, sometimes its flying away, sometimes it will stay still in the air without moving. I want it to fly from a specific position to the position of the caller, drop the supplies in radius of 10m from the position of the caller and fly back to the original position from where it took off.

LINK FOR THE FULL SCRIPT: http://pastebin.com/1pQ8xJUq

Edited by SilenceFiction

Share this post


Link to post
Share on other sites

You will need to give more detail next time of who "this" is calling, otherwise the actual engine will be confused and will do nothing with it :p (the function "this" can only be used within the editor, not by sqf bla bla bla.

I have re-done your code to this, brand-new, fixed, shiny piece of code:

// Creating the supply crate
_suppcrate = "B_supplyCrate_f" createVehicle [15301.6, 17443.1, 17.5];
sleep 1;
clearWeaponCargoGlobal _suppcrate;
clearItemCargoGlobal _suppcrate;
clearBackpackCargoGlobal _suppcrate;
clearMagazineCargoGlobal _suppcrate;
sleep 1;
_suppcrate allowDamage false;
_suppcrate addItemCargo ["FirstAidKit", 50];
_suppcrate addMagazineCargo ["RH_30Rnd_556x45_Mk262", 50];
_suppcrate addMagazineCargo ["30Rnd_556x45_Stanag_Tracer_Green", 50];
_suppcrate addMagazineCargo ["30Rnd_556x45_Stanag", 50];
_suppcrate addMagazineCargo ["HandGrenade", 50];
_suppcrate addMagazineCargo ["SmokeShellBlue", 50];
_suppcrate addMagazineCargo ["SmokeShellGreen", 50];
_suppcrate addMagazineCargo ["SmokeShell", 50];
_suppcrate addMagazineCargo ["130Rnd_338_Mag", 50];
_suppcrate addMagazineCargo ["150Rnd_93x64_Mag", 50];
_suppcrate addMagazineCargo ["9Rnd_45ACP_Mag", 50];
_suppcrate addMagazineCargo ["11Rnd_45ACP_Mag", 50];
_suppcrate addMagazineCargo ["1Rnd_Smoke_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_SmokeGreen_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_SmokeBlue_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_HE_Grenade_shell", 50];
_suppcrate addMagazineCargo ["Titan_AA", 50];
_suppcrate addMagazineCargo ["Titan_AT", 50];
_suppcrate addMagazineCargo ["DemoCharge_Remote_Mag", 3];
_suppcrate addMagazineCargo ["10Rnd_338_Mag", 50];
_suppcrate addMagazineCargo ["10Rnd_93x64_DMR_05_Mag", 50];
_suppcrate addMagazineCargo ["7Rnd_408_Mag", 50];
_suppcrate addMagazineCargo ["5Rnd_127x108_Mag", 50];
_suppcrate addMagazineCargo ["5Rnd_127x108_APDS_Mag", 50];
_suppcrate addMagazineCargo ["RH_20Rnd_556x45_Mk262", 50];
_suppcrate addMagazineCargo ["RH_20Rnd_762x51_Mk319", 50];
_suppcrate addMagazineCargo ["10Rnd_762x54_Mag", 50];
_suppcrate addMagazineCargo ["20Rnd_762x51_Mag", 50];
processInitCommands;
// Pulling the group name for the unit
_supplygrp = group supply1;
// Making a new waypoint in the position of the player
_wp = _supplygrp addWaypoint [position player, 10];
// Setting the waypoint as MOVE
[_supplygrp, 1] setWaypointType "MOVE";

As seen in the code I have written, you have already given the ammo box a name.. "_suppcrate". So therefore, all those codes "removeAllWeapons this", etc., etc., should be like "removeAllWeapons _suppcrate".

BTW: I added "sleep 1;" only to avoid possible hiccups.

Hopefully this should help you for now and the future :)

Kind Regards,

Rawner135 / Ranwer

Edited by Ranwer
Fixed up quotes

Share this post


Link to post
Share on other sites
You will need to give more detail next time of who "this" is calling, otherwise the actual engine will be confused and will do nothing with it :p (the function "this" can only be used within the editor, not by sqf bla bla bla.

I have re-done your code to this, brand-new, fixed, shiny piece of code:

// Creating the supply crate
_suppcrate = "B_supplyCrate_f" createVehicle [15301.6, 17443.1, 17.5];
sleep 1;
clearWeaponCargoGlobal _suppcrate;
clearItemCargoGlobal _suppcrate;
clearBackpackCargoGlobal _suppcrate;
clearMagazineCargoGlobal _suppcrate;
sleep 1;
_suppcrate allowDamage false;
_suppcrate addItemCargo ["FirstAidKit", 50];
_suppcrate addMagazineCargo ["RH_30Rnd_556x45_Mk262", 50];
_suppcrate addMagazineCargo ["30Rnd_556x45_Stanag_Tracer_Green", 50];
_suppcrate addMagazineCargo ["30Rnd_556x45_Stanag", 50];
_suppcrate addMagazineCargo ["HandGrenade", 50];
_suppcrate addMagazineCargo ["SmokeShellBlue", 50];
_suppcrate addMagazineCargo ["SmokeShellGreen", 50];
_suppcrate addMagazineCargo ["SmokeShell", 50];
_suppcrate addMagazineCargo ["130Rnd_338_Mag", 50];
_suppcrate addMagazineCargo ["150Rnd_93x64_Mag", 50];
_suppcrate addMagazineCargo ["9Rnd_45ACP_Mag", 50];
_suppcrate addMagazineCargo ["11Rnd_45ACP_Mag", 50];
_suppcrate addMagazineCargo ["1Rnd_Smoke_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_SmokeGreen_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_SmokeBlue_Grenade_shell", 50];
_suppcrate addMagazineCargo ["1Rnd_HE_Grenade_shell", 50];
_suppcrate addMagazineCargo ["Titan_AA", 50];
_suppcrate addMagazineCargo ["Titan_AT", 50];
_suppcrate addMagazineCargo ["DemoCharge_Remote_Mag", 3];
_suppcrate addMagazineCargo ["10Rnd_338_Mag", 50];
_suppcrate addMagazineCargo ["10Rnd_93x64_DMR_05_Mag", 50];
_suppcrate addMagazineCargo ["7Rnd_408_Mag", 50];
_suppcrate addMagazineCargo ["5Rnd_127x108_Mag", 50];
_suppcrate addMagazineCargo ["5Rnd_127x108_APDS_Mag", 50];
_suppcrate addMagazineCargo ["RH_20Rnd_556x45_Mk262", 50];
_suppcrate addMagazineCargo ["RH_20Rnd_762x51_Mk319", 50];
_suppcrate addMagazineCargo ["10Rnd_762x54_Mag", 50];
_suppcrate addMagazineCargo ["20Rnd_762x51_Mag", 50];
processInitCommands;
// Pulling the group name for the unit
_supplygrp = group supply1;
// Making a new waypoint in the position of the player
_wp = _supplygrp addWaypoint [position player, 10];
// Setting the waypoint as MOVE
[_supplygrp, 1] setWaypointType "MOVE";

As seen in the code I have written, you have already given the ammo box a name.. "_suppcrate". So therefore, all those codes "removeAllWeapons this", etc., etc., should be like "removeAllWeapons _suppcrate".

BTW: I added "sleep 1;" only to avoid possible hiccups.

Hopefully this should help you for now and the future :)

Kind Regards,

Rawner135 / Ranwer

I see, testing now.

BTW I used "this" because the command setVehicleInit works like you are writing the code straight to the init line of the object (or am I wrong?).

I also thought you can't edit object's cargo after it has been already spawned.

And also, there is no use for the command processInitCommands if you don't use setVehicleInit, or am I again, wrong? (I'm kinda new to scripting so I can only assume)

Edit:

After testing your code did work, I used setVehicleInit because I thought I can't edit an object's contents after it has been spawned already. And yes, it did work without processInitCommands.

Thank you very much for your help :)

Edited by SilenceFiction

Share this post


Link to post
Share on other sites

Your welcome :D

I too started scripting, like you, when I first joined this very forum. But hey, the more you learn, the better and more advanced you are in coding. ;)

This may also help you, I use this site all the time if I have trouble with a particular part of a script I am creating: https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

Kind Regards,

Rawner135 / Ranwer

Share this post


Link to post
Share on other sites
Your welcome :D

I too started scripting, like you, when I first joined this very forum. But hey, the more you learn, the better and more advanced you are in coding. ;)

This may also help you, I use this site all the time if I have trouble with a particular part of a script I am creating: https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

Kind Regards,

Rawner135 / Ranwer

Thanks for the tip I am using it already though :)

One more question, I am writing this script for use in mass multiplayer, but if I put "player" I don't think it will work with more than 1 player in the server, so how do I make the script work for the player who called the script? (the script is activated by radio trigger).

Share this post


Link to post
Share on other sites

custom crate you can spawn in mp by Extended_Init_EventHandlers.

Share this post


Link to post
Share on other sites
custom crate you can spawn in mp by Extended_Init_EventHandlers.

I already got it working thanks to Ranwer.

Though, if you could answer my other question it would be nice (2 replies above).

Also, I don't seem to get the heli behavior to work the way I want.

I want it to go to the player's location, drop the supply crate, and then fly back and land at the exact same location it was before it was called.

This is where I got so far: (this is only the part of the script that is related to the waypoint. Link for the full script: http://pastebin.com/ET5eNZgC)

// Pulling the group name for the unit
_supplygrp = group supply1;
// Making a new waypoint in the position of the player
_wp = _supplygrp addWaypoint [position player, 0];
// Setting the fly height of the supply helicopter
supply1 FlyInHeight 150;
// Setting the waypoint as MOVE
[_supplygrp, 1] setWaypointType "MOVE";

// Ordering the heli to fly back and land at pad_supp
waitUntil {supply1 distance (getPos player) < 300};
deleteWaypoint [_supplygrp, 1];
_supplygrp addWaypoint [position "pad_supp", 0];
[_supplygrp, 1] setWaypointType "MOVE";
supply1 land "pad_supp";

Edited by SilenceFiction

Share this post


Link to post
Share on other sites
I am trying to write a supply drop script.

I want the script to create a supply box with predefined gear by me.

I've been looking up and I used the setVehicleInit command but it wouldn't work, the boxes are being created with the default gear.

So I'm reaching out to you as last resort since you helped me in my previous script (which I am very thankful for :cool:)

This is how the script is going for now (I have been testing after every stage, I know its nowhere near complete)

EDIT:

I got the script working thanks to Ranwer, but now I have different issues:

I am writing this script for use in mass multiplayer, I use the command "player" in the script, is it going to work in multiplayer?

I can't get the behavior of the heli (supply1) to work correctly, sometimes its flying away, sometimes it will stay still in the air without moving. I want it to fly from a specific position to the position of the caller, drop the supplies in radius of 10m from the position of the caller and fly back to the original position from where it took off.

LINK FOR THE FULL SCRIPT: http://pastebin.com/1pQ8xJUq

EDITED, please help.

Share this post


Link to post
Share on other sites

You cant use "player" in MP on scripts executed by server.

Furthermore in MP the command is not initialized in functions called by initline or init eventhandlers.

You need to define player which is calling the supply to some local variable for eg.

waitUntil {_supply1 distance (getPos _caller) < 300};

using select.

Try do not use global variables in scripts because this will collapse whole thing if supply1 gets nil.

Edited by DaVIdoSS

Share this post


Link to post
Share on other sites
You cant use "player" in MP on scripts executed by server.

Furthermore in MP the command is not initialized in functions called by initline or init eventhandlers.

You need to define player which is calling the supply to some local variable for eg.

waitUntil {_supply1 distance (getPos _caller) < 300};

using select.

Try do not use global variables in scripts because this will collapse whole thing if supply1 gets nil.

How can I define the caller?

Share this post


Link to post
Share on other sites

put this in the intifield of all players who are allowed to "order" supplies.

this addEventHandler ["Fired", {_this execVM "supply_drop.sqf";}];

if you would like to allow access to supplies to a certain type of soldier like Teamleader, Medic etc. put this in the init.sqf and change the "soldier_classname1" and "soldier_classname2" to whatever classname you need.

if (hasInterface AND ((typeOf player) == "soldier_classname1" OR (typeOf player) == "soldier_classname2")) then 
{player addEventHandler ["Fired", {_this execVM "supply_drop.sqf";}];
}

put this in the init.sqf

change the "max_" variables to the maximum amount of allowed supply drops.

if (isServer) then {
supply_explosives = 0;
supply_medical = 0;
supply_ammo = 0;
max_supply_explosives = 2;
max_supply_medical = 4;
max_supply_ammo = 4;
publicVariable "supply_explosives";
publicVariable "supply_medical";
publicVariable "supply_ammo";
publicVariable "max_supply_explosives";
publicVariable "max_supply_medical";
publicVariable "max_supply_ammo";
}; 

put this in supply_drop.sqf file. Customize the supplies to whatever you need. right now it´s stuff we need in our missions. Mostly ACE3 and rhs things.

_ammo = _this select 4;
_projectile = _this select 6;

if (_ammo == "SmokeShellYellow" AND supply_explosives < max_supply_explosives) then {
supply_explosives = supply_explosives +1;
publicVariable "supply_explosives";
hint "Rucksackladungen angefordert";
sleep 26;
_para = createVehicle ["B_Parachute_02_F", [0,0,250], [], 0, ""];
_projectile setVectorUp [0,0,1];
_para setPosATL (_projectile modelToWorld[0,0,100]);
_veh = createVehicle ["B_supplyCrate_F", [0,0,80], [], 0, ""];
_veh attachTo [_para,[0,0,0]];
_veh allowDamage false;
ClearWeaponCargoGlobal _veh; 
ClearMagazineCargoGlobal _veh; 
ClearItemCargoGlobal _veh;
ClearBackpackCargoGlobal _veh;
_veh addItemCargoGlobal ["SatchelCharge_Remote_Mag",5];
};

if (_ammo == "SmokeShellRed" AND supply_medical < max_supply_medical) then {
supply_medical = supply_medical +1;
publicVariable "supply_medical";
hint "Medizinischen Nachschub angefordert";
sleep 19;
_para = createVehicle ["B_Parachute_02_F", [0,0,250], [], 0, ""];
_projectile setVectorUp [0,0,1];
_para setPosATL (_projectile modelToWorld[0,0,100]);
_veh = createVehicle ["B_supplyCrate_F", [0,0,80], [], 0, ""];
_veh attachTo [_para,[0,0,0]];
_veh allowDamage false;
ClearWeaponCargoGlobal _veh; 
ClearMagazineCargoGlobal _veh; 
ClearItemCargoGlobal _veh;
ClearBackpackCargoGlobal _veh;
_veh addItemCargoGlobal ["ACE_MapTools",2];
_veh addItemCargoGlobal ["ACE_RangeTable_82mm",2];
_veh addItemCargoGlobal ["ACE_CableTie",10];
_veh addItemCargoGlobal ["ACE_EarPlugs",5];
_veh addItemCargoGlobal ["ACE_fieldDressing",25];
_veh addItemCargoGlobal ["ACE_packingBandage",25];
_veh addItemCargoGlobal ["ACE_elasticBandage",25];
_veh addItemCargoGlobal ["ACE_tourniquet",5];
_veh addItemCargoGlobal ["ACE_morphine",25];
_veh addItemCargoGlobal ["ACE_atropine",20];
_veh addItemCargoGlobal ["ACE_epinephrine",20];
_veh addItemCargoGlobal ["ACE_salineIV_250",15];
_veh addItemCargoGlobal ["ACE_salineIV_500",10];
_veh addItemCargoGlobal ["ACE_quikclot",25];
_veh addItemCargoGlobal ["ACE_bodyBag",5];
};

if (_ammo == "SmokeShellBlue" AND supply_ammo < max_supply_ammo) then {
supply_ammo = supply_ammo +1;
publicVariable "supply_ammo";
hint "Munitionsnachschub angefordert";
sleep 22;
_para = createVehicle ["B_Parachute_02_F", [0,0,250], [], 0, ""];
_projectile setVectorUp [0,0,1];
_para setPosATL (_projectile modelToWorld[0,0,100]);
_veh = createVehicle ["B_supplyCrate_F", [0,0,80], [], 0, ""];
_veh attachTo [_para,[0,0,0]];
_veh allowDamage false;
ClearWeaponCargoGlobal _veh; 
ClearMagazineCargoGlobal _veh; 
ClearItemCargoGlobal _veh;
ClearBackpackCargoGlobal _veh;
_veh addItemCargoGlobal ["30Rnd_556x45_Stanag",24];
_veh addItemCargoGlobal ["30Rnd_556x45_Stanag_Tracer_Red",9];
_veh addItemCargoGlobal ["rhsusf_200Rnd_556x45_soft_pouch",9];
_veh addItemCargoGlobal ["rhsusf_100Rnd_762x51",9];
_veh addItemCargoGlobal ["rhsusf_20Rnd_762x51_m118_special_Mag",3];
_veh addItemCargoGlobal ["20Rnd_762x51_Mag",3];
_veh addItemCargoGlobal ["rhs_mag_m67",4];
_veh addItemCargoGlobal ["1Rnd_HE_Grenade_shell",14];
_veh addItemCargoGlobal ["SmokeShell",4];
}; 

Now get yellow, blue and red smoke grenades and throw the grenades. After 19-25 seconds there should be a parachue with a supply box coming.

Edited by CommanderX

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  

×