Try this one...
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>
#include <zmvip>
new g_norecoil[33]
new Float: cl_pushangle[33][3]
new g_itemid_norecoil, g_maxplayers
// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif
const OFFSET_LINUX_WEAPONS = 4
// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20,
10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
new g_has_unlimited_clip[33]
const WEAPONS_BITSUM = (1<<CSW_KNIFE|1<<CSW_HEGRENADE|1<<CSW_FLASHBANG|1<<CSW_SMOKEGRENADE|1<<CSW_C4)
public plugin_init()
{
register_plugin("[ZP] Extra Item: No Recoil+Unlimited Clip", "0.1.0", "CarsonMotion")
g_itemid_norecoil = zv_register_extra_item("No Recoil+Unlimited Clip", "(Single Round)", 15, ZV_TEAM_HUMAN)
new weapon_name[24]
for (new i = 1; i <= 30; i++)
{
if (!(WEAPONS_BITSUM & 1 << i) && get_weaponname(i, weapon_name, 23))
{
RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre")
RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Post", 1)
}
}
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
g_maxplayers = get_maxplayers()
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}
public zv_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_norecoil)
{
g_norecoil[player] = true
g_has_unlimited_clip[player] = true
client_print(player, print_chat, "[ZP] You have bought No Recoil+Unlimited Clip for your weapon!")
}
}
public zp_user_infected_post(id)
g_norecoil[id] = false
public client_connect(id)
g_norecoil[id] = false
public event_round_start()
{
for (new id = 1; id <= g_maxplayers; id++)
{
g_norecoil[id] = false
g_has_unlimited_clip[id] = false
}
}
public fw_Weapon_PrimaryAttack_Pre(entity)
{
new id = pev(entity, pev_owner)
if (g_norecoil[id])
{
pev(id, pev_punchangle, cl_pushangle[id])
return HAM_IGNORED;
}
return HAM_IGNORED;
}
public fw_Weapon_PrimaryAttack_Post(entity)
{
new id = pev(entity, pev_owner)
if (g_norecoil[id])
{
new Float: push[3]
pev(id, pev_punchangle, push)
xs_vec_sub(push, cl_pushangle[id], push)
xs_vec_mul_scalar(push, 0.0, push)
xs_vec_add(push, cl_pushangle[id], push)
set_pev(id, pev_punchangle, push)
return HAM_IGNORED;
}
return HAM_IGNORED;
}
// Unlimited clip code
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
// Player doesn't have the unlimited clip upgrade
if (!g_has_unlimited_clip[msg_entity])
return;
// Player not alive or not an active weapon
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
return;
static weapon, clip
weapon = get_msg_arg_int(2) // get weapon ID
clip = get_msg_arg_int(3) // get weapon clip
// Unlimited Clip Ammo
if (MAXCLIP[weapon] > 2) // skip grenades
{
set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
if (clip < 2) // refill when clip is nearly empty
{
// Get the weapon entity
static wname[32], weapon_ent
get_weaponname(weapon, wname, sizeof wname - 1)
weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
// Set max clip on weapon
fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
}
}
}
// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
return entity;
}
// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entity, amount)
{
set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}