Advertisement
Tibers

csgo inspect weapon by O-Zone

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