1 - Add new map_flag: MF_NORAGEQUIT
2 - Add new value to map_session_data: lastpk
3 - Add new configuration in battle/conf.misc with PK_TIMER (time to set sd->lastpk to 0)
4 - In battle.c when player receive damage from other player in a map with this mapflag set sd->lastpk with source damage char_id.
5 - When player who logout with (sd->lastpk) > 0 && map_id2sd(sd->lastpk) is not null (still online), set for this player who last hitted the player who logout the tsd->killedrid = sd->status.char_id this sd (lets call tsd) and execute npc_event( NPCE_KILLLEVENT, tsd).
6 - Now when player A hit player B, until a ms of time, if player B Log out, the player A garants the execution of label OnPcKillEvent.
7 - Don't forget to put Add_timer in battle.c from same line of 3 step to clean the sd->lastpk of a player (gap between damage. If a player does not hit other in time of a x ms there is no reason to give the kill to the other when logout)
let me improve the explication, with pseudo code. I don't remember the funcions name cause I'm on office
pc_damage()... // Whatever where log player damage
if(sd && tsd)
add_timer( gettick() + 5000, function_timerToCleanLastHitter, sd->bl.id); // After 5 seconds the function will set sd->lasthitter to 0
-- pc.c or map.c (dont remember from where OnPcLogOut is called, but the funcion of logout)
//before OnPcLogoutevent and other stuff
if(sd->lasthitter > 0 && get_mapflag(sd->bl.m, MF_NORAGEQUIT) // Player logout and received hit from a player in last 5 seconds
struct map_session_data* tsd = map_ids2sd( sd->lasthitter );
if(tsd != null)
tsd->killedrid = sd->status.char_id;
npce_event( map_id2sd( tsd->lasthitter, NPCE_KILLPC);
sorry about english and code. Writing without consulting google translate or source code