AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   (tf) how to get near building or Dispenser postion? (https://forums.alliedmods.net/showthread.php?t=306095)

bok141 03-16-2018 00:40

(tf) how to get near building or Dispenser postion?
 
(tf) how to get near building or Dispenser postion?
i help for
if player death then get near allied dispenser and dispenser position

eyal282 03-16-2018 12:09

Re: (tf) how to get near building or Dispenser postion?
 
Quote:

Originally Posted by bok141 (Post 2583202)
(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;
    }
}


Powerlord 03-16-2018 21:48

Re: (tf) how to get near building or Dispenser postion?
 
Quote:

Originally Posted by eyal282 (Post 2583269)
1. Find the classname of dispensers, I assume each team's dispenser gets a unique classname.

That's a silly assumption since very few classnames are team-coded.

Standard dispensers have the classname obj_dispenser
Payload dispensers have the classname mapobj_cart_dispenser

Both have the m_iTeamNum netprop. If it keeps in line with the rest of the game, team 2 is RED and team 3 is BLU.

eyal282 03-17-2018 07:44

Re: (tf) how to get near building or Dispenser postion?
 
Quote:

Originally Posted by Powerlord (Post 2583320)
That's a silly assumption since very few classnames are team-coded.

Standard dispensers have the classname obj_dispenser
Payload dispensers have the classname mapobj_cart_dispenser

Both have the m_iTeamNum netprop. If it keeps in line with the rest of the game, team 2 is RED and team 3 is BLU.

I guess the classnames I worked with happened to be team-coded.


All times are GMT -4. The time now is 20:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.