HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*================================================================================
  2.  * Team Flashed
  3.  * Plugin By ZWP8741(WPZ)
  4.   ================================================================================*/
  5.  
  6. #include <amxmodx>
  7. #include <amxmisc>
  8. #include <fakemeta>
  9. #include <fun>
  10. #include <csx>
  11. #include <hamsandwich>
  12.  
  13. new bool:g_flashdisable_round[33]
  14. new const COLOR[] = {0, 0, 0}
  15.  
  16. enum FLASH{
  17. Float:GameTime = 0,
  18. Duration,
  19. HoldTime,
  20. FadeType,
  21. Alpha
  22. }
  23. new PLAYER[33][FLASH]
  24.  
  25. new pTeamFlashed
  26. new gMsgScreenFade
  27. new gMaxPlayers
  28.  
  29. new const FLASHSOUND[2][]={
  30. "weapons/flashbang-1.wav",
  31. "weapons/flashbang-2.wav"
  32. }
  33.  
  34. public plugin_init(){
  35.  
  36. register_plugin("Team Flashed", "1.0", "WPZ")
  37. register_event("CurWeapon", "event_weapon", "b")
  38. register_forward(FM_EmitSound, "fw_FM_EmitSound")
  39. register_event("ScreenFade", "event_ScreenFade", "be", "4=255", "5=255", "6=255", "7>199")
  40. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  41. pTeamFlashed = register_cvar("team_flashed", "1")
  42. gMsgScreenFade = get_user_msgid("ScreenFade")
  43. gMaxPlayers = get_maxplayers()
  44. }
  45. public event_weapon(id){
  46. if(get_user_weapon(id) == CSW_FLASHBANG && g_flashdisable_round[id] > 0){
  47. ham_strip_weapon(id, "weapon_flashbang")
  48. client_print(id, print_center, "*!FLASH Gránát letiltva!*")
  49. }
  50. }
  51. stock ham_strip_weapon(id,weapon[]){
  52. if(!equal(weapon,"weapon_",7)) return 0;
  53. new wId = get_weaponid(weapon);
  54. if(!wId) return 0;
  55. new wEnt;
  56. while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
  57. if(!wEnt) return 0;
  58. if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
  59. if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
  60. ExecuteHamB(Ham_Item_Kill,wEnt);
  61. set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
  62. return 1;
  63. }
  64. public event_round_start(){
  65. new i
  66. for(i=0;i<= gMaxPlayers;i++)
  67. if(g_flashdisable_round[i] > 0)
  68. g_flashdisable_round[i] --
  69. }
  70. public fw_FM_EmitSound(entity, channel, const sample[], Float:volume, Float:attenuation, fFlags, pitch)
  71.  
  72. {
  73. if(!get_pcvar_num(pTeamFlashed))
  74. return FMRES_IGNORED
  75.  
  76. if(!equali(sample, FLASHSOUND[0]) && !equali(sample, FLASHSOUND[1]))
  77. return FMRES_IGNORED
  78.  
  79. static flashed, Float:time, name[32], flasher, team
  80. flashed = 0
  81. flasher = pev(entity, pev_iuser3)
  82. team = pev(entity, pev_iuser4)
  83. time = get_gametime()
  84. get_user_name(flasher, name, 31)
  85.  
  86. if (is_user_connected(flasher))
  87. {
  88. for(new id=1; id<=gMaxPlayers; id++)
  89. {
  90. if (is_user_connected(id)
  91. && PLAYER[id][GameTime]==time
  92. && team==get_user_team(id)
  93. && flasher!=id)
  94. {
  95. client_print(id, print_chat, "[AMXX] Te már vakítottad %s!", name)
  96. FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR[0], COLOR[1], COLOR[2], PLAYER[id][Alpha])
  97. flashed = 1
  98. }
  99. }
  100.  
  101. if (flashed)
  102. {
  103. client_print(flasher, print_chat, "[AMXX] Te bevakítottad a csapattársad, ezért nem vehetsz %d körben Vakító Gránátot!", 5)
  104. g_flashdisable_round[flasher] = 5
  105.  
  106. }
  107. }
  108.  
  109. return FMRES_IGNORED
  110. }
  111.  
  112. public event_ScreenFade(id)
  113. {
  114. PLAYER[id][GameTime] = _:get_gametime()
  115. PLAYER[id][Duration] = read_data(1)
  116. PLAYER[id][HoldTime] = read_data(2)
  117. PLAYER[id][FadeType] = read_data(3)
  118. PLAYER[id][Alpha] = read_data(7)
  119. }
  120.  
  121. public grenade_throw(id, entity, WpnID)
  122. {
  123. if (WpnID == CSW_FLASHBANG)
  124. {
  125. set_pev(entity, pev_iuser3, id)
  126. set_pev(entity, pev_iuser4, get_user_team(id))
  127. }
  128. }
  129.  
  130. stock FlashedEvent(id, iDuration, iHoldTime, iFadeType, iRed, iGreen, iBlue, iAlpha)
  131. {
  132. message_begin(MSG_ONE, gMsgScreenFade, {0,0,0}, id)
  133. write_short(iDuration) // Duration
  134. write_short(iHoldTime) // Hold time
  135. write_short(iFadeType) // Fade type
  136. write_byte (iRed) // Red
  137. write_byte (iGreen) // Green
  138. write_byte (iBlue) // Blue
  139. write_byte (iAlpha) // Alpha
  140. message_end()
  141. }
  142.  
  143.  
  144.