|
Veteran Member
Join Date: Jul 2006
Location: France (95)
|

04-03-2009
, 00:59
Re: Ammo reload on kill
|
#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(iVictim, iKiller/*, iGib*/)
{
if( IsPlayer(iKiller)
&& is_user_alive(iKiller)
&& get_pdata_int(iVictim, m_LastHitGroup, XTRA_OFS_PLAYER) ) // 0 on DMG_GRENADE
{
new iWeapon = get_pdata_cbase(iKiller, m_pActiveItem, XTRA_OFS_PLAYER)
if( iWeapon > 0 )
{
new iPrimaryAmmoType = get_pdata_int(iWeapon, m_iPrimaryAmmoType, XTRA_OFS_WEAPON)
if( ammo_338magnum <= iPrimaryAmmoType <= ammo_9mm )
{
#if !defined GIVE_BPAMMO
if( get_pdata_int(iKiller, m_rgAmmo_Player_Slot0 + iPrimaryAmmoType, XTRA_OFS_PLAYER) <= 0 )
{
return
}
#endif
set_pdata_int(iWeapon, m_fInReload, true, XTRA_OFS_WEAPON)
}
#if defined GIVE_BPAMMO
set_pdata_int(iKiller, m_rgAmmo_Player_Slot0 + iPrimaryAmmoType, g_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
}
}
}
__________________
Last edited by ConnorMcLeod; 05-06-2010 at 13:15.
|
|