Action upon NPC death

  1. 7 years ago

    Hello everyone, here again.

    I have a simple question, is there a way that npcs spawned with alive do a function/command everytime a player kills one?
    For example, kill an enemy/bandit and get reputation (separate mod) and if you kill a civilian, you lose rep.

    If so, how can i do it? what modules do I need?

  2. Edited 7 years ago by SpyderBlack723

    In your mission's description.ext file

    class Extended_Init_Eventhandlers {
    	class CAManBase {
    		class Custom_Killed_EH_TAG {
    			init = "_this execVM 'my_script.sqf' ";
    		};
    	};
    };

    Then in the root of your mission file create a file named my_script.sqf

    params ["_unit"];
    
    _unit addEventHandler ["Killed", "Put Code run upon unit killed here"];

    https://github.com/CBATeam/CBA_A3/wiki/Extended%20Eventhandlers
    https://community.bistudio.com/wiki/addEventHandler

  3. Thank you! will give it a go

 

or Sign Up to reply!