Advertisement
Tibers

csgo inspect weapon by hellmonja

Mar 11th, 2024
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.41 KB | Source Code | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <engine>
  6.  
  7. const XoWeapon          = 4;
  8. const XoPlayer              = 5;
  9. const m_pPlayer         = 41;
  10. const m_flNextPrimaryAttack = 46;
  11. const m_flTimeWeaponIdle    = 48;
  12. const m_fInSpecialReload    = 55;
  13. const m_flNextAttack        = 83;
  14. const m_pActiveItem         = 373;
  15.  
  16. new const PLUGIN[]  = "CS:GO Inspect Weapon";
  17. new const VERSION[]     = "5.1.3";
  18. new const DATE[]    = "5 October 2018";
  19.  
  20. new const wpns_without_inspect = (1 << CSW_C4) | (1 << CSW_HEGRENADE) | (1 << CSW_FLASHBANG) | (1 << CSW_SMOKEGRENADE);
  21. new const wpns_scoped = (1 << CSW_AUG) | (1 << CSW_AWP) | (1 << CSW_G3SG1) | (1 << CSW_SCOUT) | (1 << CSW_SG550) | (1 << CSW_SG552);
  22.  
  23. new g_deagle_overide[33];
  24.  
  25. new inspect_anim[] =
  26. {
  27.     0//null
  28.     7//p228
  29.     0//shield
  30.     5//scout
  31.     0//hegrenade
  32.     7//xm1014
  33.     0//c4
  34.     6//mac10
  35.     6//aug
  36.     0//smoke grenade
  37.     16, //elites
  38.     6//fiveseven
  39.     6//ump45
  40.     5//sg550
  41.     6//galil
  42.     6//famas
  43.     16, //usp
  44.     13, //glock
  45.     6//awp
  46.     6//mp5
  47.     5//m249
  48.     7//m3
  49.     14, //m4a1
  50.     6//tmp
  51.     5//g3sg1
  52.     0//flashbang
  53.     6//deagle
  54.     6//sg552
  55.     6//ak47
  56.     8//knife
  57.     6   //p90
  58. }
  59.  
  60. new Float:idle_calltime[] =
  61. {
  62.     0.0,    //null
  63.     6.5,    //p228
  64.     0.0,    //shield
  65.     5.3,    //scout
  66.     0.0,    //hegrenade
  67.     4.6,    //xm1014
  68.     0.0,    //c4
  69.     5.3,    //mac10
  70.     4.4,    //aug
  71.     0.0,    //smoke grenade
  72.     4.6,    //elites
  73.     6.5,    //fiveseven
  74.     6.9,    //ump45
  75.     5.3,    //sg550
  76.     4.6,    //galil
  77.     6.4,    //famas
  78.     6.5,    //usp
  79.     6.5,    //glock
  80.     5.0,    //awp
  81.     7.7,    //mp5
  82.     6.9,    //m249
  83.     5.6,    //m3
  84.     5.1,    //m4a1
  85.     7.4,    //tmp
  86.     4.5,    //g3sg1
  87.     0.0,    //flashbang
  88.     5.7,    //deagle
  89.     4.4,    //sg552
  90.     4.6,    //ak47
  91.     6.3,    //knife
  92.     5.4 //p90
  93. }
  94.  
  95. new weapon_classnames[][] =
  96. {
  97.     "weapon_p228",
  98.     "weapon_elite",
  99.     "weapon_fiveseven",
  100.     "weapon_usp",
  101.     "weapon_glock18",
  102.     "weapon_deagle",
  103.     "weapon_ak47",
  104.     "weapon_m4a1",
  105.     "weapon_awp",
  106.     "weapon_mp5navy",
  107.     "weapon_ump45",
  108.     "weapon_galil",
  109.     "weapon_famas",
  110.     "weapon_sg552",
  111.     "weapon_aug",
  112.     "weapon_mac10",
  113.     "weapon_tmp",
  114.     "weapon_scout",
  115.     "weapon_m3",
  116.     "weapon_xm1014",
  117.     "weapon_g3sg1",
  118.     "weapon_sg550",
  119.     "weapon_m249",
  120.     "weapon_knife",
  121.     "weapon_p90"
  122.    
  123. }
  124.  
  125. public plugin_init()
  126. {
  127.     register_plugin(PLUGIN, VERSION, "hellmonja");
  128.    
  129.     for(new i = 0; i < sizeof weapon_classnames; i++)
  130.         RegisterHam(Ham_Weapon_PrimaryAttack, weapon_classnames[i], "Fw_Weapon_PrimaryAttack", 1);
  131.  
  132.     RegisterHam(Ham_Item_Deploy, "weapon_deagle", "Fw_Deagle_Disable");
  133.     RegisterHam(Ham_Weapon_Reload, "weapon_deagle", "Fw_Deagle_Disable");
  134.    
  135.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_aug", "Fw_Weapon_SecondaryAttack");
  136.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_awp", "Fw_Weapon_SecondaryAttack");
  137.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_g3sg1", "Fw_Weapon_SecondaryAttack");
  138.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_scout", "Fw_Weapon_SecondaryAttack");
  139.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_sg550", "Fw_Weapon_SecondaryAttack");
  140.     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_sg552", "Fw_Weapon_SecondaryAttack");
  141.    
  142.     register_impulse(100, "Inspect_Weapon")
  143. }
  144.  
  145. public Code_Version(id)
  146. {
  147.     console_print(id, "==============================");
  148.     console_print(id, "%s v%s", PLUGIN, VERSION);
  149.     console_print(id, "%s", DATE);
  150.     console_print(id, "==============================");
  151. }
  152.  
  153. public Fw_Weapon_PrimaryAttack(weapon)
  154. {
  155.     static id;
  156.     id = get_pdata_cbase(weapon, m_pPlayer, XoWeapon);
  157.    
  158.     if(!is_user_alive(id))
  159.         return
  160.    
  161.     new wpn_id = get_user_weapon(id);
  162.     static model[32];
  163.     pev(id, pev_viewmodel2, model, 31);
  164.            
  165.     switch(wpn_id)
  166.     {
  167.         case CSW_DEAGLE:
  168.             g_deagle_overide[id] = 1;
  169.         case CSW_AWP, CSW_SCOUT, CSW_M3:
  170.             set_pdata_float(weapon, m_flTimeWeaponIdle, 1.5, XoWeapon);
  171.         case CSW_KNIFE:
  172.             set_pdata_float(weapon, m_flTimeWeaponIdle, 2.0, XoWeapon);
  173.         default:
  174.             set_pdata_float(weapon, m_flTimeWeaponIdle, 0.5, XoWeapon);
  175.     }
  176. }
  177.  
  178. public Fw_Weapon_SecondaryAttack(weapon)
  179. {
  180.     static id;
  181.     id = get_pdata_cbase(weapon, m_pPlayer, XoWeapon);
  182.     new wpn_id = get_user_weapon(id);
  183.    
  184.     if(wpns_scoped & (1 << wpn_id) && cs_get_user_zoom(id) <= 1)
  185.     {
  186.         set_pev(id, pev_weaponanim, 0);
  187.    
  188.         message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id);
  189.         write_byte(0);
  190.         write_byte(pev(id, pev_body));
  191.         message_end();
  192.     }
  193. }
  194.  
  195. public Fw_Deagle_Disable(weapon)
  196. {
  197.     static id;
  198.     id = get_pdata_cbase(weapon, m_pPlayer, XoWeapon);
  199.     remove_task(id)
  200. }
  201.  
  202. public Deagle_Overide(id)
  203.     g_deagle_overide[id] = 1;
  204.    
  205. public Inspect_Weapon(id)
  206. {
  207.     if(!is_user_alive(id) || !is_user_connected(id))
  208.         return PLUGIN_HANDLED
  209.        
  210.     if(cs_get_user_shield(id))
  211.         return PLUGIN_HANDLED
  212.        
  213.     if(cs_get_user_zoom(id) > 1)
  214.         return PLUGIN_HANDLED
  215.    
  216.     new wpn_id = get_user_weapon(id);
  217.    
  218.     if(wpns_without_inspect & (1 << wpn_id))
  219.         return PLUGIN_HANDLED
  220.  
  221.     static weapon; weapon = get_pdata_cbase(id, m_pActiveItem);
  222.     static Float:flNextAttack; flNextAttack = get_pdata_float(id, m_flNextAttack, XoPlayer);
  223.     static Float:flNextPrimaryAttack; flNextPrimaryAttack = get_pdata_float(weapon, m_flNextPrimaryAttack, XoWeapon);
  224.  
  225.     if(flNextAttack <= 0 && flNextPrimaryAttack <= 0)
  226.     {  
  227.         static model[32]; pev(id, pev_viewmodel2, model, 31);
  228.            
  229.         new anim = inspect_anim[wpn_id];
  230.         new current_anim = pev(get_pdata_cbase(weapon, m_pPlayer, XoWeapon), pev_weaponanim);
  231.  
  232.         switch (wpn_id)
  233.         {
  234.             case CSW_USP: if(!cs_get_weapon_silen(weapon)) anim = 17;
  235.             case CSW_M4A1:if(!cs_get_weapon_silen(weapon)) anim = 15;
  236.             case CSW_KNIFE: anim = random_num(8, 10);
  237.             case CSW_DEAGLE:
  238.             {
  239.                 if(wpn_id == CSW_DEAGLE && g_deagle_overide[id] == 1)
  240.                 {
  241.                     anim = random_num(6, 10);
  242.  
  243.                     new Float:f_temp;
  244.                     if(anim == 10) f_temp = 8.53;
  245.                     else f_temp = idle_calltime[CSW_DEAGLE]
  246.                        
  247.                     play_inspect(id, anim);
  248.                     remove_task(id);
  249.                     g_deagle_overide[id] = 0;
  250.                     set_task(f_temp, "Deagle_Overide", id);
  251.                     return PLUGIN_CONTINUE
  252.                 }
  253.             }
  254.         }
  255.            
  256.         if(wpn_id == CSW_KNIFE && (current_anim == 8 || current_anim == 9 || current_anim == 10 ))
  257.             return PLUGIN_HANDLED
  258.            
  259.         if(!get_pdata_int(weapon, m_fInSpecialReload, 4) && current_anim != anim)
  260.         {
  261.             play_inspect(id, anim);
  262.             set_pdata_float(weapon, m_flTimeWeaponIdle, idle_calltime[wpn_id], XoWeapon);
  263.         }
  264.     }
  265.    
  266.     return PLUGIN_CONTINUE
  267. }
  268.  
  269. play_inspect(id, anim)
  270. {
  271.     set_pev(id, pev_weaponanim, anim);
  272.    
  273.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id);
  274.     write_byte(anim);
  275.     write_byte(pev(id, pev_body));
  276.     message_end()
  277. }
  278.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement