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

[CSGO] player_hurt & player_death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 02-01-2014 , 00:31   [CSGO] player_hurt & player_death
Reply With Quote #1

Hey,

I'm having a problem with the player_hurt event returning the wrong weapon name so does Weapon_Fire but the player_death event returns the right one.

hkp2000 is returned instead of usp_silencer or usp_silencer_off
same with m4a1 is returned instead of m4a1_silencer or m4a1_silencer_off

GetClientWeapon() also returns the wrong weapon name

Anyone know a fix for this?

Sourcemod 1.5.2 & MetaMod 1.10.0 being used.

here is a image of what I mean


PHP Code:
HookEvent("player_hurt",  Event_Player_Hurt);
HookEvent("player_death",  Event_Player_Death);
HookEvent("weapon_fire"Event_Weapon_Fire);

public 
Event_Player_Hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    
// stats
    
if (GetConVarBool(g_h_stats_enabled))
    {
        new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
        new 
victim GetClientOfUserId(GetEventInt(event"userid"));
        new 
damage GetEventInt(event"dmg_health");
        new 
damage_armor GetEventInt(event"dmg_armor");
        new 
hitgroup GetEventInt(event"hitgroup");
        new 
Stringweapon[64];
        new 
Stringweapons[64];  //this is only for testing
        
GetClientWeapon(attackerweapons64);    //this is only for testing
        
GetEventString(event"weapon"weaponsizeof(weapon));
        
PrintToChatAll("Hurt = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);    //this is only for testing
[more code here but not needed for this problem]
    }
}

public 
Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
assister GetClientOfUserId(GetEventInt(event"assister"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
bool:headshot GetEventBool(event"headshot");
    new 
Stringweapon[64];
    new 
Stringweapons[64];  //this is only for testing
    
GetEventString(event"weapon"weaponsizeof(weapon));
    
GetClientWeapon(attackerweapons64);  //this is only for testing
    
PrintToChatAll("Death = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);  //this is only for testing
    
new victim_team GetClientTeam(victim);
[
there is more code here but not needed for this problem]
}

public 
Event_Weapon_Fire(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
IsActive(0true))
    {
        return;
    }
    
    
// stats
    
if (GetConVarBool(g_h_stats_enabled))
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if (
client 0)
        {
            new 
Stringweapon[64];
            new 
Stringweapons[64];  //this is only for testing
            
GetEventString(event"weapon"weaponsizeof(weapon));
            
GetClientWeapon(clientweapons64);  //this is only for testing
            
PrintToChatAll("Fire = GetEventString weapon %s - GetClientWeapon %s"weaponweapons);  //this is only for testing
            
new weapon_index GetWeaponIndex(weapon);
            if (
weapon_index > -1)
            {
                
weapon_stats[client][weapon_index][LOG_HIT_SHOTS]++;
            }
        }
    }

__________________

Last edited by versatile_bfg; 02-01-2014 at 01:00.
versatile_bfg is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 02-01-2014 , 06:17   Re: [CSGO] player_hurt & player_death
Reply With Quote #2

SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);

maybe?
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-01-2014 , 07:50   Re: [CSGO] player_hurt & player_death
Reply With Quote #3

I had similar issue with finding whether or not usp or m4a1-s was used. I found a way and implemented that in this plugin.
Here is a small snippet that I made just now, untested.
Code:
new m_bSilencerOn, m_hActiveWeapon; public OnPluginStart() {     m_bSilencerOn   = FindSendPropOffs("CWeaponCSBaseGun", "m_bSilencerOn");     m_hActiveWeapon = FindSendPropOffs("CBasePlayer",      "m_hActiveWeapon"); } public OnSomeEvent() {     // Declare weapon string and player slot     decl String:szWeapon[MAX_NAME_LENGTH], slot; // Make sure slot is valid and we can retrieve its classname     if ((slot = GetEntDataEnt2(client, m_hActiveWeapon)) != -1 && GetEdictClassname(slot, szWeapon, sizeof(szWeapon)))     {         // Check whether or not silencer is inserted         if (bool:GetEntData(slot, m_bSilencerOn, true) == true)         {             // Replace whole weapon string appropriately. If 8th char is 'h' (weapon_Hpk2000) replace string to weapon_usp, otherwise it was m4a1.             ReplaceString(szWeapon, sizeof(szWeapon), szWeapon, (szWeapon[8] == 'h' ? "weapon_usp" : "weapon_m4a1"))         }         // Other stuff     } }
To be honest I'd like to use StrCat instead of replacing whole string (due to performance purposes), so take a look at Ammo Manager as well.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot

Last edited by Root_; 02-01-2014 at 07:58.
Root_ is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-01-2014 , 14:38   Re: [CSGO] player_hurt & player_death
Reply With Quote #4

Quote:
Originally Posted by Root_ View Post
I had similar issue with finding whether or not usp or m4a1-s was used. I found a way and implemented that in this plugin.
Here is a small snippet that I made just now, untested.
Code:
new m_bSilencerOn, m_hActiveWeapon; public OnPluginStart() {     m_bSilencerOn   = FindSendPropOffs("CWeaponCSBaseGun", "m_bSilencerOn");     m_hActiveWeapon = FindSendPropOffs("CBasePlayer",      "m_hActiveWeapon"); } public OnSomeEvent() {     // Declare weapon string and player slot     decl String:szWeapon[MAX_NAME_LENGTH], slot; // Make sure slot is valid and we can retrieve its classname     if ((slot = GetEntDataEnt2(client, m_hActiveWeapon)) != -1 && GetEdictClassname(slot, szWeapon, sizeof(szWeapon)))     {         // Check whether or not silencer is inserted         if (bool:GetEntData(slot, m_bSilencerOn, true) == true)         {             // Replace whole weapon string appropriately. If 8th char is 'h' (weapon_Hpk2000) replace string to weapon_usp, otherwise it was m4a1.             ReplaceString(szWeapon, sizeof(szWeapon), szWeapon, (szWeapon[8] == 'h' ? "weapon_usp" : "weapon_m4a1"))         }         // Other stuff     } }
To be honest I'd like to use StrCat instead of replacing whole string (due to performance purposes), so take a look at Ammo Manager as well.
Is that not causing problem if you remove the silencer from the gun?
Mathias. is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-01-2014 , 15:31   Re: [CSGO] player_hurt & player_death
Reply With Quote #5

Black-Rabbit, I have no idea so far, because silencer check made when weapon just created in Ammo Manager. It's enough for me.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-01-2014 , 23:10   Re: [CSGO] player_hurt & player_death
Reply With Quote #6

But you looking if the the silencer is ON, so if I get a usp and I remove the silencer from it manually in-game and kill someone it will still cause the issue isnt?
Mathias. is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-02-2014 , 07:32   Re: [CSGO] player_hurt & player_death
Reply With Quote #7

Quote:
Originally Posted by Black-Rabbit View Post
But you looking if the the silencer is ON, so if I get a usp and I remove the silencer from it manually in-game and kill someone it will still cause the issue isnt?
Just test it out and tell whether or not issue occurs.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 02-02-2014 , 17:41   Re: [CSGO] player_hurt & player_death
Reply With Quote #8

Thanks for that. I will have a play around tonight and see what happens. For the moment I have just forced it to use m4a1 or hkp2000 for player death atm.
__________________
versatile_bfg is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-02-2014 , 22:36   Re: [CSGO] player_hurt & player_death
Reply With Quote #9

Quote:
Originally Posted by Root_ View Post
Just test it out and tell whether or not issue occurs.
Don't need to, the answer is already wrote.
Mathias. is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 02-13-2014 , 19:09   Re: [CSGO] player_hurt & player_death
Reply With Quote #10

FFS now it is happening with cz75a being p250 for player hurt and weapon fire but cz75a on player death. =(

Is this a sourcemod thing or a csgo [valve] thing?
__________________
versatile_bfg 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 21:18.


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