Jump to content
Sign in to follow this  
Th3IndianCannon

Problem implementing scripted action on body

Recommended Posts

Alright, I am just getting in some scripting practice and I'm trying to script a simple investigative action here. The problem I am having is getting the Action "Investigate Body" to go away while I'm WALKING AWAY from the body, not when I do the action. I have not fully scripted the action script, as I am just trying to get it to go away when I walk away from the body. I really need some help here, once again I am sorry that i can't locate a similar topic and that I had to post in here, but i figured this probably gets the most views so I would get the help that I am searching for. Right now my scripts look like this:

civ1invest = create Trigger ["EmptyDetector",position Civ_1];

sleep 1;

civ1invest setTriggerArea [5,5,0,false];

civ1invest setTriggerActivation["WEST", "PRESENT",true];

civ1invest setTriggerStatements ["this", player addAction ["<t color=#FF0000'>Investigate Body</t>","], player removeAction _Id

I am confused as I was told the best way to keep track of the id's assigned to the actions were to put it in a variable. I tried that as well with different code, but I still couldn't figure it out. This thing has me going crazy. Please help!

Share this post


Link to post
Share on other sites

Hey there.. You need to use more parameters of addAction. You also need to add it to the units you want to be investigating, not the actual player unless you want to investigate yourself, which is why it's always showing the action. Here's an example from a script I made that adds an action to take first aid kits from bodies that have any.

The last string contains the conditional code, the unit must be dead and less than 2 meters away for the action to show. I don't know how you're placing your units, I used this on spawned units but it will work in the init lines of editor placed units, just replace "_unit" with "this" or the name of the unit, maybe "Officer1" etc...

_unit addAction ["<t color='#FF0000'>Take FirstAidKit</t>", {(_this select 0) removeItem "FirstAidKit"; player addItem "FirstAidKit"; (_this select 0) removeAction (_this select 2)},[],1,false,true,"","_this distance _target < 2 && !alive _target"];

In the last string with the conditional code, _this is the unit that called the action (ie: the player), _target is the unit that has the action, your enemy soldier or whatever.

The action will remove itself once activated as seen in the (_this select 0) removeAction (_this select 2) part.

Study the params here carefully: https://community.bistudio.com/wiki/addAction

Btw if you do need to remove an action from somewhere else in your code do this: myAction = unit addAction [blah blah];

Some other script or trigger a while later...

unit removeAction myAction;

Good luck, shout if you need more help.

Edited by LowFlyZone

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  

×