Raised This Month: $ Target: $400
 0% 

[TF2] Do something when touching resupply closet


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ywa*NL
Senior Member
Join Date: Apr 2005
Location: The Netherlands
Old 03-30-2009 , 13:48   [TF2] Do something when touching resupply closet
Reply With Quote #1

Hello everyone,

I've got a question. Is it possible to fire an event when a player is touching a resupply closet (when he gets ammo and health and such)?

Any help with this is welcome.

Thanks in advance.

Regards,
Ywa
__________________
Ywa*NL is offline
Send a message via MSN to Ywa*NL
NeoDement
Member
Join Date: Mar 2009
Old 03-30-2009 , 18:36   Re: [TF2] Do something when touching resupply closet
Reply With Quote #2

I've checked a few threads and I'm fairly sure the answers' no. The most you could probably do is hooking playanimation event of every prop dynamic. Or something. I dunno how they work.
__________________
I'm not being funny but guys, I'm a bit fit, y'know?
NeoDement is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 03-30-2009 , 19:31   Re: [TF2] Do something when touching resupply closet
Reply With Quote #3

Without an extension, no. I didnt see any game events pertaining to it although I thought there was one.
__________________
CrimsonGT is offline
CrancK
Senior Member
Join Date: Jan 2009
Location: Netherlands
Old 03-31-2009 , 03:49   Re: [TF2] Do something when touching resupply closet
Reply With Quote #4

you can hook the entity output of the prop_dynamic and then make a while loop loking for the classname of the resupply cabinet.... something like this:

PHP Code:
public OnPluginStart() {
HookEntityOutput("prop_dynamic""OnAnimationBegun"EntityOutput_OnAnimationBegun);
}

public 
EntityOutput_OnAnimationBegun(const String:output[], calleractivatorFloat:delay)
{
    if (
IsValidEntity(caller))
    {
        new 
String:modelname[128];
        
GetEntPropString(callerProp_Data"m_ModelName"modelname128);
        if (
StrEqual(modelname"models/props_gameplay/resupply_locker.mdl"))
        {
            new 
Float:pos[3];
            
GetEntPropVector(callerProp_Send"m_vecOrigin"pos);
            
FindPlayersInRange(pos128.00, -1false, -1);
            new 
j;
            new 
maxplayers GetMaxClients();
            for (
j=1;j<=maxplayers;j++)
            {
                if(
PlayersInRange[j]>0.0)
                {
                    
// do your stuff
                
}
            }
        }
    }
}

// players in range setup  (self = 0 if doesn't affect self)
FindPlayersInRange(Float:location[3], Float:radiusteamselfbool:tracedonthit)
{
    new 
Float:rsquare radius*radius;
    new 
Float:orig[3];
    new 
Float:distance;
    new 
Handle:tr;
    new 
j;
    new 
maxplayers GetMaxClients();
    for (
j=1;j<=maxplayers;j++)
    {
        
PlayersInRange[j] = 0.0;
        if (
IsClientInGame(j))
        {
            if (
IsPlayerAlive(j))
            {
                if ( (
team>&& GetClientTeam(j)==team) || team==|| j==self)
                {
                    
GetClientAbsOrigin(jorig);
                    
orig[0]-=location[0];
                    
orig[1]-=location[1];
                    
orig[2]-=location[2];
                    
orig[0]*=orig[0];
                    
orig[1]*=orig[1];
                    
orig[2]*=orig[2];
                    
distance orig[0]+orig[1]+orig[2];
                    if (
distance rsquare)
                    {
                        if (
trace)
                        {
                            
GetClientEyePosition(jorig);
                            
tr TR_TraceRayFilterEx(locationorigMASK_SOLIDRayType_EndPointTraceRayDontHitSelfOrPlayersdonthit);
                            if (
tr!=INVALID_HANDLE)
                            {
                                if (
TR_GetFraction(tr)>0.98)
                                {
                                    
PlayersInRange[j] = SquareRoot(distance)/radius;
                                }
                                
CloseHandle(tr);
                            }
                            
                        }
                        else
                        {
                            
PlayersInRange[j] = SquareRoot(distance)/radius;
                        }
                    }
                }
            }
        }
    }

though then again, i use a function to search around the ressuply cabinet, it's also possible to get the client index somehow, MikeJS told me how... but i kinda forgot...

anyway... this is the basic way of hooking ressuply cabinets
CrancK is offline
Ywa*NL
Senior Member
Join Date: Apr 2005
Location: The Netherlands
Old 03-31-2009 , 09:04   Re: [TF2] Do something when touching resupply closet
Reply With Quote #5

Thanks CrancK!
__________________
Ywa*NL is offline
Send a message via MSN to Ywa*NL
MikeJS
Senior Member
Join Date: Nov 2008
Old 03-31-2009 , 11:21   Re: [TF2] Do something when touching resupply closet
Reply With Quote #6

Quote:
Originally Posted by CrancK View Post
though then again, i use a function to search around the ressuply cabinet, it's also possible to get the client index somehow, MikeJS told me how... but i kinda forgot...
It wouldn't work for this anyway (assuming you mean m_hOwnerEntity)
__________________
MikeJS is offline
Reply



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 10:04.


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