AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] Do something when touching resupply closet (https://forums.alliedmods.net/showthread.php?t=88918)

Ywa*NL 03-30-2009 13:48

[TF2] Do something when touching resupply closet
 
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

NeoDement 03-30-2009 18:36

Re: [TF2] Do something when touching resupply closet
 
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.

CrimsonGT 03-30-2009 19:31

Re: [TF2] Do something when touching resupply closet
 
Without an extension, no. I didnt see any game events pertaining to it although I thought there was one.

CrancK 03-31-2009 03:49

Re: [TF2] Do something when touching resupply closet
 
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

Ywa*NL 03-31-2009 09:04

Re: [TF2] Do something when touching resupply closet
 
Thanks CrancK!

MikeJS 03-31-2009 11:21

Re: [TF2] Do something when touching resupply closet
 
Quote:

Originally Posted by CrancK (Post 793805)
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)


All times are GMT -4. The time now is 06:26.

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