Raised This Month: $ Target: $400
 0% 

Ammo reload on kill


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-03-2009 , 00:59   Re: Ammo reload on kill
Reply With Quote #15

Try this version :

Untested :
PHP Code:
// #define GIVE_BPAMMO

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.2"

#define FIRST_PLAYER_ID        1

#define XTRA_OFS_WEAPON        4
#define m_iPrimaryAmmoType    49
#define m_fInReload            54

#define XTRA_OFS_PLAYER        5
#define m_LastHitGroup        75
#define m_pActiveItem        373
#define m_rgAmmo_Player_Slot0    376

#define ammo_338magnum        1
#define ammo_9mm            10

#if defined GIVE_BPAMMO
    
new const g_iMaxBpAmmo[] = {
        
0,
        
30,    // ammo_338magnum
        
90,    // ammo_762nato
        
200,    // ammo_556natobox
        
90,    // ammo_556nato
        
32,    // ammo_buckshot
        
100,    // ammo_45acp
        
100,    // ammo_57mm
        
35,    // ammo_50ae
        
52,    // ammo_357sig
        
120,    // ammo_9mm
        
2,    // ammo_flashbang
        
1,    // ammo_hegrenade
        
1,    // ammo_smokegrenade
        
1    // ammo_c4
    
}
#endif

new g_iMaxPlayers
#define IsPlayer(%1)    ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

public plugin_init()
{
    
register_plugin("Refill Weapon On Kill"VERSION"ConnorMcLeod")

    
RegisterHam(Ham_Killed"player""Player_Killed"1)

    
g_iMaxPlayers get_maxplayers()
}

public 
Player_Killed(iVictimiKiller/*, iGib*/)
{
    if(    
IsPlayer(iKiller)
    &&    
is_user_alive(iKiller)
    &&    
get_pdata_int(iVictimm_LastHitGroupXTRA_OFS_PLAYER)    ) // 0 on DMG_GRENADE
    
{
        new 
iWeapon get_pdata_cbase(iKillerm_pActiveItemXTRA_OFS_PLAYER)
        if( 
iWeapon )
        {
            new 
iPrimaryAmmoType get_pdata_int(iWeaponm_iPrimaryAmmoTypeXTRA_OFS_WEAPON)
            if( 
ammo_338magnum <= iPrimaryAmmoType <= ammo_9mm )
            {
                
#if !defined GIVE_BPAMMO
                    
if( get_pdata_int(iKillerm_rgAmmo_Player_Slot0 iPrimaryAmmoTypeXTRA_OFS_PLAYER) <= )
                    {
                        return
                    }
                
#endif
                
set_pdata_int(iWeaponm_fInReloadtrueXTRA_OFS_WEAPON)
            }
        
#if defined GIVE_BPAMMO
                    
set_pdata_int(iKillerm_rgAmmo_Player_Slot0 iPrimaryAmmoTypeg_iMaxBpAmmo[iPrimaryAmmoType], XTRA_OFS_WEAPON)
        
#endif
        
}
    }


Old version
Code:
//#define GIVE_BPAMMO

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Refill Weapon On Kill"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

#define m_iId                43
#define m_iPrimaryAmmoType    49
#define m_fInReload            54

#define m_flNextAttack    83
#define m_pActiveItem    373
#define m_rgAmmo_Player_Slot0    376

#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

const NOCLIP_WPN_BS    = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))

new g_iMaxPlayers

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	RegisterHam(Ham_Killed, "player", "Player_Killed", 1)

	g_iMaxPlayers = get_maxplayers()
}

public Player_Killed(iVictim, iKiller, iGib)
{
	if( IsPlayer(iKiller) && is_user_alive(iKiller) )
	{
		new iWeapon = get_pdata_cbase(iKiller, m_pActiveItem)
		if(    iWeapon > 0
		&&    !( NOCLIP_WPN_BS & (1<<get_pdata_int(iWeapon, m_iId, 4)) )    )
		{
		//	set_pdata_float(iKiller, m_flNextAttack, -0.001, 5)

			set_pdata_int(iWeapon, m_fInReload, 1, 4)
		//	ExecuteHamB(Ham_Item_PostFrame, iWeapon)

#if defined GIVE_BPAMMO
			set_pdata_int(iKiller, m_rgAmmo_Player_Slot0 + get_pdata_int(iWeapon, m_iPrimaryAmmoType, 4), 200)
#endif
		}
	}
}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-06-2010 at 13:15.
ConnorMcLeod is offline
 



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 15:46.


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