Jump to content
Sign in to follow this  
coolfact

addaction trouble using "in" in condition

Recommended Posts

I have some trouble with my addaction script which is placed in a for loop, the addaction works fine beside when I want to pose a condition that can only be used for specific sides, it doesn't give anyone access.

_box addAction [format["<t color='#FF0000'>%1</t>",(_descname select _i)], spawn_object ,[(_type select _i),(_items select _i),(_magazines select _i),(_backpacks select _i),(_weapons select _i),_spawnpoint],6, false, true, "","player distance _target < 5 && {(side player in _side)}"];
systemchat format["objects: %1",side player in _side];//returns true

I have tried

(side player == civilian)

which works just fine so it must be the "in" function which does not work, the _side function is:

_side = [WEST,civilian]

Share this post


Link to post
Share on other sites

Its a different scope and a variable local to that scope needs to be defined. In this case, _side would be undefined.

Share this post


Link to post
Share on other sites
Guest

Hello.

You are trying to call a local variable in your addAction thread.

You can still use two playerside checks playerside == side OR playerside == side.

Or you need to define the local variable in the same scope as the addAction.

Share this post


Link to post
Share on other sites

WHEN USING ADDACTION CONDITIONS DO NOT USE PLAYER!!!!!!!

use:

_target (the object/unit where the object is attached)

_this (the object/unit looking at the addAction)

 

in this case _target is _box and _this is player

Share this post


Link to post
Share on other sites

I see so how do I define the local scope in the same scope as the addaction? I have tried add the _side array to the argument, but that didn't seem to work

_box addAction [format["<t color='#FF0000'>%1</t>",(_descname select _i)], spawn_object ,[(_type select _i),(_items select _i),(_magazines select _i),(_backpacks select _i),(_weapons select _i),_spawnpoint,_side],6, false, true, "","_this distance _target < 5 && {(side _this in (_target select 3 select 6))}"];

Share this post


Link to post
Share on other sites

WHEN USING ADDACTION CONDITIONS DO NOT USE PLAYER!!!!!!!

use:

_target (the object/unit where the object is attached)

_this (the object/unit looking at the addAction)

 

in this case _target is _box and _this is player

 

Using player is perfectly fine as long as you know what you are doing. Unless you can prove otherwise?

 

 

One way could be saving the sides into the box:

_box setVariable ["COOLTAG_Side",_side];
_box addAction [format["<t color='#FF0000'>%1</t>",(_descname select _i)], spawn_object ,[(_type select _i),(_items select _i),(_magazines select _i),(_backpacks select _i),(_weapons select _i),_spawnpoint],6, false, true, "","player distance _target < 5 && (side player in (_target getVariable 'COOLTAG_Side'))"];

Share this post


Link to post
Share on other sites

okay so variables are saved in the right scopes, will try that out.

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  

×