Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <fakemeta>
  4. #include <engine>
  5. #include <hamsandwich>
  6. #include <csgomod>
  7.  
  8. #define PLUGIN "CS:GO Inspect"
  9. #define AUTHOR "O'Zone"
  10. #define VALID_PDATA 2
  11.  
  12. new const weaponsWithoutInspect = (1<<CSW_C4) | (1<<CSW_HEGRENADE) | (1<<CSW_FLASHBANG) | (1<<CSW_SMOKEGRENADE);
  13.  
  14. new bool:deagleDisable[MAX_PLAYERS + 1];
  15.  
  16. new inspectAnimation[] =
  17. {
  18. 0, //null
  19. 7, //p228
  20. 0, //shield
  21. 5, //scout
  22. 0, //hegrenade
  23. 7, //xm1014
  24. 0, //c4
  25. 6, //mac10
  26. 6, //aug
  27. 0, //smoke grenade
  28. 16, //elites
  29. 6, //fiveseven
  30. 6, //ump45
  31. 5, //sg550
  32. 6, //galil
  33. 6, //famas
  34. 16, //usp
  35. 13, //glock
  36. 6, //awp
  37. 6, //mp5
  38. 5, //m249
  39. 7, //m3
  40. 14, //m4a1
  41. 6, //tmp
  42. 5, //g3sg1
  43. 0, //flashbang
  44. 6, //deagle
  45. 6, //sg552
  46. 6, //ak47
  47. 8, //knife
  48. 6 //p90
  49. };
  50.  
  51. public plugin_init()
  52. {
  53. register_plugin(PLUGIN, VERSION, AUTHOR);
  54.  
  55. RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "deagle_reload");
  56. RegisterHam(Ham_Item_Deploy, "weapon_deagle", "deagle_override");
  57. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "deagle_override");
  58. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "knife_override");
  59.  
  60. register_impulse(100, "inspect_weapon");
  61. }
  62.  
  63. public deagle_reload(weapon)
  64. {
  65. if (pev_valid(weapon) != VALID_PDATA) return HAM_IGNORED;
  66.  
  67. new id = get_pdata_cbase(weapon, OFFSET_PLAYER, OFFSET_ITEM_LINUX);
  68.  
  69. remove_task(id);
  70.  
  71. if (!pev_valid(id) || !is_user_alive(id)) return HAM_IGNORED;
  72.  
  73. deagleDisable[id] = true;
  74.  
  75. set_task(2.5, "deagle_enable", id);
  76.  
  77. return HAM_IGNORED;
  78. }
  79.  
  80. public deagle_override(weapon)
  81. {
  82. if (pev_valid(weapon) != VALID_PDATA) return HAM_IGNORED;
  83.  
  84. new id = get_pdata_cbase(weapon, OFFSET_PLAYER, OFFSET_ITEM_LINUX);
  85.  
  86. remove_task(id);
  87.  
  88. if (!pev_valid(id) || !is_user_alive(id)) return HAM_IGNORED;
  89.  
  90. deagleDisable[id] = true;
  91.  
  92. set_task(0.8, "deagle_enable", id);
  93.  
  94. return HAM_IGNORED;
  95. }
  96.  
  97. public knife_override(weapon)
  98. {
  99. if (pev_valid(weapon) != VALID_PDATA) return HAM_IGNORED;
  100.  
  101. set_pdata_float(weapon, OFFSET_WEAPON_IDLE, 0.8, OFFSET_ITEM_LINUX);
  102.  
  103. return HAM_IGNORED;
  104. }
  105.  
  106. public deagle_enable(id)
  107. deagleDisable[id] = false;
  108.  
  109. public inspect_weapon(id)
  110. {
  111. if (pev_valid(id) != VALID_PDATA || !is_user_alive(id) || cs_get_user_shield(id) || cs_get_user_zoom(id) > 1)
  112. {
  113. return PLUGIN_HANDLED;
  114. }
  115.  
  116. new weaponId = get_user_weapon(id),
  117. weapon = get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_PLAYER_LINUX);
  118.  
  119. if (weaponsWithoutInspect & (1<<weaponId) || !pev_valid(weapon)) return PLUGIN_HANDLED;
  120.  
  121. new animation = inspectAnimation[weaponId], currentAnimation = pev(get_pdata_cbase(weapon, OFFSET_PLAYER, OFFSET_ITEM_LINUX), pev_weaponanim);
  122.  
  123. switch (weaponId) {
  124. case CSW_M4A1: {
  125. if (!cs_get_weapon_silen(weapon)) animation = 15;
  126.  
  127. if (!currentAnimation || currentAnimation == 7 || currentAnimation == animation) play_inspect(id, weapon, animation);
  128. } case CSW_USP: {
  129. if (!cs_get_weapon_silen(weapon)) animation = 17;
  130.  
  131. if (!currentAnimation || currentAnimation == 8 || currentAnimation == animation) play_inspect(id, weapon, animation);
  132. } case CSW_DEAGLE: {
  133. if (!deagleDisable[id]) play_inspect(id, weapon, animation);
  134. } case CSW_GLOCK18: {
  135. if (!currentAnimation || currentAnimation == 1 || currentAnimation == 2 || currentAnimation == 9 || currentAnimation == 10 || currentAnimation == animation) play_inspect(id, weapon, animation);
  136. } default: {
  137. if (!currentAnimation || currentAnimation == animation) play_inspect(id, weapon, animation);
  138. }
  139. }
  140.  
  141. return PLUGIN_HANDLED;
  142. }
  143.  
  144. stock play_inspect(id, weapon, animation)
  145. {
  146. set_pdata_float(weapon, OFFSET_WEAPON_IDLE, 7.0, OFFSET_ITEM_LINUX);
  147. set_pev(id, pev_weaponanim, animation);
  148.  
  149. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id);
  150. write_byte(animation);
  151. write_byte(pev(id, pev_body));
  152. message_end();
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement