Approved No Recoil (1 round)

Zombies/Humans Extra-Items
Post Reply
User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

No Recoil (1 round)

#1

Post by Mark » 5 years ago

No - Recoil 1 Round


Description:
  • A new extra-item for Humans, No Recoil (1 round)



  1. #include <zombie_escape>
  2. #include <xs>
  3.  
  4. new g_norecoil[33]
  5. new Float: cl_pushangle[33][3]
  6. new g_itemid_norecoil, g_maxplayers
  7.  
  8. const WEAPONS_BITSUM = (1<<CSW_KNIFE|1<<CSW_HEGRENADE|1<<CSW_FLASHBANG|1<<CSW_SMOKEGRENADE|1<<CSW_C4)
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin("[ZE] Extra Item: No Recoil", "1.0", "Mark")
  13.  
  14.     g_itemid_norecoil = ze_register_item("No Recoil (Single Round)", 50, 0)
  15.  
  16.     new weapon_name[24]
  17.     for (new i = 1; i <= 30; i++)
  18.     {
  19.         if (!(WEAPONS_BITSUM & 1 << i) && get_weaponname(i, weapon_name, 23))
  20.         {
  21.             RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Pre")
  22.             RegisterHam(Ham_Weapon_PrimaryAttack, weapon_name, "fw_Weapon_PrimaryAttack_Post", 1)
  23.         }
  24.     }
  25.  
  26.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  27.  
  28.     g_maxplayers = get_maxplayers()
  29. }
  30.  
  31. public ze_select_item_pre(id, itemid)
  32. {
  33.     if (itemid != g_itemid_norecoil)
  34.         return ZE_ITEM_AVAILABLE
  35.    
  36.     if (ze_is_user_zombie(id))
  37.         return ZE_ITEM_DONT_SHOW
  38.        
  39.     return ZE_ITEM_AVAILABLE
  40. }
  41.  
  42. public ze_select_item_post(id, itemid)
  43. {
  44.     if (itemid != g_itemid_norecoil)
  45.         return
  46.  
  47.     ze_colored_print(id, "Congrats! You have bought No Recoil! :D")
  48.    
  49.     Get_NoRecoil(id)
  50. }
  51.  
  52. public Get_NoRecoil(id)
  53. {
  54.     g_norecoil[id] = true
  55. }
  56.  
  57. public ze_user_humanized(id)
  58. {
  59.     g_norecoil[id] = false
  60. }
  61.  
  62. public ze_user_infected(iVictim)
  63. {
  64.     g_norecoil[iVictim] = false
  65. }
  66.  
  67.  
  68. public client_connect(id)
  69. {
  70.     g_norecoil[id] = false
  71. }
  72.  
  73. public event_round_start()
  74. {
  75.     for (new id = 1; id <= g_maxplayers; id++)
  76.         g_norecoil[id] = false
  77. }
  78.  
  79. public fw_Weapon_PrimaryAttack_Pre(entity)
  80. {
  81.     new id = pev(entity, pev_owner)
  82.  
  83.     if (g_norecoil[id])
  84.     {
  85.         pev(id, pev_punchangle, cl_pushangle[id])
  86.         return HAM_IGNORED;
  87.     }
  88.     return HAM_IGNORED;
  89. }
  90.  
  91. public fw_Weapon_PrimaryAttack_Post(entity)
  92. {
  93.     new id = pev(entity, pev_owner)
  94.  
  95.     if (g_norecoil[id])
  96.     {
  97.         new Float: push[3]
  98.         pev(id, pev_punchangle, push)
  99.         xs_vec_sub(push, cl_pushangle[id], push)
  100.         xs_vec_mul_scalar(push, 0.0, push)
  101.         xs_vec_add(push, cl_pushangle[id], push)
  102.         set_pev(id, pev_punchangle, push)
  103.         return HAM_IGNORED;
  104.     }
  105.     return HAM_IGNORED;
  106. }
  107.  

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 5 years ago

Nice one, +LIKE. Thanks.
He who fails to plan is planning to fail

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#3

Post by Muhammet20 » 5 years ago

+LIKE
Nice Bro

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 1 guest