Jump to content
Sign in to follow this  
aie-boshell

Event Handler Entity Killed Help

Recommended Posts

Hello, I have an issue with this event handler I'm using.  What I would like is for a radio message to play after an air strike that tells the player how successful or unsuccessful the strike was.  If enemies are neutralized the strike is successful but if friendlies or civilians are killed then the strike is unsuccessful and a different message would play.   I'm using the Support provider module and am naming the plane that spawns for CAS bombing, for example, plane_1.  Here is my script

 

Quote

 

addMissionEventHandler ["EntityKilled", {
    params ["_killed", "_killer", "_instigator"];

    
    //If we don not have an instigator,  where we controlling a UAV
    if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0};
    //If we still do not have an instigator use killer instead
    if (isNull _instigator) then {_instigator = _killer};


    if (vehiclevarname _killer isEqualTo "plane_1" and side group _killed isEqualTo east ) then {p_1 customradio [1, "cas_effective"]}; 

 


 

 

 

The only problem I'm having is that the radio message is playing multiple times, once for each enemy killed for the successful message and once for each friendly or civilian killed for the unsuccessful message.  I would like the message to only play once after the strike for all enemies killed for example.  I'm struggling in finding a way to make this possible and the BIS data/script commands website being under maintenance is not helping me.  I thought of some type of idea such as making it only true once and a timeout after that, but any help anyone can give me to point me the right direction is very much appreciated :-)

Share this post


Link to post
Share on other sites

Just remove the eventhandler again, when the radio message is beeing sent.

Share this post


Link to post
Share on other sites

Two ways , using this MEH:

 

Run it on server only and remoteExec the code where you want to fire it:

if (isServer) then { addMissionEventHandler ["entityKilled", { params ["_killed","_killer"];  "bla bla"  remoteExec ["hint",_killer] }];  // as example

fine, but need to broadcast (remoteExec) the code. Not really network friendly.

 

or run the MEH on every PC (write it if init.sqf), and select the local PC as a condition for the code:

addMissionEventHandler ["entityKilled", {params ["_killed","_killer"];if (local _killer) then {hint "bla bla"}}];

I guess much better for network and acceptable for all PCs.

 

  • Confused 1

Share this post


Link to post
Share on other sites

Thank you both very much for taking the time to help me.  I will give these methods a try today then will respond to let the community know which method worked for me.  

Share this post


Link to post
Share on other sites

@Tajin You feel "confused". What is the problem? How are you using this MEH if you don't want to trigger a code on each PC and have duplication, but reach the killer PC?

It's a general remark, complementary to your post.

Share this post


Link to post
Share on other sites

I'm confused because that is not what he asked for. ^^

 

He wants to stop the EH from firing once the first unit goes down.

Its not a locality issue and he apparently wants the message to be shown to everyone not just the killer.

Share this post


Link to post
Share on other sites

Ah OK. I understand. I keep my remark, MP oriented (for personal hint on a player for example).

Your solution is fine, depending on how many air strikes are possible (repeatable?)

You can kill the MEH after single usage, or make it limited and re-actionable:

addMissionEventHandler ["entityKilled", {

  params ["_killed","_killer"];

 {

     if (isNil {missionNameSpace getVariable "done"}) then {

        < any code here >

      missionNameSpace setVariable ["done", true];

    }

 }];

Then missionNameSpace setVariable ["done",nil]; each time you want to use it again (in expression field of a support module for example)

 

 

  • 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
Sign in to follow this  

×