I cannot be bothered to test this but I'm pretty sure...
At line 983 would do the trick.
if(sd != NULL && sd->status.guild_id == guild_id) {
// do stuff that needs the guild_id first, BEFORE we wipe it
npc_event_doall_id("OnLeaveGuild", account_id);
if (sd->state.storage_flag == 2) //Close the guild storage.
storage_guild_storageclose(sd);
guild_send_dot_remove(sd);
channel_pcquit(sd,3); //leave guild and ally chan
sd->status.guild_id = 0;
sd->guild = NULL;
sd->guild_emblem_id = 0;
if (g->instance_id) {
struct map_data *mapdata = map_getmapdata(sd->bl.m);
if (mapdata->instance_id) { // User was on the instance map
if (mapdata->save.map)
pc_setpos(sd, mapdata->save.map, mapdata->save.x, mapdata->save.y, CLR_TELEPORT);
else
pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
}
}
clif_name_area(&sd->bl); //Update display name [Skotlex]
status_change_end(&sd->bl,SC_LEADERSHIP,INVALID_TIMER);
status_change_end(&sd->bl,SC_GLORYWOUNDS,INVALID_TIMER);
status_change_end(&sd->bl,SC_SOULCOLD,INVALID_TIMER);
status_change_end(&sd->bl,SC_HAWKEYES,INVALID_TIMER);
status_change_end(&sd->bl,SC_EMERGENCY_MOVE,INVALID_TIMER);
//@TODO: Send emblem update to self and people around
}
else {
npc_event_doall_id("OnKickGuild");
}
If they are not online when being kicked it would trigger OnKickGuild without an RID attached.
Edit: Also moved topic to source requests since it's becoming a source thing.