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 , 10:15   Re: Double kill with a grenade
Reply With Quote #1

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 #2

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 #3

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 #4

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
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 03:25.


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