Jump to content
Sign in to follow this  
Raddik

AddAction Condition Question

Recommended Posts

Can someone tell me what is wrong with the below addAction code? I have placed it in my init.sqf file. The intended purpose is to run the said script when a player is inside a plane.

takeoff2= _target addaction ["Go","go.sqf",nil,1,false,true,"","(_target isKindof "plane")"];

Any expert insight here would be much appreciated.

Raddik

Share this post


Link to post
Share on other sites

Like this?

takeoff2= _target addaction ["Go","go.sqf",nil,1,false,true,"","_target isKindof ""plane""];

Share this post


Link to post
Share on other sites

Missed one. :)

takeoff2= _target addaction ["Go","go.sqf",nil,1,false,true,"","_target isKindof ""plane"""];

Share this post


Link to post
Share on other sites

Hmmm... Still not working. It works with a simpler condition and when i use a specific vehicle's name in place of the first _target...can I use that object name there? I know I can in the condition field but I'm unsure about there.

---------- Post added at 01:24 AM ---------- Previous post was at 01:03 AM ----------

Just confirmed it is in fact the first _target at the beginning of the code that breaks it. If I change it to a specific vehicle name and I'm in the said vehicle it works. How can I make this work with any plane I get into?

Edited by Raddik

Share this post


Link to post
Share on other sites

shk,

isKindof returns a Boolean correct? How would I use that here:

takeoff2= _target addaction

Thanks for the help,

Raddik

Share this post


Link to post
Share on other sites

Question, could you show your init.sqf or tell me how you have defined _target in:

takeoff2= _target addaction

Not that I've used addactions that much, but as I've understood them, you can't use the _target that is passed to the action script outside of it (obviously). Or, are you just using a var with same name.

EDIT:

init.sqf

{
_x addaction ["Go","go.sqf",nil,1,false,true,"","(vehicle player) == _target"];
} foreach [plane1,plane2];

Edited by Shuko

Share this post


Link to post
Share on other sites

The reason why the initial code and the the one above my post won't work is that _target is undefined in the condition scope.

You need to compose the condition string using format:

takeoff2= _target addaction ["Go","go.sqf",nil,1,false,true,"", format ['%1 isKindof "plane", _target]']

Share this post


Link to post
Share on other sites
You need to compose the condition string using format:

No he doesnt. _target works just fine in the condition parameter. It will refer to the object the action was attached to.

Share this post


Link to post
Share on other sites

shk, your code has worked perfectly...thank you greatly for clarifying things for me!

Regards,

Raddik

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  

×