Guest User

граната

a guest
May 25th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3.  
  4. new const Version[] = "1.0.1"
  5.  
  6. new MsgScreenFade, MsgScreenShake
  7. new FLenable, FLcolor, FLradius, FLlightcolor, FLsound
  8.  
  9. new const Sound[] = "sound/ultrasound.mp3"
  10.  
  11. public plugin_precache() {
  12. FLsound = register_cvar("amx_rfl_sound", "1")
  13.  
  14. if(get_pcvar_num(FLsound))
  15. precache_generic(Sound)
  16. }
  17.  
  18. public plugin_init()
  19. {
  20. register_plugin("Realistic FlashBang", Version, "GlaDiuS")
  21.  
  22. FLenable = register_cvar("amx_rfl_enable", "1")
  23. FLcolor = register_cvar("amx_rfl_color", "255 255 255")
  24. FLradius = register_cvar("amx_rfl_radius","50")
  25. FLlightcolor = register_cvar("amx_rfl_lightcolor","255 255 255")
  26.  
  27. register_event("ScreenFade","FlashEvent","b","4=255","5=255","6=255","7>199")
  28. register_forward(FM_EmitSound,"fw_emitsound")
  29.  
  30. MsgScreenFade = get_user_msgid("ScreenFade")
  31. MsgScreenShake = get_user_msgid("ScreenShake");
  32. }
  33.  
  34. public FlashEvent(id)
  35. {
  36. if(!get_pcvar_num(FLenable))
  37. return
  38.  
  39. // get color
  40. new Colores[12], rgb[3][4], Red, Green, Blue
  41. get_pcvar_string(FLcolor, Colores, charsmax(Colores))
  42. parse(Colores, rgb[0], 3, rgb[1], 3, rgb[2], 3)
  43. Red = clamp(str_to_num(rgb[0]), 0, 255)
  44. Green = clamp(str_to_num(rgb[1]), 0, 255)
  45. Blue = clamp(str_to_num(rgb[2]), 0, 255)
  46.  
  47. new Duration, HoldTime, Fade, Alpha
  48. Duration = read_data(1)
  49. HoldTime = read_data(2)
  50. Fade = read_data(3)
  51. Alpha = read_data(7)
  52.  
  53. message_begin(MSG_ONE, MsgScreenFade, {0,0,0}, id)
  54. write_short(Duration) // Duration
  55. write_short(HoldTime) // Hold time
  56. write_short(Fade) // Fade type
  57. write_byte(Red) // Red
  58. write_byte(Green) // Green
  59. write_byte(Blue) // Blue
  60. write_byte(Alpha) // Alpha
  61. message_end()
  62.  
  63. set_pev(id, pev_punchangle, Float:{125.0, 125.0, 125.0})
  64.  
  65. if(get_pcvar_num(FLsound)) {
  66. client_cmd(id, "mp3 play %s", Sound)
  67. set_task(8.0, "stoppedsound", id)
  68. }
  69.  
  70. set_task(3.0, "Shake", id)
  71. }
  72.  
  73. public Shake(id)
  74. {
  75. new Dura = UTIL_FixedUnsigned16(4.0, 1 << 12)
  76. new Freq = UTIL_FixedUnsigned16(0.7 , 1 << 8)
  77. new Ampl = UTIL_FixedUnsigned16(20.0, 1 << 12)
  78.  
  79. message_begin(MSG_ONE , MsgScreenShake , {0,0,0} ,id)
  80. write_short( Ampl ) // --| Shake amount.
  81. write_short( Dura ) // --| Shake lasts this long.
  82. write_short( Freq ) // --| Shake noise frequency.
  83. message_end ()
  84. }
  85.  
  86. public stoppedsound(id)
  87. client_cmd(id, "mp3 stop %s", Sound)
  88.  
  89. public fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
  90. {
  91. if(!get_pcvar_num(FLenable))
  92. return FMRES_IGNORED
  93.  
  94. // not a flashbang exploding
  95. if(!equali(sample,"weapons/flashbang-1.wav") && !equali(sample,"weapons/flashbang-2.wav"))
  96. return FMRES_IGNORED
  97.  
  98. // light effect
  99. flashbang_explode(entity)
  100.  
  101. return FMRES_IGNORED
  102. }
  103.  
  104. public flashbang_explode(greindex)
  105. {
  106. if(!pev_valid(greindex))
  107. return
  108.  
  109. // get origin of explosion
  110. new Float:origin[3]
  111. pev(greindex, pev_origin, origin)
  112.  
  113. // get color
  114. new Colores[12], rgb[3][4], Red, Green, Blue
  115. get_pcvar_string(FLlightcolor, Colores, charsmax(Colores))
  116. parse(Colores, rgb[0], 3, rgb[1], 3, rgb[2], 3)
  117. Red = clamp(str_to_num(rgb[0]), 0, 255)
  118. Green = clamp(str_to_num(rgb[1]), 0, 255)
  119. Blue = clamp(str_to_num(rgb[2]), 0, 255)
  120.  
  121. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  122. write_byte(TE_DLIGHT) // 27
  123. write_coord(floatround(origin[0])) // x
  124. write_coord(floatround(origin[1])) // y
  125. write_coord(floatround(origin[2])) // z
  126. write_byte(get_pcvar_num(FLradius)) // radius
  127. write_byte(Red) // Red
  128. write_byte(Green) // Green
  129. write_byte(Blue) // Blue
  130. write_byte(8) // life
  131. write_byte(60) // decay rate
  132. message_end()
  133. }
  134.  
  135. UTIL_FixedUnsigned16 ( const Float:Value, const Scale ) {
  136. return clamp( floatround( Value * Scale ), 0, 0xFFFF );
  137. }
Advertisement
Add Comment
Please, Sign In to add comment