Участник
Пользователь
- Сообщения
- 31
- Реакции
- 11
- Помог
- 1 раз(а)
Собственно что я натворил:
C++:
stock UTIL_UnstickPlayer(id)
{
if(!is_user_alive(id)) return -1;
if(get_user_noclip(id)) return -2;
if(g_iCvar[UNSTUCK_FREQUENCY_STATUS])
{
new Float:fMinFrequency = g_iCvar[UNSTUCK_FREQUENCY];
new Float:fElapsedCmdTime = get_gametime() - g_fLastCmdtime[id];
if(fElapsedCmdTime < fMinFrequency)
{
g_fLastGetTime[id] = fMinFrequency - fElapsedCmdTime;
return -4;
}
g_fLastCmdtime[id] = get_gametime();
}
static Float:vecOrigin[coord_s];
static Float:fMins[coord_s], PlayerHullSize;
static Float:vecVelocity[coord_s];
static o;
get_entvar(id, var_origin, vecOrigin);
PlayerHullSize = (get_entvar(id, var_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN);
new bool:g_bUserStuck[MAX_PLAYERS + 1];
new ptr;
engfunc(EngFunc_TraceHull, vecOrigin, vecOrigin, 0, PlayerHullSize, id, ptr);
g_bUserStuck[id] = bool:(!(!get_tr2(ptr, TR_StartSolid) && !get_tr2(ptr, TR_AllSolid)) && !(get_entvar(id, var_solid) & SOLID_NOT));
switch(g_bUserStuck[id])
{
case false: return 0;
case true:
{
get_entvar(id, var_mins, fMins);
vecVelocity[y] = vecOrigin[y];
for(o = 0; o < sizeof fSize; ++o)
{
vecVelocity[x] = vecOrigin[x] - fMins[x] * fSize[o][x];
vecVelocity[y] = vecOrigin[y] - fMins[y] * fSize[o][y];
vecVelocity[z] = vecOrigin[z] - fMins[z] * fSize[o][z];
engfunc(EngFunc_TraceHull, vecVelocity, vecVelocity, 0, PlayerHullSize, id, ptr);
if(get_tr2(ptr, TR_InOpen))
{
if(!get_tr2(ptr, TR_StartSolid) && !get_tr2(ptr, TR_AllSolid))
{
engfunc(EngFunc_SetOrigin, id, vecVelocity);
client_print_color(id, print_team_default, "%L %L", id, "RZ_CHAT_PREFIX", id, "JBE_CHAT_ID_STUCK_YES");
client_cmd(id,"spk fvox/blip.wav");
set_entvar(id, var_velocity, {0.0, 0.0, 0.0});
o = sizeof fSize;
return 1;
}
}
}
}
}
return -3;
}
C++:
stock UTIL_UnstickPlayer(id)
{
if(!is_user_alive(id)) return -1;
if(get_user_noclip(id)) return -2;
if(g_iCvar[UNSTUCK_FREQUENCY_STATUS])
{
new Float:fMinFrequency = g_iCvar[UNSTUCK_FREQUENCY];
new Float:fElapsedCmdTime = get_gametime() - g_fLastCmdtime[id];
if(fElapsedCmdTime < fMinFrequency)
{
g_fLastGetTime[id] = fMinFrequency - fElapsedCmdTime;
return -4;
}
g_fLastCmdtime[id] = get_gametime();
}
static Float:vecOrigin[coord_s];
static Float:fMins[coord_s], PlayerHullSize;
static Float:vecVelocity[coord_s];
static o;
get_entvar(id, var_origin, vecOrigin);
PlayerHullSize = (get_entvar(id, var_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN);
new bool:g_bUserStuck[MAX_PLAYERS + 1];
new ptr;
engfunc(EngFunc_TraceHull, vecOrigin, vecOrigin, 0, PlayerHullSize, id, ptr);
g_bUserStuck[id] = bool:(!(!get_pmtrace(ptr, pmt_startsolid) && !get_pmtrace(ptr, pmt_allsolid)) && !(get_entvar(id, var_solid) & SOLID_NOT));
switch(g_bUserStuck[id])
{
case false: return 0;
case true:
{
get_entvar(id, var_mins, fMins);
vecVelocity[y] = vecOrigin[y];
for(o = 0; o < sizeof fSize; ++o)
{
vecVelocity[x] = vecOrigin[x] - fMins[x] * fSize[o][x];
vecVelocity[y] = vecOrigin[y] - fMins[y] * fSize[o][y];
vecVelocity[z] = vecOrigin[z] - fMins[z] * fSize[o][z];
engfunc(EngFunc_TraceHull, vecVelocity, vecVelocity, 0, PlayerHullSize, id, ptr);
if(get_pmtrace(ptr, pmt_inopen))
{
if(!get_pmtrace(ptr, pmt_startsolid) && !get_pmtrace(ptr, pmt_allsolid))
{
engfunc(EngFunc_SetOrigin, id, vecVelocity);
client_print_color(id, print_team_default, "%L %L", id, "RZ_CHAT_PREFIX", id, "JBE_CHAT_ID_STUCK_YES");
client_cmd(id,"spk fvox/blip.wav");
set_entvar(id, var_velocity, {0.0, 0.0, 0.0});
o = sizeof fSize;
return 1;
}
}
}
}
}
return -3;
}