TF2-Sandbox-Studio / TF2SB

🧰 TF2 Sandbox Core Plugin
https://sandbox.moddage.site
GNU General Public License v3.0
10 stars 3 forks source link

To-do: Find a way to stop the playerstuck issue #5

Open Danct12 opened 7 years ago

Danct12 commented 7 years ago

Stopping players from stucking players.

By making let you spawn it at a distance of 400 from another player to the prop.

http://steamcommunity.com/groups/titantf/discussions/19/1471969431590714131/?tscn=1503799009

http://steamcommunity.com/sharedfiles/filedetails/?id=1120472866 https://steamuserimages-a.akamaihd.net/ugc/844843469648565763/266478152A31897CFE1E9344027EED48B4BF1AB1/

BattlefieldDuck commented 7 years ago
stock bool IsBuildable(int client) //Is the place that client pointing is build-able?
{
    float flSightEnd[3];
    GetClientSightEnd(client, flSightEnd); //get client pointed place

    for(int i = 1; i < MAXPLAYERS; i++) //loop every client
    {
        if(IsValidClient(i))
        {
            float flOrigin[3];
            GetClientEyePosition(i, flOrigin);

            int iDistance = RoundFloat(GetVectorDistance(flOrigin, flSightEnd)); //get distance between clients and the client pointed place
            if(iDistance > 400)
            {
                return false;
            }
        }
    }
    return true;
}
stock bool IsValidClient(int client) 
{ 
    if(client <= 0 ) return false; 
    if(client > MaxClients) return false; 
    if(!IsClientConnected(client)) return false; 
    return IsClientInGame(client); 
}
void GetClientSightEnd(int client, float out[3])
{
    float m_fEyes[3];
    float m_fAngles[3];

    GetClientEyePosition(client, m_fEyes);
    GetClientEyeAngles(client, m_fAngles);
    TR_TraceRayFilter(m_fEyes, m_fAngles, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitPlayers);
    if (TR_DidHit())
        TR_GetEndPosition(out);
}
public bool TraceRayDontHitPlayers(int entity, int mask, any data)
{
    if (0 < entity <= MaxClients)
        return false;

    return true;
}
Danct12 commented 7 years ago

Thank you, I'll be merging this to the next update.

Danct12 commented 7 years ago

image

No, I mean to do this.

DJPlaya commented 7 years ago

You should include this, the Code is pretty good > https://forums.alliedmods.net/showthread.php?t=243151