Ok, then you just compare the differences from the entity origin and the player origin to the size of the entity and the one that is the lowest contains your answer.
EDIT: I found the subject interesting so I decided to try it out. This is the best I could create:
There may be some math errors but I don't think so. If there is, it would be because it's 4AM here and I need to sleep.
Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
new const g_TouchedSide[][] = {
"east",
"north",
"top",
"west",
"south",
"bottom"
}
public plugin_init() {
register_plugin("Test Plugin 9", "", "");
RegisterHam(Ham_Touch, "player", "HamTouch");
}
public HamTouch(id, ent) {
if ( 0 >= id > 32 || ! ent )
return;
new iSide, Float:plOrigin[3], Float:entOrigin[3], Float:entSize[3], Float:entMins[3], Float:entMaxs[3];
pev(id, pev_origin, plOrigin);
pev(ent, pev_origin, entOrigin);
pev(ent, pev_size, entSize);
pev(ent, pev_mins, entMins);
pev(ent, pev_maxs, entMaxs);
new Float:fDifference[4] = {0.0,0.0,0.0,9999.9};
fDifference[0] = floatabs(floatabs(floatabs(plOrigin[0]) - floatabs(entOrigin[0] + entMins[0] + ( ( floatabs(entMins[0]) + floatabs(entMaxs[0]) ) / 2 ) ) ) - entSize[0] / 2 - 16); // Touched East/West
fDifference[1] = floatabs(floatabs(floatabs(plOrigin[1]) - floatabs(entOrigin[1] + entMins[1] + ( ( floatabs(entMins[1]) + floatabs(entMaxs[1]) ) / 2 ) ) ) - entSize[1] / 2 - 16); // Touched North/South
fDifference[2] = floatabs(floatabs(floatabs(plOrigin[2]) - floatabs(entOrigin[2] + entMins[2] + ( ( floatabs(entMins[2]) + floatabs(entMaxs[2]) ) / 2 ) ) ) - entSize[2] / 2 - ( pev(id, pev_flags) & FL_DUCKING ? 18 : 36 ) ); // Touched Top/Bottom
for ( new i = 0; i < 3 ; i++ ) {
if ( fDifference[i] < fDifference[3] ) {
iSide = i;
fDifference[3] = fDifference[i]
}
}
if ( plOrigin[iSide] < entOrigin[iSide] )
iSide += 3;
client_print(id, print_chat, "%d touched %d on the %s side", id, ent, g_TouchedSide[iSide]);
}
/*
Player offsets:
* X
* +16
* Y
* +16
* Z
* Standing: +36
* Ducking: +18
*/