Jump to content
Sign in to follow this  
JacobJ

Some problems with removing the addactions for everyone

Recommended Posts

I guess you wanted to removeactionW.sqf:

if (!isServer) exitWith {};

// Remove actions on WEST


	heli1 removeAction heli1load;
	heli2 removeAction heli2load;
	heli3 removeAction heli3load;
	heli4 removeAction heli4load;
	Her1 removeAction her1load;		
	hum1 removeAction hum1load;
	hum2 removeAction hum2load;
	hum3 removeAction hum3load;
	truck1 removeAction truck1load;

Share this post


Link to post
Share on other sites

I'm probably going to confuse you even more, but maybe a bit different approach. You don't need to add and remove the actions all the time, you can just use the condition parameter to hide them.

example mission

init.sqf

SHK_loadAmmobox = {
 private ["_box","_veh"];
 _box = _this select 0;
 _veh = _this select 3;
 _box attachto [_veh,[0,-1.5,-0.5]];
 _box setvariable ["SHK_Loaded",true,true];
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _this select 3;
 detach _box;
 _pos = _veh modelToWorld [0,-5,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _box setvariable ["SHK_Loaded",false,true];
};

mhq1_ammobox setvariable ["SHK_Loaded",false];
mhq1_ammobox addaction ["Load box","action.sqf",[hum1,SHK_loadAmmobox],1,true,true,"","hum1 distance _target < 16 && !isEngineOn hum1 && !(_target getvariable 'SHK_Loaded')"];
hum1 addaction ["Unload box","action.sqf",[mhq1_ammobox,SHK_unloadAmmobox],1,true,true,"","!isEngineOn _target && (mhq1_ammobox getvariable 'SHK_Loaded')"];

action.sqf

private ["_t","_c","_i","_a"];
_t = _this select 0;
_c = _this select 1;
_i = _this select 2;
_a = _this select 3;

if (typename _a == typename []) then {
 [_t,_c,_i,(_a select 0)] spawn (_a select 1);
} else {
 [_t,_c,_i] spawn _a;
};

Edited by Shuko

Share this post


Link to post
Share on other sites

Okay it does confuse me, but maybe I will understand it when working with it.

I have a few questions to this:

1. Will this work on all clients or do I still need the hum1jumbo trigger?

2. Can I just switch the hum1 name with any other name and then change the attachTo position to use it on any other vehicle?

3. If I want to go to the hum1 to load the box, what would I do? Just changing the mhq1_ammobox to hum1 in the second last line doesnt seem to work.

Share this post


Link to post
Share on other sites

1. Check the example mission. No triggers, nothing but placing units and naming them is done in editor.

2./3. It's more of an example of the idea, just for one box and vehicle. Once you understand how it works you can easily modify it. For example, you can add a switch-case to the load action, which uses a correct attach position based on the type of the vehicle.

Share this post


Link to post
Share on other sites

Okay, not totally sure what I am doing, but this seems to work for getting the addaction at the hum1:

SHK_loadAmmobox = {
 private ["_box","_veh"];
 _box = _this select 3;
 _veh = _this select 0;
 _box attachto [_veh,[0,-1.5,-0.5]];
 _veh setvariable ["SHK_Loaded",true,true];
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _this select 3;
 detach _box;
 _pos = _veh modelToWorld [0,-5,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _veh setvariable ["SHK_Loaded",false,true];
};

hum1 setvariable ["SHK_Loaded",false];
hum1 addaction ["Load box","action.sqf",[mhq1_ammobox,SHK_loadAmmobox],1,true,true,"","hum1 distance mhq1_ammobox < 16 && !isEngineOn hum1 && !(hum1 getvariable 'SHK_Loaded')"];
hum1 addaction ["Unload box","action.sqf",[mhq1_ammobox,SHK_unloadAmmobox],1,true,true,"","!isEngineOn _target && (hum1 getvariable 'SHK_Loaded')"];

---------- Post added at 10:26 ---------- Previous post was at 10:20 ----------

Okay now I got two hummers and I can load to them both. BUT if I load the box from hum1 and directly to hum2, then the menu at the hum1 (unload box) doesnt disapear. Do I have to change some variables to make this option on hum1 go away?

Share this post


Link to post
Share on other sites

Updated the example mission as well, but nothing important in it.

SHK_CarriedObject = objNull;

SHK_loadAmmobox = {
 private ["_veh","_pos"];
 _veh = cursorTarget;
 switch true do {
   case (_veh iskindof "HMMWV"):     {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "UH60_Base"): {_pos = [0,-0.2,0.4]};
   default {_pos = []};
 };
 if (count _pos == 0) then {
   private "_name";
   _name = getText (configFile >> "CfgVehicles" >> typeof _veh >> "displayName");
   hint format ["You are not allowed to load the box on to:\n%1",_name];
 } else {
   detach SHK_CarriedObject;
   SHK_CarriedObject attachto [_veh,_pos];
   _veh setvariable ["SHK_LoadedObject",SHK_CarriedObject,true];
   SHK_CarriedObject = objNull;
 };
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [0,-5,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _veh setvariable ["SHK_LoadedObject",objNull,true];
};
SHK_pickupAmmobox = {
 private ["_box"];
 _box = _this select 0;
 _box attachto [player,[0,1,0.5]];
 SHK_CarriedObject = _box;
};
SHK_dropAmmobox = {
 private ["_pos"];
 detach SHK_CarriedObject;
 _pos = player modelToWorld [0,1,0];
 SHK_CarriedObject setPos [_pos select 0, _pos select 1, 0];
 SHK_CarriedObject = objNull;
};

{
 _x addaction ["Pickup box","action.sqf",SHK_pickupAmmobox,1,true,true,"","isnull SHK_CarriedObject"];
} foreach [ammobox1,ammobox2];
{
 _x addaction ["Unload box","action.sqf",SHK_unloadAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull])"];
} foreach [hum1,hum2,heli1];

// Add actions to player, not tested for respawn mission.
if !isdedicated then {
 [] spawn {
   waituntil {!isnull player};
   player addaction ["Drop box","action.sqf",SHK_dropAmmobox,1,true,true,"","!isnull SHK_CarriedObject"];
   player addaction ["Load box","action.sqf",SHK_loadAmmobox,2,true,true,"","!isnull SHK_CarriedObject && cursorTarget distance player < 10 && isnull (cursorTarget getvariable ['SHK_LoadedObject',objNull])"];
 };
};

Edited by Shuko

Share this post


Link to post
Share on other sites

Where is the link to the test mission?

I can see you have included a dropammobox or what is that?

Share this post


Link to post
Share on other sites

Previous page, but here it is: _jacob_ammobox.utes.rar

---------- Post added at 02:41 PM ---------- Previous post was at 02:39 PM ----------

Depending on what kind of people you play with, you might need to add a timer or something to force drop the box so some bright kid doesn't decide to start carrying it around all the time. :)

Share this post


Link to post
Share on other sites

Peeps, dont mean to derail this thread...

Can someone explain to me how to remove the action in a SP mission please?

To explain:

In my mission "Investigation" you have to find answers to questions... At each location I have a notice board with this in its init:

ob1 = q1_board addaction ["Get Question 2", "Quest2.sqf"];

How do remove the "Get Question 2" from the HUD after the script has fired?

Quest2.sqf:

dale_Obj1 setTaskState "Succeeded"; 

taskhint ["Well done, Question 2 now...!", [0, 1, 1, 1], "taskDone"]; 

dale_Obj2=player createSimpleTask ["Question 2"];

dale_Obj2 setSimpleTaskDescription ["The next clue to find is in the the area of:<br/><br/><br/>raze alL (It's an anagram)!!","Question 2","Question 2"];

player setCurrentTask dale_Obj2; 

dale_Obj2 setTaskState "Assigned"; 

taskhint ["Read your notes for clues to question 2.", [1, .7, .4, 1], "taskNew"];

player removeAction ob1;

Share this post


Link to post
Share on other sites

You are adding the action to q1_board not player, thus this:

player removeAction ob1;

doesn't do it's job, but this will:

q1_board removeAction ob1;

Share this post


Link to post
Share on other sites

It doesnt matter, they can carry it all the time if they want. Its a 10on10 I am making, so they are all in the same team.

Edited by JacobJ

Share this post


Link to post
Share on other sites

Okay, this is a really crazy script! Very nice man!

If I want some other vehicles/planes or something, I just put some more cases into the switch command right and edit the position for the specific type of vehicle?

Share this post


Link to post
Share on other sites

wow, that indeed is a very nice script. Simple to use (harder to understand;D). I will test it now with my mate and see if it works as it should in multiplayer.

How would I implement a parashute dropping script? I have the script and it is working, but I am not sure how to put it into the code of yours.

Earlier I put this into the attach_ammoboxheli1.sqf file:

dropbox1 = heli1 addaction ["Drop ammobox", "dropsupplyheli1.sqf"];

Here is the code I have in the dropsupplyheli1.sqf:

if (((getPosATL heli1) select 2) > 100) then {

deTach mhq1_ammobox;
worldpos = heli1 modeltoworld [0,-20,-5];
mhq1_ammobox setPos worldpos;
sleep 0.1;
parachute = "ParachuteWest" createVehicle position mhq1_ammobox;
parachute setPos [(getPos mhq1_ammobox select 0),(getPos mhq1_ammobox select 1),(getpos mhq1_ammobox select 2)];

mhq1_ammobox attachTo [parachute,[0,0,-1.5]];

heli1 removeAction dropbox1;
heli1 removeAction heli1unload;

if (playerside == WEST) then {

hint "Supply dropped!";

};

waituntil {(getPos mhq1_ammobox select 2) < 2};
deTach mhq1_ammobox;
mhq1_ammobox setPos [(getPos mhq1_ammobox select 0),(getPos mhq1_ammobox select 1),0.001];

if (playerside == WEST) then {

hint "Supply landed!";

};


addactionW = execVM "addActionW.sqf";
waitUntil {scriptDone addactionW};

dropmsg = execVM "dropmsg.sqf";
waitUntil {scriptDone dropmsg};

} else {
// If the engine was running, warn the user.
hint "You have to be above 100 meters to drop";
};
//};

---------- Post added at 12:52 ---------- Previous post was at 12:46 ----------

Another problem ive got now, is that I can unload the ammobox while the engine is running and I can unload while in the air with the heli. How would I restrict the options to only work when on the ground and the engine is off?

Share this post


Link to post
Share on other sites
Another problem ive got now, is that I can unload the ammobox while the engine is running and I can unload while in the air with the heli. How would I restrict the options to only work when on the ground and the engine is off?

Just add more conditions to the end of the addaction:

Unload action:

&& !isengineon _target

Load action:

&& !isengineon cursorTarget

As for the para drop, you could add another function and action with suitable conditions to run that code. The principle is there, copy-paste and modify. ;)

Share this post


Link to post
Share on other sites

Okay yes that with the more conditions did work as it should.

I will try to put in my drop scripts conditions and see if I can get it to work.

I can report that the script works on multiplayer just as it should! Again thank you very much for your help so far!

---------- Post added at 14:41 ---------- Previous post was at 13:22 ----------

Another problem I have discovered is, that you can "Pickup box" when it is loaded. I guess some conditions need to be added to the "Pickup box" addaction, but I can't figure out how to code it. If it could check if the box has been loaded, then it wouldnt show the addaction "Pickup box".

---------- Post added at 15:00 ---------- Previous post was at 14:41 ----------

Ive got the parachute to work. Here is how I did:

SHK_CarriedObject = objNull;

SHK_loadAmmobox = {
 private ["_veh","_pos"];
 _veh = cursorTarget;
 switch true do {
   case (_veh iskindof "MH60S"):     {_pos = [0,-0.2,0.4]};
   case (_veh iskindof "MH6J_EP1"): {_pos = [0,0.7,0.25]};
   case (_veh iskindof "Ural_CDF"):     {_pos = [0.5,0.3,0.7]};
   case (_veh iskindof "HMMWV_Armored"): {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "HMMWV_M2"):     {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "ACE_HC130_N"): {_pos = [0,0,-3.5]};
   case (_veh iskindof "BAF_Merlin_HC3_D"): {_pos = [0,0,-0.5]};
   default {_pos = []};
 };
 if (count _pos == 0) then {
   private "_name";
   _name = getText (configFile >> "CfgVehicles" >> typeof _veh >> "displayName");
   hint format ["You are not allowed to load the box on to:\n%1",_name];
 } else {
   detach SHK_CarriedObject;
   SHK_CarriedObject attachto [_veh,_pos];
   _veh setvariable ["SHK_LoadedObject",SHK_CarriedObject,true];
   SHK_CarriedObject = objNull;
 };
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [-5,0,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _veh setvariable ["SHK_LoadedObject",objNull,true];
};

SHK_dropAirAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [0,-20,-5];
 _box setPos _pos;
sleep 0.1;
parachute = "ParachuteWest" createVehicle position _box;
parachute setPos [(getPos _box select 0),(getPos _box select 1),(getpos _box select 2)];

_box attachto [parachute,[0,0,-1.5]];
_veh setvariable ["SHK_LoadedObject",objNull,true];

if (playerside == WEST) then {

hint "Supply dropped!";

};

waituntil {(getPos _box select 2) < 2};
deTach _box;
_box setPos [(getPos _box select 0),(getPos _box select 1),0.001];

if (playerside == WEST) then {

hint "Supply landed!";

};

if (playerside == WEST) then {
Sleep 3;
dropmark = createMarker ["dropmark", _box];  
dropmark setMarkerShape "ICON";  
dropmark setMarkerType "warning"; 
dropmark setMarkerText "Supplies";

hint "Supplies marked on map";

};

};

SHK_pickupAmmobox = {
 private ["_box"];
 _box = _this select 0;
 _box attachto [player,[0,1,1.8]];
 SHK_CarriedObject = _box;
deletemarker "dropmark";
};
SHK_dropAmmobox = {
 private ["_pos"];
 detach SHK_CarriedObject;
 _pos = player modelToWorld [0,1,0];
 SHK_CarriedObject setPos [_pos select 0, _pos select 1, 0];
 SHK_CarriedObject = objNull;
};

{
 _x addaction ["Pickup box","action.sqf",SHK_pickupAmmobox,1,true,true,"","isnull SHK_CarriedObject"];
} foreach [mhq1_ammobox,mhq1_ammobox1];
{
 _x addaction ["Unload box","action.sqf",SHK_unloadAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn _Target) && (((getPosATL _Target) select 2) < 1)"];
} foreach [heli1,heli2,heli3,heli4,hum1,hum2,hum3,humrescue,truck1,truck2,her1];

{
 _x addaction ["Drop box","action.sqf",SHK_dropAirAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (((getPosATL _Target) select 2) > 100)"];
} foreach [heli1,heli2,heli3,heli4,her1];

// Add actions to player, not tested for respawn mission.
if !isdedicated then {
 [] spawn {
   waituntil {!isnull player};
   player addaction ["Put box down","action.sqf",SHK_dropAmmobox,1,true,true,"","!isnull SHK_CarriedObject"];
   player addaction ["Load box","action.sqf",SHK_loadAmmobox,2,true,true,"","!isnull SHK_CarriedObject && cursorTarget distance player < 10 && isnull (cursorTarget getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn cursorTarget) && (((getPosATL cursorTarget) select 2) < 1)"];

 };
};

Share this post


Link to post
Share on other sites

Well, you can add something like this to the load action:

SHK_CarriedObject setvariable ["SHK_IsLoaded",true,true];

Then to the unload:

_box setvariable ["SHK_IsLoaded",false,true];

Then add to the pickup action condition:

!(_target getvariable ['SHK_IsLoaded',false])

Share this post


Link to post
Share on other sites

Is this how you meant it? It doesnt work this way for me. I can pick up the crate but then I get no further options.

//Attach script

SHK_CarriedObject = objNull;

SHK_loadAmmobox = {
 private ["_veh","_pos"];
 _veh = cursorTarget;
 switch true do {
   case (_veh iskindof "MH60S"):     {_pos = [0,-0.2,0.4]};
   case (_veh iskindof "MH6J_EP1"): {_pos = [0,0.7,0.25]};
   case (_veh iskindof "Ural_CDF"):     {_pos = [0.5,0.3,0.7]};
   case (_veh iskindof "HMMWV_Armored"): {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "HMMWV_M2"):     {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "ACE_HC130_N"): {_pos = [0,0,-3.5]};
   case (_veh iskindof "BAF_Merlin_HC3_D"): {_pos = [0,0,-0.5]};
   default {_pos = []};
 };
 if (count _pos == 0) then {
   private "_name";
   _name = getText (configFile >> "CfgVehicles" >> typeof _veh >> "displayName");
   hint format ["You are not allowed to load the box on to:\n%1",_name];
 } else {
   detach SHK_CarriedObject;
   SHK_CarriedObject attachto [_veh,_pos];
   _veh setvariable ["SHK_LoadedObject",SHK_CarriedObject,true];
   SHK_CarriedObject = objNull;
 };
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [-5,0,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _veh setvariable ["SHK_LoadedObject",objNull,true];
};

SHK_dropAirAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [0,-20,-5];
 _box setPos _pos;
sleep 0.1;
parachute = "ParachuteWest" createVehicle position _box;
parachute setPos [(getPos _box select 0),(getPos _box select 1),(getpos _box select 2)];

_box attachto [parachute,[0,0,-1.5]];
_veh setvariable ["SHK_LoadedObject",objNull,true];

if (playerside == WEST) then {

hint "Supply dropped!";

};

waituntil {(getPos _box select 2) < 2};
deTach _box;
_box setPos [(getPos _box select 0),(getPos _box select 1),0.001];

if (playerside == WEST) then {

hint "Supply landed!";

};

if (playerside == WEST) then {
Sleep 3;
dropmark = createMarker ["dropmark", _box];  
dropmark setMarkerShape "ICON";  
dropmark setMarkerType "warning"; 
dropmark setMarkerText "Supplies";

hint "Supplies marked on map";

};

};

SHK_pickupAmmobox = {
 private ["_box"];
 _box = _this select 0;
 _box attachto [player,[0,1,1.8]];
 SHK_CarriedObject = _box;
deletemarker "dropmark";
};
SHK_dropAmmobox = {
 private ["_pos"];
 detach SHK_CarriedObject;
 _pos = player modelToWorld [0,1,0];
 SHK_CarriedObject setPos [_pos select 0, _pos select 1, 0];
 SHK_CarriedObject = objNull;
};

{
 _x addaction ["Pickup box","action.sqf",SHK_pickupAmmobox,1,true,true,"","isnull SHK_CarriedObject && [color="red"]!(_target getvariable ['SHK_IsLoaded',false])[/color]"];
} foreach [mhq1_ammobox,mhq1_ammobox1];
{
 _x addaction ["Unload box","action.sqf",SHK_unloadAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn _Target) && (((getPosATL _Target) select 2) < 1) && [color="red"](_box setvariable ["SHK_IsLoaded",false,true])[/color]"];
} foreach [heli1,heli2,heli3,heli4,hum1,hum2,hum3,humrescue,truck1,truck2,her1];

{
 _x addaction ["Drop box","action.sqf",SHK_dropAirAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (((getPosATL _Target) select 2) > 100)"];
} foreach [heli1,heli2,heli3,heli4,her1];

// Add actions to player, not tested for respawn mission.
if !isdedicated then {
 [] spawn {
   waituntil {!isnull player};
   player addaction ["Put box down","action.sqf",SHK_dropAmmobox,1,true,true,"","!isnull SHK_CarriedObject"];
   player addaction ["Load box","action.sqf",SHK_loadAmmobox,2,true,true,"","!isnull SHK_CarriedObject && cursorTarget distance player < 10 && isnull (cursorTarget getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn cursorTarget) && (((getPosATL cursorTarget) select 2) < 1) && [color="Red"](SHK_CarriedObject setvariable ["SHK_IsLoaded",true,true])"];[/color]

 };
};

---------- Post added at 16:00 ---------- Previous post was at 15:58 ----------

Another minnor problem is that you can take the ammobox from another player. And if you do so, then the other player still has the option to "Put box down" and that puts the ammobox right at the feet of the first guy that had the ammobox picked up.

Share this post


Link to post
Share on other sites

Test this.

I changed the iscarried variable to a more generic ispickupable, which of course has a reverse values. I also added code to drop the box if the carrier dies or gets into a vehicle. Oh and, shouldn't be able to steal boxes anymore.

//Attach script

SHK_CarriedObject = objNull;

SHK_loadAmmobox = {
 private ["_veh","_pos"];
 _veh = cursorTarget;
 switch true do {
   case (_veh iskindof "MH60S"):     {_pos = [0,-0.2,0.4]};
   case (_veh iskindof "MH6J_EP1"): {_pos = [0,0.7,0.25]};
   case (_veh iskindof "Ural_CDF"):     {_pos = [0.5,0.3,0.7]};
   case (_veh iskindof "HMMWV_Armored"): {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "HMMWV_M2"):     {_pos = [0,-1.5,-0.5]};
   case (_veh iskindof "ACE_HC130_N"): {_pos = [0,0,-3.5]};
   case (_veh iskindof "BAF_Merlin_HC3_D"): {_pos = [0,0,-0.5]};
   default {_pos = []};
 };
 if (count _pos == 0) then {
   private "_name";
   _name = getText (configFile >> "CfgVehicles" >> typeof _veh >> "displayName");
   hint format ["You are not allowed to load the box on to:\n%1",_name];
 } else {
   detach SHK_CarriedObject;
   SHK_CarriedObject attachto [_veh,_pos];
   _veh setvariable ["SHK_LoadedObject",SHK_CarriedObject,true];
   SHK_CarriedObject setvariable ["SHK_IsPickupable",false,true];
   SHK_CarriedObject = objNull;
 };
};
SHK_unloadAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [-5,0,0];
 _box setPos [_pos select 0, _pos select 1, 0];
 _veh setvariable ["SHK_LoadedObject",objNull,true];
 _box setvariable ["SHK_IsPickupable",true,true];
};

SHK_dropAirAmmobox = {
 private ["_box","_veh","_pos"];
 _veh = _this select 0;
 _box = _veh getvariable "SHK_LoadedObject";
 detach _box;
 _pos = _veh modelToWorld [0,-20,-5];
 _box setPos _pos;
 sleep 0.1;
 parachute = "ParachuteWest" createVehicle position _box;
 parachute setPos [(getPos _box select 0),(getPos _box select 1),(getpos _box select 2)];

 _box attachto [parachute,[0,0,-1.5]];
 _veh setvariable ["SHK_LoadedObject",objNull,true];

 if (playerside == WEST) then {

 hint "Supply dropped!";

 };

 waituntil {(getPos _box select 2) < 2};
 deTach _box;
 _box setPos [(getPos _box select 0),(getPos _box select 1),0.001];

 if (playerside == WEST) then {

 hint "Supply landed!";

 };
 _box setvariable ["SHK_IsPickupable",true,true];

 if (playerside == WEST) then {
 Sleep 3;
 dropmark = createMarker ["dropmark", _box];  
 dropmark setMarkerShape "ICON";  
 dropmark setMarkerType "warning"; 
 dropmark setMarkerText "Supplies";

 hint "Supplies marked on map";

 };
};

SHK_pickupAmmobox = {
 private ["_box","_player"];
 _box = _this select 0;
 _player = player;
 _box attachto [player,[0,1,1.8]];
 SHK_CarriedObject = _box;
 SHK_CarriedObject setvariable ["SHK_IsPickupable",false,true];
 deletemarker "dropmark";

 // Drop box if player dies or gets into a vehicle. Exit spawn if player drops the box.
 _player spawn {
   waituntil {!alive _this || vehicle player != _this || (SHK_CarriedObject getvariable ["SHK_IsPickupable",false])};
   if !(SHK_CarriedObject getvariable ["SHK_IsPickupable",false]) then {
     [_this] call SHK_dropAmmobox;
   };
 };
};
SHK_dropAmmobox = {
 private ["_pos","_veh"];
 _veh = _this select 0;
 detach SHK_CarriedObject;
 _pos = _veh modelToWorld [0,1,0];
 SHK_CarriedObject setPos [_pos select 0, _pos select 1, 0];
 SHK_CarriedObject setvariable ["SHK_IsPickupable",true,true];
 SHK_CarriedObject = objNull;
};

{
 _x addaction ["Pickup box","action.sqf",SHK_pickupAmmobox,1,true,true,"","isnull SHK_CarriedObject && (_target getvariable ['SHK_IsPickupable',true])"];
} foreach [mhq1_ammobox,mhq1_ammobox1];
{
 _x addaction ["Unload box","action.sqf",SHK_unloadAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn _Target) && (((getPosATL _Target) select 2) < 1)"];
} foreach [heli1,heli2,heli3,heli4,hum1,hum2,hum3,humrescue,truck1,truck2,her1];
{
 _x addaction ["Drop box","action.sqf",SHK_dropAirAmmobox,1,true,true,"","!isnull (_target getvariable ['SHK_LoadedObject',objNull]) && (((getPosATL _Target) select 2) > 100)"];
} foreach [heli1,heli2,heli3,heli4,her1];

// Add actions to player, not tested for respawn mission.
if !isdedicated then {
 [] spawn {
   waituntil {!isnull player};
   player addaction ["Put box down","action.sqf",SHK_dropAmmobox,1,true,true,"","!isnull SHK_CarriedObject"];
   player addaction ["Load box","action.sqf",SHK_loadAmmobox,2,true,true,"","!isnull SHK_CarriedObject && cursorTarget distance player < 10 && isnull (cursorTarget getvariable ['SHK_LoadedObject',objNull]) && (!isEngineOn cursorTarget) && (((getPosATL cursorTarget) select 2) < 1)"];
 };
};

Share this post


Link to post
Share on other sites

Indeed indeed! that did the trick.

Thank you very much for your help. Now I am a big step closer to finishing my first 10on10 mission. I think there are a lot of people out there wanting a script like this.

ps. you don't know how to change the respawntype on the fly with a script? Or am I locked with the respawntype I choose in the description.ext?

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  

×