Jump to content
Sign in to follow this  
jedders

removeAction problem

Recommended Posts

I have an issue with removing multiple actions from an object. The actions are first added by the init.sqf for the mission to the object. And then I want it so when you choose the mission it will remove all other actions and then add in an accept and decline action. However, I cannot seem to make it remove the actions when I name them as I am not sure where I'm going wrong.

Here is the script:

_target = _this select 0; // Mission select object with addAction
_caller = _this select 1; // Person using the mission select addAction
_accept = "Accept Find Missing Person mission";
_decline = "Decline Find Missing Person mission";
_accepted = "fmpmission.sqf";
_declined = "fmpdecline.sqf";
_mSelect = MissionSelector;

// Define global varibles for removing actions.
fmp = _target addaction ["Find Missing Person", "fmp.sqf"];
rs = _target addaction ["Rescue Hostage", "rh.sqf"]; 
dr = _target addaction ["Drug Raid", "dr.sqf"];

// Define the global varibles as local variables
_id1 = fmp;
_id2 = rs;
_id3 = dr;

// Remove all missions from mission selector. 
_target removeAction _id1;
_target removeAction _id2;
_target removeAction _id3;

// Chat to tell user to confirm choice of mission.
_mSelect globalChat "Please confirm your choice of mission.";

// Add options to accept or decline mission to run either script.
_missionaccepted = _target addAction [_accept, _accepted];
_missionaccepted = _target addAction [_decline, _declined];

Share this post


Link to post
Share on other sites

Is this really one script? If yes then should add and remove actions right away

Share this post


Link to post
Share on other sites

The object gets the addActions from the init.sqf but I don't know how to remove those actions through this script is my issue.

Share this post


Link to post
Share on other sites

huh? just store their IDs in some variable and that's it

Init.sqf

whateverActionID = player addAction ["Whatever", {hint "Whatever";}];

somewhere else

player removeAction whateverActionID;

Edited by SaMatra

Share this post


Link to post
Share on other sites

Wow that was simple enough haha. I was thinking a bit too hard about this I think and got a bit mixed up. Thanks for helping me see straight!

Share this post


Link to post
Share on other sites
Wow that was simple enough haha. I was thinking a bit too hard about this I think and got a bit mixed up. Thanks for helping me see straight!

Fixed a typo in my example, it should have been removeAction, not removeActionID

Share this post


Link to post
Share on other sites

You're adding and removing actions you declare within the script but never removing the action that called the script in the first place.

To remove the action that was called use:

_target = _this select 0;
_caller = _this select 1;
_action = _this select 2;

_target removeAction _action;

to remove all actions:

_act = _target addAction["foo", "foo.sqf"];
while {_act >= 0} do {
_target removeAction _act;
_act = _act - 1;
};

Share this post


Link to post
Share on other sites

I could really use some help here as well gentlemen as I've been hacking my way thru this :o

So Ive got a Passport that is needed to pickup.

1st I have the map trigger which reads: Player distance Passport < 2; On Activation: nul = execvm "Passact.sqf"

Passact.sqf:

photoact = player addAction ["Take Passport", "passport.sqf"];
sleep 10;
player removeaction photoact;

passport.sqf

deletevehicle passport;
player addmagazine "ARP_Objects_passport_m";
Hint "Passport Taken";
playsound "sound5";
Optional1 = true;
["Taskpassport", "succeeded", "taskDestroy"] call FHQ_TT_markTaskAndNext;
player addrating 1000;
Hint "(+1000 Rating)"; 

So as you can see, this is an awful hack in which I use a 10 second timer to allow the action but after that poof, it's gone...

Is there a command ie PlayerHas, which I could than state to RemoveAction once it's in his possession?

Edited by froggyluv

Share this post


Link to post
Share on other sites

Put the action on the passport from the start.

this addAction ["Take Passport","passport.sqf",[],1,false,true,"","(_this distance _target) < 2"];

Then use your code as passport.sqf. The action won't show up till someone is within 2 meters of the passport. Don't have to worry about removing the action since you delete the item right away.

You can use this to detect if he has it:

"ARP_Objects_passport_m" in items player

Share this post


Link to post
Share on other sites

In Items player..!!!! I've been looking for something like that for a long time!

I also decided to use CursorTarget instead so player actually has to find though for some reason I have to zoom on it for it to register.

Many thanks kylania -you've always been super helpful :)

Share this post


Link to post
Share on other sites

I always like doing things like attaching an "explosive" (not in A3 yet :( ) under a car so you had to lay down and look under the cars before defusing it. Sometimes even in the backseat of a car. Fun times!

Share this post


Link to post
Share on other sites

You can use this to detect if he has it:

"ARP_Objects_passport_m" in items player

Hmmm, that's not firing for me :confused:

Share this post


Link to post
Share on other sites

That item isn't a default item so won't work unless you have whatever mod he's using.

Share this post


Link to post
Share on other sites

Also tried with NVG's

Condition: "nvgoggles" in items player

Activation: Hint "You've got NVG's"

Still no luck. I have a workaround for why I needed it but could definitely use a command like that for the future.

Share this post


Link to post
Share on other sites

Well, for NVGoggles specifically you need to use:

"NVGoggles" in assignedItems player

Can't really find any "non weapony" items to test with in beta though. Everything is a weapon, mag or assigned item.

Share this post


Link to post
Share on other sites

I also decided to use CursorTarget instead so player actually has to find though for some reason I have to zoom on it for it to register.

try to "reveal" it to your player when he gets in the area, like 20 meter radius, so you won't need to zoom it first. it's probably the "knowsabout" that is too low. just a guess though.

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  

×