Jump to content
Cigs4

EventHandlers and side problem

Recommended Posts

Hello!!

 

I did a mission with some animations created via remoteExec and others I removed the "PATH", all on a dedicated server.
What I'm trying to do is when an AI gets shot or someone fires nearby, it exits the animation and engages the enemy. So, I tried this:

if (side _x isEqualTo EAST) then {
	_x addMPEventHandler ["MPHit", {
	(_this select 0) enableAI "PATH";
	[(_this select 0),""]remoteExec["switchmove"];
	(_this select 0) setUnitPos "UP";}];
} forEach allUnits;

if (side _x isEqualTo EAST) then {
	_x addEventHandler ["FiredNear", {
	(_this select 0) enableAI "PATH";
	[(_this select 0),""]remoteExec["switchmove"];
	(_this select 0) setUnitPos "UP";}];
} forEach allUnits;

But no sucess... I don't know what I'm doing wrong or if I did something right at all.

Please, help! Thanks in advance.

 

Share this post


Link to post
Share on other sites

your code is clunky. You can't start a condition if then and finish the scope by forEach. These are two different things:
{ _x (element here) ...} forEach an array;

if (something true) then {a code};

 

 

{
  call {
    if (side _x isEqualTo EAST) exitWith {
      _x addMPEventHandler ["MPHit", {
        (_this select 0) enableAI "PATH";
        [(_this select 0),""]remoteExec["switchmove"];
        (_this select 0) setUnitPos "UP";
        }];
    };
    if (side _x isEqualTo EAST) exitWith {
      _x addEventHandler ["FiredNear", {
        (_this select 0) enableAI "PATH";
        [(_this select 0),""]remoteExec["switchmove"];
        (_this select 0) setUnitPos "UP";
      }];
    };
  };
} forEach allUnits;

Note: it's just a way to code, on your basis, not saying you will obtain the perfect intended result using this commands.

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

addMPEventHandler

MP EH fires on every PC you dont need or want to use remote exec in it

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you very much for the answers and the correction. Really helpful.
I will dig a little more about this, but if anyone knows something else, I would really appreciate any help.

  • Like 1

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

×