Jump to content
patpowercat

Hostage rescue script

Recommended Posts

I am trying to make a simple script for an addaction. Addaction on unit, rescue them and they join your group, then delete the addaction so they don't always have a "Rescue" option over them.

 

I currently have this in the hostage's (h1) init field:

 this addaction ["Rescue", {[h1] joinsilent (_this select 1); h1 setcaptive false; h1 enableAI "Move";}]; 

This works great. However, if I put the code 

{[h1] joinsilent (_this select 1); h1 setcaptive false; h1 enableAI "Move";}]; 

into a script and call it rescue.sqf and then put this in the units init field

 this addaction ["Rescue","rescue.sqf"]; 

Nothing at all happens. Any ideas?

 

Additionally I would like to add to the script a removeaction, how would I go about doing this? Sorry, I'm coming back from about a five month break from Arma and I'm pretty rusty on things. 

Share this post


Link to post
Share on other sites
this addaction ["Rescue","rescue.sqf"];

 

rescue.sqf


 

private _hostage = _this select 0;
private _rescue = _this select 1;
private _actionid = _this select 2;

[_hostage] joinSilent _rescue;
_hostage setCaptive false;
_hostage enableAI "MOVE";
_hostage removeAction _actionid;

 

Share this post


Link to post
Share on other sites

Thanks. Seems like what I had was almost the same, except naming the unit. This is more versatile though, thanks a lot again!

Share this post


Link to post
Share on other sites

Late response but might be useful for someone else.

You either didn't use this in a multiplayer scenario or somehow it worked, but from my tests, in a multiplayer situation the "removeAction" command needs to be broadcasted to the other players, otherwise it will only remove for the player that activated the action. For example:

[_hostage, _actionid] remoteExec ["removeAction"];

 

Share this post


Link to post
Share on other sites

in MP

You can put into init.sqf.

 

hostageaddaction = namevariableuniteditor addaction ["Rescue","rescue.sqf"];

publicvariable "hostageaddaction";

 

all clients can read the addaction on the hostage

 

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

×