HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fakemeta>
  6. #include <hamsandwich>
  7. #include <cstrike>
  8.  
  9. #define PLUGIN "Anti-No Flash"
  10. #define VERSION "1.0.7"
  11. #define AUTHOR "sHiFT"
  12.  
  13. new Float:g_flashed_until[33];
  14.  
  15. new pcv_on;
  16. new pcv_demo;
  17. new pcv_delay;
  18. new pcv_ignore;
  19. new g_msg_screen_fade;
  20. new g_isBot[33];
  21. new g_isAlive[33];
  22. new g_team[33];
  23. new g_plugin_on, g_ignore;
  24.  
  25. public plugin_init() {
  26.  
  27. register_plugin(PLUGIN, VERSION, AUTHOR);
  28. register_cvar("anti_noflash_version", VERSION, FCVAR_SERVER);
  29.  
  30. pcv_on = register_cvar ("anti_noflash_on", "1");
  31. pcv_demo = register_cvar ("anti_noflash_demo", "0");
  32. pcv_delay = register_cvar ("anti_noflash_delay", "0.0");
  33. pcv_ignore = register_cvar ("anti_noflash_ignore_team", "0");
  34.  
  35. register_event("ScreenFade", "event_flashed", "b", "7=255");
  36. register_forward(FM_AddToFullPack, "fw_addtofullpack", 0);
  37.  
  38. g_msg_screen_fade = get_user_msgid("ScreenFade");
  39.  
  40. //Just for caching purposes
  41. RegisterHam( Ham_Spawn, "player", "fw_PlayerSpawn", 1);
  42. RegisterHam( Ham_Killed, "player", "fw_PlayerKilled", 1);
  43.  
  44. }
  45.  
  46.  
  47. public event_flashed(id){
  48.  
  49. //Cache this value so it is not called in AddToFullPack
  50. g_plugin_on = get_pcvar_num(pcv_on);
  51.  
  52. if (!g_plugin_on || !is_user_connected(id) )
  53. return PLUGIN_CONTINUE;
  54.  
  55. g_ignore = get_pcvar_num(pcv_ignore);
  56.  
  57. //Up to when this player should be flashed
  58. g_flashed_until[id] = read_data(2)/4096.0 + get_gametime() + get_pcvar_float(pcv_delay);
  59.  
  60. if(get_pcvar_num(pcv_demo)){
  61. client_print(id, print_chat, "Gametime: %0.2f - Flashed until: %0.2f",get_gametime(),g_flashed_until[id]);
  62. remove_flash(id);
  63. }
  64.  
  65. return PLUGIN_CONTINUE;
  66.  
  67. }
  68.  
  69. public fw_addtofullpack(es, e, ent, host, flags, player, set){
  70.  
  71. //
  72. if (!g_plugin_on || !g_isAlive[host] || g_isBot[host])
  73. return FMRES_IGNORED;
  74.  
  75. //
  76. if(g_ignore==g_team[host])
  77. return FMRES_IGNORED;
  78.  
  79. if(player)
  80. {
  81. //
  82. if(!g_isAlive[ent] || ent == host)
  83. return FMRES_IGNORED;
  84. } else
  85. if(pev_valid(ent))
  86. {
  87. //
  88. static Classname[33];
  89. pev(ent, pev_classname, Classname,32);
  90. new is_grenade = equal(Classname,"grenade");
  91.  
  92. //
  93. //
  94. if(!is_grenade || pev(ent, pev_owner)==host)
  95. return FMRES_IGNORED;
  96.  
  97. } else
  98. return FMRES_IGNORED;
  99.  
  100. //
  101. if(get_gametime() < g_flashed_until[host])
  102. {
  103. //client_print(host, print_chat, "Gametime: %0.2f - Flashed until: %0.2f",get_gametime(),g_flashed_until[host]);
  104. forward_return(FMV_CELL, 0);
  105. return FMRES_SUPERCEDE;
  106. }
  107.  
  108. return FMRES_IGNORED;
  109.  
  110. }
  111.  
  112. public remove_flash(id){
  113.  
  114. //
  115. message_begin(MSG_ONE_UNRELIABLE, g_msg_screen_fade, {0, 0, 0}, id);
  116. write_short(0);
  117. write_short(0);
  118. write_short(0);
  119. write_byte(0);
  120. write_byte(0);
  121. write_byte(0);
  122. write_byte(0);
  123. message_end();
  124.  
  125. }
  126.  
  127. //Caching functions
  128. public client_putinserver(id)
  129. {
  130. g_isBot[id] = is_user_bot(id);
  131. }
  132.  
  133. public client_disconnect(id)
  134. {
  135. g_isAlive[id] = false;
  136. g_isBot[id] = false;
  137. }
  138.  
  139.  
  140. public fw_PlayerSpawn(id)
  141. {
  142. g_isAlive[id] = is_user_alive(id);
  143. g_team[id] = cs_get_user_team(id);
  144. //g_team[id] = get_user_team(id);
  145. }
  146.  
  147. public fw_PlayerKilled(id)
  148. {
  149. g_isAlive[id] = false;
  150. }
  151.