Jump to content
Sign in to follow this  
Deg

removeAction trouble

Recommended Posts

Hi all, so firstly i have a 3 heli's in my mission on the Fallujah map 2 for transport and 1 for support that can move anywhere on the map with radio calls, in the support chopper(named heli) init i put a

heli addAction ["Unload Ammo",Unload.sqf]

now wherever the heli lands i am able to spawn an ammo crate named ammobox beside the heli to kind of simulate Unloading the ammo, i also put an

heli addAction ["Load",Load.sqf]

that will delete the ammobox when im done to well.. simulate loading the ammo back. Now what im trying to accomplish is when the ammobox spawns i want to remove the action Unload so i tried

if (alive ammobox) then {heli removeAction Unload Ammo}

and of course it doesnt work , i know this is obviously wrong but am i on the right track? Thanks.

Deg

Edited by Deg
forgot Ammo in last code bit

Share this post


Link to post
Share on other sites

It needs a name/handle

act1 = heli addAction ["Unload Ammo","Unload.sqf"]

to remove it

if (alive ammobox) then {heli removeAction act1}

Share this post


Link to post
Share on other sites

Thanks F2k Sel i tried what you said, but i still get the Unload action on the heli after the ammobox spawns

Share this post


Link to post
Share on other sites

Then I think the problem is with the way your spawning the box, maybe the name is wrong. You could just add heli removeAction act1 to the end of the Unload script.

Share this post


Link to post
Share on other sites

Thanks that worked this is what i have now the heli's init

 if (alive ammobox) then { heli removeAction act1};  if !(alive ammobox) then { heli removeAction act2};

then my Unload.sqf

 ammobox = "USSpecialWeapons_EP1" createVehicle(position heli); ammobox setPos [(getPos heli select 0)+3,(getPos heli select 1)+1,(getPos heli select 2)]; heli removeAction act1 

and Load.sqf

deleteVehicle(ammobox);

and my base.sqf where i call the addActions from

if !(alive heliPilot) exitWith
{
	onMapSingleClick "";
	1 setRadioMsg "null";
	2 setRadioMsg "null";
	"blackhawk" setMarkerType "empty";
};


onMapSingleClick "";
2 setRadioMsg "null";
"blackhawk" setMarkerType "empty";
heliPilot sideChat "Viper is Returning To Base";

heliPilot doMove (getPos hBase);

if !(alive heliPilot) exitWith
{
	onMapSingleClick "";
	1 setRadioMsg "null";
	2 setRadioMsg "null";
	"blackhawk" setMarkerType "empty";
};
waitUntil {(unitReady heliPilot) && (getPos heli select 2) > 10};

heliPilot sideChat "Viper is Landing at Base";
sleep .5;
heli land "land";

waitUntil {(unitReady heliPilot) && (getPos heli select 2) < 1.5};
heliPilot sideChat "Viper is refueling at Base";
1 setRadioMsg "null";

act1 = heli addaction ["Unload Ammo","Unload.sqf",[], 6, true, true, "", "(_this distance (_target))<6"]; act2 = heli addaction ["Load Ammo","Load.sqf",[], 6, true, true, "", "(_this distance (_target))<6"]; 
heliPilot setdammage 0;
heliGunner setdammage 0;
heli setdammage 0;
sleep .5;


heliPilot sideChat "Viper ready at Base";

if !(alive heliPilot) exitWith
{
	onMapSingleClick "";
	1 setRadioMsg "null";
	2 setRadioMsg "null";
	"blackhawk" setMarkerType "empty";
};

if (alive heliPilot) exitWith
{
	1 setRadioMsg "Viper Move";

};

I use a trigger on mission start with the addActions script and set to once and delete on activation so that i dont have to call the chopper first and get him to land at the base to call that addAction script from the base.sqf, now im just trying to get rid of the Load action if the ammobox isnt spawned.

Share this post


Link to post
Share on other sites

Ok so now that when the ammobox spawns it will remove the Unload action for the heli and i also removed this from my base.sqf

act2 = heli addaction ["Load Ammo","Load.sqf",[], 6, true, true, "", "(_this distance (_target))<6"]; 

and i removed what was in my heli's init and put in

if (alive ammobox) then {heli addAction ["Load Ammo","Load.sqf"]};

but when the ammobox spawns i cant get the Load Ammo action on my heli, what am i doing wrong?

I could put

heli addAction ["Load Ammo","Load.sqf"];

in my heli's init, but i dont want the Load Ammo action there until after the ammobox spawns.

Share this post


Link to post
Share on other sites

how about just using conditions in the actions, so they are always there but will only be visible under certain conditions:

_act1 = heli addaction ["Load Ammo","Load.sqf",[], 6, true, true, "", "(getDammage _target) < 1 AND (_target getVariable ['ammoLoaded', 'notLoaded']) == 'notLoaded'"];

and in the load ammo script you use:

heli setVariable ["ammoLoaded", [b]"loaded"[/b], true];

and for the unload just reverse the condition used:

_act2 = heli addaction ["Unload Ammo","Unload.sqf",[], 6, true, true, "", "(getDammage _target) < 1 AND (_target getVariable ['ammoLoaded', 'loaded']) == 'loaded'"];

and in the unload script use:

heli setVariable ["ammoLoaded", [b]"notLoaded"[/b], true];

now the actions for load ammo is only visible when 2 conditions are true:

1: that damage of heli is below 1. (not destroyed)

2: that you get the variable "ammoLoaded" from the vehicle and it is set to "notLoaded"

also the unload ammo action is only visible when 2 conditions are met:

1: that damage of heli is below 1. (not destroyed)

2: that you get the variable "ammoLoaded" from the vehicle and it is set to "loaded"

note, that im not sure, but i think there was a issue with using ' instead of "" in conditions so just replace every ' with 2 qoutes "" if issues.

Edited by Demonized

Share this post


Link to post
Share on other sites

Sorry for the late reply, but thanks Demonized that worked but i had to remove '_' before the acts so the unload and load cant get spammed when the heli lands, i just needed it to work once when the heli lands so that you only get those options after the heli returns to base. Thanks again.

Deg

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  

×