GaMeRFoReVeR

Fast reload

Jul 3rd, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.76 KB | None | 0 0
  1. /*  Copyright © 2009, ConnorMcLeod
  2.  
  3.     Reload Status Bar is free software;
  4.     you can redistribute it and/or modify it under the terms of the
  5.     GNU General Public License as published by the Free Software Foundation.
  6.  
  7.     This program is distributed in the hope that it will be useful,
  8.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.     GNU General Public License for more details.
  11.  
  12.     You should have received a copy of the GNU General Public License
  13.     along with Reload Status Bar; if not, write to the
  14.     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15.     Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. #include <amxmodx>
  19. #include <fakemeta>
  20. #include <hamsandwich>
  21.  
  22. #define PLUGIN "Reload Speed"
  23. #define AUTHOR "ConnorMcLeod"
  24. #define VERSION "1.0.0"
  25.  
  26. const NOCLIP_WPN_BS = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
  27. const SHOTGUNS_BS   = ((1<<CSW_M3)|(1<<CSW_XM1014))
  28.  
  29. const m_pPlayer         = 41
  30. const m_fInReload           = 54
  31.  
  32. const m_flNextAttack        = 83
  33.  
  34. new gmsgBarTime2
  35.  
  36. new isVip[33] = false
  37.  
  38. new g_pCvarReloadSpeed, g_pCvarReloadBar
  39.  
  40. public plugin_init()
  41. {
  42.     register_plugin(PLUGIN, VERSION, AUTHOR)
  43.  
  44.     g_pCvarReloadSpeed = register_cvar("vip_reload_speed", "0.2")
  45.     g_pCvarReloadBar = register_cvar("vip_reload_bar", "1")
  46.  
  47.     new szWeapon[17]
  48.     for(new i=1; i<=CSW_P90; i++)
  49.     {
  50.         if( !( NOCLIP_WPN_BS & (1<<i) )
  51.         &&  !( SHOTGUNS_BS & (1<<i) )
  52.         &&  get_weaponname(i, szWeapon, charsmax(szWeapon)) )
  53.         {
  54.             RegisterHam(Ham_Weapon_Reload, szWeapon, "Weapon_Reload", 1)
  55.             RegisterHam(Ham_Item_Holster, szWeapon, "Item_Holster")
  56.  
  57.         }
  58.     }
  59.  
  60.     gmsgBarTime2 = get_user_msgid("BarTime2")
  61. }
  62.  
  63. public client_putinserver(id)
  64. {
  65.     if(get_user_flags(id) & ADMIN_LEVEL_H)
  66.         isVip[id] = true
  67.     return PLUGIN_CONTINUE
  68. }
  69.  
  70. public Weapon_Reload( iEnt )
  71. {
  72.     if(!isVip[iEnt])
  73.         return PLUGIN_HANDLED
  74.  
  75.     if( get_pdata_int(iEnt, m_fInReload, 4) )
  76.     {
  77.         new id = get_pdata_cbase(iEnt, m_pPlayer, 4)
  78.         new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, 5) * get_pcvar_float(g_pCvarReloadSpeed)
  79.         set_pdata_float(id, m_flNextAttack, flNextAttack, 5)
  80.        
  81.         if( get_pcvar_num(g_pCvarReloadBar) )
  82.         {
  83.             new iSeconds = floatround(flNextAttack, floatround_ceil)
  84.             Make_BarTime2(id, iSeconds, 100 - floatround( (flNextAttack/iSeconds) * 100 ))
  85.         }
  86.     }
  87.  
  88.     return PLUGIN_CONTINUE
  89. }
  90.  
  91. public Item_Holster( iEnt )
  92. {
  93.     if(!isVip[iEnt])
  94.         return PLUGIN_HANDLED
  95.  
  96.     if( get_pdata_int(iEnt, m_fInReload, 4) )
  97.     {
  98.         Make_BarTime2(get_pdata_cbase(iEnt, m_pPlayer, 4), 0, 0)
  99.     }
  100.  
  101.     return PLUGIN_CONTINUE
  102. }
  103.  
  104. Make_BarTime2(id, iSeconds, iPercent)
  105. {
  106.     message_begin(MSG_ONE_UNRELIABLE, gmsgBarTime2, _, id)
  107.     write_short(iSeconds)
  108.     write_short(iPercent)
  109.     message_end()
  110. }
Add Comment
Please, Sign In to add comment