Raised This Month: $ Target: $400
 0% 

Solved (HELP) Detect self grenade kill


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
E1_531G
Senior Member
Join Date: Dec 2017
Old 06-07-2018 , 16:16   Re: (HELP) Detect self grenade kill
Reply With Quote #1

Quote:
if(Killer == Victim && get_user_weapon(Killer) == CSW_HEGRENADE)
So, guys, are you trying to see what gun the killer has when he is victim? (this means he's already dead)... *insert_facepalm_meme_here*

Use read_data(4) to see how the victim died.
__________________
My English is A0

Last edited by E1_531G; 06-07-2018 at 16:17.
E1_531G is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-07-2018 , 20:15   Re: (HELP) Detect self grenade kill
Reply With Quote #2

Even if the killer wasn't the victim, when a grenade is thrown the player (killer) switches back to a primary or secondary by the time the grenade explodes and potentially kills someone. You cannot use get_user_weapon() on the thrower of a grenade.
PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
register_event"DeathMsg" "DeathMsg" "a" "4=grenade" "1>0" );
}

public 
DeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);

    if ( 
iKiller == iVictim )
    {
        new 
szName32 ];
        
get_user_nameiVictim szName charsmaxszName ) );
    
        
client_printprint_chat "%s killed by grenade" szName );
    }

__________________

Last edited by Bugsy; 06-07-2018 at 20:17.
Bugsy is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-08-2018 , 08:26   Re: (HELP) Detect self grenade kill
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Even if the killer wasn't the victim, when a grenade is thrown the player (killer) switches back to a primary or secondary by the time the grenade explodes and potentially kills someone. You cannot use get_user_weapon() on the thrower of a grenade.
PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
register_event"DeathMsg" "DeathMsg" "a" "4=grenade" "1>0" );
}

public 
DeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);

    if ( 
iKiller == iVictim )
    {
        new 
szName32 ];
        
get_user_nameiVictim szName charsmaxszName ) );
    
        
client_printprint_chat "%s killed by grenade" szName );
    }

Some tutorials point to get_user_weapon anyway, i did not remember if is in the killer or victim, but also works with param 4

Quote:
Originally Posted by CrazY. View Post
I'm not trying to chage his way. Ham_Killed is better in my opnion, otherwise amx developers team would not need add, or I'm wrong? Think about this.
"Ham_Killed is better in my opnion"

But not, is not...
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-08-2018 at 08:26.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 04:40.


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