You can use sub EVENT_KILLED_MERIT and then use quest globals to define the flags. Quest globals are much better IMO, as I think flags may have some issues.
You will need to make sure to enable the NPC for quest globals as well as any NPC who is supposed to see that flag. You do that by changing the qglobal field in the npc_types table from 0 to 1.
Then, you should be able to use something like this on your flagging NPC when it dies:
Code:
sub EVENT_KILLED_MERIT {
quest::setglobal("myflag",1,5,"F");
}
Then, to check for the flag, you would just use:
Code:
if($qglobals{myflag} == 1);