No - Recoil 1 Round
Description:
- A new extra-item for Humans, No Recoil (1 round)
- #include <zombie_escape>
- #include <xs>
- new g_norecoil[33]
- new Float: cl_pushangle[33][3]
- new g_itemid_norecoil, g_maxplayers
- const WEAPONS_BITSUM = (1<<CSW_KNIFE|1<<CSW_HEGRENADE|1<<CSW_FLASHBANG|1<<CSW_SMOKEGRENADE|1<<CSW_C4)
- public plugin_init()
- {
- register_plugin("[ZE] Extra Item: No Recoil", "1.0", "Mark")
- g_itemid_norecoil = ze_register_item("No Recoil (Single Round)", 50, 0)
- 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()
- }
- public ze_select_item_pre(id, itemid)
- {
- if (itemid != g_itemid_norecoil)
- return ZE_ITEM_AVAILABLE
- if (ze_is_user_zombie(id))
- return ZE_ITEM_DONT_SHOW
- return ZE_ITEM_AVAILABLE
- }
- public ze_select_item_post(id, itemid)
- {
- if (itemid != g_itemid_norecoil)
- return
- ze_colored_print(id, "Congrats! You have bought No Recoil! :D")
- Get_NoRecoil(id)
- }
- public Get_NoRecoil(id)
- {
- g_norecoil[id] = true
- }
- public ze_user_humanized(id)
- {
- g_norecoil[id] = false
- }
- public ze_user_infected(iVictim)
- {
- g_norecoil[iVictim] = 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
- }
- 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;
- }