Palmi69 2 Posted October 1, 2021 hi, i want to define same condition for two objets ("obj1" and "obj2") and scripted in one condition: "if" \\i've tryed this: if (obj1 or obj2 distance player < 20) then {.... \\but "or" gone wrong ! \\i don' t want to repeat condition for each obj like this: if (obj1 distance player < 20 ) then {... if (obj2 distance player < 20) then {... thanks for help ! Share this post Link to post Share on other sites
sizraide 4 Posted October 1, 2021 1 hour ago, sil.lau@free.fr said: hi, i want to define same condition for two objets ("obj1" and "obj2") and scripted in one condition: "if" \\i've tryed this: if (obj1 or obj2 distance player < 20) then {.... \\but "or" gone wrong ! \\i don' t want to repeat condition for each obj like this: if (obj1 distance player < 20 ) then {... if (obj2 distance player < 20) then {... thanks for help ! Quote if(player distance obj1 < 20 OR player distance obj2 <20) then { }; You can use OR or || for both conditions.EDIT: Your if condition doesn't work because when you wrote obj1 OR obj2 distance player < 20. the condition is basically saying if variable "obj1" returns true OR obj2 is less than 20m from the player. You must type the whole condition and separate them using alias, like OR, AND, or isEqualTo. Your second if statement is correct, you just need to combine both conditions together using alias. Like I mentioned. 3 Share this post Link to post Share on other sites
Palmi69 2 Posted October 1, 2021 thanks a lot Sizraide ! 1 Share this post Link to post Share on other sites
Schatten 268 Posted October 1, 2021 @sil.lau@free.fr, you can also use this code: if (([obj1, obj2] findIf { (player distance _x) < 20 }) >= 0) then { ... }; 4 Share this post Link to post Share on other sites
wogz187 1085 Posted October 1, 2021 @sil.lau@free.fr, Loop the condition and identify the nearest activator. //method 1 [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this select {_x distance player < 20}; if !(_near isEqualTo []) then {systemChat str (_near #0); true} else {false} } }; //method 2 (probably faster) [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this findIf {_x distance player < 20}; if (_near> -1) then {systemChat str (_this select _near); true} else {false} } }; Have fun! 2 Share this post Link to post Share on other sites
Soapbox0331 17 Posted October 1, 2021 3 hours ago, wogz187 said: @sil.lau@free.fr, Loop the condition and identify the nearest activator. //method 1 [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this select {_x distance player < 20}; if !(_near isEqualTo []) then {systemChat str (_near #0); true} else {false} } }; //method 2 (probably faster) [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this findIf {_x distance player < 20}; if (_near> -1) then {systemChat str (_this select _near); true} else {false} } }; Have fun! I understand "player" is used for SP. How does this look for MP dedicated? Is it just replacing with "anyPlayer"? I am thinking it is more than that, but I may be a little code paranoid by now;) 2 Share this post Link to post Share on other sites
pierremgi 4739 Posted October 1, 2021 condition: {if (allPlayers inAreaArray [getpos _x, 20, 20] isNotEqualTo []) exitWith {TRUE}; FALSE} forEach [obj_0,obj_1] https://community.bistudio.com/wiki/inAreaArray 2 1 Share this post Link to post Share on other sites
Palmi69 2 Posted October 1, 2021 Many Thanks SCHATTEN ! it's a good code when there are a lot of objetcs to define . 1 Share this post Link to post Share on other sites
Soapbox0331 17 Posted October 2, 2021 3 hours ago, pierremgi said: {if (allPlayers inAreaArray [getpos _x, 20, 20] isNotEqualTo []) exitWith {TRUE}; FALSE} forEach [obj_0,obj_1] @pierre MGI When I add to trigger condition I get this error: Condition: Missing ] 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted October 2, 2021 copy/paste known bug on forum. Not on my side. Anyway, that works as condition in a loop, that doesn't work in a trigger condition, due to undefined result in 3den. Prefer: [obj_0,obj_1] findIf {allPlayers inAreaArray [getpos _x, 20, 20] isNotEqualTo []} >-1 2 1 Share this post Link to post Share on other sites
Soapbox0331 17 Posted October 2, 2021 7 hours ago, pierremgi said: copy/paste known bug on forum. Not on my side. Anyway, that works as condition in a loop, that doesn't work in a trigger condition, due to undefined result in 3den. Prefer: [obj_0,obj_1] findIf {allPlayers inAreaArray [getpos _x, 20, 20] isNotEqualTo []} >-1 My misunderstanding, thanks! 1 Share this post Link to post Share on other sites