Raised This Month: $12 Target: $400
 3% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bok141
Junior Member
Join Date: Feb 2011
Old 03-16-2018 , 00:40   (tf) how to get near building or Dispenser postion?
Reply With Quote #1

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

Last edited by bok141; 03-16-2018 at 00:44.
bok141 is offline
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
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-16-2018 , 21:48   Re: (tf) how to get near building or Dispenser postion?
Reply With Quote #3

Quote:
Originally Posted by eyal282 View Post
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.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 03-17-2018 , 07:44   Re: (tf) how to get near building or Dispenser postion?
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
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.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:18.


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