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

[L4D2] detecting when a player uses a throwable


Post New Thread Reply   
 
Thread Tools Display Modes
Alexmy
Senior Member
Join Date: Oct 2014
Location: Russian Federation
Old 05-25-2019 , 06:49   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #11

How can I track a shot of a player who hit the canister gascan?
Alexmy is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 05-25-2019 , 08:07   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #12

Quote:
Originally Posted by Alexmy View Post
How can I track a shot of a player who hit the canister gascan?
Try something like this
PHP Code:
for(int i 33<= 2048; ++i)
{
    if(
IsGasCan(i))
    {
        
SDKHook_OnTakeDamage
    
}
}

stock bool IsGasCan(int entity)
{
    if(
IsValidEntity(entity) && entity 0)
    {
        
char sType[32]
        
GetEntityClassname(entitysTypesizeof(sType))
        return 
StrEqual(sType"weapon_gascan")
    }
    return 
false;

BHaType is offline
Send a message via AIM to BHaType
Alexmy
Senior Member
Join Date: Oct 2014
Location: Russian Federation
Old 05-25-2019 , 09:05   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #13

In general, I debugged the event and found the desired event. But I can not understand what is wrong?

PHP Code:
public Action break_prop(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if((
entity event.GetInt("entindex")) && IsValidEdict(entity) && GetEdictClassname(entityentClasssizeof(entClass)))
    {
        if(
StrEqual(entClass"weapon_gascan")) PrintToChatAll("................ %N"client);
        else if(
StrEqual(entClass"weapon_propanetank")) PrintToChatAll("................ %N"client);
    }

Alexmy is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-03-2019 , 10:14   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #14

Quote:
Originally Posted by dustinandband View Post
for some reason, propane tank explosions are incrementing the pipe bomb count.
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

char MODEL_PROPANE[] = "models/props_junk/propanecanister001a.mdl";

int g_iPipes;

public 
void OnMapStart()
{
    
HookEntityOutput("prop_physics""OnBreak"OnEntityOutput );
}

void OnEntityOutput (const char[] outputint brokeint breakerfloat delay)
{
    static 
char sBrokeModel[PLATFORM_MAX_PATH];
    
    if (
breaker >= && breaker <= MaxClients && IsClientInGame(breaker)) {
        if (
broke MaxClients && IsValidEntity(broke))
        {
            
GetEntPropString(brokeProp_Data"m_ModelName"sBrokeModelsizeof(sBrokeModel));
            if (
StrEqual(sBrokeModelMODEL_PROPANEfalse))
            {
                
PrintToChatAll("%N broke the propane tank."breaker);
                
g_iPipes--;
            }
        }
    }

Quote:
Originally Posted by Silvers View Post
The problem with this method is that thats are cleared by any plugin using SM Respawn by Atomic. Unless the more advanced one I helped put together which saves and restores player stats actually works and is public, I've no idea.
We made such plugin with you: [L4D1/2] Respawn Statistics Fixer
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-03-2019 , 10:32   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #15

or you can use (in case you didn't modify /scripts for throwables):

PHP Code:
public void OnPluginStart()
{
    
HookEvent("weapon_fire"OnWeaponFire);
}

public 
void OnWeaponFire(Event event, const char[] namebool dontBroadcast)
{
    static 
char sWeapon[64];
    static 
int thrower;
    
    
thrower GetClientOfUserId(event.GetInt("userid"));
    if (
IsClientInGame(thrower) && GetClientTeam(thrower) == 2)
    {
        
event.GetString("weapon"sWeaponsizeof(sWeapon));
        
        if (
StrEqual(sWeapon"molotov"true))
        {
            
CPrintToChatAll("%t""Molotov"thrower); // "\x04%N\x01 threw a \x05molotov!"
        
}
        else if (
StrEqual(sWeapon"pipe_bomb"true))
        {
            
CPrintToChatAll("%t""Pipebomb"thrower); // "\x04%N\x01 threw a \x05pipe-bomb!"
        
}
    }

__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 06-03-2019 at 10:34.
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-03-2019 , 10:41   Re: [L4D2] detecting when a player uses a throwable
Reply With Quote #16

Quote:
Originally Posted by dustinandband View Post
tried including some additional checks that this guy also used but can't find a way to differentiate between an actual pipe and propane tank.
Possibly, by angle rotation:

PHP Code:
public void IncrementPipeBomb(int entity

    
SDKUnhook(entitySDKHook_SpawnPostIncrementPipeBomb); 

    
float vAngles[3];
    
GetEntPropVector(entityProp_Send"m_angRotation"vAngles);
    if (
vAngles[0] == 0.0 && vAngles[1] == 0.0 && vAngles[2] == 0.0) {
            
PrintToChatAll("pipe");
    }
    else {
        
PrintToChatAll("propane");
    }

__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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:14.


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