Raised This Month: $ Target: $400
 0% 

Double kill with a grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-07-2011 , 09:17   Double kill with a grenade
Reply With Quote #1

Hello.

I'd like to know how to detect when two players are killed by 1 grenade.
I'm not sure if deathmsg defines the killer properly when it's done by grenade, so:
1. Is the killer in DeathMsg index of player who actually killed someone with grenade? If so, is the grenade's string "hegren", as it is for all other weapons?
2. How do I detect if it was a double kill?

For the second point, I think the gametime for both the kills should be the same, but I'm not sure.
Backstabnoob is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-07-2011 , 09:53   Re: Double kill with a grenade
Reply With Quote #2

Yes, killer is the player index and it's "hegren"... you could've just tested by debugging deathmsg

And yeah, game time + killer check should be ok, but they don't have to match exacly, you can allow at least 1 second for error because a player can't throw grenades faster than 1 second AFAIK.
__________________
Hunter-Digital is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-07-2011 , 10:15   Re: Double kill with a grenade
Reply With Quote #3

In DeathMsg if(equali(weapon, "hegren")) works not.

Edit: The weapon name is actually "grenade"

Last edited by Backstabnoob; 08-07-2011 at 10:21.
Backstabnoob is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-07-2011 , 10:37   Re: Double kill with a grenade
Reply With Quote #4

See, it took you 5 minutes to test it out (the additional minute to edit your post )
__________________
Hunter-Digital is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-07-2011 , 12:24   Re: Double kill with a grenade
Reply With Quote #5

There may be a better way but this works. It will notify via client_print if more than 1 kill is made with the same grenade.
PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <fakemeta>
#include <celltrie>

new const Version[] = "0.1";

new 
Trie:g_Trie;

public 
plugin_init() 
{
    
register_plugin"Multi Grenade Kill" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
    
register_think"grenade" "fw_GrenadeThink" );

    
g_Trie TrieCreate();
}

public 
plugin_end()
{
    
TrieDestroyg_Trie );
}

public 
fw_GrenadeThinkiEntity 
{
    
//This gets called 3 times when the condition ( get_gametime() > entity_get_float( iEntity, EV_FL_dmgtime ) is checked.
    //The third and last time always occurred at approx 0.650005 in my tests.
    
if( !is_valid_entiEntity ) || ( ( get_gametime() - entity_get_floatiEntityEV_FL_dmgtime ) ) < 0.64 ) )
        return;
    
    new 
szKey];
    
num_to_striEntity szKey charsmaxszKey ) );
    
    if ( 
TrieKeyExistsg_Trie szKey ) )
    {
        new 
iKills;
        
TrieGetCellg_Trie szKey iKills );
        
        if ( 
iKills )
        {
            new 
szOwner] , iKiller szName33 ]
            
formatexszOwner charsmaxszOwner ) , "%s%s" szKey "OWNER" );
            
TrieGetCellg_Trie szOwner iKiller );
            
            
get_user_nameiKiller szName charsmaxszName ) );
            
client_printprint_chat "* %s's grenade killed %d players!" szName iKills );
            
            
TrieDeleteKeyg_Trie szOwner );
        }
        
        
TrieDeleteKeyg_Trie szKey );
    }
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iDamageBits )
{
    if ( 
iInflictor && ( iInflictor != iAttacker ) && !is_user_aliveiVictim ) && ( fm_cs_get_grenade_typeiInflictor ) == CSW_HEGRENADE ) )
    {
        new 
szKey] , szOwner] , iKillCount;
        
num_to_striInflictor szKey charsmaxszKey ) );
        
formatexszOwner charsmaxszOwner ) , "%sOWNER" szKey );
        
TrieGetCellg_Trie szKey iKillCount );
        
TrieSetCellg_Trie szKey , ++iKillCount );
        
TrieSetCellg_Trie szOwner iAttacker );
    }
}

fm_cs_get_grenade_typeindex 
{
    if (!
pev_valid(index))
        return 
0
    
    
new classname[9]
    
pev(indexpev_classnameclassname8)
    if (!
equal(classname"grenade"))
        return 
0
    
    
if (get_pdata_int(index96) & (1<<8))
        return 
CSW_C4
    
    
new bits get_pdata_int(index114)
    if (
bits & (1<<0))
        return 
CSW_HEGRENADE
    
else if (bits & (1<<1))
        return 
CSW_SMOKEGRENADE
    
else if (!bits)
        return 
CSW_FLASHBANG
    
    
return 0

__________________

Last edited by Bugsy; 08-07-2011 at 12:27.
Bugsy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-07-2011 , 16:54   Re: Double kill with a grenade
Reply With Quote #6

I prefer this method:
Code:
#include <amxmodx> #include <csx> #include <hamsandwich> new g_grenadeKills[33] public plugin_init() {     RegisterHam(Ham_Think, "grenade", "FwdGrenadeThink") } public FwdGrenadeThink(ent) {     if(!pev(ent, pev_bInDuck)) {         new Float:dmgtime         pev(ent, pev_dmgtime, dmgtime)                 if(dmgtime <= get_gametime()) {             g_grenadeKills[pev(ent, pev_owner)] = 0             set_pev(ent, pev_bInDuck, 1)         }     } } public client_death(victim, killer, weapon, hitPlace, teamKill) {     if(weapon == CSW_HEGRENADE && ++g_grenadeKills[killer] > 1) {         // more than 1 kill for nade     } }

The only difference with my method is that you can't properly check for more than 1 kill number without using tasks and more stuff.
But with bugsy's code, it's easy to check for more than 1 kill number.
(By more than 1 kill number, I mean checking for 2 or 3 kills)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-07-2011 , 17:20   Re: Double kill with a grenade
Reply With Quote #7

Is it the same with other weapons?
SpeeDeeR is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-07-2011 , 17:36   Re: Double kill with a grenade
Reply With Quote #8

Quote:
Originally Posted by SpeeDeeR View Post
Is it the same with other weapons?
No, that's for grenades only.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-07-2011 , 17:50   Re: Double kill with a grenade
Reply With Quote #9

Could you show me how can it be made with the other weapons.
SpeeDeeR is offline
r14170
Veteran Member
Join Date: Dec 2009
Old 08-07-2011 , 18:12   Re: Double kill with a grenade
Reply With Quote #10

deleted.

Last edited by r14170; 08-07-2011 at 18:13. Reason: wrong thread.
r14170 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 14:39.


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