Jump to content
Sign in to follow this  
1para{god-father}

Remove Addaction then put it back ?

Recommended Posts

Thanks to kylania, i am can remove all actions on somone, but what i am trying to do is remove the action but for only a limited time say 10 min then put them back, any idea how I can do that ?

It is MP mission btw.

Addaction

this addAction ["Get Intel","intel1.sqf",["marker1", 5000]]

intel1.sqf

//blablabla
_dummyAction = _object addAction["foo", "foo.sqf"];
while {_action >= 0} do {
_object removeAction _action;
_action = _action - 1;
};

//blabla bla

Share this post


Link to post
Share on other sites

Yeah, as CarlGustaffa said, use condition field. That work around there was from before we knew about the condition field and is a bit brutal in how it works. :)

this addAction ["Get Intel","intel1.sqf",["marker1", 5000],1,false,true,"","actionActive"];

So the condition is basically a Boolean type statement.

In that example there you'd set a variable called "actionActive" to true or false depending on your timers. Like if you wanted intel to be found only every 10 minutes something like this:

Init.sqf =

actionActive = true;

Trigger:

Timeout Min/Mid/Max = 600

condition =

!actionActive

onAct:

actionActive = true;

Then in intel1.sqf:

actionActive = false; publicVariable "actionActive";

Here's a demo mission showing this at work.

Share this post


Link to post
Share on other sites

Easy way is to use a condition.

If you don't want to stack too many actions on something, though, you could properly save the action index and then use that index to properly remove it. Removing all actions, especially the way you tried to, is quite messy and not recommended.

ex:

_getIntelActionArr = ["Get Intel","intel1.sqf",["marker1", 5000]];
_index = _object addAction getIntelActionArr;
waitUntil {whatever}; // isntead of waitUntil you could also place the following code in a different script triggered from somewhere, but then you will need to use global variables instead of local so they are accessible by the other script.
_object removeAction _index;
sleep whatever2;
_object addAction _getIntelActionArr;

Either way, you need to make sure you get everything updated on all machines, not just the one that runs the action script. If you use a condition you need to publicVariable the condition variable. If you use an action you need to use some publicVariable on some variable that will trigger a script that removes/re-adds the action as needed.

Edited by galzohar

Share this post


Link to post
Share on other sites
Yeah, as CarlGustaffa said, use condition field. That work around there was from before we knew about the condition field and is a bit brutal in how it works. :)

this addAction ["Get Intel","intel1.sqf",["marker1", 5000],1,false,true,"","actionActive"];

So the condition is basically a Boolean type statement.

In that example there you'd set a variable called "actionActive" to true or false depending on your timers. Like if you wanted intel to be found only every 10 minutes something like this:

Init.sqf =

actionActive = true;

Trigger:

Timeout Min/Mid/Max = 600

condition =

!actionActive

onAct:

actionActive = true;

Then in intel1.sqf:

actionActive = false; publicVariable "actionActive";

Here's a demo mission showing this at work.

Will this way work on Hosted server for MP ?

Share this post


Link to post
Share on other sites

yes it will because publicVariable broadcast the variable to all clients, but unsure if the addaction is JIP friendly when placed on a object in game wich is not player.

my guess is that JIP joining server after the addaction is created will not see it.

you can use MP framework to fix that if needed.

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  

×