Here is my solution.
In your function :
if (pc_cant_act(sd))
break;
if(sd->state.arealoot == 1 && map_foreachinallrange(skill_greed, &sd->bl, 5, BL_ITEM, &sd->bl) == 0)
return;
else if (!pc_takeitem(sd, fitem))
break;
In pc.cpp
Change this :
if (!check_distance_bl(&fitem->bl, &sd->bl, 2) && sd->ud.skill_id!=BS_GREED)
return false; // Distance is too far
to this :
if (sd->state.arealoot == 0 && (!check_distance_bl(&fitem->bl, &sd->bl, 2) && sd->ud.skill_id!=BS_GREED))
return false; // Distance is too far