View Single Post
eyal282
Veteran Member
Join Date: Aug 2011
Old 03-16-2018 , 12:09   Re: (tf) how to get near building or Dispenser postion?
Reply With Quote #2

Quote:
Originally Posted by bok141 View Post
(tf) how to get near building or Dispenser postion?
i help for
if player death then get near allied dispenser and dispenser position
You need to:

1. Find the classname of dispensers, I assume each team's dispenser gets a unique classname.

2. ( I coded without compiling so it might not even compile )

Code:
new Dispenser, entity = -1, Float:dispenserOrigin[3], Float:playerOrigin[3], Float:WinningDistance = -1, Float:Distance;

GetEntPropVector(client, Prop_Data, "m_vecOrigin", playerOrigin);

while(FindEntityByClassname(entity, "Your classname here") != -1)
{
    if(!IsValidEdict(entity) || !IsValidEntity(entity))
        continue;

    GetEntPropVector(entity, Prop_Data, "m_vecOrigin", dispenserOrigin);
    
    Distance = GetVectorDistance(playerOrigin, dispenserOrigin, false);

    if(WinningDistance == -1 || Distance < WinningDistance)
    {
        WinningDistance = Distance;
        Dispenser = entity;
    }
}
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline