Advertisement
Guest User

Untitled

a guest
Apr 13th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 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 g_pCvarReloadSpeed, g_pCvarReloadBar
  37.  
  38. public plugin_init()
  39. {
  40. register_plugin(PLUGIN, VERSION, AUTHOR)
  41.  
  42. g_pCvarReloadSpeed = register_cvar("amx_reload_speed", "0.2")
  43. g_pCvarReloadBar = register_cvar("amx_reload_bar", "1")
  44.  
  45. new szWeapon[17]
  46. for(new i=1; i<=CSW_P90; i++)
  47. {
  48. if( !( NOCLIP_WPN_BS & (1<<i) )
  49. && !( SHOTGUNS_BS & (1<<i) )
  50. && get_weaponname(i, szWeapon, charsmax(szWeapon)) )
  51. {
  52. RegisterHam(Ham_Weapon_Reload, szWeapon, "Weapon_Reload", 1)
  53. RegisterHam(Ham_Item_Holster, szWeapon, "Item_Holster")
  54.  
  55. }
  56. }
  57.  
  58. gmsgBarTime2 = get_user_msgid("BarTime2")
  59. }
  60.  
  61. public Weapon_Reload( iEnt )
  62. {
  63. if(!(get_user_flags(iEnt) & ADMIN_LEVEL_H))
  64. return HAM_IGNORED
  65.  
  66. if( get_pdata_int(iEnt, m_fInReload, 4) )
  67. {
  68. new id = get_pdata_cbase(iEnt, m_pPlayer, 4)
  69. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, 5) * get_pcvar_float(g_pCvarReloadSpeed)
  70. set_pdata_float(id, m_flNextAttack, flNextAttack, 5)
  71.  
  72. if( get_pcvar_num(g_pCvarReloadBar) )
  73. {
  74. new iSeconds = floatround(flNextAttack, floatround_ceil)
  75. Make_BarTime2(id, iSeconds, 100 - floatround( (flNextAttack/iSeconds) * 100 ))
  76. }
  77. }
  78. }
  79.  
  80. public Item_Holster( iEnt )
  81. {
  82. if( get_pdata_int(iEnt, m_fInReload, 4) )
  83. {
  84. Make_BarTime2(get_pdata_cbase(iEnt, m_pPlayer, 4), 0, 0)
  85. }
  86. }
  87.  
  88. Make_BarTime2(id, iSeconds, iPercent)
  89. {
  90. message_begin(MSG_ONE_UNRELIABLE, gmsgBarTime2, _, id)
  91. write_short(iSeconds)
  92. write_short(iPercent)
  93. message_end()
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement