HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2. #include <amxmodx>
  3. #include <fakemeta>
  4.  
  5. new enabled_cvar;
  6. new radius_cvar;
  7. new color_cvar;
  8.  
  9. public plugin_init()
  10. {
  11. register_plugin("Flashbang Dynamic Light","0.10","Avalanche");
  12. register_forward(FM_EmitSound,"fw_emitsound");
  13.  
  14. enabled_cvar = register_cvar("fbl_enabled","1");
  15. radius_cvar = register_cvar("fbl_radius","50");
  16. color_cvar = register_cvar("fbl_color","0 255 255");
  17. }
  18.  
  19. public fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
  20. {
  21. // plugin disabled
  22. if(!get_pcvar_num(enabled_cvar))
  23. return FMRES_IGNORED;
  24.  
  25. // not a flashbang exploding
  26. if(!equali(sample,"weapons/flashbang-1.wav") && !equali(sample,"weapons/flashbang-2.wav"))
  27. return FMRES_IGNORED;
  28.  
  29. // light effect
  30. flashbang_explode(entity);
  31.  
  32. return FMRES_IGNORED;
  33. }
  34.  
  35.  
  36. public flashbang_explode(greindex)
  37. {
  38. // invalid entity
  39. if(!pev_valid(greindex)) return;
  40.  
  41. // get origin of explosion
  42. new Float:origin[3];
  43. pev(greindex,pev_origin,origin);
  44.  
  45. // get color from cvar
  46. new color[16];
  47. get_pcvar_string(color_cvar,color,15);
  48.  
  49. // split it into red, green, blue
  50. new redamt[5], greenamt[5], blueamt[5];
  51. parse(color,redamt,4,greenamt,4,blueamt,4);
  52.  
  53. // send the light flash
  54. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  55. write_byte(27); // TE_DLIGHT
  56. write_coord(floatround(origin[0])); // x
  57. write_coord(floatround(origin[1])); // y
  58. write_coord(floatround(origin[2])); // z
  59. write_byte(get_pcvar_num(radius_cvar)); // radius
  60. write_byte(random(255)); // r
  61. write_byte(random(255)); // g
  62. write_byte(random(255)); // b
  63. write_byte(8); // life
  64. write_byte(60); // decay rate
  65. message_end();
  66. }