public checkstuck() {
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++)
{
player = players[i]
if (is_user_alive(player))
{
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!get_user_noclip(player) && !(pev(player, pev_solid) & SOLID_NOT) && !is_hull_vacant(origin, hull,player))
{
++stuck[player]
if(stuck[player] >= 3)
{
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o)
{
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player))
{
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 0
}
}
}
}
stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
static tr;
engfunc(EngFunc_TraceHull, origin, origin, 0, hull, id, tr)
if(is_client(get_tr2 (tr, TR_pHit)) || get_tr2(tr, TR_InOpen) && !get_tr2(tr, TR_StartSolid) || !get_tr2(tr, TR_AllSolid)) {
return true
}
return false
}