Raised This Month: $32 Target: $400
 8% 

Solved [L4D2]How to find which player deploy the upgradeAmmo pack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 12-03-2022 , 06:15   [L4D2]How to find which player deploy the upgradeAmmo pack
Reply With Quote #1

I was writing a mine plugin. When players deploy the upgrade ammo pack, a mine will be deploy instead. I use the "SDKHook_StartTouch" hook the mine so i can let the mine explode when someone touch it.Here's some my code:
PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    if (
StrEqual(classname"upgrade_ammo_explosive"false) || StrEqual(classname"upgrade_ammo_incendiary"false)){
        
RequestFrame(OnNextFrameEntIndexToEntRef(entity));
    }
}

void OnNextFrame(int iEntRef)
{
    if (!
IsValidEntRef(iEntRef)){
        return;
    }

    
int entity EntRefToEntIndex(iEntRef);
    
float Pos[3];
    
char mineExplosive[64];

    
GetEntPropVector(entityProp_Send"m_vecOrigin"Pos);//position
    // PrintToChatAll("%f %f %f", Pos[0], Pos[1], Pos[2]);
    
AcceptEntityInput(entity"kill");
    
int physics CreateEntityByName("prop_dynamic_override");
    if (
IsValidEntity(physics) && IsValidEdict(physics)){
        
char tmp[128];
        
Format(mineExplosivesizeof(mineExplosive), "mineExplosive%d"gCount);
        
gCount gCount 10000 gCount 1;
        if (
gCount 10000){
            
gCount 1;
        }

        
DispatchKeyValue(physics"model"MDL_MINE);
        
DispatchSpawn(physics);

        
TeleportEntity(physicsPosNULL_VECTORNULL_VECTOR);

        
SetEntProp(physicsProp_Send"m_iGlowType"2);
        
SetEntProp(physicsProp_Send"m_glowColorOverride"GetColor("255 0 0"));
        
SetEntProp(physicsProp_Send"m_nGlowRange"320);

        
SetEntProp(physicsProp_Data"m_usSolidFlags"152);
        
SetEntProp(physicsProp_Data"m_CollisionGroup"1);// Collides with nothing but world and static stuff
        
SetEntityMoveType(physicsMOVETYPE_NONE);
        
SetEntProp(physicsProp_Data"m_MoveCollide"0);
        
SetEntProp(physicsProp_Data"m_nSolidType"6);// solid vphysics object, get vcollide from the model and collide with that

        
DispatchKeyValue(physics"ExplodeRadius""10");
        
DispatchKeyValue(physics"ExplodeDamage""1");

        
Format(tmpsizeof(tmp), "%s,Explode,,0,-1"mineExplosive);
        
DispatchKeyValue(physics"OnBreak"tmp);
        
SetEntProp(physicsProp_Data"m_takedamage"2);//DAMAGE_YES

    
}

    
int explosion CreateEntityByName("env_explosion");
    if (
IsValidEntity(explosion) && IsValidEdict(explosion)){
        
TeleportEntity(explosionPosNULL_VECTORNULL_VECTOR);
        
DispatchKeyValue(explosion"targetname"mineExplosive);
        
DispatchKeyValue(explosion"spawnflags""1916");    // Random orientation
        
DispatchKeyValue(explosion"iMagnitude""1000");
        
DispatchKeyValue(explosion"iRadiusOverride""500");
        
SetEntProp(explosionProp_Data"m_iHammerID"1078682);
        
DispatchSpawn(explosion);
        
    }

    
SDKHook(physics SDKHook_StartTouchOnTouch);

}

public 
OnTouch(physicsclient)
{
    
// PrintToChatAll("client touched!");
    
if( IsValidEntity(physics) && IsValidEdict(physics))
    {
        if(
IsValidClient(client) || IsWitchOrInfected(client))
        {
            
AcceptEntityInput(physics"Break");
        }
    }

The most quetion is i want to SetEntPropEnt(explosion, Prop_Data, "m_hLastAttacker", client), so player will get score when their mine kill infect / zombies;
But i can't get the client who deploy it. is there a better way to get the client?
Sorry for my poor English

Last edited by kazya3; 12-03-2022 at 11:10.
kazya3 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-03-2022 , 09:41   Re: [L4D2]How to find which player deploy the upgradeAmmo pack
Reply With Quote #2

I believe you can get that by storing the userid in the event below:

Server event "upgrade_pack_used", Tick 77782:
- "upgradeid" = "234"
- "userid" = "2"
__________________
Marttt is offline
kazya3
Member
Join Date: Aug 2019
Location: CN
Old 12-03-2022 , 11:10   Re: [L4D2]How to find which player deploy the upgradeAmmo pack
Reply With Quote #3

Quote:
Originally Posted by Marttt View Post
Server event "upgrade_pack_used", Tick 77782:
- "upgradeid" = "234"
- "userid" = "2"
got it,Thanks
kazya3 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 00:23.


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