added check to prevent from teleporting player if they would get stuck
This commit is contained in:
parent
d5dae5c045
commit
0f19ab08cf
@ -88,10 +88,19 @@ public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
|
||||
int total_nearest = -1;
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
//if player would get stuck being teleported dont teleport them to this player
|
||||
if (!IsValidClient(i) || !IsPlayerAlive(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (IsPlayerStuck(i) != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float nearestdistance = -1.0;
|
||||
int nearest = -1;
|
||||
for (int j = 1; j <= MaxClients; j++)
|
||||
if (IsValidClient(i) && IsPlayerAlive(i) && IsValidClient(j) && IsPlayerAlive(j) && GetClientTeam(i) != GetClientTeam(j) && GetClientTeam(i) == 3)
|
||||
if (IsValidClient(j) && IsPlayerAlive(j) && GetClientTeam(i) != GetClientTeam(j) && GetClientTeam(i) == 3)
|
||||
{
|
||||
float pos[3];
|
||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
||||
@ -102,7 +111,7 @@ public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
|
||||
nearestdistance = dist_target;
|
||||
}
|
||||
}
|
||||
//the closest enemy to this player is further away than previous player
|
||||
//the closest enemy to this player is further away than previous players closest enemy
|
||||
if (nearestdistance > total_furthest_distance)
|
||||
{
|
||||
total_furthest_distance = nearestdistance;
|
||||
@ -117,6 +126,28 @@ public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
stock int IsPlayerStuck(int client) {
|
||||
float vecMin[3];
|
||||
float vecMax[3];
|
||||
float vecOrigin[3];
|
||||
|
||||
GetClientMins(client, vecMin);
|
||||
GetClientMaxs(client, vecMax);
|
||||
vecMax[2] = 63.0;
|
||||
vecMin[2] += 1.0;
|
||||
GetClientAbsOrigin(client, vecOrigin);
|
||||
|
||||
TR_TraceHullFilter(vecOrigin, vecOrigin, vecMin, vecMax, MASK_PLAYERSOLID, TraceRayDontHitPlayerAndWorld);
|
||||
return TR_GetEntityIndex();
|
||||
}
|
||||
|
||||
public bool TraceRayDontHitPlayerAndWorld(int entityhit, int mask) {
|
||||
return entityhit>MaxClients
|
||||
}
|
||||
public bool TraceRayHitOnlyEnt(int entityhit, int mask, any data) {
|
||||
return entityhit==data;
|
||||
}
|
||||
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
client_target[client] = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user