Jump to content
wesley32

Execute killed EH code locally in MP

Recommended Posts

Hi all,

 

How would I go about executing killed EH code only on the machine of the killer (or filter him out) with the mission running on a dedicated server?.

I see that using addEventHandler  ["killed"] only executes on the machine where the unit is local to (server in this case). That means the killer won't have the code executed.

I also see that addMPEventHandler  ["MPkilled"] will execute the code on every machine.

 

Can't seem to figure this one out. Any help is greatly appreciated!

 

Thanks.

Share this post


Link to post
Share on other sites

i think u have to add the EH on the machine of the victim (unit) and then u use remoteExec to run code on killers machine.

  • Like 1

Share this post


Link to post
Share on other sites

Example

    params ["_civUnit", "_ehkilledIdx"];
    
    _ehkilledIdx = _civUnit addEventHandler ["killed", {

        params ["_cvictim", "_ckiller", "_ckillerID"];
        
        if (isnull _ckiller) exitWith {["Unnecessary civilian casualties detected!", "systemChat"] call BIS_fnc_MP;};
        


        if (isPlayer _ckiller) then {
    
            if (vehicle _ckiller isEqualTo vehicle _cvictim) exitWith {
            
                ["Unnecessary civilian casualties detected!", "systemChat"] call BIS_fnc_MP;

            };
            
                _ckillerID = owner _ckiller;
                {[profileName + " has killed civilian!", "systemChat"] call BIS_fnc_MP;} remoteExec ["bis_fnc_call", _ckillerID, false];
                    

        } else {
    
            if (side _ckiller == west) then {
                
                ["Unnecessary civilian casualties detected!", "systemChat"] call BIS_fnc_MP;
            
            } else {
            
                if (side _ckiller == east) then {
                
                    ["Enemy is killing civilians, stop this madness", "systemChat"] call BIS_fnc_MP;
                
                };
            };    
        };
    
    }];

Share this post


Link to post
Share on other sites
player addEventHandler [
     'MPKilled',
     {
          params ['_killed','_killer'];
          if (isDedicated) exitWith {};
          if (player isEqualTo _killer) then {
               /* you are the killer */
          };
     }
];

Share this post


Link to post
Share on other sites
player addEventHandler [
     'MPKilled',
     {
          params ['_killed','_killer'];
          if (isDedicated) exitWith {};
          if (player isEqualTo _killer) then {
               /* you are the killer */
          };
     }
];

The "MPKilled" must be used in conjunction with the addMPEventHandler command.

  • 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

×