Jump to content
Sign in to follow this  
kdk11

what is "_x"?

Recommended Posts

what is "_x"? what does it mean

Share this post


Link to post
Share on other sites

In the context of loops, _x is a special variable that means "The element in question"

So if you're doing a simple loop like:

{
   _x setDamage 1;
} forEach [man1, man2, man3];

Then essentially you are telling Arma to do the following:

man1 setDamage 1;
man2 setDamage 1;
man3 setDamage 1;

_x is the element you are currently using in an array. In the above case, _x is man1, then man2, then man3 because the forEach command loops through each element in the array.

Does that make some sense of it for you?

Share this post


Link to post
Share on other sites

Yeah thanks but why do I get an error with this?

_x addEventHandler ["killed", {["Task_Objectives", "Failed"] call BIS_fnc_taskSetState; [["end1", true, true], "BIS_fnc_endMission", true, true] spawn BIS_fnc_MP;}]} forEach [c1,c2,c3,c4,c5,c6,c7,c8,c9];

Share this post


Link to post
Share on other sites

Hmm, nasty bit of code to debug there. I think _x isn't in scope because you have missed out an opening bracket. Maybe...

Try:

{
   _x addEventHandler ["killed", {["Task_Objectives", "Failed"] call BIS_fnc_taskSetState; [["end1", true, true], "BIS_fnc_endMission", true, true] spawn BIS_fnc_MP;}];
} forEach [c1,c2,c3,c4,c5,c6,c7,c8,c9]; 

Placed one of these at the start {

Disclaimer: Untested.

Share this post


Link to post
Share on other sites

I get no errors now :) is the [c1,c2,c3,c4,c5,c6,c7,c8,c9]; Who it calls this action for?

Share this post


Link to post
Share on other sites

Can you clarify? I'm not understanding what you mean exactly. Are you asking what [c1,c2,c3,c4,c5,c6,c7,c8,c9] is?

Share this post


Link to post
Share on other sites

if isServer then
{
 {
   _x addEventHandler ["killed",
   {
     ["Task_Objectives", "Failed"] call BIS_fnc_taskSetState;
     [["end1", true, true], "BIS_fnc_endMission", true, true] spawn BIS_fnc_MP;
   }];
 }
 forEach [c1,c2,c3,c4,c5,c6,c7,c8,c9];
};

---------- Post added at 19:05 ---------- Previous post was at 19:04 ----------

Can you clarify? I'm not understanding what you mean exactly. Are you asking what [c1,c2,c3,c4,c5,c6,c7,c8,c9] is?

u should start here http://forums.bistudio.com/showthread.php?158297-arma-MP-mission-ending-not-working

Share this post


Link to post
Share on other sites

LoonyWarrior I would prefer you didnt comment if your not going to help! you edited every post you made on that link. And told me I wasnt listening even though I was doing what you said to do!

Share this post


Link to post
Share on other sites
LoonyWarrior I would prefer you didnt comment if your not going to help! you edited every post you made on that link. And told me I wasnt listening even though I was doing what you said to do!

at this point i hope that other ppl will see how many post i edited that thread... :eek:

Share this post


Link to post
Share on other sites
at this point i hope that other ppl will see how many post i edited that thread... :eek:

yes you edited the actual one what was "supposed" to help many times because everything you said was wrong. Just like your last comment on there. Which causes an error. Like I said stop commenting if you are not trying to help!

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  

×