weffer

Untitled

Sep 24th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 192.39 KB | None | 0 0
  1.  
  2.  
  3. #include <sdkhooks>
  4. #include <clientprefs>
  5. #include <core>
  6. #include <sdkhooks>
  7. #include <colors>
  8. #include <geoip>
  9. #include <socket>
  10. #include <sourcemod>
  11.  
  12.  
  13.  
  14. new Float:RDifficultyMultiplier = 1.0;
  15. new playerscount = 4;
  16. new bool:l4d2_plugin_loot = true;
  17. new bool:l4d2_plugin_monsterbots = true;
  18. new bool:extra_charger;
  19. new bool:autodifficulty_calculated;
  20. new Handle:hm_autodifficulty;
  21. new Handle:hm_autodifficulty_forcehp;
  22. new Handle:z_difficulty;
  23. new Handle:z_special_spawn_interval;
  24. new Handle:director_special_respawn_interval;
  25. new Handle:z_max_player_zombies;
  26. new Handle:hm_auto_tongue_range_min;
  27. new Handle:hm_auto_tongue_range_max;
  28. new Handle:hm_auto_tongue_miss_delay_min;
  29. new Handle:hm_auto_tongue_miss_delay_max;
  30. new Handle:hm_auto_tongue_hit_delay_min;
  31. new Handle:hm_auto_tongue_hit_delay_max;
  32. new Handle:hm_auto_tongue_choke_dmg_min;
  33. new Handle:hm_auto_tongue_choke_dmg_max;
  34. new Handle:hm_auto_tongue_drag_dmg_min;
  35. new Handle:hm_auto_tongue_drag_dmg_max;
  36. new Handle:hm_auto_smoker_pz_claw_dmg_min;
  37. new Handle:hm_auto_smoker_pz_claw_dmg_max;
  38. new Handle:hm_auto_jockey_pz_claw_dmg_min;
  39. new Handle:hm_auto_jockey_pz_claw_dmg_max;
  40. new Handle:hm_auto_grenade_lr_dmg_min;
  41. new Handle:hm_auto_grenade_lr_dmg_max;
  42. new Handle:damage_type;
  43. new Handle:hm_damage_ak47_min;
  44. new Handle:hm_damage_ak47_max;
  45. new Handle:hm_damage_awp_min;
  46. new Handle:hm_damage_awp_max;
  47. new Handle:hm_damage_m60_min;
  48. new Handle:hm_damage_m60_max;
  49. new Handle:hm_damage_scout_min;
  50. new Handle:hm_damage_scout_max;
  51. new Handle:hm_damage_sg552_min;
  52. new Handle:hm_damage_sg552_max;
  53. new Handle:hm_damage_spas_min;
  54. new Handle:hm_damage_spas_max;
  55. new Handle:hm_damage_sniper_military_min;
  56. new Handle:hm_damage_sniper_military_max;
  57. new Handle:hm_damage2_ak47_min;
  58. new Handle:hm_damage2_ak47_max;
  59. new Handle:hm_damage2_awp_min;
  60. new Handle:hm_damage2_awp_max;
  61. new Handle:hm_damage2_m60_min;
  62. new Handle:hm_damage2_m60_max;
  63. new Handle:hm_damage2_scout_min;
  64. new Handle:hm_damage2_scout_max;
  65. new Handle:hm_damage2_sg552_min;
  66. new Handle:hm_damage2_sg552_max;
  67. new Handle:hm_damage2_spas_min;
  68. new Handle:hm_damage2_spas_max;
  69. new Handle:hm_damage2_sniper_military_min;
  70. new Handle:hm_damage2_sniper_military_max;
  71. new Handle:hm_meleefix_min;
  72. new Handle:hm_meleefix_max;
  73. new Handle:hm_meleefix_headshot_min;
  74. new Handle:hm_meleefix_headshot_max;
  75. new Handle:hm_meleefix_tank_min;
  76. new Handle:hm_meleefix_tank_max;
  77. new Handle:hm_meleefix_tank_headshot_min;
  78. new Handle:hm_meleefix_tank_headshot_max;
  79. new Handle:hm_meleefix_witch_min;
  80. new Handle:hm_meleefix_witch_max;
  81. new Handle:hm_loot_mod;
  82. new Handle:hm_tank_hp_mod;
  83. new Handle:hm_infected_hp_mod;
  84. new Handle:hm_spawn_time_mod;
  85. new Handle:hm_spawn_count_mod;
  86. new Handle:hm_special_infected_min;
  87. new Handle:hm_special_infected_max;
  88. new Handle:hm_spawn_interval_min;
  89. new Handle:hm_spawn_interval_max;
  90. new Handle:hm_tank_burn_duration_min;
  91. new Handle:hm_tank_burn_duration_max;
  92. new Handle:hm_autohp_automod;
  93. new Handle:hm_autohp_supercharger_auto;
  94. new Handle:hm_autohp_zombie_min;
  95. new Handle:hm_autohp_zombie_max;
  96. new Handle:hm_autohp_hunter_min;
  97. new Handle:hm_autohp_hunter_max;
  98. new Handle:hm_autohp_smoker_min;
  99. new Handle:hm_autohp_smoker_max;
  100. new Handle:hm_autohp_boomer_min;
  101. new Handle:hm_autohp_boomer_max;
  102. new Handle:hm_autohp_jockey_min;
  103. new Handle:hm_autohp_jockey_max;
  104. new Handle:hm_autohp_charger_min;
  105. new Handle:hm_autohp_charger_max;
  106. new Handle:hm_autohp_spitter_min;
  107. new Handle:hm_autohp_spitter_max;
  108. new Handle:hm_autohp_witch_min;
  109. new Handle:hm_autohp_witch_max;
  110. new Handle:hm_autohp_tank_min;
  111. new Handle:hm_autohp_tank_max;
  112. new Handle:hm_items_automod;
  113. new Handle:hm_items_supercharger_auto;
  114. new Handle:hm_items_hunter_min;
  115. new Handle:hm_items_hunter_max;
  116. new Handle:hm_items_smoker_min;
  117. new Handle:hm_items_smoker_max;
  118. new Handle:hm_items_boomer_min;
  119. new Handle:hm_items_boomer_max;
  120. new Handle:hm_items_jockey_min;
  121. new Handle:hm_items_jockey_max;
  122. new Handle:hm_items_charger_min;
  123. new Handle:hm_items_charger_max;
  124. new Handle:hm_items_spitter_min;
  125. new Handle:hm_items_spitter_max;
  126. new Handle:hm_items_tank_min;
  127. new Handle:hm_items_tank_max;
  128. new Handle:hm_spawn_automod;
  129. new Handle:hm_spawn_zombie_min;
  130. new Handle:hm_spawn_zombie_max;
  131. new Handle:hm_spawn_hunter_min;
  132. new Handle:hm_spawn_hunter_max;
  133. new Handle:hm_spawn_smoker_min;
  134. new Handle:hm_spawn_smoker_max;
  135. new Handle:hm_spawn_boomer_min;
  136. new Handle:hm_spawn_boomer_max;
  137. new Handle:hm_spawn_jockey_min;
  138. new Handle:hm_spawn_jockey_max;
  139. new Handle:hm_spawn_charger_min;
  140. new Handle:hm_spawn_charger_max;
  141. new Handle:hm_spawn_spitter_min;
  142. new Handle:hm_spawn_spitter_max;
  143. new Handle:hm_speed_automod;
  144. new Handle:hm_speed_hunter_min;
  145. new Handle:hm_speed_hunter_max;
  146. new Handle:hm_speed_smoker_min;
  147. new Handle:hm_speed_smoker_max;
  148. new Handle:hm_speed_boomer_min;
  149. new Handle:hm_speed_boomer_max;
  150. new Handle:hm_speed_jockey_min;
  151. new Handle:hm_speed_jockey_max;
  152. new Handle:hm_speed_charger_min;
  153. new Handle:hm_speed_charger_max;
  154. new Handle:hm_speed_spitter_min;
  155. new Handle:hm_speed_spitter_max;
  156. new Handle:hm_speed_tank_min;
  157. new Handle:hm_speed_tank_max;
  158. new String:sGameDifficulty[16];
  159. new String:Server_UpTime[20];
  160. new UpTime;
  161. new cvar_difficulty = 1;
  162. new cvar_maxplayers;
  163. new AutodifficultyHP[66][9];
  164. new AutodifficultyGrenadeLRDmg[66];
  165. new AutodifficultyItems[66][9];
  166. new AutodifficultySpawnLimit[66][9];
  167. new AutodifficultySpeed[66][9];
  168. new AutodifficultySpawnInterval[66];
  169. new AutodifficultySpawnCount[66];
  170. new AutodifficultyTongueMissDelay[66];
  171. new AutodifficultyTongueHitDelay[66];
  172. new AutodifficultyTongueRange[66];
  173. new AutodifficultyTongueChokeDmg[66];
  174. new AutodifficultyTongueDragDmg[66];
  175. new AutodifficultySmokerClawDmg[66];
  176. new AutodifficultyJockeyClawDmg[66];
  177. new AutodifficultyTankBurnTime[66];
  178. new Autodifficulty_ak47_Dmg[66];
  179. new Autodifficulty_awp_Dmg[66];
  180. new Autodifficulty_m60_Dmg[66];
  181. new Autodifficulty_scout_Dmg[66];
  182. new Autodifficulty_sg552_Dmg[66];
  183. new Autodifficulty_spas_Dmg[66];
  184. new Autodifficulty_sniper_military_Dmg[66];
  185. new Autodifficulty_meleefix_Dmg[66];
  186. new Autodifficulty_meleefix_headshot_Dmg[66];
  187. new Autodifficulty_meleefix_tank_Dmg[66];
  188. new Autodifficulty_meleefix_tank_headshot_Dmg[66];
  189. new Autodifficulty_meleefix_witch_Dmg[66];
  190. new bool:g_IsTimeAutodifficulty;
  191. new Handle:MeleeDmg[10];
  192. new Handle:MeleeHeadshotDmg[9];
  193. new Float:DamageBody[10];
  194. new Float:DamageHeadshot[9];
  195. new Handle:hm_damage;
  196. new Handle:hm_damage_friendly;
  197. new Handle:hm_damage_showvalue;
  198. new Handle:hm_damage_hunter;
  199. new Handle:hm_damage_smoker;
  200. new Handle:hm_damage_boomer;
  201. new Handle:hm_damage_spitter1;
  202. new Handle:hm_damage_spitter2;
  203. new Handle:hm_damage_jockey;
  204. new Handle:hm_damage_charger;
  205. new Handle:hm_damage_tank;
  206. new Handle:hm_damage_tankrock;
  207. new Handle:hm_damage_common;
  208. new Handle:hm_damage_type;
  209. new Handle:hm_damage_ak47;
  210. new Handle:hm_damage2_ak47;
  211. new Handle:hm_damage_awp;
  212. new Handle:hm_damage2_awp;
  213. new Handle:hm_damage_scout;
  214. new Handle:hm_damage2_scout;
  215. new Handle:hm_damage_m60;
  216. new Handle:hm_damage2_m60;
  217. new Handle:hm_damage_pipebomb;
  218. new Handle:hm_damage_spas;
  219. new Handle:hm_damage2_spas;
  220. new Handle:hm_damage_sg552;
  221. new Handle:hm_damage2_sg552;
  222. new Handle:hm_damage_smg;
  223. new Handle:hm_damage_smg_silenced;
  224. new Handle:hm_damage_m16;
  225. new Handle:hm_damage_pumpshotgun;
  226. new Handle:hm_damage_autoshotgun;
  227. new Handle:hm_damage_hunting_rifle;
  228. new Handle:hm_damage_rifle_desert;
  229. new Handle:hm_damage_shotgun_chrome;
  230. new Handle:hm_damage_smg_mp5;
  231. new Handle:hm_damage_sniper_military;
  232. new Handle:hm_damage2_sniper_military;
  233. new Handle:hm_damage_pistol;
  234. new Handle:hm_damage_pistol_magnum;
  235. new tystatsbalans;
  236. new bonus;
  237. new Handle:db;
  238. new RankTotal;
  239. new round_end_repeats;
  240. new ClientRank[66];
  241. new ClientPoints[66];
  242. new ClientKills[66];
  243. new ProtectedFriendlyCounter[66];
  244. new ClientPlaytime[66];
  245. new Playtime[66];
  246. new KillsInfected[66];
  247. new NewPoints[66];
  248. new TKblockDamage[66];
  249. new TKblockPunishment[66];
  250. new TKblockmin = 120;
  251. new TKblockmax = 360;
  252. new bool:IsTimeAutodifficulty;
  253. new bool:IsMapFinished;
  254. new bool:IsPrint;
  255. new bool:IsRoundStarted;
  256. new Handle:Join_Timer[66];
  257. new Pills[4096];
  258. new Adrenaline[4096];
  259. new g_votekick[66];
  260. new LastVotebanTIME[66];
  261. new Handle:hm_count_fails;
  262. new Handle:hm_stats_colors;
  263. new Handle:hm_stats_bot_colors;
  264. new Handle:l4d2_rankmod_mode;
  265. new Handle:l4d2_rankmod_min;
  266. new Handle:l4d2_rankmod_max;
  267. new Handle:l4d2_rankmod_logarithm;
  268. new Handle:l4d2_players_join_message_timer;
  269. new Handle:hm_blockvote_kick;
  270. new Handle:hm_blockvote_map;
  271. new Handle:hm_allowvote_map_players;
  272. new Handle:hm_blockvote_lobby;
  273. new Handle:hm_blockvote_restart;
  274. new Handle:hm_blockvote_difficulty;
  275. new Handle:hm_blockvote_difference;
  276. new Handle:hm_allowvote_mission;
  277. new String:CV_FileName[256];
  278. new Handle:cvar_Hunter;
  279. new Handle:cvar_Smoker;
  280. new Handle:cvar_Boomer;
  281. new Handle:cvar_Spitter;
  282. new Handle:cvar_Jockey;
  283. new Handle:cvar_Charger;
  284. new Handle:cvar_Witch;
  285. new Handle:cvar_Tank;
  286. new Handle:cvar_Bonus;
  287. new Handle:cvar_SiteURL;
  288. new Float:rank_sum;
  289. new Handle:SDifficultyMultiplier;
  290. new bool:g_Socket[66];
  291. new bool:g_HaveSteam[66];
  292. new String:g_SteamID[66][32];
  293. new String:g_ProfileID[66][20];
  294. new Handle:g_HaveSteam_Trie;
  295. new String:MOTD_TITLE[32] = "Message Of The Day";
  296. new String:MessageOfTheDay[1024];
  297. new Float:MapTimingStartTime = -1.0;
  298. new String:datafilepath[256];
  299. public Plugin:myinfo =
  300. {
  301. name = "l4d2 stats with autodifficulty",
  302. description = "",
  303. author = "TY (edited by SupermenCJ)",
  304. version = "3.0",
  305. url = "http://www.zambiland.ru/"
  306. };
  307.  
  308.  
  309.  
  310. public CoopAutoDiffOnPluginStart()
  311. {
  312. UpTime = GetTime({0,0});
  313. hm_autodifficulty = CreateConVar("hm_autodifficulty", "1", "Is the plugin enabled.", 262144, false, 0.0, false, 0.0);
  314. hm_autodifficulty_forcehp = CreateConVar("hm_autodifficulty_forcehp", "0", "", 262144, false, 0.0, false, 0.0);
  315. hm_loot_mod = CreateConVar("hm_loot_mod", "1.0", "", 262144, false, 0.0, false, 0.0);
  316. hm_tank_hp_mod = CreateConVar("hm_tank_hp_mod", "1.0", "", 262144, false, 0.0, false, 0.0);
  317. hm_infected_hp_mod = CreateConVar("hm_infected_hp_mod", "1.0", "", 262144, false, 0.0, false, 0.0);
  318. hm_spawn_time_mod = CreateConVar("hm_spawn_time_mod", "1.0", "", 262144, false, 0.0, false, 0.0);
  319. hm_spawn_count_mod = CreateConVar("hm_spawn_count_mod", "1.0", "", 262144, false, 0.0, false, 0.0);
  320. z_difficulty = FindConVar("z_difficulty");
  321. HookConVarChange(z_difficulty, z_difficulty_changed);
  322. z_special_spawn_interval = FindConVar("z_special_spawn_interval");
  323. director_special_respawn_interval = FindConVar("director_special_respawn_interval");
  324. z_max_player_zombies = FindConVar("z_max_player_zombies");
  325. hm_auto_tongue_range_min = CreateConVar("hm_auto_tongue_range_min", "750", "", 262144, false, 0.0, false, 0.0);
  326. hm_auto_tongue_range_max = CreateConVar("hm_auto_tongue_range_max", "1500", "", 262144, false, 0.0, false, 0.0);
  327. hm_auto_tongue_miss_delay_min = CreateConVar("hm_auto_tongue_miss_delay_min", "5", "Минимальное время перезарядки языка при промахе.", 262144, false, 0.0, false, 0.0);
  328. hm_auto_tongue_miss_delay_max = CreateConVar("hm_auto_tongue_miss_delay_max", "15", "Максимальное время перезарядки языка при промахе.", 262144, false, 0.0, false, 0.0);
  329. hm_auto_tongue_hit_delay_min = CreateConVar("hm_auto_tongue_hit_delay_min", "5", "Минимальное время перезарядки языка, после отпускания (не важно по какой причине) предыдущей жертвы.", 262144, false, 0.0, false, 0.0);
  330. hm_auto_tongue_hit_delay_max = CreateConVar("hm_auto_tongue_hit_delay_max", "20", "Максимальное время перезарядки языка, после отпускания (не важно по какой причине) предыдущей жертвы.", 262144, false, 0.0, false, 0.0);
  331. hm_auto_tongue_choke_dmg_min = CreateConVar("hm_auto_tongue_choke_dmg_min", "24", "", 262144, false, 0.0, false, 0.0);
  332. hm_auto_tongue_choke_dmg_max = CreateConVar("hm_auto_tongue_choke_dmg_max", "67", "", 262144, false, 0.0, false, 0.0);
  333. hm_auto_tongue_drag_dmg_min = CreateConVar("hm_auto_tongue_drag_dmg_min", "9", "", 262144, false, 0.0, false, 0.0);
  334. hm_auto_tongue_drag_dmg_max = CreateConVar("hm_auto_tongue_drag_dmg_max", "35", "", 262144, false, 0.0, false, 0.0);
  335. hm_auto_smoker_pz_claw_dmg_min = CreateConVar("hm_auto_smoker_pz_claw_dmg_min", "5", "", 262144, false, 0.0, false, 0.0);
  336. hm_auto_smoker_pz_claw_dmg_max = CreateConVar("hm_auto_smoker_pz_claw_dmg_max", "18", "", 262144, false, 0.0, false, 0.0);
  337. hm_auto_jockey_pz_claw_dmg_min = CreateConVar("hm_auto_jockey_pz_claw_dmg_min", "5", "", 262144, false, 0.0, false, 0.0);
  338. hm_auto_jockey_pz_claw_dmg_max = CreateConVar("hm_auto_jockey_pz_claw_dmg_max", "18", "", 262144, false, 0.0, false, 0.0);
  339. hm_auto_grenade_lr_dmg_min = CreateConVar("hm_auto_grenade_lr_dmg_min", "400", "", 262144, false, 0.0, false, 0.0);
  340. hm_auto_grenade_lr_dmg_max = CreateConVar("hm_auto_grenade_lr_dmg_max", "4000", "", 262144, false, 0.0, false, 0.0);
  341. hm_damage_ak47_min = CreateConVar("hm_damage_ak47_min", "2523", "", 262144, false, 0.0, false, 0.0);
  342. hm_damage_ak47_max = CreateConVar("hm_damage_ak47_max", "11160", "", 262144, false, 0.0, false, 0.0);
  343. hm_damage_awp_min = CreateConVar("hm_damage_awp_min", "9486", "", 262144, false, 0.0, false, 0.0);
  344. hm_damage_awp_max = CreateConVar("hm_damage_awp_max", "39272", "", 262144, false, 0.0, false, 0.0);
  345. hm_damage_m60_min = CreateConVar("hm_damage_m60_min", "1652", "", 262144, false, 0.0, false, 0.0);
  346. hm_damage_m60_max = CreateConVar("hm_damage_m60_max", "9812", "", 262144, false, 0.0, false, 0.0);
  347. hm_damage_scout_min = CreateConVar("hm_damage_scout_min", "4667", "", 262144, false, 0.0, false, 0.0);
  348. hm_damage_scout_max = CreateConVar("hm_damage_scout_max", "20286", "", 262144, false, 0.0, false, 0.0);
  349. hm_damage_sg552_min = CreateConVar("hm_damage_sg552_min", "1111", "", 262144, false, 0.0, false, 0.0);
  350. hm_damage_sg552_max = CreateConVar("hm_damage_sg552_max", "4500", "", 262144, false, 0.0, false, 0.0);
  351. hm_damage_spas_min = CreateConVar("hm_damage_spas_min", "3000", "", 262144, false, 0.0, false, 0.0);
  352. hm_damage_spas_max = CreateConVar("hm_damage_spas_max", "12430", "", 262144, false, 0.0, false, 0.0);
  353. hm_damage_sniper_military_min = CreateConVar("hm_damage_sniper_military_min", "1055", "", 262144, false, 0.0, false, 0.0);
  354. hm_damage_sniper_military_max = CreateConVar("hm_damage_sniper_military_max", "2000", "", 262144, false, 0.0, false, 0.0);
  355. hm_damage2_ak47_min = CreateConVar("hm_damage2_ak47_min", "140", "", 262144, false, 0.0, false, 0.0);
  356. hm_damage2_ak47_max = CreateConVar("hm_damage2_ak47_max", "600", "", 262144, false, 0.0, false, 0.0);
  357. hm_damage2_awp_min = CreateConVar("hm_damage2_awp_min", "700", "", 262144, false, 0.0, false, 0.0);
  358. hm_damage2_awp_max = CreateConVar("hm_damage2_awp_max", "4000", "", 262144, false, 0.0, false, 0.0);
  359. hm_damage2_m60_min = CreateConVar("hm_damage2_m60_min", "85", "", 262144, false, 0.0, false, 0.0);
  360. hm_damage2_m60_max = CreateConVar("hm_damage2_m60_max", "490", "", 262144, false, 0.0, false, 0.0);
  361. hm_damage2_scout_min = CreateConVar("hm_damage2_scout_min", "420", "", 262144, false, 0.0, false, 0.0);
  362. hm_damage2_scout_max = CreateConVar("hm_damage2_scout_max", "1820", "", 262144, false, 0.0, false, 0.0);
  363. hm_damage2_sg552_min = CreateConVar("hm_damage2_sg552_min", "70", "", 262144, false, 0.0, false, 0.0);
  364. hm_damage2_sg552_max = CreateConVar("hm_damage2_sg552_max", "250", "", 262144, false, 0.0, false, 0.0);
  365. hm_damage2_spas_min = CreateConVar("hm_damage2_spas_min", "60", "", 262144, false, 0.0, false, 0.0);
  366. hm_damage2_spas_max = CreateConVar("hm_damage2_spas_max", "250", "", 262144, false, 0.0, false, 0.0);
  367. hm_damage2_sniper_military_min = CreateConVar("hm_damage2_sniper_military_min", "50", "", 262144, false, 0.0, false, 0.0);
  368. hm_damage2_sniper_military_max = CreateConVar("hm_damage2_sniper_military_max", "150", "", 262144, false, 0.0, false, 0.0);
  369. hm_meleefix_min = CreateConVar("hm_meleefix_min", "650", "", 262144, false, 0.0, false, 0.0);
  370. hm_meleefix_max = CreateConVar("hm_meleefix_max", "3200", "", 262144, false, 0.0, false, 0.0);
  371. hm_meleefix_headshot_min = CreateConVar("hm_meleefix_headshot_min", "900", "", 262144, false, 0.0, false, 0.0);
  372. hm_meleefix_headshot_max = CreateConVar("hm_meleefix_headshot_max", "3800", "", 262144, false, 0.0, false, 0.0);
  373. hm_meleefix_tank_min = CreateConVar("hm_meleefix_tank_min", "700", "", 262144, false, 0.0, false, 0.0);
  374. hm_meleefix_tank_max = CreateConVar("hm_meleefix_tank_max", "4000", "", 262144, false, 0.0, false, 0.0);
  375. hm_meleefix_tank_headshot_min = CreateConVar("hm_meleefix_tank_headshot_min", "1400", "", 262144, false, 0.0, false, 0.0);
  376. hm_meleefix_tank_headshot_max = CreateConVar("hm_meleefix_tank_headshot_max", "5000", "", 262144, false, 0.0, false, 0.0);
  377. hm_meleefix_witch_min = CreateConVar("hm_meleefix_witch_min", "200", "", 262144, false, 0.0, false, 0.0);
  378. hm_meleefix_witch_max = CreateConVar("hm_meleefix_witch_max", "360", "", 262144, false, 0.0, false, 0.0);
  379. hm_special_infected_min = CreateConVar("hm_special_infected_min", "4", "", 262144, false, 0.0, false, 0.0);
  380. hm_special_infected_max = CreateConVar("hm_special_infected_max", "6", "", 262144, false, 0.0, false, 0.0);
  381. hm_spawn_interval_min = CreateConVar("hm_spawn_interval_min", "8", "", 262144, false, 0.0, false, 0.0);
  382. hm_spawn_interval_max = CreateConVar("hm_spawn_interval_max", "16", "", 262144, false, 0.0, false, 0.0);
  383. hm_tank_burn_duration_min = CreateConVar("hm_tank_burn_duration_min", "75", "", 262144, false, 0.0, false, 0.0);
  384. hm_tank_burn_duration_max = CreateConVar("hm_tank_burn_duration_max", "250", "", 262144, false, 0.0, false, 0.0);
  385. hm_autohp_automod = CreateConVar("hm_autohp_automod", "1", "", 262144, false, 0.0, false, 0.0);
  386. hm_autohp_supercharger_auto = CreateConVar("hm_autohp_supercharger_auto", "0", "", 262144, false, 0.0, false, 0.0);
  387. hm_autohp_zombie_min = CreateConVar("hm_autohp_zombie_min", "50", "", 262144, false, 0.0, false, 0.0);
  388. hm_autohp_zombie_max = CreateConVar("hm_autohp_zombie_max", "120", "", 262144, false, 0.0, false, 0.0);
  389. hm_autohp_hunter_min = CreateConVar("hm_autohp_hunter_min", "250", "", 262144, false, 0.0, false, 0.0);
  390. hm_autohp_hunter_max = CreateConVar("hm_autohp_hunter_max", "2500", "", 262144, false, 0.0, false, 0.0);
  391. hm_autohp_smoker_min = CreateConVar("hm_autohp_smoker_min", "250", "", 262144, false, 0.0, false, 0.0);
  392. hm_autohp_smoker_max = CreateConVar("hm_autohp_smoker_max", "2800", "", 262144, false, 0.0, false, 0.0);
  393. hm_autohp_boomer_min = CreateConVar("hm_autohp_boomer_min", "100", "", 262144, false, 0.0, false, 0.0);
  394. hm_autohp_boomer_max = CreateConVar("hm_autohp_boomer_max", "1000", "", 262144, false, 0.0, false, 0.0);
  395. hm_autohp_jockey_min = CreateConVar("hm_autohp_jockey_min", "325", "", 262144, false, 0.0, false, 0.0);
  396. hm_autohp_jockey_max = CreateConVar("hm_autohp_jockey_max", "3200", "", 262144, false, 0.0, false, 0.0);
  397. hm_autohp_spitter_min = CreateConVar("hm_autohp_spitter_min", "100", "", 262144, false, 0.0, false, 0.0);
  398. hm_autohp_spitter_max = CreateConVar("hm_autohp_spitter_max", "1700", "", 262144, false, 0.0, false, 0.0);
  399. hm_autohp_charger_min = CreateConVar("hm_autohp_charger_min", "600", "", 262144, false, 0.0, false, 0.0);
  400. hm_autohp_charger_max = CreateConVar("hm_autohp_charger_max", "3400", "", 262144, false, 0.0, false, 0.0);
  401. hm_autohp_witch_min = CreateConVar("hm_autohp_witch_min", "1000", "", 262144, false, 0.0, false, 0.0);
  402. hm_autohp_witch_max = CreateConVar("hm_autohp_witch_max", "1800", "", 262144, false, 0.0, false, 0.0);
  403. hm_autohp_tank_min = CreateConVar("hm_autohp_tank_min", "16000", "", 262144, false, 0.0, false, 0.0);
  404. hm_autohp_tank_max = CreateConVar("hm_autohp_tank_max", "150000", "", 262144, false, 0.0, false, 0.0);
  405. hm_items_automod = CreateConVar("hm_items_automod", "1", "", 262144, false, 0.0, false, 0.0);
  406. hm_items_supercharger_auto = CreateConVar("hm_items_supercharger_auto", "2", "", 262144, false, 0.0, false, 0.0);
  407. hm_items_hunter_min = CreateConVar("hm_items_hunter_min", "1", "", 262144, false, 0.0, false, 0.0);
  408. hm_items_hunter_max = CreateConVar("hm_items_hunter_max", "3", "", 262144, false, 0.0, false, 0.0);
  409. hm_items_smoker_min = CreateConVar("hm_items_smoker_min", "1", "", 262144, false, 0.0, false, 0.0);
  410. hm_items_smoker_max = CreateConVar("hm_items_smoker_max", "3", "", 262144, false, 0.0, false, 0.0);
  411. hm_items_boomer_min = CreateConVar("hm_items_boomer_min", "1", "", 262144, false, 0.0, false, 0.0);
  412. hm_items_boomer_max = CreateConVar("hm_items_boomer_max", "3", "", 262144, false, 0.0, false, 0.0);
  413. hm_items_jockey_min = CreateConVar("hm_items_jockey_min", "1", "", 262144, false, 0.0, false, 0.0);
  414. hm_items_jockey_max = CreateConVar("hm_items_jockey_max", "3", "", 262144, false, 0.0, false, 0.0);
  415. hm_items_charger_min = CreateConVar("hm_items_charger_min", "2", "", 262144, false, 0.0, false, 0.0);
  416. hm_items_charger_max = CreateConVar("hm_items_charger_max", "4", "", 262144, false, 0.0, false, 0.0);
  417. hm_items_spitter_min = CreateConVar("hm_items_spitter_min", "1", "", 262144, false, 0.0, false, 0.0);
  418. hm_items_spitter_max = CreateConVar("hm_items_spitter_max", "3", "", 262144, false, 0.0, false, 0.0);
  419. hm_items_tank_min = CreateConVar("hm_items_tank_min", "7", "", 262144, false, 0.0, false, 0.0);
  420. hm_items_tank_max = CreateConVar("hm_items_tank_max", "24", "", 262144, false, 0.0, false, 0.0);
  421. hm_spawn_automod = CreateConVar("hm_spawn_automod", "1", "", 262144, false, 0.0, false, 0.0);
  422. hm_spawn_zombie_min = CreateConVar("hm_spawn_zombie_min", "15", "", 262144, false, 0.0, false, 0.0);
  423. hm_spawn_zombie_max = CreateConVar("hm_spawn_zombie_max", "10", "", 262144, false, 0.0, false, 0.0);
  424. hm_spawn_hunter_min = CreateConVar("hm_spawn_hunter_min", "1", "", 262144, false, 0.0, false, 0.0);
  425. hm_spawn_hunter_max = CreateConVar("hm_spawn_hunter_max", "3", "", 262144, false, 0.0, false, 0.0);
  426. hm_spawn_smoker_min = CreateConVar("hm_spawn_smoker_min", "1", "", 262144, false, 0.0, false, 0.0);
  427. hm_spawn_smoker_max = CreateConVar("hm_spawn_smoker_max", "3", "", 262144, false, 0.0, false, 0.0);
  428. hm_spawn_boomer_min = CreateConVar("hm_spawn_boomer_min", "1", "", 262144, false, 0.0, false, 0.0);
  429. hm_spawn_boomer_max = CreateConVar("hm_spawn_boomer_max", "4", "", 262144, false, 0.0, false, 0.0);
  430. hm_spawn_jockey_min = CreateConVar("hm_spawn_jockey_min", "1", "", 262144, false, 0.0, false, 0.0);
  431. hm_spawn_jockey_max = CreateConVar("hm_spawn_jockey_max", "3", "", 262144, false, 0.0, false, 0.0);
  432. hm_spawn_spitter_min = CreateConVar("hm_spawn_spitter_min", "1", "", 262144, false, 0.0, false, 0.0);
  433. hm_spawn_spitter_max = CreateConVar("hm_spawn_spitter_max", "3", "", 262144, false, 0.0, false, 0.0);
  434. hm_spawn_charger_min = CreateConVar("hm_spawn_charger_min", "1", "", 262144, false, 0.0, false, 0.0);
  435. hm_spawn_charger_max = CreateConVar("hm_spawn_charger_max", "3", "", 262144, false, 0.0, false, 0.0);
  436. hm_speed_automod = CreateConVar("hm_speed_automod", "1", "", 262144, false, 0.0, false, 0.0);
  437. hm_speed_hunter_min = CreateConVar("hm_speed_hunter_min", "300", "", 262144, false, 0.0, false, 0.0);
  438. hm_speed_hunter_max = CreateConVar("hm_speed_hunter_max", "350", "", 262144, false, 0.0, false, 0.0);
  439. hm_speed_smoker_min = CreateConVar("hm_speed_smoker_min", "210", "", 262144, false, 0.0, false, 0.0);
  440. hm_speed_smoker_max = CreateConVar("hm_speed_smoker_max", "315", "", 262144, false, 0.0, false, 0.0);
  441. hm_speed_boomer_min = CreateConVar("hm_speed_boomer_min", "175", "", 262144, false, 0.0, false, 0.0);
  442. hm_speed_boomer_max = CreateConVar("hm_speed_boomer_max", "280", "", 262144, false, 0.0, false, 0.0);
  443. hm_speed_jockey_min = CreateConVar("hm_speed_jockey_min", "250", "", 262144, false, 0.0, false, 0.0);
  444. hm_speed_jockey_max = CreateConVar("hm_speed_jockey_max", "300", "", 262144, false, 0.0, false, 0.0);
  445. hm_speed_charger_min = CreateConVar("hm_speed_charger_min", "250", "", 262144, false, 0.0, false, 0.0);
  446. hm_speed_charger_max = CreateConVar("hm_speed_charger_max", "300", "", 262144, false, 0.0, false, 0.0);
  447. hm_speed_spitter_min = CreateConVar("hm_speed_spitter_min", "210", "", 262144, false, 0.0, false, 0.0);
  448. hm_speed_spitter_max = CreateConVar("hm_speed_spitter_max", "315", "", 262144, false, 0.0, false, 0.0);
  449. hm_speed_tank_min = CreateConVar("hm_speed_tank_min", "210", "", 262144, false, 0.0, false, 0.0);
  450. hm_speed_tank_max = CreateConVar("hm_speed_tank_max", "315", "", 262144, false, 0.0, false, 0.0);
  451. RegAdminCmd("sm_autodifficulty_init", Command_AutoDifficultyInit, 256, "", "", 0);
  452. RegAdminCmd("sm_autodifficulty_refresh", Command_AutoDifficultyRefresh, 256, "", "", 0);
  453. RegAdminCmd("sm_check", Command_Check, 256, "", "", 0);
  454. RegAdminCmd("sm_spawn_limits", Command_SpawnLimits, 256, "", "", 0);
  455. RegConsoleCmd("sm_rankmod", Command_RankMod, "", 0);
  456. RegConsoleCmd("sm_ddfull", Command_ddfull, "", 0);
  457. RegConsoleCmd("sm_damage", Command_damage, "", 0);
  458. RegConsoleCmd("sm_chance", Command_ammo, "", 0);
  459. RegConsoleCmd("sm_melee", Command_melee, "", 0);
  460. RegConsoleCmd("sm_info1", Command_info2, "", 0);
  461. RegConsoleCmd("sm_pinfo", Command_pinfo, "", 0);
  462. RegAdminCmd("sm_swd", Command_swd, 2, "sm_swd", "", 0);
  463. RegAdminCmd("sm_swdoff", Command_swdoff, 2, "sm_swdoff", "", 0);
  464. HookConVarChange(FindConVar("sv_maxplayers"), cvar_maxplayers_changed);
  465. RegConsoleCmd("say", cmd_Say, "", 0);
  466. RegConsoleCmd("say_team", cmd_Say, "", 0);
  467. return 0;
  468. }
  469.  
  470. ADOnMapStart()
  471. {
  472. g_IsTimeAutodifficulty = false;
  473. return 0;
  474. }
  475.  
  476. ADRoundStart()
  477. {
  478. if (FindConVar("monsterbots_interval"))
  479. {
  480. l4d2_plugin_monsterbots = true;
  481. }
  482. else
  483. {
  484. l4d2_plugin_monsterbots = false;
  485. }
  486. if (!l4d2_plugin_monsterbots)
  487. {
  488. new flags = GetConVarFlags(FindConVar("z_max_player_zombies"));
  489. SetConVarBounds(FindConVar("z_max_player_zombies"), ConVarBounds:0, false, 0.0);
  490. SetConVarFlags(FindConVar("z_max_player_zombies"), flags & -257);
  491. }
  492. cvar_maxplayers = GetConVarInt(FindConVar("sv_maxplayers")) + -5;
  493. CreateTimer(25.0, g_TimedAutoDifficultyInit, any:0, 0);
  494. return 0;
  495. }
  496.  
  497. public Action:g_TimedAutoDifficultyInit(Handle:timer, any:client)
  498. {
  499. g_IsTimeAutodifficulty = true;
  500. return Action:0;
  501. }
  502.  
  503. public Action:Command_AutoDifficultyInit(client, args)
  504. {
  505. AutoDifficultyInit();
  506. return Action:0;
  507. }
  508.  
  509. public Action:Command_AutoDifficultyRefresh(client, args)
  510. {
  511. new var1;
  512. if (GetRealtyClientCount(true) > 0 && g_IsTimeAutodifficulty)
  513. {
  514. Autodifficulty();
  515. }
  516. return Action:0;
  517. }
  518.  
  519. public Action:Command_Check(client, args)
  520. {
  521. PrintToServer("hm_autohp_charger_min = %d, hm_autohp_charger_max = %d, sv_maxplayers = %d", GetConVarInt(hm_autohp_charger_min), GetConVarInt(hm_autohp_charger_max), cvar_maxplayers);
  522. new i = 4;
  523. while (i <= MaxClients)
  524. {
  525. PrintToServer("AutodifficultyItems[%d][ZC_SMOKER] = %d | AutodifficultyHP[%d][ZC_CHARGER] = %d", i, AutodifficultyItems[i][1], i, AutodifficultyHP[i][6]);
  526. i++;
  527. }
  528. return Action:0;
  529. }
  530.  
  531. public Action:Command_SpawnLimits(client, args)
  532. {
  533. if (client)
  534. {
  535. PrintToChat(client, "z_common_limit = %d", GetConVarInt(FindConVar("z_common_limit")));
  536. PrintToChat(client, "z_hunter_limit = %d", GetConVarInt(FindConVar("z_hunter_limit")));
  537. PrintToChat(client, "z_smoker_limit = %d", GetConVarInt(FindConVar("z_smoker_limit")));
  538. PrintToChat(client, "z_boomer_limit = %d", GetConVarInt(FindConVar("z_boomer_limit")));
  539. PrintToChat(client, "z_spitter_limit = %d", GetConVarInt(FindConVar("z_spitter_limit")));
  540. PrintToChat(client, "z_jockey_limit = %d", GetConVarInt(FindConVar("z_jockey_limit")));
  541. PrintToChat(client, "z_charger_limit = %d", GetConVarInt(FindConVar("z_charger_limit")));
  542. }
  543. else
  544. {
  545. PrintToServer("z_common_limit = %d", GetConVarInt(FindConVar("z_common_limit")));
  546. PrintToServer("z_hunter_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_hunter_limit")), CountMonsters(3));
  547. PrintToServer("z_smoker_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_smoker_limit")), CountMonsters(1));
  548. PrintToServer("z_boomer_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_boomer_limit")), CountMonsters(2));
  549. PrintToServer("z_spitter_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_spitter_limit")), CountMonsters(4));
  550. PrintToServer("z_jockey_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_jockey_limit")), CountMonsters(5));
  551. PrintToServer("z_charger_limit = %d (spawned %d)", GetConVarInt(FindConVar("z_charger_limit")), CountMonsters(6));
  552. }
  553. return Action:0;
  554. }
  555.  
  556. CountMonsters(ZOMBIE_CLASS)
  557. {
  558. new count;
  559. new i = 1;
  560. while (i <= MaxClients)
  561. {
  562. if (ZOMBIE_CLASS == GetClientZC(i))
  563. {
  564. count++;
  565. }
  566. i++;
  567. }
  568. return count;
  569. }
  570.  
  571. public z_difficulty_changed(Handle:hVariable, String:strOldValue[], String:strNewValue[])
  572. {
  573. UpdateDifficultyName();
  574. return 0;
  575. }
  576.  
  577. public hm_ad_options_changed(Handle:hVariable, String:strOldValue[], String:strNewValue[])
  578. {
  579. AutoDifficultyInit();
  580. return 0;
  581. }
  582.  
  583. UpdateDifficultyName()
  584. {
  585. GetConVarString(z_difficulty, sGameDifficulty, 16);
  586. if (ReplaceString(sGameDifficulty, 16, "Impossible", "Expert", false))
  587. {
  588. cvar_difficulty = 4;
  589. }
  590. else
  591. {
  592. if (ReplaceString(sGameDifficulty, 16, "Hard", "Master", false))
  593. {
  594. cvar_difficulty = 3;
  595. }
  596. }
  597. return 0;
  598. }
  599.  
  600. AutoDifficultyInit()
  601. {
  602. UpdateDifficultyName();
  603. if (!cvar_maxplayers)
  604. {
  605. cvar_maxplayers = GetConVarInt(FindConVar("sv_maxplayers")) + -5;
  606. }
  607. if (cvar_maxplayers < 1)
  608. {
  609. return 0;
  610. }
  611. damage_type = FindConVar("hm_damage_type");
  612. if (FindConVar("l4d2_loot_h_drop_items"))
  613. {
  614. l4d2_plugin_loot = true;
  615. }
  616. else
  617. {
  618. l4d2_plugin_loot = false;
  619. }
  620. if (FindConVar("monsterbots_interval"))
  621. {
  622. l4d2_plugin_monsterbots = true;
  623. }
  624. else
  625. {
  626. l4d2_plugin_monsterbots = false;
  627. }
  628. new var1;
  629. if (FindConVar("l4d2_charger_steering_allow") && GetConVarInt(FindConVar("l4d2_charger_steering_allow")) > 0 && GetConVarFloat(hm_autohp_supercharger_auto) > 0)
  630. {
  631. extra_charger = true;
  632. }
  633. else
  634. {
  635. extra_charger = false;
  636. }
  637. new i = 4;
  638. while (i <= MaxClients)
  639. {
  640. AutodifficultyHP[i][0] = GetLineFunction(GetConVarInt(hm_autohp_zombie_min), GetConVarInt(hm_autohp_zombie_max), i);
  641. AutodifficultyHP[i][1] = GetLineFunction(GetConVarInt(hm_autohp_smoker_min), GetConVarInt(hm_autohp_smoker_max), i);
  642. AutodifficultyHP[i][2] = GetLineFunction(GetConVarInt(hm_autohp_boomer_min), GetConVarInt(hm_autohp_boomer_max), i);
  643. AutodifficultyHP[i][3] = GetLineFunction(GetConVarInt(hm_autohp_hunter_min), GetConVarInt(hm_autohp_hunter_max), i);
  644. AutodifficultyHP[i][4] = GetLineFunction(GetConVarInt(hm_autohp_spitter_min), GetConVarInt(hm_autohp_spitter_max), i);
  645. AutodifficultyHP[i][5] = GetLineFunction(GetConVarInt(hm_autohp_jockey_min), GetConVarInt(hm_autohp_jockey_max), i);
  646. AutodifficultyHP[i][6] = GetLineFunction(GetConVarInt(hm_autohp_charger_min), GetConVarInt(hm_autohp_charger_max), i);
  647. AutodifficultyHP[i][7] = GetLineFunction(GetConVarInt(hm_autohp_witch_min), GetConVarInt(hm_autohp_witch_max), i);
  648. AutodifficultyHP[i][8] = RoundToNearest(GetLineFunction(GetConVarInt(hm_autohp_tank_min), GetConVarInt(hm_autohp_tank_max), i) / 1.7);
  649. if (l4d2_plugin_loot)
  650. {
  651. AutodifficultyItems[i][1] = GetLineFunction(GetConVarInt(hm_items_smoker_min), GetConVarInt(hm_items_smoker_max), i);
  652. AutodifficultyItems[i][2] = GetLineFunction(GetConVarInt(hm_items_boomer_min), GetConVarInt(hm_items_boomer_max), i);
  653. AutodifficultyItems[i][3] = GetLineFunction(GetConVarInt(hm_items_hunter_min), GetConVarInt(hm_items_hunter_max), i);
  654. AutodifficultyItems[i][4] = GetLineFunction(GetConVarInt(hm_items_spitter_min), GetConVarInt(hm_items_spitter_max), i);
  655. AutodifficultyItems[i][5] = GetLineFunction(GetConVarInt(hm_items_jockey_min), GetConVarInt(hm_items_jockey_max), i);
  656. AutodifficultyItems[i][6] = GetLineFunction(GetConVarInt(hm_items_charger_min), GetConVarInt(hm_items_charger_max), i);
  657. AutodifficultyItems[i][8] = GetLineFunction(GetConVarInt(hm_items_tank_min), GetConVarInt(hm_items_tank_max), i);
  658. }
  659. AutodifficultySpawnLimit[i][0] = GetLineFunction(GetConVarInt(hm_spawn_zombie_min), GetConVarInt(hm_spawn_zombie_max), i);
  660. AutodifficultySpawnLimit[i][1] = GetLineFunction(GetConVarInt(hm_spawn_smoker_min), GetConVarInt(hm_spawn_smoker_max), i);
  661. AutodifficultySpawnLimit[i][2] = GetLineFunction(GetConVarInt(hm_spawn_boomer_min), GetConVarInt(hm_spawn_boomer_max), i);
  662. AutodifficultySpawnLimit[i][3] = GetLineFunction(GetConVarInt(hm_spawn_hunter_min), GetConVarInt(hm_spawn_hunter_max), i);
  663. AutodifficultySpawnLimit[i][4] = GetLineFunction(GetConVarInt(hm_spawn_spitter_min), GetConVarInt(hm_spawn_spitter_max), i);
  664. AutodifficultySpawnLimit[i][5] = GetLineFunction(GetConVarInt(hm_spawn_jockey_min), GetConVarInt(hm_spawn_jockey_max), i);
  665. AutodifficultySpawnLimit[i][6] = GetLineFunction(GetConVarInt(hm_spawn_charger_min), GetConVarInt(hm_spawn_charger_max), i);
  666. AutodifficultySpeed[i][1] = GetLineFunction(GetConVarInt(hm_speed_smoker_min), GetConVarInt(hm_speed_smoker_max), i);
  667. AutodifficultySpeed[i][2] = GetLineFunction(GetConVarInt(hm_speed_boomer_min), GetConVarInt(hm_speed_boomer_max), i);
  668. AutodifficultySpeed[i][3] = GetLineFunction(GetConVarInt(hm_speed_hunter_min), GetConVarInt(hm_speed_hunter_max), i);
  669. AutodifficultySpeed[i][4] = GetLineFunction(GetConVarInt(hm_speed_spitter_min), GetConVarInt(hm_speed_spitter_max), i);
  670. AutodifficultySpeed[i][5] = GetLineFunction(GetConVarInt(hm_speed_jockey_min), GetConVarInt(hm_speed_jockey_max), i);
  671. AutodifficultySpeed[i][6] = GetLineFunction(GetConVarInt(hm_speed_charger_min), GetConVarInt(hm_speed_charger_max), i);
  672. AutodifficultySpeed[i][8] = GetLineFunction(GetConVarInt(hm_speed_tank_min), GetConVarInt(hm_speed_tank_max), i);
  673. AutodifficultySpawnInterval[i] = GetLineFunction(GetConVarInt(hm_spawn_interval_max), GetConVarInt(hm_spawn_interval_min), i);
  674. AutodifficultySpawnCount[i] = GetLineFunction(GetConVarInt(hm_special_infected_min), GetConVarInt(hm_special_infected_max), i);
  675. AutodifficultyTongueRange[i] = GetLineFunction(GetConVarInt(hm_auto_tongue_range_min), GetConVarInt(hm_auto_tongue_range_max), i);
  676. AutodifficultyTongueMissDelay[i] = GetLineFunction(GetConVarInt(hm_auto_tongue_miss_delay_max), GetConVarInt(hm_auto_tongue_miss_delay_min), i);
  677. AutodifficultyTongueHitDelay[i] = GetLineFunction(GetConVarInt(hm_auto_tongue_hit_delay_max), GetConVarInt(hm_auto_tongue_hit_delay_min), i);
  678. AutodifficultyTongueChokeDmg[i] = GetLineFunction(GetConVarInt(hm_auto_tongue_choke_dmg_min), GetConVarInt(hm_auto_tongue_choke_dmg_max), i);
  679. AutodifficultyTongueDragDmg[i] = GetLineFunction(GetConVarInt(hm_auto_tongue_drag_dmg_min), GetConVarInt(hm_auto_tongue_drag_dmg_max), i);
  680. AutodifficultySmokerClawDmg[i] = GetLineFunction(GetConVarInt(hm_auto_smoker_pz_claw_dmg_min), GetConVarInt(hm_auto_smoker_pz_claw_dmg_max), i);
  681. AutodifficultyJockeyClawDmg[i] = GetLineFunction(GetConVarInt(hm_auto_jockey_pz_claw_dmg_min), GetConVarInt(hm_auto_jockey_pz_claw_dmg_max), i);
  682. AutodifficultyGrenadeLRDmg[i] = GetLineFunction(GetConVarInt(hm_auto_grenade_lr_dmg_min), GetConVarInt(hm_auto_grenade_lr_dmg_max), i);
  683. AutodifficultyTankBurnTime[i] = GetLineFunction(GetConVarInt(hm_tank_burn_duration_min), GetConVarInt(hm_tank_burn_duration_max), i);
  684. if (GetConVarInt(damage_type) == 1)
  685. {
  686. Autodifficulty_ak47_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_ak47_min), GetConVarInt(hm_damage_ak47_max), i);
  687. Autodifficulty_awp_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_awp_min), GetConVarInt(hm_damage_awp_max), i);
  688. Autodifficulty_m60_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_m60_min), GetConVarInt(hm_damage_m60_max), i);
  689. Autodifficulty_scout_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_scout_min), GetConVarInt(hm_damage_scout_max), i);
  690. Autodifficulty_sg552_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_sg552_min), GetConVarInt(hm_damage_sg552_max), i);
  691. Autodifficulty_spas_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_spas_min), GetConVarInt(hm_damage_spas_max), i);
  692. Autodifficulty_sniper_military_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage_sniper_military_min), GetConVarInt(hm_damage_sniper_military_max), i);
  693. }
  694. else
  695. {
  696. if (GetConVarInt(damage_type) == 2)
  697. {
  698. Autodifficulty_ak47_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_ak47_min), GetConVarInt(hm_damage2_ak47_max), i);
  699. Autodifficulty_awp_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_awp_min), GetConVarInt(hm_damage2_awp_max), i);
  700. Autodifficulty_m60_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_m60_min), GetConVarInt(hm_damage2_m60_max), i);
  701. Autodifficulty_scout_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_scout_min), GetConVarInt(hm_damage2_scout_max), i);
  702. Autodifficulty_sg552_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_sg552_min), GetConVarInt(hm_damage2_sg552_max), i);
  703. Autodifficulty_spas_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_spas_min), GetConVarInt(hm_damage2_spas_max), i);
  704. Autodifficulty_sniper_military_Dmg[i] = GetLineFunction(GetConVarInt(hm_damage2_sniper_military_min), GetConVarInt(hm_damage2_sniper_military_max), i);
  705. }
  706. }
  707. Autodifficulty_meleefix_Dmg[i] = GetLineFunction(GetConVarInt(hm_meleefix_min), GetConVarInt(hm_meleefix_max), i);
  708. Autodifficulty_meleefix_headshot_Dmg[i] = GetLineFunction(GetConVarInt(hm_meleefix_headshot_min), GetConVarInt(hm_meleefix_headshot_max), i);
  709. Autodifficulty_meleefix_tank_Dmg[i] = GetLineFunction(GetConVarInt(hm_meleefix_tank_min), GetConVarInt(hm_meleefix_tank_max), i);
  710. Autodifficulty_meleefix_tank_headshot_Dmg[i] = GetLineFunction(GetConVarInt(hm_meleefix_tank_headshot_min), GetConVarInt(hm_meleefix_tank_headshot_max), i);
  711. Autodifficulty_meleefix_witch_Dmg[i] = GetLineFunction(GetConVarInt(hm_meleefix_witch_min), GetConVarInt(hm_meleefix_witch_max), i);
  712. i++;
  713. }
  714. autodifficulty_calculated = true;
  715. return 0;
  716. }
  717.  
  718. GetLineFunction(GLF_Min, GLF_Max, i)
  719. {
  720. new result = GetLineFunctionEx(GLF_Min, GLF_Max, i, cvar_maxplayers);
  721. if (0 > result)
  722. {
  723. return GLF_Min;
  724. }
  725. return result;
  726. }
  727.  
  728. GetLineFunctionEx(GLF_Min, GLF_Max, i, GLF_maxplayers)
  729. {
  730. new Float:k = 1065353216 * GLF_Max - GLF_Min / GLF_maxplayers + -4 * 1.0;
  731. new Float:b = 1065353216 * GLF_Max - k * GLF_maxplayers;
  732. return RoundToNearest(k * i + b);
  733. }
  734.  
  735. GetTankHP()
  736. {
  737. new i = 1;
  738. while (i <= MaxClients)
  739. {
  740. new var1;
  741. if (IsValidEntity(i) && IsClientInGame(i) && GetClientTeam(i) == 3)
  742. {
  743. if (GetEntProp(i, PropType:0, "m_zombieClass", 4, 0) == 8)
  744. {
  745. if (GetEntProp(i, PropType:0, "m_isIncapacitated", 4, 0))
  746. {
  747. return 0;
  748. }
  749. return GetClientHealth(i);
  750. }
  751. }
  752. i++;
  753. }
  754. return GetConVarInt(FindConVar("z_tank_health")) * 2;
  755. }
  756.  
  757. public Action:Command_info2(client, args)
  758. {
  759. if (client)
  760. {
  761. new String:sFormattedTime[24];
  762. FormatTime(sFormattedTime, 22, "%m/%d/%Y - %H:%M:%S", GetTime({0,0}));
  763. decl String:Mapname[128];
  764. GetCurrentMap(Mapname, 128);
  765. UpdateServerUpTime();
  766. PrintToChat(client, "%t", "L4D2°•Rus Coop-25°•(Hardmod v0.4.34) | UpTime: %s", Server_UpTime);
  767. if (RDifficultyMultiplier >= 1000.0)
  768. {
  769. decl String:MapDifficultyMultiplier[8];
  770. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 8);
  771. PrintToChat(client, "%t", "Difficulty: %s x %s | Players: %i", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  772. }
  773. else
  774. {
  775. if (RDifficultyMultiplier >= 100.0)
  776. {
  777. decl String:MapDifficultyMultiplier[8];
  778. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 7);
  779. PrintToChat(client, "%t", "Difficulty: %s x %s | Players: %i", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  780. }
  781. if (RDifficultyMultiplier >= 10.0)
  782. {
  783. decl String:MapDifficultyMultiplier[8];
  784. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 6);
  785. PrintToChat(client, "%t", "Difficulty: %s x %s | Players: %i", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  786. }
  787. decl String:MapDifficultyMultiplier[8];
  788. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 5);
  789. CPrintToChat(client, "%t", "Difficulty: %s x %s | Players: %i | Live Survivors: %i", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true), GetLiveSurvivorsCount(true));
  790. }
  791. if (IsTankAlive())
  792. {
  793. new String:Message[256];
  794. new String:TempMessage[64];
  795. new bool:more_than_one;
  796. Format(TempMessage, 64, "%t", "Tank HP: ");
  797. StrCat(Message, 256, TempMessage);
  798. new i = 1;
  799. while (GetMaxClients() >= i)
  800. {
  801. if (IsClientInGame(i))
  802. {
  803. new var1;
  804. if (GetClientTeam(i) == 3 && !IsIncapacitated(i) && IsPlayerAlive(i) && GetClientZC(i) == 8 && GetClientHealth(i) > 0)
  805. {
  806. if (more_than_one)
  807. {
  808. Format(TempMessage, 64, "\x04& \x03%d ", GetClientHealth(i));
  809. StrCat(Message, 256, TempMessage);
  810. }
  811. else
  812. {
  813. Format(TempMessage, 64, "\x03%d ", GetClientHealth(i));
  814. StrCat(Message, 256, TempMessage);
  815. }
  816. more_than_one = true;
  817. }
  818. }
  819. i++;
  820. }
  821. Format(TempMessage, 64, "%t", "| Witch HP: %i | Zombie HP: %i", GetConVarInt(FindConVar("z_witch_health")), GetConVarInt(FindConVar("z_health")));
  822. StrCat(Message, 256, TempMessage);
  823. PrintToChat(client, Message);
  824. }
  825. else
  826. {
  827. PrintToChat(client, "%t", "Tank HP: %i | Witch HP: %i | Zombie HP: %i", GetTankHP(), GetConVarInt(FindConVar("z_witch_health")), GetConVarInt(FindConVar("z_health")));
  828. }
  829. PrintToChat(client, "%t", "Hunter HP: %i | Smoker HP: %i | Boomer HP: %i \nCharger HP: %i | Spitter HP: %i | Jockey HP: %i", GetConVarInt(FindConVar("z_hunter_health")), GetConVarInt(FindConVar("z_gas_health")), GetConVarInt(FindConVar("z_exploding_health")), GetConVarInt(FindConVar("z_charger_health")), GetConVarInt(FindConVar("z_spitter_health")), GetConVarInt(FindConVar("z_jockey_health")));
  830. PrintToChat(client, "%t", "Grenade Launcher Damage: %d. Server time: %s", GetConVarInt(FindConVar("grenadelauncher_damage")), sFormattedTime);
  831. PrintToChat(client, "%t", "CurrentMap: %s", Mapname);
  832. return Action:0;
  833. }
  834. return Action:3;
  835. }
  836.  
  837. public Autodifficulty()
  838. {
  839. if (GetConVarInt(hm_autodifficulty) < 1)
  840. {
  841. return 0;
  842. }
  843. if (!autodifficulty_calculated)
  844. {
  845. AutoDifficultyInit();
  846. return 0;
  847. }
  848. if (playerscount < 4)
  849. {
  850. playerscount = 4;
  851. }
  852. if (playerscount > cvar_maxplayers)
  853. {
  854. playerscount = cvar_maxplayers;
  855. }
  856. if (l4d2_plugin_monsterbots)
  857. {
  858. SetConVarInt(FindConVar("monsterbots_maxbots"), RoundToNearest(GetConVarFloat(hm_spawn_count_mod) * AutodifficultySpawnCount[playerscount]), false, false);
  859. SetConVarInt(FindConVar("monsterbots_interval"), RoundToNearest(GetConVarFloat(hm_spawn_time_mod) * AutodifficultySpawnInterval[playerscount]), false, false);
  860. }
  861. else
  862. {
  863. SetConVarInt(z_special_spawn_interval, RoundToNearest(GetConVarFloat(hm_spawn_time_mod) * AutodifficultySpawnInterval[playerscount]), false, false);
  864. SetConVarInt(director_special_respawn_interval, RoundToNearest(GetConVarFloat(hm_spawn_time_mod) * AutodifficultySpawnInterval[playerscount]), false, false);
  865. SetConVarInt(z_max_player_zombies, RoundToNearest(GetConVarFloat(hm_spawn_count_mod) * AutodifficultySpawnCount[playerscount]), false, false);
  866. }
  867. RDifficultyMultiplier = Calculate_Rank_Mod();
  868. if (0 < GetConVarInt(hm_speed_automod))
  869. {
  870. SetConVarInt(FindConVar("z_hunter_speed"), AutodifficultySpeed[playerscount][3], false, false);
  871. SetConVarInt(FindConVar("z_gas_speed"), AutodifficultySpeed[playerscount][1], false, false);
  872. SetConVarInt(FindConVar("z_exploding_speed"), AutodifficultySpeed[playerscount][2], false, false);
  873. SetConVarInt(FindConVar("z_spitter_speed"), AutodifficultySpeed[playerscount][4], false, false);
  874. SetConVarInt(FindConVar("z_jockey_speed"), AutodifficultySpeed[playerscount][5], false, false);
  875. SetConVarInt(FindConVar("z_charge_start_speed"), AutodifficultySpeed[playerscount][6], false, false);
  876. SetConVarInt(FindConVar("z_tank_speed"), AutodifficultySpeed[playerscount][8], false, false);
  877. }
  878. new Handle:tank_burn_duration;
  879. switch (cvar_difficulty)
  880. {
  881. case 1:
  882. {
  883. tank_burn_duration = FindConVar("tank_burn_duration");
  884. }
  885. case 3:
  886. {
  887. tank_burn_duration = FindConVar("tank_burn_duration_hard");
  888. }
  889. case 4:
  890. {
  891. tank_burn_duration = FindConVar("tank_burn_duration_expert");
  892. }
  893. default:
  894. {
  895. }
  896. }
  897. SetConVarInt(tank_burn_duration, AutodifficultyTankBurnTime[playerscount], false, false);
  898. SetConVarInt(FindConVar("grenadelauncher_damage"), AutodifficultyGrenadeLRDmg[playerscount], false, false);
  899. if (0 < GetConVarInt(hm_spawn_automod))
  900. {
  901. SetConVarInt(FindConVar("z_common_limit"), AutodifficultySpawnLimit[playerscount][0], false, false);
  902. SetConVarInt(FindConVar("z_hunter_limit"), AutodifficultySpawnLimit[playerscount][3], false, false);
  903. SetConVarInt(FindConVar("z_smoker_limit"), AutodifficultySpawnLimit[playerscount][1], false, false);
  904. SetConVarInt(FindConVar("z_boomer_limit"), AutodifficultySpawnLimit[playerscount][2], false, false);
  905. SetConVarInt(FindConVar("z_spitter_limit"), AutodifficultySpawnLimit[playerscount][4], false, false);
  906. SetConVarInt(FindConVar("z_jockey_limit"), AutodifficultySpawnLimit[playerscount][5], false, false);
  907. SetConVarInt(FindConVar("z_charger_limit"), AutodifficultySpawnLimit[playerscount][6], false, false);
  908. }
  909. new Float:HealthMod = GetConVarFloat(hm_infected_hp_mod);
  910. if (0 < GetConVarInt(hm_autohp_automod))
  911. {
  912. HealthMod *= RDifficultyMultiplier;
  913. }
  914. SetConVarInt(FindConVar("z_charger_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][6]), false, false);
  915. SetConVarInt(FindConVar("z_hunter_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][3]), false, false);
  916. SetConVarInt(FindConVar("z_gas_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][1]), false, false);
  917. SetConVarInt(FindConVar("z_exploding_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][2]), false, false);
  918. SetConVarInt(FindConVar("z_spitter_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][4]), false, false);
  919. SetConVarInt(FindConVar("z_jockey_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][5]), false, false);
  920. SetConVarInt(FindConVar("z_witch_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][7]), false, false);
  921. SetConVarInt(FindConVar("z_tank_health"), RoundToNearest(HealthMod * AutodifficultyHP[playerscount][8] * GetConVarFloat(hm_tank_hp_mod)), false, false);
  922. SetConVarInt(FindConVar("z_health"), RoundToNearest(1.0 * AutodifficultyHP[playerscount][0]), false, false);
  923. SetConVarInt(FindConVar("l4d2_ammo_witches"), RoundToNearest(1040187392 * playerscount + 0.5 * 4 * RDifficultyMultiplier), false, false);
  924. new var1;
  925. if (l4d2_plugin_loot && GetConVarInt(hm_items_automod) > 0)
  926. {
  927. new Float:LootMod = GetConVarFloat(hm_loot_mod);
  928. SetConVarInt(FindConVar("l4d2_loot_h_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][3]), false, false);
  929. SetConVarInt(FindConVar("l4d2_loot_b_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][2]), false, false);
  930. SetConVarInt(FindConVar("l4d2_loot_s_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][1]), false, false);
  931. SetConVarInt(FindConVar("l4d2_loot_sp_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][4]), false, false);
  932. SetConVarInt(FindConVar("l4d2_loot_j_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][5]), false, false);
  933. SetConVarInt(FindConVar("l4d2_loot_t_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][8]), false, false);
  934. if (extra_charger)
  935. {
  936. SetConVarInt(FindConVar("l4d2_loot_c_drop_items"), RoundToNearest(AutodifficultyItems[playerscount][6][LootMod * GetConVarInt(hm_items_supercharger_auto)]), false, false);
  937. }
  938. else
  939. {
  940. SetConVarInt(FindConVar("l4d2_loot_c_drop_items"), RoundToNearest(LootMod * AutodifficultyItems[playerscount][6]), false, false);
  941. }
  942. }
  943. SetConVarInt(FindConVar("tongue_miss_delay"), AutodifficultyTongueMissDelay[playerscount], false, false);
  944. SetConVarInt(FindConVar("tongue_hit_delay"), AutodifficultyTongueHitDelay[playerscount], false, false);
  945. SetConVarInt(FindConVar("tongue_range"), AutodifficultyTongueRange[playerscount], false, false);
  946. SetConVarInt(FindConVar("smoker_pz_claw_dmg"), AutodifficultySmokerClawDmg[playerscount], false, false);
  947. SetConVarInt(FindConVar("jockey_pz_claw_dmg"), AutodifficultyJockeyClawDmg[playerscount], false, false);
  948. SetConVarInt(FindConVar("tongue_choke_damage_amount"), AutodifficultyTongueChokeDmg[playerscount], false, false);
  949. SetConVarInt(FindConVar("tongue_drag_damage_amount"), AutodifficultyTongueDragDmg[playerscount], false, false);
  950. new Float:WeaponMod = GetConVarFloat(hm_infected_hp_mod);
  951. if (0 < GetConVarInt(hm_autohp_automod))
  952. {
  953. WeaponMod *= RDifficultyMultiplier;
  954. }
  955. if (GetConVarInt(damage_type) == 1)
  956. {
  957. SetConVarInt(FindConVar("hm_damage_ak47"), RoundToNearest(WeaponMod * Autodifficulty_ak47_Dmg[playerscount]), false, false);
  958. SetConVarInt(FindConVar("hm_damage_awp"), RoundToNearest(WeaponMod * Autodifficulty_awp_Dmg[playerscount]), false, false);
  959. SetConVarInt(FindConVar("hm_damage_m60"), RoundToNearest(WeaponMod * Autodifficulty_m60_Dmg[playerscount]), false, false);
  960. SetConVarInt(FindConVar("hm_damage_scout"), RoundToNearest(WeaponMod * Autodifficulty_scout_Dmg[playerscount]), false, false);
  961. SetConVarInt(FindConVar("hm_damage_sg552"), RoundToNearest(WeaponMod * Autodifficulty_sg552_Dmg[playerscount]), false, false);
  962. SetConVarInt(FindConVar("hm_damage_spas"), RoundToNearest(WeaponMod * Autodifficulty_spas_Dmg[playerscount]), false, false);
  963. SetConVarInt(FindConVar("hm_damage_sniper_military"), RoundToNearest(WeaponMod * Autodifficulty_sniper_military_Dmg[playerscount]), false, false);
  964. }
  965. else
  966. {
  967. if (GetConVarInt(damage_type) == 2)
  968. {
  969. SetConVarInt(FindConVar("hm_damage2_ak47"), RoundToNearest(WeaponMod * Autodifficulty_ak47_Dmg[playerscount]), false, false);
  970. SetConVarInt(FindConVar("hm_damage2_awp"), RoundToNearest(WeaponMod * Autodifficulty_awp_Dmg[playerscount]), false, false);
  971. SetConVarInt(FindConVar("hm_damage2_m60"), RoundToNearest(WeaponMod * Autodifficulty_m60_Dmg[playerscount]), false, false);
  972. SetConVarInt(FindConVar("hm_damage2_scout"), RoundToNearest(WeaponMod * Autodifficulty_scout_Dmg[playerscount]), false, false);
  973. SetConVarInt(FindConVar("hm_damage2_sg552"), RoundToNearest(WeaponMod * Autodifficulty_sg552_Dmg[playerscount]), false, false);
  974. SetConVarInt(FindConVar("hm_damage2_spas"), RoundToNearest(WeaponMod * Autodifficulty_spas_Dmg[playerscount]), false, false);
  975. SetConVarInt(FindConVar("hm_damage2_sniper_military"), RoundToNearest(WeaponMod * Autodifficulty_sniper_military_Dmg[playerscount]), false, false);
  976. }
  977. }
  978. SetConVarInt(FindConVar("hm_meleefix_smoker"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  979. SetConVarInt(FindConVar("hm_meleefix_smoker_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  980. SetConVarInt(FindConVar("hm_meleefix_boomer"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  981. SetConVarInt(FindConVar("hm_meleefix_boomer_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  982. SetConVarInt(FindConVar("hm_meleefix_hunter"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  983. SetConVarInt(FindConVar("hm_meleefix_hunter_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  984. SetConVarInt(FindConVar("hm_meleefix_jockey"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  985. SetConVarInt(FindConVar("hm_meleefix_jockey_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  986. SetConVarInt(FindConVar("hm_meleefix_spitter"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  987. SetConVarInt(FindConVar("hm_meleefix_spitter_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  988. SetConVarInt(FindConVar("hm_meleefix_charger"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_Dmg[playerscount]), false, false);
  989. SetConVarInt(FindConVar("hm_meleefix_charger_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_headshot_Dmg[playerscount]), false, false);
  990. SetConVarInt(FindConVar("hm_meleefix_tank"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_tank_Dmg[playerscount]), false, false);
  991. SetConVarInt(FindConVar("hm_meleefix_tank_headshot"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_tank_headshot_Dmg[playerscount]), false, false);
  992. SetConVarInt(FindConVar("hm_meleefix_witch"), RoundToNearest(WeaponMod * Autodifficulty_meleefix_witch_Dmg[playerscount]), false, false);
  993. if (playerscount > 4)
  994. {
  995. SetConVarInt(FindConVar("z_spitter_max_wait_time"), 34 - playerscount, false, false);
  996. SetConVarInt(FindConVar("z_vomit_interval"), 34 - playerscount, false, false);
  997. }
  998. else
  999. {
  1000. SetConVarInt(FindConVar("z_spitter_max_wait_time"), 30, false, false);
  1001. SetConVarInt(FindConVar("z_vomit_interval"), 30, false, false);
  1002. }
  1003. return 0;
  1004. }
  1005.  
  1006. public cvar_maxplayers_changed(Handle:hVariable, String:strOldValue[], String:strNewValue[])
  1007. {
  1008. cvar_maxplayers = GetConVarInt(FindConVar("sv_maxplayers")) + -5;
  1009. return 0;
  1010. }
  1011.  
  1012. public Action:Command_RankMod(client, args)
  1013. {
  1014. new Float:RankMod = Calculate_Rank_Mod();
  1015. if (client)
  1016. {
  1017. PrintToChat(client, "\x05loc_result: \x04%f", RankMod);
  1018. }
  1019. else
  1020. {
  1021. PrintToServer("local_result: %f", RankMod);
  1022. }
  1023. return Action:0;
  1024. }
  1025.  
  1026. ADPlayerSpawn(Handle:event)
  1027. {
  1028. if (GetConVarInt(hm_autodifficulty_forcehp) < 1)
  1029. {
  1030. return 0;
  1031. }
  1032. new client = GetClientOfUserId(GetEventInt(event, "userid", 0));
  1033. new var1;
  1034. if (IsValidClient(client) && GetClientTeam(client) == 3)
  1035. {
  1036. switch (GetClientZC(client))
  1037. {
  1038. case 1:
  1039. {
  1040. SetEntityHealth(client, GetConVarInt(FindConVar("z_gas_health")));
  1041. }
  1042. case 2:
  1043. {
  1044. SetEntityHealth(client, GetConVarInt(FindConVar("z_exploding_health")));
  1045. }
  1046. case 3:
  1047. {
  1048. SetEntityHealth(client, GetConVarInt(FindConVar("z_hunter_health")));
  1049. }
  1050. case 4:
  1051. {
  1052. SetEntityHealth(client, GetConVarInt(FindConVar("z_spitter_health")));
  1053. }
  1054. case 5:
  1055. {
  1056. SetEntityHealth(client, GetConVarInt(FindConVar("z_jockey_health")));
  1057. }
  1058. case 6:
  1059. {
  1060. SetEntityHealth(client, GetConVarInt(FindConVar("z_charger_health")));
  1061. }
  1062. case 8:
  1063. {
  1064. SetEntityHealth(client, GetConVarInt(FindConVar("z_tank_health")) * 2);
  1065. }
  1066. default:
  1067. {
  1068. }
  1069. }
  1070. }
  1071. return 0;
  1072. }
  1073.  
  1074. public Action:Command_melee(client, args)
  1075. {
  1076. if (IsClientInGame(client))
  1077. {
  1078. PrintToChat(client, "\x05melee damage for bosses: \x04%d \x05| melee damage for bosses (HEADSHOT): \x04%d", GetConVarInt(FindConVar("hm_meleefix_boomer")), GetConVarInt(FindConVar("hm_meleefix_boomer_headshot")));
  1079. PrintToChat(client, "\x05melee damage for tank: \x04%d \x05| tank headshot: \x04%d \x05| witch: \x04%d", GetConVarInt(FindConVar("hm_meleefix_tank")), GetConVarInt(FindConVar("hm_meleefix_tank_headshot")), GetConVarInt(FindConVar("hm_meleefix_witch")));
  1080. }
  1081. return Action:0;
  1082. }
  1083.  
  1084. public Action:Command_ammo(client, args)
  1085. {
  1086. if (IsClientInGame(client))
  1087. {
  1088. PrintToChat(client, "\x05witches: \x04%d \x05| ammochance medbox: \x04%d \x05| ammochance healbox: \x04%d", GetConVarInt(FindConVar("l4d2_ammo_witches")), GetConVarInt(FindConVar("l4d2_ammochance_medbox")), GetConVarInt(FindConVar("l4d2_ammochance_healbox")));
  1089. }
  1090. return Action:0;
  1091. }
  1092.  
  1093. public Action:Command_damage(client, args)
  1094. {
  1095. if (IsClientInGame(client))
  1096. {
  1097. if (GetConVarInt(damage_type) == 1)
  1098. {
  1099. PrintToChat(client, "\x05awp damage: \x04%d \x05| ak47 damage: \x04%d", GetConVarInt(FindConVar("hm_damage_awp")) / 1000 * 143, GetConVarInt(FindConVar("hm_damage_ak47")) / 1000 * 72);
  1100. PrintToChat(client, "\x05scout damage: \x04%d \x05| m60 damage: \x04%d", GetConVarInt(FindConVar("hm_damage_scout")) / 1000 * 112, GetConVarInt(FindConVar("hm_damage_m60")) / 1000 * 62);
  1101. PrintToChat(client, "\x05spas damage: \x04%d \x05| sg552 damage: \x04%d", GetConVarInt(FindConVar("hm_damage_spas")) / 1000 * 22, GetConVarInt(FindConVar("hm_damage_sg552")) / 1000 * 36);
  1102. }
  1103. if (GetConVarInt(damage_type) == 2)
  1104. {
  1105. PrintToChat(client, "\x05awp damage: \x04%d \x05| ak47 damage: \x04%d", GetConVarInt(FindConVar("hm_damage2_awp")), GetConVarInt(FindConVar("hm_damage2_ak47")));
  1106. PrintToChat(client, "\x05scout damage: \x04%d \x05| m60 damage: \x04%d", GetConVarInt(FindConVar("hm_damage2_scout")), GetConVarInt(FindConVar("hm_damage2_m60")));
  1107. PrintToChat(client, "\x05spas damage: \x04%d \x05| sg552 damage: \x04%d", GetConVarInt(FindConVar("hm_damage2_spas")), GetConVarInt(FindConVar("hm_damage2_sg552")));
  1108. }
  1109. }
  1110. return Action:0;
  1111. }
  1112.  
  1113. public Action:Command_swd(client, args)
  1114. {
  1115. SetConVarInt(FindConVar("hm_damage_showvalue"), 1, false, false);
  1116. PrintToChat(client, "\x05Показ урона \x04включен");
  1117. return Action:0;
  1118. }
  1119.  
  1120. public Action:Command_swdoff(client, args)
  1121. {
  1122. SetConVarInt(FindConVar("hm_damage_showvalue"), 0, false, false);
  1123. PrintToChat(client, "\x05Показ урона \x04выключен");
  1124. return Action:0;
  1125. }
  1126.  
  1127. public Action:Command_ddfull(client, args)
  1128. {
  1129. Command_melee(client, args);
  1130. Command_ammo(client, args);
  1131. Command_damage(client, args);
  1132. return Action:0;
  1133. }
  1134.  
  1135. IsTankAlive()
  1136. {
  1137. new i = 1;
  1138. while (i <= MaxClients)
  1139. {
  1140. if (IsClientInGame(i))
  1141. {
  1142. if (IsPlayerAlive(i))
  1143. {
  1144. new var1;
  1145. if (GetClientZC(i) == 8 && !IsIncapacitated(i))
  1146. {
  1147. return 1;
  1148. }
  1149. }
  1150. }
  1151. i++;
  1152. }
  1153. return 0;
  1154. }
  1155.  
  1156. public bool:IsIncapacitated(client)
  1157. {
  1158. new isIncap = GetEntProp(client, PropType:0, "m_isIncapacitated", 4, 0);
  1159. if (isIncap)
  1160. {
  1161. return true;
  1162. }
  1163. return false;
  1164. }
  1165.  
  1166. GetRealClientCount(bool:inGameOnly)
  1167. {
  1168. new clients;
  1169. new i = 1;
  1170. while (i <= MaxClients)
  1171. {
  1172. if (IsClientInGame(i))
  1173. {
  1174. if (!IsFakeClient(i))
  1175. {
  1176. clients++;
  1177. }
  1178. }
  1179. i++;
  1180. }
  1181. return clients;
  1182. }
  1183.  
  1184. UpdateServerUpTime()
  1185. {
  1186. decl String:str_uptime_temp[8];
  1187. new Current_UpTime = GetTime({0,0}) - UpTime;
  1188. new Days = RoundToFloor(Current_UpTime / 1202241536);
  1189. Current_UpTime -= Days * 86400;
  1190. if (0 < Days)
  1191. {
  1192. if (Days > 1)
  1193. {
  1194. Format(Server_UpTime, 20, "%d days ", Days);
  1195. }
  1196. else
  1197. {
  1198. Format(Server_UpTime, 20, "1 day ");
  1199. }
  1200. }
  1201. new Hours = RoundToFloor(Current_UpTime / 1163984896);
  1202. if (Hours < 10)
  1203. {
  1204. Format(str_uptime_temp, 8, "0%d:", Hours);
  1205. }
  1206. else
  1207. {
  1208. Format(str_uptime_temp, 8, "%d:", Hours);
  1209. }
  1210. StrCat(Server_UpTime, 20, str_uptime_temp);
  1211. Current_UpTime -= Hours * 3600;
  1212. FormatTime(str_uptime_temp, 8, "%M:%S", Current_UpTime);
  1213. StrCat(Server_UpTime, 20, str_uptime_temp);
  1214. return 0;
  1215. }
  1216.  
  1217. public Action:Command_pinfo(client, args)
  1218. {
  1219. new var1;
  1220. if (client > 0 && args < 1)
  1221. {
  1222. ShowMyPanel(client);
  1223. }
  1224. return Action:3;
  1225. }
  1226.  
  1227. ShowMyPanel(client)
  1228. {
  1229. new Handle:panel = CreatePanel(Handle:0);
  1230. new String:text[1024];
  1231. new String:sFormattedTime[24];
  1232. FormatTime(sFormattedTime, 22, "%m/%d/%Y - %H:%M:%S", GetTime({0,0}));
  1233. decl String:Mapname[128];
  1234. GetCurrentMap(Mapname, 128);
  1235. UpdateServerUpTime();
  1236. Format(text, 1024, "%t", "L4D2°•Rus Coop-25°•(Hardmod v0.4.34) | UpTime: %s (panel)", Server_UpTime);
  1237. SetPanelTitle(panel, text, false);
  1238. if (RDifficultyMultiplier >= 1000.0)
  1239. {
  1240. decl String:MapDifficultyMultiplier[8];
  1241. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 8);
  1242. Format(text, 1024, "%t", "Difficulty: %s x %s | Players: %i (panel)", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  1243. DrawPanelText(panel, text);
  1244. }
  1245. else
  1246. {
  1247. if (RDifficultyMultiplier >= 100.0)
  1248. {
  1249. decl String:MapDifficultyMultiplier[8];
  1250. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 7);
  1251. Format(text, 1024, "%t", "Difficulty: %s x %s | Players: %i (panel)", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  1252. DrawPanelText(panel, text);
  1253. }
  1254. if (RDifficultyMultiplier >= 10.0)
  1255. {
  1256. decl String:MapDifficultyMultiplier[8];
  1257. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 6);
  1258. Format(text, 1024, "%t", "Difficulty: %s x %s | Players: %i (panel)", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true));
  1259. DrawPanelText(panel, text);
  1260. }
  1261. decl String:MapDifficultyMultiplier[8];
  1262. FloatToString(RDifficultyMultiplier, MapDifficultyMultiplier, 5);
  1263. Format(text, 1024, "%t", "Difficulty: %s x %s | Players: %i | Live Survivors: %i (panel)", sGameDifficulty, MapDifficultyMultiplier, GetRealClientCount(true), GetLiveSurvivorsCount(true));
  1264. DrawPanelText(panel, text);
  1265. }
  1266. if (IsTankAlive())
  1267. {
  1268. new String:Message[256];
  1269. new String:TempMessage[64];
  1270. Format(TempMessage, 64, "%t", "Tank HP: (panel)");
  1271. StrCat(Message, 256, TempMessage);
  1272. new i = 1;
  1273. while (GetMaxClients() >= i)
  1274. {
  1275. if (IsClientInGame(i))
  1276. {
  1277. new var1;
  1278. if (GetClientTeam(i) == 3 && !IsIncapacitated(i) && IsPlayerAlive(i) && GetClientZC(i) == 8 && GetClientHealth(i) > 0)
  1279. {
  1280. Format(TempMessage, 64, "%d ", GetClientHealth(i));
  1281. StrCat(Message, 256, TempMessage);
  1282. }
  1283. }
  1284. i++;
  1285. }
  1286. Format(TempMessage, 64, "%t", "| Witch HP: %i | Zombie HP: %i (panel)", GetConVarInt(FindConVar("z_witch_health")), GetConVarInt(FindConVar("z_health")));
  1287. StrCat(Message, 256, TempMessage);
  1288. DrawPanelText(panel, Message);
  1289. }
  1290. else
  1291. {
  1292. Format(text, 1024, "%t", "Tank HP: %i | Witch HP: %i | Zombie HP: %i (panel)", GetTankHP(), GetConVarInt(FindConVar("z_witch_health")), GetConVarInt(FindConVar("z_health")));
  1293. DrawPanelText(panel, text);
  1294. }
  1295. Format(text, 1024, "%t", "Hunter HP: %i | Smoker HP: %i | Boomer HP: %i (panel)", GetConVarInt(FindConVar("z_hunter_health")), GetConVarInt(FindConVar("z_gas_health")), GetConVarInt(FindConVar("z_exploding_health")));
  1296. DrawPanelText(panel, text);
  1297. Format(text, 1024, "%t", "Charger HP: %i | Spitter HP: %i | Jockey HP: %i (panel)", GetConVarInt(FindConVar("z_charger_health")), GetConVarInt(FindConVar("z_spitter_health")), GetConVarInt(FindConVar("z_jockey_health")));
  1298. DrawPanelText(panel, text);
  1299. Format(text, 1024, "%t", "Grenade Launcher Damage: %d. Server time: %s (panel)", GetConVarInt(FindConVar("grenadelauncher_damage")), sFormattedTime);
  1300. DrawPanelText(panel, text);
  1301. Format(text, 1024, "%t", "CurrentMap: %s (panel)", Mapname);
  1302. DrawPanelText(panel, text);
  1303. DrawPanelItem(panel, "Close", 0);
  1304. SendPanelToClient(panel, client, PanelHandler, 30);
  1305. CloseHandle(panel);
  1306. return 0;
  1307. }
  1308.  
  1309. public PanelHandler(Handle:menu, MenuAction:action, param1, param2)
  1310. {
  1311. return 0;
  1312. }
  1313.  
  1314. public Action:cmd_Say(client, args)
  1315. {
  1316. decl String:Text[192];
  1317. new Start;
  1318. GetCmdArgString(Text, 192);
  1319. new TextLen = strlen(Text);
  1320. if (0 >= TextLen)
  1321. {
  1322. return Action:0;
  1323. }
  1324. if (Text[TextLen + -1] == '"')
  1325. {
  1326. Text[TextLen + -1] = MissingTAG:0;
  1327. Start = 1;
  1328. }
  1329. return HandleCommands(client, Text[Start]);
  1330. }
  1331.  
  1332. public Action:HandleCommands(client, String:Text[])
  1333. {
  1334. if (strcmp(Text, "!info2", false))
  1335. {
  1336. if (!(strcmp(Text, "/info2", false)))
  1337. {
  1338. Command_info2(client, 0);
  1339. return Action:3;
  1340. }
  1341. }
  1342. else
  1343. {
  1344. Command_info2(client, 0);
  1345. }
  1346. return Action:0;
  1347. }
  1348.  
  1349. public DamageOnPluginStart()
  1350. {
  1351. hm_damage = CreateConVar("hm_damage", "1", "Enable/Disable damage", 262144, false, 0.0, false, 0.0);
  1352. hm_damage_friendly = CreateConVar("hm_damage_friendly", "0.3", "Enable/Disable ff damage", 262144, false, 0.0, false, 0.0);
  1353. hm_damage_showvalue = CreateConVar("hm_damage_showvalue", "0", "Enable/Disable show damage", 262144, false, 0.0, false, 0.0);
  1354. hm_damage_hunter = CreateConVar("hm_damage_hunter", "1.0", "Hunter additional damage", 262144, false, 0.0, false, 0.0);
  1355. hm_damage_smoker = CreateConVar("hm_damage_smoker", "1.2", "Smoker additional damage", 262144, false, 0.0, false, 0.0);
  1356. hm_damage_boomer = CreateConVar("hm_damage_boomer", "1.2", "Boomer additional damage", 262144, false, 0.0, false, 0.0);
  1357. hm_damage_spitter1 = CreateConVar("hm_damage_spitter1", "1.2", "Spitter additional damage", 262144, false, 0.0, false, 0.0);
  1358. hm_damage_spitter2 = CreateConVar("hm_damage_spitter2", "4", "Spitter additional damage (spit)", 262144, false, 0.0, false, 0.0);
  1359. hm_damage_jockey = CreateConVar("hm_damage_jockey", "1.2", "Jockey additional damage", 262144, false, 0.0, false, 0.0);
  1360. hm_damage_charger = CreateConVar("hm_damage_charger", "1.2", "Charger additional damage", 262144, false, 0.0, false, 0.0);
  1361. hm_damage_tank = CreateConVar("hm_damage_tank", "1.0", "Tank additional damage", 262144, false, 0.0, false, 0.0);
  1362. hm_damage_tankrock = CreateConVar("hm_damage_tankrock", "1.0", "Tank additional damage", 262144, false, 0.0, false, 0.0);
  1363. hm_damage_common = CreateConVar("hm_damage_common", "0", "Common additional damage", 262144, false, 0.0, false, 0.0);
  1364. hm_damage_type = CreateConVar("hm_damage_type", "2", "damage type", 262144, false, 0.0, false, 0.0);
  1365. hm_damage_ak47 = CreateConVar("hm_damage_ak47", "2523", "AK47 additional damage", 262144, false, 0.0, false, 0.0);
  1366. hm_damage2_ak47 = CreateConVar("hm_damage2_ak47", "140", "AK47 damage", 262144, false, 0.0, false, 0.0);
  1367. hm_damage_awp = CreateConVar("hm_damage_awp", "9486", "AWP additional damage", 262144, false, 0.0, false, 0.0);
  1368. hm_damage2_awp = CreateConVar("hm_damage2_awp", "700", "AWP damage", 262144, false, 0.0, false, 0.0);
  1369. hm_damage_scout = CreateConVar("hm_damage_scout", "4667", "Scout additional damage", 262144, false, 0.0, false, 0.0);
  1370. hm_damage2_scout = CreateConVar("hm_damage2_scout", "420", "Scout damage", 262144, false, 0.0, false, 0.0);
  1371. hm_damage_m60 = CreateConVar("hm_damage_m60", "1652", "M60 additional damage", 262144, false, 0.0, false, 0.0);
  1372. hm_damage2_m60 = CreateConVar("hm_damage2_m60", "85", "M60 damage", 262144, false, 0.0, false, 0.0);
  1373. hm_damage_spas = CreateConVar("hm_damage_spas", "3000", "SPAS additional damage", 262144, false, 0.0, false, 0.0);
  1374. hm_damage2_spas = CreateConVar("hm_damage2_spas", "60", "SPAS damage", 262144, false, 0.0, false, 0.0);
  1375. hm_damage_sg552 = CreateConVar("hm_damage_sg552", "1111", "SG552 additional damage", 262144, false, 0.0, false, 0.0);
  1376. hm_damage2_sg552 = CreateConVar("hm_damage2_sg552", "70", "SG552 damage", 262144, false, 0.0, false, 0.0);
  1377. hm_damage_smg = CreateConVar("hm_damage_smg", "0.6", "SMG additional damage", 262144, false, 0.0, false, 0.0);
  1378. hm_damage_smg_silenced = CreateConVar("hm_damage_smg_silenced", "0.6", "SMG_SILENCED additional damage", 262144, false, 0.0, false, 0.0);
  1379. hm_damage_m16 = CreateConVar("hm_damage_m16", "0.6", "M16 additional damage", 262144, false, 0.0, false, 0.0);
  1380. hm_damage_pumpshotgun = CreateConVar("hm_damage_pumpshotgun", "0.6", "PUMPSHOTGUN additional damage", 262144, false, 0.0, false, 0.0);
  1381. hm_damage_autoshotgun = CreateConVar("hm_damage_autoshotgun", "0.6", "AUTOSHOTGUN additional damage", 262144, false, 0.0, false, 0.0);
  1382. hm_damage_hunting_rifle = CreateConVar("hm_damage_hunting_rifle", "0.6", "HUNTING_RIFLE additional damage", 262144, false, 0.0, false, 0.0);
  1383. hm_damage_rifle_desert = CreateConVar("hm_damage_rifle_desert", "0.6", "RIFLE_DESERT additional damage", 262144, false, 0.0, false, 0.0);
  1384. hm_damage_shotgun_chrome = CreateConVar("hm_damage_shotgun_chrome", "0.6", "SHOTGUN_CHROME additional damage", 262144, false, 0.0, false, 0.0);
  1385. hm_damage_smg_mp5 = CreateConVar("hm_damage_smg_mp5", "0.6", "MP5 additional damage", 262144, false, 0.0, false, 0.0);
  1386. hm_damage_sniper_military = CreateConVar("hm_damage_sniper_military", "1055", "sniper military additional damage", 262144, false, 0.0, false, 0.0);
  1387. hm_damage2_sniper_military = CreateConVar("hm_damage2_sniper_military", "50", "sniper military damage", 262144, false, 0.0, false, 0.0);
  1388. hm_damage_pistol = CreateConVar("hm_damage_pistol", "0.6", "pistol additional damage", 262144, false, 0.0, false, 0.0);
  1389. hm_damage_pistol_magnum = CreateConVar("hm_damage_pistol_magnum", "1.0", "pistol magnum additional damage", 262144, false, 0.0, false, 0.0);
  1390. hm_damage_pipebomb = CreateConVar("hm_damage_pipebomb", "90", "Pipe bomb additional damage", 262144, false, 0.0, false, 0.0);
  1391. MeleeDmg[1] = CreateConVar("hm_meleefix_smoker", "1000.0", "Melee damage Smoker", 262144, false, 0.0, false, 0.0);
  1392. MeleeDmg[2] = CreateConVar("hm_meleefix_boomer", "1000.0", "Melee damage Boomer", 262144, false, 0.0, false, 0.0);
  1393. MeleeDmg[3] = CreateConVar("hm_meleefix_hunter", "1000.0", "Melee damage Hunter", 262144, false, 0.0, false, 0.0);
  1394. MeleeDmg[5] = CreateConVar("hm_meleefix_jockey", "1000.0", "Melee damage Jockey", 262144, false, 0.0, false, 0.0);
  1395. MeleeDmg[4] = CreateConVar("hm_meleefix_spitter", "1000.0", "Melee damage Spitter", 262144, false, 0.0, false, 0.0);
  1396. MeleeDmg[6] = CreateConVar("hm_meleefix_charger", "1000.0", "Melee damage Charger", 262144, false, 0.0, false, 0.0);
  1397. MeleeDmg[0] = CreateConVar("hm_meleefix_witch", "400.0", "Melee damage Witch", 262144, false, 0.0, false, 0.0);
  1398. MeleeDmg[8] = CreateConVar("hm_meleefix_tank", "1000.0", "Melee damage Tank", 262144, false, 0.0, false, 0.0);
  1399. MeleeHeadshotDmg[1] = CreateConVar("hm_meleefix_smoker_headshot", "2000.0", "Headshot Melee damage Smoker", 262144, false, 0.0, false, 0.0);
  1400. MeleeHeadshotDmg[2] = CreateConVar("hm_meleefix_boomer_headshot", "2000.0", "Headshot Melee damage Boomer", 262144, false, 0.0, false, 0.0);
  1401. MeleeHeadshotDmg[3] = CreateConVar("hm_meleefix_hunter_headshot", "2000.0", "Headshot Melee damage Hunter", 262144, false, 0.0, false, 0.0);
  1402. MeleeHeadshotDmg[5] = CreateConVar("hm_meleefix_jockey_headshot", "2000.0", "Headshot Melee damage Jockey", 262144, false, 0.0, false, 0.0);
  1403. MeleeHeadshotDmg[4] = CreateConVar("hm_meleefix_spitter_headshot", "2000.0", "Headshot Melee damage Spitter", 262144, false, 0.0, false, 0.0);
  1404. MeleeHeadshotDmg[6] = CreateConVar("hm_meleefix_charger_headshot", "2000.0", "Headshot Melee damage Charger", 262144, false, 0.0, false, 0.0);
  1405. MeleeHeadshotDmg[8] = CreateConVar("hm_meleefix_tank_headshot", "1000.0", "Headshot Melee damage Tank", 262144, false, 0.0, false, 0.0);
  1406. HookConVarChange(MeleeDmg[1], ConVarChanged);
  1407. HookConVarChange(MeleeDmg[2], ConVarChanged);
  1408. HookConVarChange(MeleeDmg[3], ConVarChanged);
  1409. HookConVarChange(MeleeDmg[5], ConVarChanged);
  1410. HookConVarChange(MeleeDmg[4], ConVarChanged);
  1411. HookConVarChange(MeleeDmg[6], ConVarChanged);
  1412. HookConVarChange(MeleeDmg[0], ConVarChanged);
  1413. HookConVarChange(MeleeDmg[8], ConVarChanged);
  1414. HookConVarChange(MeleeHeadshotDmg[1], ConVarChanged);
  1415. HookConVarChange(MeleeHeadshotDmg[2], ConVarChanged);
  1416. HookConVarChange(MeleeHeadshotDmg[3], ConVarChanged);
  1417. HookConVarChange(MeleeHeadshotDmg[5], ConVarChanged);
  1418. HookConVarChange(MeleeHeadshotDmg[4], ConVarChanged);
  1419. HookConVarChange(MeleeHeadshotDmg[6], ConVarChanged);
  1420. HookConVarChange(MeleeHeadshotDmg[8], ConVarChanged);
  1421. HookEvent("player_hurt", Event_DPlayerHurt, EventHookMode:0);
  1422. HookEvent("witch_spawn", OnWitchSpawn_Event, EventHookMode:1);
  1423. HookEvent("witch_killed", OnWitchKilled_Event, EventHookMode:1);
  1424. ConVarsInit();
  1425. new x = 1;
  1426. while (x <= MaxClients)
  1427. {
  1428. if (ValidClient(x))
  1429. {
  1430. SDKHook(x, SDKHookType:2, OnTakeDamage);
  1431. }
  1432. x++;
  1433. }
  1434. return 0;
  1435. }
  1436.  
  1437. public void:OnPluginEnd()
  1438. {
  1439. new x = 1;
  1440. while (x <= MaxClients)
  1441. {
  1442. if (ValidClient(x))
  1443. {
  1444. SDKUnhook(x, SDKHookType:2, OnTakeDamage);
  1445. }
  1446. x++;
  1447. }
  1448. return void:0;
  1449. }
  1450.  
  1451. ValidClient(ok)
  1452. {
  1453. new var1;
  1454. if (0 < ok <= MaxClients && IsClientConnected(ok) && IsClientInGame(ok))
  1455. {
  1456. return 1;
  1457. }
  1458. return 0;
  1459. }
  1460.  
  1461. public ConVarChanged(Handle:hVariable, String:strOldValue[], String:strNewValue[])
  1462. {
  1463. ConVarsInit();
  1464. return 0;
  1465. }
  1466.  
  1467. public ConVarsInit()
  1468. {
  1469. DamageBody[1] = GetConVarFloat(MeleeDmg[1]);
  1470. DamageBody[2] = GetConVarFloat(MeleeDmg[2]);
  1471. DamageBody[3] = GetConVarFloat(MeleeDmg[3]);
  1472. DamageBody[5] = GetConVarFloat(MeleeDmg[5]);
  1473. DamageBody[4] = GetConVarFloat(MeleeDmg[4]);
  1474. DamageBody[6] = GetConVarFloat(MeleeDmg[6]);
  1475. DamageBody[0] = GetConVarFloat(MeleeDmg[0]);
  1476. DamageBody[8] = GetConVarFloat(MeleeDmg[8]);
  1477. DamageHeadshot[1] = GetConVarFloat(MeleeHeadshotDmg[1]);
  1478. DamageHeadshot[2] = GetConVarFloat(MeleeHeadshotDmg[2]);
  1479. DamageHeadshot[3] = GetConVarFloat(MeleeHeadshotDmg[3]);
  1480. DamageHeadshot[5] = GetConVarFloat(MeleeHeadshotDmg[5]);
  1481. DamageHeadshot[4] = GetConVarFloat(MeleeHeadshotDmg[4]);
  1482. DamageHeadshot[6] = GetConVarFloat(MeleeHeadshotDmg[6]);
  1483. DamageHeadshot[8] = GetConVarFloat(MeleeHeadshotDmg[8]);
  1484. return 0;
  1485. }
  1486.  
  1487. public void:OnAllPluginsLoaded()
  1488. {
  1489. new i = 1;
  1490. while (i <= MaxClients)
  1491. {
  1492. SDKHook(i, SDKHookType:11, OnTraceAttack);
  1493. i++;
  1494. }
  1495. return void:0;
  1496. }
  1497.  
  1498. public void:OnClientPutInServer(client)
  1499. {
  1500. SDKHook(client, SDKHookType:11, OnTraceAttack);
  1501. SDKHook(client, SDKHookType:2, OnTakeDamage);
  1502. return void:0;
  1503. }
  1504.  
  1505. DMOnClientDisconnect(client)
  1506. {
  1507. SDKUnhook(client, SDKHookType:11, OnTraceAttack);
  1508. SDKUnhook(client, SDKHookType:2, OnTakeDamage);
  1509. return 0;
  1510. }
  1511.  
  1512. public OnWitchSpawn_Event(Handle:event, String:name[], bool:dontBroadcast)
  1513. {
  1514. if (0.0 == DamageBody[0])
  1515. {
  1516. return 0;
  1517. }
  1518. new witch = GetEventInt(event, "witchid", 0);
  1519. new var1;
  1520. if (witch < 1 || !IsValidEntity(witch))
  1521. {
  1522. return 0;
  1523. }
  1524. SDKHook(witch, SDKHookType:2, OnWitchTakeDamage);
  1525. return 0;
  1526. }
  1527.  
  1528. public OnWitchKilled_Event(Handle:event, String:name[], bool:dontBroadcast)
  1529. {
  1530. if (0.0 == DamageBody[0])
  1531. {
  1532. return 0;
  1533. }
  1534. new witch = GetEventInt(event, "witchid", 0);
  1535. new var1;
  1536. if (witch < 1 || !IsValidEntity(witch))
  1537. {
  1538. return 0;
  1539. }
  1540. SDKUnhook(witch, SDKHookType:2, OnWitchTakeDamage);
  1541. return 0;
  1542. }
  1543.  
  1544. public Action:OnWitchTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
  1545. {
  1546. new var1;
  1547. if (!damage > 0.0 || attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker) || GetClientTeam(attacker) == 2)
  1548. {
  1549. return Action:0;
  1550. }
  1551. decl String:clsname[64];
  1552. GetEdictClassname(inflictor, clsname, 64);
  1553. if (!StrEqual(clsname, "weapon_melee", true))
  1554. {
  1555. return Action:0;
  1556. }
  1557. damage = DamageBody[0];
  1558. return Action:1;
  1559. }
  1560.  
  1561. public Action:OnTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
  1562. {
  1563. new var1;
  1564. if (0.0 == damage || victim < 1 || victim > MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) == 3 || attacker < 1 || attacker > MaxClients || !IsClientInGame(attacker) || GetClientTeam(attacker) == 2)
  1565. {
  1566. return Action:0;
  1567. }
  1568. decl String:clsname[64];
  1569. GetEdictClassname(inflictor, clsname, 64);
  1570. if (!StrEqual(clsname, "weapon_melee", true))
  1571. {
  1572. return Action:0;
  1573. }
  1574. new zClass = GetEntProp(victim, PropType:0, "m_zombieClass", 4, 0);
  1575. new var2;
  1576. if ((zClass > 0 && zClass < 7) || zClass == 8)
  1577. {
  1578. if (0.0 == DamageBody[zClass])
  1579. {
  1580. return Action:0;
  1581. }
  1582. if (hitgroup == 1)
  1583. {
  1584. if (0.0 == DamageHeadshot[zClass])
  1585. {
  1586. return Action:0;
  1587. }
  1588. damage = DamageHeadshot[zClass];
  1589. return Action:1;
  1590. }
  1591. damage = DamageBody[zClass];
  1592. return Action:1;
  1593. }
  1594. return Action:0;
  1595. }
  1596.  
  1597. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
  1598. {
  1599. new var1;
  1600. if (GetConVarInt(hm_damage) == 1 && !victim)
  1601. {
  1602. return Action:0;
  1603. }
  1604. new var2;
  1605. if (inflictor > MaxClients || attacker > MaxClients || !attacker || 0.0 == damage)
  1606. {
  1607. return Action:0;
  1608. }
  1609. decl String:Weapon[32];
  1610. GetClientWeapon(attacker, Weapon, 32);
  1611. new Float:original_damage = damage;
  1612. if (damagetype == 128)
  1613. {
  1614. if (StrEqual(Weapon, "weapon_boomer_claw", true))
  1615. {
  1616. damage = damage * GetConVarFloat(hm_damage_boomer);
  1617. }
  1618. else
  1619. {
  1620. if (StrEqual(Weapon, "weapon_charger_claw", true))
  1621. {
  1622. damage = damage * GetConVarFloat(hm_damage_charger);
  1623. }
  1624. if (StrEqual(Weapon, "weapon_hunter_claw", true))
  1625. {
  1626. damage = damage * GetConVarFloat(hm_damage_hunter);
  1627. }
  1628. if (StrEqual(Weapon, "weapon_smoker_claw", true))
  1629. {
  1630. damage = damage * GetConVarFloat(hm_damage_smoker);
  1631. }
  1632. if (StrEqual(Weapon, "weapon_spitter_claw", true))
  1633. {
  1634. damage = damage * GetConVarFloat(hm_damage_spitter1);
  1635. }
  1636. if (StrEqual(Weapon, "weapon_jockey_claw", true))
  1637. {
  1638. damage = damage * GetConVarFloat(hm_damage_jockey);
  1639. }
  1640. if (StrEqual(Weapon, "weapon_tank_claw", true))
  1641. {
  1642. damage = damage * GetConVarFloat(hm_damage_tank);
  1643. }
  1644. if (StrEqual(Weapon, "weapon_tank_rock", true))
  1645. {
  1646. damage = damage * GetConVarFloat(hm_damage_tankrock);
  1647. }
  1648. }
  1649. }
  1650. else
  1651. {
  1652. if (GetConVarInt(hm_damage_type) == 1)
  1653. {
  1654. if (StrEqual(Weapon, "weapon_rifle_ak47", true))
  1655. {
  1656. damage = damage * GetConVarFloat(hm_damage_ak47) / 1000;
  1657. }
  1658. else
  1659. {
  1660. if (StrEqual(Weapon, "weapon_sniper_awp", true))
  1661. {
  1662. damage = damage * GetConVarFloat(hm_damage_awp) / 1000;
  1663. }
  1664. if (StrEqual(Weapon, "weapon_sniper_scout", true))
  1665. {
  1666. damage = damage * GetConVarFloat(hm_damage_scout) / 1000;
  1667. }
  1668. if (StrEqual(Weapon, "weapon_rifle_m60", true))
  1669. {
  1670. damage = damage * GetConVarFloat(hm_damage_m60) / 1000;
  1671. }
  1672. if (StrEqual(Weapon, "weapon_shotgun_spas", true))
  1673. {
  1674. damage = damage * GetConVarFloat(hm_damage_spas) / 1000;
  1675. }
  1676. if (StrEqual(Weapon, "weapon_rifle_sg552", true))
  1677. {
  1678. damage = damage * GetConVarFloat(hm_damage_sg552) / 1000;
  1679. }
  1680. if (StrEqual(Weapon, "weapon_smg", true))
  1681. {
  1682. damage = damage * GetConVarFloat(hm_damage_smg);
  1683. }
  1684. if (StrEqual(Weapon, "weapon_smg_silenced", true))
  1685. {
  1686. damage = damage * GetConVarFloat(hm_damage_smg_silenced);
  1687. }
  1688. if (StrEqual(Weapon, "weapon_rifle", true))
  1689. {
  1690. damage = damage * GetConVarFloat(hm_damage_m16);
  1691. }
  1692. if (StrEqual(Weapon, "weapon_pumpshotgun", true))
  1693. {
  1694. damage = damage * GetConVarFloat(hm_damage_pumpshotgun);
  1695. }
  1696. if (StrEqual(Weapon, "weapon_autoshotgun", true))
  1697. {
  1698. damage = damage * GetConVarFloat(hm_damage_autoshotgun);
  1699. }
  1700. if (StrEqual(Weapon, "weapon_hunting_rifle", true))
  1701. {
  1702. damage = damage * GetConVarFloat(hm_damage_hunting_rifle);
  1703. }
  1704. if (StrEqual(Weapon, "weapon_rifle_desert", true))
  1705. {
  1706. damage = damage * GetConVarFloat(hm_damage_rifle_desert);
  1707. }
  1708. if (StrEqual(Weapon, "weapon_shotgun_chrome", true))
  1709. {
  1710. damage = damage * GetConVarFloat(hm_damage_shotgun_chrome);
  1711. }
  1712. if (StrEqual(Weapon, "weapon_smg_mp5", true))
  1713. {
  1714. damage = damage * GetConVarFloat(hm_damage_smg_mp5);
  1715. }
  1716. if (StrEqual(Weapon, "weapon_sniper_military", true))
  1717. {
  1718. damage = damage * GetConVarFloat(hm_damage_sniper_military) / 1000;
  1719. }
  1720. if (StrEqual(Weapon, "weapon_pistol", true))
  1721. {
  1722. damage = damage * GetConVarFloat(hm_damage_pistol);
  1723. }
  1724. if (StrEqual(Weapon, "weapon_pistol_magnum", true))
  1725. {
  1726. damage = damage * GetConVarFloat(hm_damage_pistol_magnum);
  1727. }
  1728. }
  1729. }
  1730. if (GetConVarInt(hm_damage_type) == 2)
  1731. {
  1732. if (StrEqual(Weapon, "weapon_rifle_ak47", true))
  1733. {
  1734. damage = GetConVarFloat(hm_damage2_ak47);
  1735. }
  1736. if (StrEqual(Weapon, "weapon_sniper_awp", true))
  1737. {
  1738. damage = GetConVarFloat(hm_damage2_awp);
  1739. }
  1740. if (StrEqual(Weapon, "weapon_sniper_scout", true))
  1741. {
  1742. damage = GetConVarFloat(hm_damage2_scout);
  1743. }
  1744. if (StrEqual(Weapon, "weapon_rifle_m60", true))
  1745. {
  1746. damage = GetConVarFloat(hm_damage2_m60);
  1747. }
  1748. if (StrEqual(Weapon, "weapon_shotgun_spas", true))
  1749. {
  1750. damage = GetConVarFloat(hm_damage2_spas);
  1751. }
  1752. if (StrEqual(Weapon, "weapon_rifle_sg552", true))
  1753. {
  1754. damage = GetConVarFloat(hm_damage2_sg552);
  1755. }
  1756. if (StrEqual(Weapon, "weapon_smg", true))
  1757. {
  1758. damage = damage * GetConVarFloat(hm_damage_smg);
  1759. }
  1760. if (StrEqual(Weapon, "weapon_smg_silenced", true))
  1761. {
  1762. damage = damage * GetConVarFloat(hm_damage_smg_silenced);
  1763. }
  1764. if (StrEqual(Weapon, "weapon_rifle", true))
  1765. {
  1766. damage = damage * GetConVarFloat(hm_damage_m16);
  1767. }
  1768. if (StrEqual(Weapon, "weapon_pumpshotgun", true))
  1769. {
  1770. damage = damage * GetConVarFloat(hm_damage_pumpshotgun);
  1771. }
  1772. if (StrEqual(Weapon, "weapon_autoshotgun", true))
  1773. {
  1774. damage = damage * GetConVarFloat(hm_damage_autoshotgun);
  1775. }
  1776. if (StrEqual(Weapon, "weapon_hunting_rifle", true))
  1777. {
  1778. damage = damage * GetConVarFloat(hm_damage_hunting_rifle);
  1779. }
  1780. if (StrEqual(Weapon, "weapon_rifle_desert", true))
  1781. {
  1782. damage = damage * GetConVarFloat(hm_damage_rifle_desert);
  1783. }
  1784. if (StrEqual(Weapon, "weapon_shotgun_chrome", true))
  1785. {
  1786. damage = damage * GetConVarFloat(hm_damage_shotgun_chrome);
  1787. }
  1788. if (StrEqual(Weapon, "weapon_smg_mp5", true))
  1789. {
  1790. damage = damage * GetConVarFloat(hm_damage_smg_mp5);
  1791. }
  1792. if (StrEqual(Weapon, "weapon_sniper_military", true))
  1793. {
  1794. damage = GetConVarFloat(hm_damage2_sniper_military);
  1795. }
  1796. if (StrEqual(Weapon, "weapon_pistol", true))
  1797. {
  1798. damage = damage * GetConVarFloat(hm_damage_pistol);
  1799. }
  1800. if (StrEqual(Weapon, "weapon_pistol_magnum", true))
  1801. {
  1802. damage = damage * GetConVarFloat(hm_damage_pistol_magnum);
  1803. }
  1804. }
  1805. }
  1806. if (original_damage != damage)
  1807. {
  1808. new var3;
  1809. if (GetClientTeam(victim) == 2 && GetClientTeam(attacker) == 2)
  1810. {
  1811. if (!IsPlayerIncapped(victim))
  1812. {
  1813. damage = damage * GetConVarFloat(hm_damage_friendly);
  1814. if (damage >= 1065353216 * GetHealth(victim))
  1815. {
  1816. damage = 1065353216 * GetHealth(victim) - 1;
  1817. }
  1818. }
  1819. damage = damage * GetConVarFloat(hm_damage_friendly) * 0.5;
  1820. }
  1821. return Action:1;
  1822. }
  1823. return Action:0;
  1824. }
  1825.  
  1826. public IncapTarget(target)
  1827. {
  1828. if (IsValidEntity(target))
  1829. {
  1830. new iDmgEntity = CreateEntityByName("point_hurt", -1);
  1831. SetEntityHealth(target, 1);
  1832. DispatchKeyValue(target, "targetname", "bm_target");
  1833. DispatchKeyValue(iDmgEntity, "DamageTarget", "bm_target");
  1834. DispatchKeyValue(iDmgEntity, "Damage", "100");
  1835. DispatchKeyValue(iDmgEntity, "DamageType", "0");
  1836. DispatchSpawn(iDmgEntity);
  1837. AcceptEntityInput(iDmgEntity, "Hurt", target, -1, 0);
  1838. DispatchKeyValue(target, "targetname", "bm_targetoff");
  1839. RemoveEdict(iDmgEntity);
  1840. }
  1841. return 0;
  1842. }
  1843.  
  1844. public Action:Event_DPlayerHurt(Handle:event, String:name[], bool:dontBroadcast)
  1845. {
  1846. if (GetConVarInt(hm_damage) < 1)
  1847. {
  1848. return Action:0;
  1849. }
  1850. new enemy = GetClientOfUserId(GetEventInt(event, "attacker", 0));
  1851. new target = GetClientOfUserId(GetEventInt(event, "userid", 0));
  1852. new dmg_health = GetEventInt(event, "dmg_health", 0);
  1853. new damagetype = GetEventInt(event, "type", 0);
  1854. new var1;
  1855. if ((GetConVarInt(hm_damage) < 2 && damagetype == 128) || (target && !dmg_health))
  1856. {
  1857. return Action:0;
  1858. }
  1859. decl String:weapon[16];
  1860. GetEventString(event, "weapon", weapon, 16, "");
  1861. new hardmod_damage;
  1862. if (StrEqual(weapon, "insect_swarm", false))
  1863. {
  1864. hardmod_damage = GetConVarInt(hm_damage_spitter2);
  1865. }
  1866. else
  1867. {
  1868. if (StrEqual(weapon, "pipe_bomb", false))
  1869. {
  1870. hardmod_damage = GetConVarInt(hm_damage_pipebomb);
  1871. }
  1872. if (StrEqual(weapon, "", false))
  1873. {
  1874. hardmod_damage = GetConVarInt(hm_damage_common);
  1875. }
  1876. new var3;
  1877. if (GetConVarInt(hm_damage) > 1 && enemy)
  1878. {
  1879. if (damagetype == 128)
  1880. {
  1881. if (StrEqual(weapon, "boomer_claw", true))
  1882. {
  1883. hardmod_damage = GetConVarInt(hm_damage_boomer);
  1884. }
  1885. else
  1886. {
  1887. if (StrEqual(weapon, "charger_claw", true))
  1888. {
  1889. hardmod_damage = GetConVarInt(hm_damage_charger);
  1890. }
  1891. if (StrEqual(weapon, "hunter_claw", true))
  1892. {
  1893. hardmod_damage = GetConVarInt(hm_damage_hunter);
  1894. }
  1895. if (StrEqual(weapon, "smoker_claw", true))
  1896. {
  1897. hardmod_damage = GetConVarInt(hm_damage_smoker);
  1898. }
  1899. if (StrEqual(weapon, "spitter_claw", true))
  1900. {
  1901. hardmod_damage = GetConVarInt(hm_damage_spitter1);
  1902. }
  1903. if (StrEqual(weapon, "jockey_claw", true))
  1904. {
  1905. hardmod_damage = GetConVarInt(hm_damage_jockey);
  1906. }
  1907. if (StrEqual(weapon, "tank_claw", true))
  1908. {
  1909. hardmod_damage = GetConVarInt(hm_damage_tank);
  1910. }
  1911. if (StrEqual(weapon, "tank_rock", true))
  1912. {
  1913. hardmod_damage = GetConVarInt(hm_damage_tankrock);
  1914. }
  1915. }
  1916. }
  1917. if (StrEqual(weapon, "rifle_ak47", true))
  1918. {
  1919. hardmod_damage = GetConVarInt(hm_damage_ak47);
  1920. }
  1921. if (StrEqual(weapon, "sniper_awp", true))
  1922. {
  1923. hardmod_damage = GetConVarInt(hm_damage_awp);
  1924. }
  1925. if (StrEqual(weapon, "sniper_scout", true))
  1926. {
  1927. hardmod_damage = GetConVarInt(hm_damage_scout);
  1928. }
  1929. if (StrEqual(weapon, "rifle_m60", true))
  1930. {
  1931. hardmod_damage = GetConVarInt(hm_damage_m60);
  1932. }
  1933. if (StrEqual(weapon, "shotgun_spas", true))
  1934. {
  1935. hardmod_damage = GetConVarInt(hm_damage_spas);
  1936. }
  1937. if (StrEqual(weapon, "rifle_sg552", true))
  1938. {
  1939. hardmod_damage = GetConVarInt(hm_damage_sg552);
  1940. }
  1941. if (StrEqual(weapon, "smg", true))
  1942. {
  1943. hardmod_damage = GetConVarInt(hm_damage_smg);
  1944. }
  1945. if (StrEqual(weapon, "smg_silenced", true))
  1946. {
  1947. hardmod_damage = GetConVarInt(hm_damage_smg_silenced);
  1948. }
  1949. if (StrEqual(weapon, "rifle", true))
  1950. {
  1951. hardmod_damage = GetConVarInt(hm_damage_m16);
  1952. }
  1953. if (StrEqual(weapon, "pumpshotgun", true))
  1954. {
  1955. hardmod_damage = GetConVarInt(hm_damage_pumpshotgun);
  1956. }
  1957. if (StrEqual(weapon, "autoshotgun", true))
  1958. {
  1959. hardmod_damage = GetConVarInt(hm_damage_autoshotgun);
  1960. }
  1961. if (StrEqual(weapon, "hunting_rifle", true))
  1962. {
  1963. hardmod_damage = GetConVarInt(hm_damage_hunting_rifle);
  1964. }
  1965. if (StrEqual(weapon, "rifle_desert", true))
  1966. {
  1967. hardmod_damage = GetConVarInt(hm_damage_rifle_desert);
  1968. }
  1969. if (StrEqual(weapon, "shotgun_chrome", true))
  1970. {
  1971. hardmod_damage = GetConVarInt(hm_damage_shotgun_chrome);
  1972. }
  1973. if (StrEqual(weapon, "smg_mp5", true))
  1974. {
  1975. hardmod_damage = GetConVarInt(hm_damage_smg_mp5);
  1976. }
  1977. if (StrEqual(weapon, "sniper_military", true))
  1978. {
  1979. hardmod_damage = GetConVarInt(hm_damage_sniper_military);
  1980. }
  1981. if (StrEqual(weapon, "pistol", true))
  1982. {
  1983. hardmod_damage = GetConVarInt(hm_damage_pistol);
  1984. }
  1985. if (StrEqual(weapon, "pistol_magnum", true))
  1986. {
  1987. hardmod_damage = GetConVarInt(hm_damage_pistol_magnum);
  1988. }
  1989. }
  1990. }
  1991. if (0 < hardmod_damage)
  1992. {
  1993. new var4;
  1994. if (enemy && GetClientTeam(target) == 2 && GetClientTeam(enemy) == 2)
  1995. {
  1996. hardmod_damage = RoundToNearest(GetConVarFloat(hm_damage_friendly) * hardmod_damage);
  1997. }
  1998. dmg_health = hardmod_damage + dmg_health;
  1999. SetEventInt(event, "dmg_health", dmg_health);
  2000. DamageTarget(target, hardmod_damage);
  2001. }
  2002. if (0 < GetConVarInt(hm_damage_showvalue))
  2003. {
  2004. new var5;
  2005. if (IsValidClient(enemy) && !IsFakeClient(enemy))
  2006. {
  2007. PrintHintText(enemy, "%d", dmg_health);
  2008. PrintToChat(enemy, "\x05(урон) \x04%d", dmg_health);
  2009. }
  2010. new var6;
  2011. if (IsValidClient(target) && !IsFakeClient(target))
  2012. {
  2013. PrintHintText(target, "-%d", dmg_health);
  2014. }
  2015. }
  2016. return Action:0;
  2017. }
  2018.  
  2019. public DamageTarget(any:client, damage)
  2020. {
  2021. if (GetHealth(client) < 1)
  2022. {
  2023. return 0;
  2024. }
  2025. new HP = GetHealth(client);
  2026. if (HP > damage)
  2027. {
  2028. SetEntityHealth(client, HP - damage);
  2029. }
  2030. else
  2031. {
  2032. if (HP > 1)
  2033. {
  2034. damage -= HP + -1;
  2035. SetEntityHealth(client, 1);
  2036. }
  2037. new TempHP = GetClientTempHealth(client);
  2038. if (TempHP >= damage)
  2039. {
  2040. SetTempHealth(client, TempHP - damage);
  2041. }
  2042. else
  2043. {
  2044. new var1;
  2045. if (GetClientTeam(client) == 2 && !IsGoingToDie(client))
  2046. {
  2047. IncapTarget(client);
  2048. }
  2049. if (GetConVarInt(hm_damage) > 2)
  2050. {
  2051. DamageEffect(client, 5.0);
  2052. }
  2053. SetTempHealth(client, 0);
  2054. }
  2055. }
  2056. return 0;
  2057. }
  2058.  
  2059. DamageEffect(target, Float:damage)
  2060. {
  2061. decl String:tName[20];
  2062. Format(tName, 20, "target%d", target);
  2063. new pointHurt = CreateEntityByName("point_hurt", -1);
  2064. DispatchKeyValue(target, "targetname", tName);
  2065. DispatchKeyValueFloat(pointHurt, "Damage", damage);
  2066. DispatchKeyValue(pointHurt, "DamageTarget", tName);
  2067. DispatchKeyValue(pointHurt, "DamageType", "65536");
  2068. DispatchSpawn(pointHurt);
  2069. AcceptEntityInput(pointHurt, "Hurt", -1, -1, 0);
  2070. AcceptEntityInput(pointHurt, "Kill", -1, -1, 0);
  2071. return 0;
  2072. }
  2073.  
  2074. public GetHealth(client)
  2075. {
  2076. return GetEntProp(client, PropType:0, "m_iHealth", 4, 0);
  2077. }
  2078.  
  2079. GetClientTempHealth(client)
  2080. {
  2081. new var1;
  2082. if (!client || !IsValidEntity(client) || !IsClientInGame(client) || !IsPlayerAlive(client) || IsClientObserver(client) || GetClientTeam(client) == 2)
  2083. {
  2084. return -1;
  2085. }
  2086. new Float:buffer = GetEntPropFloat(client, PropType:0, "m_healthBuffer", 0);
  2087. new Float:TempHealth = 0.0;
  2088. if (buffer <= 0.0)
  2089. {
  2090. TempHealth = 0.0;
  2091. }
  2092. else
  2093. {
  2094. new Float:difference = GetGameTime() - GetEntPropFloat(client, PropType:0, "m_healthBufferTime", 0);
  2095. new Float:decay = GetConVarFloat(FindConVar("pain_pills_decay_rate"));
  2096. new Float:constant = 1.0 / decay;
  2097. TempHealth = buffer - difference / constant;
  2098. }
  2099. if (TempHealth < 0.0)
  2100. {
  2101. TempHealth = 0.0;
  2102. }
  2103. return RoundToFloor(TempHealth);
  2104. }
  2105.  
  2106. public SetTempHealth(client, hp)
  2107. {
  2108. SetEntPropFloat(client, PropType:0, "m_healthBufferTime", GetGameTime(), 0);
  2109. new Float:newOverheal = 1.0 * hp;
  2110. SetEntPropFloat(client, PropType:0, "m_healthBuffer", newOverheal, 0);
  2111. return 0;
  2112. }
  2113.  
  2114. public bool:IsGoingToDie(client)
  2115. {
  2116. new var1;
  2117. if (!IsValidEntity(client) || !IsValidEdict(client))
  2118. {
  2119. return false;
  2120. }
  2121. new m_isGoingToDie = GetEntProp(client, PropType:0, "m_isGoingToDie", 4, 0);
  2122. if (m_isGoingToDie > 1)
  2123. {
  2124. return true;
  2125. }
  2126. return false;
  2127. }
  2128.  
  2129. GetLiveSurvivorsCount(bool:inGameOnly)
  2130. {
  2131. new clients;
  2132. new i = 1;
  2133. while (i <= MaxClients)
  2134. {
  2135. if (IsClientInGame(i))
  2136. {
  2137. if (GetClientTeam(i) == 2)
  2138. {
  2139. if (IsPlayerAlive(i))
  2140. {
  2141. clients++;
  2142. }
  2143. }
  2144. }
  2145. i++;
  2146. }
  2147. return clients;
  2148. }
  2149.  
  2150. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  2151. {
  2152. CreateNative("TYSTATS_GetPoints", Native_TYSTATS_GetPoints);
  2153. CreateNative("TYSTATS_GetRank", Native_TYSTATS_GetRank);
  2154. return APLRes:0;
  2155. }
  2156.  
  2157. public Native_TYSTATS_GetPoints(Handle:plugin, numParams)
  2158. {
  2159. return ClientPoints[GetNativeCell(1)];
  2160. }
  2161.  
  2162. public Native_TYSTATS_GetRank(Handle:plugin, numParams)
  2163. {
  2164. return ClientRank[GetNativeCell(1)];
  2165. }
  2166.  
  2167. public void:OnPluginStart()
  2168. {
  2169. LoadTranslations("tystats.phrases");
  2170. BuildPath(PathType:0, datafilepath, 256, "configs/tystats.txt");
  2171. ConnectDB();
  2172. CoopAutoDiffOnPluginStart();
  2173. DamageOnPluginStart();
  2174. RegConsoleCmd("callvote", Callvote_Handler, "", 0);
  2175. hm_blockvote_kick = CreateConVar("hm_blockvote_kick", "1", "", 262144, false, 0.0, false, 0.0);
  2176. hm_blockvote_map = CreateConVar("hm_blockvote_map", "1", "", 262144, false, 0.0, false, 0.0);
  2177. hm_allowvote_map_players = CreateConVar("hm_allowvote_map_players", "6", "", 262144, false, 0.0, false, 0.0);
  2178. hm_blockvote_lobby = CreateConVar("hm_blockvote_lobby", "1", "", 262144, false, 0.0, false, 0.0);
  2179. hm_blockvote_restart = CreateConVar("hm_blockvote_restart", "1", "", 262144, false, 0.0, false, 0.0);
  2180. hm_blockvote_difficulty = CreateConVar("hm_blockvote_difficulty", "0", "", 262144, false, 0.0, false, 0.0);
  2181. hm_blockvote_difference = CreateConVar("hm_blockvote_difference", "0", "", 262144, false, 0.0, false, 0.0);
  2182. hm_allowvote_mission = CreateConVar("hm_allowvote_mission", "21", "", 262144, false, 0.0, false, 0.0);
  2183. BuildPath(PathType:0, CV_FileName, 256, "hardmod/forbiddenmaps.txt");
  2184. cvar_Hunter = CreateConVar("l4d2_tystats_hunter", "4", "Base score for killing a Hunter", 262144, true, 1.0, false, 0.0);
  2185. cvar_Smoker = CreateConVar("l4d2_tystats_smoker", "4", "Base score for killing a Smoker", 262144, true, 1.0, false, 0.0);
  2186. cvar_Boomer = CreateConVar("l4d2_tystats_boomer", "3", "Base score for killing a Boomer", 262144, true, 1.0, false, 0.0);
  2187. cvar_Spitter = CreateConVar("l4d2_tystats_spitter", "5", "Base score for killing a Spitter", 262144, true, 1.0, false, 0.0);
  2188. cvar_Jockey = CreateConVar("l4d2_tystats_jockey", "4", "Base score for killing a Jockey", 262144, true, 1.0, false, 0.0);
  2189. cvar_Charger = CreateConVar("l4d2_tystats_charger", "6", "Base score for killing a Charger", 262144, true, 1.0, false, 0.0);
  2190. cvar_Witch = CreateConVar("l4d2_tystats_witch", "7", "Base score for killing a Witch", 262144, true, 1.0, false, 0.0);
  2191. cvar_Tank = CreateConVar("l4d2_tystats_tank", "10", "Base score for killing a Tank", 262144, true, 1.0, false, 0.0);
  2192. cvar_Bonus = CreateConVar("l4d2_tystats_bonus", "2", "Bonus score for killing bosses", 262144, true, 1.0, false, 0.0);
  2193. cvar_SiteURL = CreateConVar("l4d_stats_siteurl", "ruscoop25.myarena.ru/l4dstats/", "Community site URL, for rank panel display", 262144, false, 0.0, false, 0.0);
  2194. HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode:1);
  2195. HookEvent("witch_killed", Event_WitchKilled, EventHookMode:1);
  2196. HookEvent("player_death", Event_PlayerDeath, EventHookMode:1);
  2197. HookEvent("player_incapacitated", Event_PlayerIncap, EventHookMode:1);
  2198. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode:1);
  2199. HookEvent("round_start", Event_RoundStart, EventHookMode:1);
  2200. HookEvent("heal_success", Event_HealPlayer, EventHookMode:1);
  2201. HookEvent("defibrillator_used", Event_DefibPlayer, EventHookMode:1);
  2202. HookEvent("revive_success", Event_ReviveSuccess, EventHookMode:1);
  2203. HookEvent("player_now_it", Event_PlayerNowIt, EventHookMode:1);
  2204. HookEvent("survivor_rescued", Event_SurvivorRescued, EventHookMode:1);
  2205. HookEvent("award_earned", Event_Award_L4D2, EventHookMode:1);
  2206. HookEvent("player_team", Event_PlayerTeam, EventHookMode:1);
  2207. HookEvent("map_transition", Event_MapTransition, EventHookMode:1);
  2208. HookEvent("finale_win", Event_FinalWin, EventHookMode:1);
  2209. HookEvent("player_disconnect", Event_Disconnect, EventHookMode:0);
  2210. HookEvent("player_left_start_area", Event_StartArea, EventHookMode:1);
  2211. HookEvent("player_left_checkpoint", Event_StartArea, EventHookMode:1);
  2212. HookEvent("round_end", Event_RoundEnd, EventHookMode:1);
  2213. RegConsoleCmd("sm_myrank", cmd_ShowRank, "", 0);
  2214. RegConsoleCmd("sm_rank", Command_RankPlayer, "sm_rank <target>", 0);
  2215. RegConsoleCmd("sm_top10", cmd_ShowTop10, "", 0);
  2216. RegConsoleCmd("sm_top15", cmd_ShowTop15, "", 0);
  2217. RegConsoleCmd("sm_top20", cmd_ShowTop20, "", 0);
  2218. RegConsoleCmd("sm_nextrank", cmd_NextRank, "", 0);
  2219. RegConsoleCmd("sm_ranktarget", cmd_ShowRankTarget, "", 0);
  2220. RegConsoleCmd("sm_showpoints", Command_totalPoints_to_all, "", 0);
  2221. RegConsoleCmd("sm_points", Command_Points, "", 0);
  2222. RegConsoleCmd("sm_playtime", Command_Playtime, "", 0);
  2223. RegConsoleCmd("sm_maptop", Command_MapTop, "", 0);
  2224. RegConsoleCmd("sm_ranksum", Command_RankSum, "", 0);
  2225. RegConsoleCmd("sm_city17", Command_city17l4d2, "", 0);
  2226. RegConsoleCmd("sm_warcelona", Command_warcelona, "", 0);
  2227. RegConsoleCmd("sm_ravenholm", Command_ravenholm, "", 0);
  2228. RegConsoleCmd("sm_lastsummer", Command_lastsummer, "", 0);
  2229. RegConsoleCmd("sm_yama", Command_yama, "", 0);
  2230. RegConsoleCmd("sm_one4nine", Command_one4nine, "", 0);
  2231. RegAdminCmd("sm_rankpluginrefresh", Command_Refresh, 256, "", "", 0);
  2232. RegAdminCmd("sm_mapfinished", Command_MapFinished, 256, "", "", 0);
  2233. RegAdminCmd("sm_mapnotfinished", Command_MapNotFinished, 256, "", "", 0);
  2234. RegAdminCmd("sm_tystatsbonus", Command_Bonus, 256, "", "", 0);
  2235. RegAdminCmd("sm_givepoints", Command_GivePoints, 16384, "sm_givepoints <target> [Score]", "", 0);
  2236. RegAdminCmd("sm_rank_motd", Command_SetMotd, 2, "Set Message Of The Day", "", 0);
  2237. hm_count_fails = CreateConVar("hm_count_fails", "1", "", 262144, false, 0.0, false, 0.0);
  2238. hm_stats_colors = CreateConVar("hm_stats_colors", "2", "", 262144, false, 0.0, false, 0.0);
  2239. hm_stats_bot_colors = CreateConVar("hm_stats_bot_colors", "1", "", 262144, false, 0.0, false, 0.0);
  2240. l4d2_players_join_message_timer = CreateConVar("l4d2_players_join_message_timer", "10", "", 262144, false, 0.0, false, 0.0);
  2241. l4d2_rankmod_mode = CreateConVar("l4d2_rankmod_mode", "0", "", 262144, false, 0.0, false, 0.0);
  2242. l4d2_rankmod_min = CreateConVar("l4d2_rankmod_min", "0.5", "", 262144, false, 0.0, false, 0.0);
  2243. l4d2_rankmod_max = CreateConVar("l4d2_rankmod_max", "1.0", "", 262144, false, 0.0, false, 0.0);
  2244. l4d2_rankmod_logarithm = CreateConVar("l4d2_rankmod_logarithm", "0.008", "", 262144, false, 0.0, false, 0.0);
  2245. SDifficultyMultiplier = CreateConVar("l4d2_difficulty_stats", "1.0", "", 262144, false, 0.0, false, 0.0);
  2246. g_HaveSteam_Trie = CreateTrie();
  2247. RegConsoleCmd("steam", steam_command, "", 0);
  2248. CreateTimer(60.0, timer_UpdatePlayersPlaytime, any:0, 1);
  2249. return void:0;
  2250. }
  2251.  
  2252. public void:OnClientConnected(client)
  2253. {
  2254. g_Socket[client] = 0;
  2255. g_HaveSteam[client] = 0;
  2256. g_SteamID[client][0] = MissingTAG:0;
  2257. g_ProfileID[client][0] = MissingTAG:0;
  2258. return void:0;
  2259. }
  2260.  
  2261. public Action:timer_UpdatePlayersPlaytime(Handle:timer, Handle:hndl)
  2262. {
  2263. if (StatsDisabled())
  2264. {
  2265. return Action:0;
  2266. }
  2267. new i = 1;
  2268. while (i <= MaxClients)
  2269. {
  2270. new var1;
  2271. if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  2272. {
  2273. Playtime[i] += 1;
  2274. CheckPlayerDB(i);
  2275. }
  2276. i++;
  2277. }
  2278. return Action:0;
  2279. }
  2280.  
  2281. public KnowRankPoints(client)
  2282. {
  2283. if (StatsDisabled())
  2284. {
  2285. return 0;
  2286. }
  2287. if (!client)
  2288. {
  2289. return 0;
  2290. }
  2291. if (!IsClientInGame(client))
  2292. {
  2293. return 0;
  2294. }
  2295. if (IsFakeClient(client))
  2296. {
  2297. return 0;
  2298. }
  2299. decl String:steamId[64];
  2300. GetClientAuthId(client, AuthIdType:1, steamId, 64, true);
  2301. decl String:query[256];
  2302. Format(query, 256, "SELECT COUNT(*) FROM players");
  2303. SQL_TQuery(db, GetRankTotal, query, client, DBPriority:1);
  2304. Format(query, 256, "SELECT points FROM players WHERE steamid = '%s'", steamId);
  2305. SQL_TQuery(db, GetClientPoints, query, client, DBPriority:1);
  2306. CreateTimer(0.6, TimertyGetClientRank, client, 0);
  2307. return 0;
  2308. }
  2309.  
  2310. public KnowRankKills(client)
  2311. {
  2312. if (StatsDisabled())
  2313. {
  2314. return 0;
  2315. }
  2316. if (!client)
  2317. {
  2318. return 0;
  2319. }
  2320. if (!IsClientInGame(client))
  2321. {
  2322. return 0;
  2323. }
  2324. if (IsFakeClient(client))
  2325. {
  2326. return 0;
  2327. }
  2328. decl String:SteamID[64];
  2329. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  2330. decl String:query[1024];
  2331. Format(query, 1024, "SELECT kill_hunter,kill_smoker,kill_boomer,kill_spitter,kill_jockey,kill_charger,award_tankkill FROM players WHERE steamid = '%s'", SteamID);
  2332. SQL_TQuery(db, GetClientKills, query, client, DBPriority:1);
  2333. return 0;
  2334. }
  2335.  
  2336. public KnowRankPlaytime(client)
  2337. {
  2338. if (StatsDisabled())
  2339. {
  2340. return 0;
  2341. }
  2342. if (!client)
  2343. {
  2344. return 0;
  2345. }
  2346. if (!IsClientInGame(client))
  2347. {
  2348. return 0;
  2349. }
  2350. if (IsFakeClient(client))
  2351. {
  2352. return 0;
  2353. }
  2354. decl String:SteamID[64];
  2355. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  2356. decl String:query[512];
  2357. Format(query, 512, "SELECT playtime FROM players WHERE steamid = '%s'", SteamID);
  2358. SQL_TQuery(db, GetClientPlaytime, query, client, DBPriority:1);
  2359. return 0;
  2360. }
  2361.  
  2362. public void:OnClientDisconnect(client)
  2363. {
  2364. DMOnClientDisconnect(client);
  2365. g_votekick[client] = 0;
  2366. if (Join_Timer[client])
  2367. {
  2368. KillTimer(Join_Timer[client], false);
  2369. Join_Timer[client] = 0;
  2370. }
  2371. if (StatsDisabled())
  2372. {
  2373. return void:0;
  2374. }
  2375. if (!client)
  2376. {
  2377. return void:0;
  2378. }
  2379. if (IsFakeClient(client))
  2380. {
  2381. return void:0;
  2382. }
  2383. InterstitialPlayerUpdate(client);
  2384. UpdatePlaytimePlayers(client);
  2385. return void:0;
  2386. }
  2387.  
  2388. public void:OnClientDisconnect_Post(client)
  2389. {
  2390. OnClientConnected(client);
  2391. return void:0;
  2392. }
  2393.  
  2394. public void:OnClientAuthorized(client, String:steamid[])
  2395. {
  2396. if (!(StrContains(steamid, "STEAM_", false)))
  2397. {
  2398. strcopy(g_SteamID[client], 30, steamid);
  2399. decl bool:steam_client;
  2400. if (GetTrieValue(g_HaveSteam_Trie, steamid, steam_client))
  2401. {
  2402. g_HaveSteam[client] = steam_client;
  2403. }
  2404. else
  2405. {
  2406. wS_GetProfileId(client, steamid);
  2407. }
  2408. }
  2409. return void:0;
  2410. }
  2411.  
  2412. public InterstitialPlayerUpdate(client)
  2413. {
  2414. decl String:SteamID[64];
  2415. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  2416. decl String:query[1024];
  2417. Format(query, 1024, "UPDATE players SET points = points + %i, kills = kills + %i, kill_infected = kill_infected + %i, award_protect = award_protect + %i WHERE steamid = '%s'", CalculatePoints(NewPoints[client]), KillsInfected[client], KillsInfected[client], ProtectedFriendlyCounter[client], SteamID);
  2418. SendSQLUpdate(query);
  2419. ProtectedFriendlyCounter[client] = 0;
  2420. NewPoints[client] = 0;
  2421. KillsInfected[client] = 0;
  2422. return 0;
  2423. }
  2424.  
  2425. UpdatePlaytimePlayers(client)
  2426. {
  2427. if (StatsDisabled())
  2428. {
  2429. return 0;
  2430. }
  2431. if (!client)
  2432. {
  2433. return 0;
  2434. }
  2435. if (!IsClientInGame(client))
  2436. {
  2437. return 0;
  2438. }
  2439. if (IsFakeClient(client))
  2440. {
  2441. return 0;
  2442. }
  2443. if (Playtime[client])
  2444. {
  2445. new PlaytimeDB = Playtime[client] * 60;
  2446. decl String:SteamID[64];
  2447. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  2448. decl String:query[512];
  2449. Format(query, 512, "UPDATE players SET playtime = playtime + %i WHERE steamid = '%s'", PlaytimeDB, SteamID);
  2450. SendSQLUpdate(query);
  2451. PlaytimeDB = 0;
  2452. Playtime[client] = 0;
  2453. return 0;
  2454. }
  2455. return 0;
  2456. }
  2457.  
  2458. public Action:Event_Disconnect(Handle:event, String:name[], bool:bDontBroadcast)
  2459. {
  2460. new client = GetClientOfUserId(GetEventInt(event, "userid", 0));
  2461. if (!client)
  2462. {
  2463. return Action:0;
  2464. }
  2465. if (IsFakeClient(client))
  2466. {
  2467. return Action:0;
  2468. }
  2469. decl String:ip[16];
  2470. decl String:country[48];
  2471. if (IsClientInGame(client))
  2472. {
  2473. if (IsRealClient(client))
  2474. {
  2475. GetClientIP(client, ip, 16, true);
  2476. new flags = GetUserFlagBits(client);
  2477. if (GeoipCountry(ip, country, 45))
  2478. {
  2479. if (g_HaveSteam[client])
  2480. {
  2481. if (flags & 16384)
  2482. {
  2483. CPrintToChatAll("%t {red}%N \x05(%s)", "- Owner", client, country);
  2484. }
  2485. else
  2486. {
  2487. if (flags & 8192)
  2488. {
  2489. CPrintToChatAll("%t {red}%N \x05(%s)", "- Admin", client, country);
  2490. }
  2491. if (flags & 2)
  2492. {
  2493. CPrintToChatAll("%t {red}%N \x05(%s)", "- Moderator", client, country);
  2494. }
  2495. if (flags & 1)
  2496. {
  2497. CPrintToChatAll("%t {red}%N \x05(%s)", "- VIP", client, country);
  2498. }
  2499. CPrintToChatAll("%t {blue}%N \x05(%s)", "- Player", client, country);
  2500. }
  2501. }
  2502. else
  2503. {
  2504. if (flags & 16384)
  2505. {
  2506. CPrintToChatAll("%t {red}%N \x05(%s) \x04[\x03no-steam\x04]", "- Owner", client, country);
  2507. }
  2508. if (flags & 8192)
  2509. {
  2510. CPrintToChatAll("%t {red}%N \x05(%s) \x04[\x03no-steam\x04]", "- Admin", client, country);
  2511. }
  2512. if (flags & 2)
  2513. {
  2514. CPrintToChatAll("%t {red}%N \x05(%s) \x04[\x03no-steam\x04]", "- Moderator", client, country);
  2515. }
  2516. if (flags & 1)
  2517. {
  2518. CPrintToChatAll("%t {red}%N \x05(%s) \x04[\x03no-steam\x04]", "- VIP", client, country);
  2519. }
  2520. CPrintToChatAll("%t {blue}%N \x05(%s) \x04[\x03no-steam\x04]", "- Player", client, country);
  2521. }
  2522. }
  2523. else
  2524. {
  2525. if (g_HaveSteam[client])
  2526. {
  2527. if (flags & 16384)
  2528. {
  2529. CPrintToChatAll("%t {red}%N", "- Owner", client);
  2530. }
  2531. else
  2532. {
  2533. if (flags & 8192)
  2534. {
  2535. CPrintToChatAll("%t {red}%N", "- Admin", client);
  2536. }
  2537. if (flags & 2)
  2538. {
  2539. CPrintToChatAll("%t {red}%N", "- Moderator", client);
  2540. }
  2541. if (flags & 1)
  2542. {
  2543. CPrintToChatAll("%t {red}%N", "- VIP", client);
  2544. }
  2545. CPrintToChatAll("%t {blue}%N", "- Player", client);
  2546. }
  2547. }
  2548. if (flags & 16384)
  2549. {
  2550. CPrintToChatAll("%t {red}%N \x04[\x03no-steam\x04]", "- Owner", client);
  2551. }
  2552. if (flags & 8192)
  2553. {
  2554. CPrintToChatAll("%t {red}%N \x04[\x03no-steam\x04]", "- Admin", client);
  2555. }
  2556. if (flags & 2)
  2557. {
  2558. CPrintToChatAll("%t {red}%N \x04[\x03no-steam\x04]", "- Moderator", client);
  2559. }
  2560. if (flags & 1)
  2561. {
  2562. CPrintToChatAll("%t {red}%N \x04[\x03no-steam\x04]", "- VIP", client);
  2563. }
  2564. CPrintToChatAll("%t {blue}%N \x04[\x03no-steam\x04]", "- Player", client);
  2565. }
  2566. }
  2567. }
  2568. if (!IsTimeAutodifficulty)
  2569. {
  2570. return Action:0;
  2571. }
  2572. ADPlayerTeam();
  2573. return Action:0;
  2574. }
  2575.  
  2576. public Action:TimertyGetClientRank(Handle:timer, any:client)
  2577. {
  2578. if (StatsDisabled())
  2579. {
  2580. return Action:4;
  2581. }
  2582. if (!client)
  2583. {
  2584. return Action:4;
  2585. }
  2586. if (!IsClientInGame(client))
  2587. {
  2588. return Action:4;
  2589. }
  2590. if (IsFakeClient(client))
  2591. {
  2592. return Action:4;
  2593. }
  2594. decl String:query[256];
  2595. Format(query, 256, "SELECT COUNT(*) FROM players WHERE points >=%i", ClientPoints[client]);
  2596. SQL_TQuery(db, GetClientRank, query, client, DBPriority:1);
  2597. return Action:4;
  2598. }
  2599.  
  2600. public GetClientPoints(Handle:owner, Handle:hndl, String:error[], any:client)
  2601. {
  2602. new var1;
  2603. if (!client || hndl)
  2604. {
  2605. return 0;
  2606. }
  2607. while (SQL_FetchRow(hndl))
  2608. {
  2609. ClientPoints[client] = SQL_FetchInt(hndl, 0, 0);
  2610. }
  2611. return 0;
  2612. }
  2613.  
  2614. public GetClientKills(Handle:owner, Handle:hndl, String:error[], any:client)
  2615. {
  2616. new var1;
  2617. if (!client || hndl)
  2618. {
  2619. return 0;
  2620. }
  2621. while (SQL_FetchRow(hndl))
  2622. {
  2623. ClientKills[client] = SQL_FetchInt(hndl, 6, 0) + SQL_FetchInt(hndl, 5, 0) + SQL_FetchInt(hndl, 4, 0) + SQL_FetchInt(hndl, 3, 0) + SQL_FetchInt(hndl, 2, 0) + SQL_FetchInt(hndl, 1, 0) + SQL_FetchInt(hndl, 0, 0);
  2624. }
  2625. return 0;
  2626. }
  2627.  
  2628. public GetClientPlaytime(Handle:owner, Handle:hndl, String:error[], any:client)
  2629. {
  2630. new var1;
  2631. if (!client || hndl)
  2632. {
  2633. return 0;
  2634. }
  2635. while (SQL_FetchRow(hndl))
  2636. {
  2637. ClientPlaytime[client] = SQL_FetchInt(hndl, 0, 0);
  2638. }
  2639. return 0;
  2640. }
  2641.  
  2642. public GetClientRank(Handle:owner, Handle:hndl, String:error[], any:client)
  2643. {
  2644. new var1;
  2645. if (!client || hndl)
  2646. {
  2647. return 0;
  2648. }
  2649. while (SQL_FetchRow(hndl))
  2650. {
  2651. ClientRank[client] = SQL_FetchInt(hndl, 0, 0);
  2652. }
  2653. return 0;
  2654. }
  2655.  
  2656. public GetRankTotal(Handle:owner, Handle:hndl, String:error[], any:data)
  2657. {
  2658. if (!hndl)
  2659. {
  2660. return 0;
  2661. }
  2662. while (SQL_FetchRow(hndl))
  2663. {
  2664. RankTotal = SQL_FetchInt(hndl, 0, 0);
  2665. }
  2666. return 0;
  2667. }
  2668.  
  2669. public updateptystatslayers()
  2670. {
  2671. new round_fails = round_end_repeats;
  2672. if (round_end_repeats > 3)
  2673. {
  2674. round_fails = 3;
  2675. }
  2676. if (GetRealtyClientCount(true) > 15)
  2677. {
  2678. tystatsbalans = 3 - round_fails;
  2679. }
  2680. else
  2681. {
  2682. if (GetRealtyClientCount(true) > 8)
  2683. {
  2684. tystatsbalans = 2 - round_fails;
  2685. }
  2686. if (GetRealtyClientCount(true) > 4)
  2687. {
  2688. tystatsbalans = 1 - round_fails;
  2689. }
  2690. tystatsbalans = 0;
  2691. }
  2692. return 0;
  2693. }
  2694.  
  2695. public void:OnMapStart()
  2696. {
  2697. ADOnMapStart();
  2698. IsTimeAutodifficulty = false;
  2699. round_end_repeats = 0;
  2700. PrecacheSound("buttons/blip1.wav", true);
  2701. PrecacheSound("level/countdown.wav", true);
  2702. PrecacheSound("level/bell_normal.wav", true);
  2703. new i = 1;
  2704. while (i <= MaxClients)
  2705. {
  2706. g_votekick[i] = 0;
  2707. i++;
  2708. }
  2709. return void:0;
  2710. }
  2711.  
  2712. public Action:Event_RoundStart(Handle:hEvent, String:strName[], bool:DontBroadcast)
  2713. {
  2714. ADRoundStart();
  2715. IsMapFinished = false;
  2716. IsRoundStarted = true;
  2717. tystatsbalans = 0;
  2718. bonus = 0;
  2719. MapTimingStartTime = 0.0;
  2720. CreateTimer(6.0, TimedColortystats, any:0, 0);
  2721. CreateTimer(25.0, TimedAutoDifficultyInit, any:0, 0);
  2722. return Action:0;
  2723. }
  2724.  
  2725. public Event_RoundEnd(Handle:event, String:name[], bool:dontBroadcast)
  2726. {
  2727. if (!IsRoundStarted)
  2728. {
  2729. return 0;
  2730. }
  2731. round_end_repeats += 1;
  2732. return 0;
  2733. }
  2734.  
  2735. public Action:TimedColortystats(Handle:timer, any:client)
  2736. {
  2737. new i = 1;
  2738. while (i <= MaxClients)
  2739. {
  2740. new var1;
  2741. if (IsValidEntity(i) && IsClientInGame(i) && !IsFakeClient(i))
  2742. {
  2743. RanktyConnect(i);
  2744. }
  2745. i++;
  2746. }
  2747. return Action:0;
  2748. }
  2749.  
  2750. public Action:TimedAutoDifficultyInit(Handle:timer, any:client)
  2751. {
  2752. IsTimeAutodifficulty = true;
  2753. AutoDifficultyInit();
  2754. Autodifficulty();
  2755. return Action:0;
  2756. }
  2757.  
  2758. public void:OnClientPostAdminCheck(client)
  2759. {
  2760. if (!IsValidEntity(client))
  2761. {
  2762. return void:0;
  2763. }
  2764. if (IsFakeClient(client))
  2765. {
  2766. return void:0;
  2767. }
  2768. Join_Timer[client] = CreateTimer(1065353216 * GetConVarInt(l4d2_players_join_message_timer), PlayerJoinMessage, client, 0);
  2769. if (StatsDisabled())
  2770. {
  2771. return void:0;
  2772. }
  2773. TKblockPunishment[client] = 0;
  2774. TKblockDamage[client] = 0;
  2775. ClientPoints[client] = 0;
  2776. ClientRank[client] = 0;
  2777. ClientKills[client] = 0;
  2778. ProtectedFriendlyCounter[client] = 0;
  2779. ClientPlaytime[client] = 0;
  2780. Playtime[client] = 0;
  2781. KillsInfected[client] = 0;
  2782. NewPoints[client] = 0;
  2783. g_votekick[client] = 0;
  2784. CreateTimer(7.0, Timedtyclient, client, 0);
  2785. return void:0;
  2786. }
  2787.  
  2788. public Action:Timedtyclient(Handle:timer, any:client)
  2789. {
  2790. if (!client)
  2791. {
  2792. return Action:4;
  2793. }
  2794. if (!IsClientInGame(client))
  2795. {
  2796. return Action:4;
  2797. }
  2798. if (IsFakeClient(client))
  2799. {
  2800. return Action:4;
  2801. }
  2802. if (StatsDisabled())
  2803. {
  2804. return Action:4;
  2805. }
  2806. CheckPlayerDB(client);
  2807. KnowRankPoints(client);
  2808. CreateTimer(GetRandomFloat(5.5, 8.5) * 1.0, RankConnect, client, 0);
  2809. return Action:4;
  2810. }
  2811.  
  2812. public Action:RankConnect(Handle:timer, any:client)
  2813. {
  2814. if (!client)
  2815. {
  2816. return Action:4;
  2817. }
  2818. if (!IsClientInGame(client))
  2819. {
  2820. return Action:4;
  2821. }
  2822. if (IsFakeClient(client))
  2823. {
  2824. return Action:4;
  2825. }
  2826. PrintToChat(client, "%t", "Rank: %i of %i. Points: %i", ClientRank[client], RankTotal, ClientPoints[client]);
  2827. RanktyConnect(client);
  2828. return Action:4;
  2829. }
  2830.  
  2831. public Action:PlayerJoinMessage(Handle:timer, any:client)
  2832. {
  2833. decl String:ip[16];
  2834. decl String:country[48];
  2835. if (IsClientInGame(client))
  2836. {
  2837. if (IsRealClient(client))
  2838. {
  2839. GetClientIP(client, ip, 16, true);
  2840. new flags = GetUserFlagBits(client);
  2841. if (GeoipCountry(ip, country, 45))
  2842. {
  2843. if (g_HaveSteam[client])
  2844. {
  2845. if (flags & 16384)
  2846. {
  2847. }
  2848. else
  2849. {
  2850. if (flags & 8192)
  2851. {
  2852. CPrintToChatAll("%t {blue}%N \x05(%s)", "+ Admin", client, country);
  2853. }
  2854. if (flags & 2)
  2855. {
  2856. CPrintToChatAll("%t {blue}%N \x05(%s)", "+ Moderator", client, country);
  2857. }
  2858. if (flags & 1)
  2859. {
  2860. CPrintToChatAll("%t {blue}%N \x05(%s)", "+ VIP", client, country);
  2861. }
  2862. CPrintToChatAll("%t {blue}%N \x05(%s)", "+ Player", client, country);
  2863. }
  2864. }
  2865. else
  2866. {
  2867. if (!(flags & 16384))
  2868. {
  2869. if (flags & 8192)
  2870. {
  2871. CPrintToChatAll("%t {blue}%N \x05(%s) \x04[\x03no-steam\x04]", "+ Admin", client, country);
  2872. }
  2873. if (flags & 2)
  2874. {
  2875. CPrintToChatAll("%t {blue}%N \x05(%s) \x04[\x03no-steam\x04]", "+ Moderator", client, country);
  2876. }
  2877. if (flags & 1)
  2878. {
  2879. CPrintToChatAll("%t {blue}%N \x05(%s) \x04[\x03no-steam\x04]", "+ VIP", client, country);
  2880. }
  2881. CPrintToChatAll("%t {blue}%N \x05(%s) \x04[\x03no-steam\x04]", "+ Player", client, country);
  2882. }
  2883. }
  2884. }
  2885. else
  2886. {
  2887. if (g_HaveSteam[client])
  2888. {
  2889. if (flags & 16384)
  2890. {
  2891. }
  2892. else
  2893. {
  2894. if (flags & 8192)
  2895. {
  2896. CPrintToChatAll("%t {blue}%N", "+ Admin", client);
  2897. }
  2898. if (flags & 2)
  2899. {
  2900. CPrintToChatAll("%t {blue}%N", "+ Moderator", client);
  2901. }
  2902. if (flags & 1)
  2903. {
  2904. CPrintToChatAll("%t {blue}%N", "+ VIP", client);
  2905. }
  2906. CPrintToChatAll("%t {blue}%N", "+ Player", client);
  2907. }
  2908. }
  2909. if (!(flags & 16384))
  2910. {
  2911. if (flags & 8192)
  2912. {
  2913. CPrintToChatAll("%t {blue}%N \x04[\x03no-steam\x04]", "+ Admin", client);
  2914. }
  2915. if (flags & 2)
  2916. {
  2917. CPrintToChatAll("%t {blue}%N \x04[\x03no-steam\x04]", "+ Moderator", client);
  2918. }
  2919. if (flags & 1)
  2920. {
  2921. CPrintToChatAll("%t {blue}%N \x04[\x03no-steam\x04]", "+ VIP", client);
  2922. }
  2923. CPrintToChatAll("%t {blue}%N \x04[\x03no-steam\x04]", "+ Player", client);
  2924. }
  2925. }
  2926. EmitSoundToAll("buttons/blip1.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
  2927. }
  2928. }
  2929. Join_Timer[client] = 0;
  2930. return Action:0;
  2931. }
  2932.  
  2933. public RanktyConnect(client)
  2934. {
  2935. new var1;
  2936. if (IsClientInGame(client) && !IsFakeClient(client))
  2937. {
  2938. if (GetClientTeam(client) == 2)
  2939. {
  2940. if (IsPlayerAlive(client))
  2941. {
  2942. if (ClientPoints[client] >= 640000)
  2943. {
  2944. SetEntityRenderColor(client, 255, 97, 3, 255);
  2945. }
  2946. if (ClientPoints[client] >= 320000)
  2947. {
  2948. SetEntityRenderColor(client, 255, 0, 0, 255);
  2949. }
  2950. if (ClientPoints[client] >= 160000)
  2951. {
  2952. SetEntityRenderColor(client, 255, 104, 240, 255);
  2953. }
  2954. if (ClientPoints[client] >= 80000)
  2955. {
  2956. SetEntityRenderColor(client, 102, 25, 140, 255);
  2957. }
  2958. if (ClientPoints[client] >= 40000)
  2959. {
  2960. SetEntityRenderColor(client, 0, 139, 0, 255);
  2961. }
  2962. if (ClientPoints[client] >= 20000)
  2963. {
  2964. SetEntityRenderColor(client, 0, 0, 255, 255);
  2965. }
  2966. if (ClientPoints[client] >= 10000)
  2967. {
  2968. SetEntityRenderColor(client, 255, 255, 0, 255);
  2969. }
  2970. if (ClientPoints[client] >= 5000)
  2971. {
  2972. SetEntityRenderColor(client, 173, 255, 47, 255);
  2973. }
  2974. }
  2975. }
  2976. }
  2977. return 0;
  2978. }
  2979.  
  2980. public ConnectDB()
  2981. {
  2982. if (SQL_CheckConfig("l4dstats"))
  2983. {
  2984. new String:Error[256];
  2985. db = SQL_Connect("l4dstats", true, Error, 256);
  2986. if (db)
  2987. {
  2988. SendSQLUpdate("SET NAMES 'utf8'");
  2989. }
  2990. else
  2991. {
  2992. LogError("Failed to connect to database: %s", Error);
  2993. }
  2994. }
  2995. else
  2996. {
  2997. LogError("database.cfg missing 'l4dstats' entry!");
  2998. }
  2999. return 0;
  3000. }
  3001.  
  3002. CheckPlayerDB(client)
  3003. {
  3004. if (StatsDisabled())
  3005. {
  3006. return 0;
  3007. }
  3008. if (!client)
  3009. {
  3010. return 0;
  3011. }
  3012. if (!IsClientInGame(client))
  3013. {
  3014. return 0;
  3015. }
  3016. if (IsFakeClient(client))
  3017. {
  3018. return 0;
  3019. }
  3020. decl String:SteamID[64];
  3021. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  3022. decl String:query[512];
  3023. Format(query, 512, "SELECT steamid FROM players WHERE steamid = '%s'", SteamID);
  3024. SQL_TQuery(db, InsertPlayerDB, query, client, DBPriority:1);
  3025. return 0;
  3026. }
  3027.  
  3028. public InsertPlayerDB(Handle:owner, Handle:hndl, String:error[], any:data)
  3029. {
  3030. if (StatsDisabled())
  3031. {
  3032. return 0;
  3033. }
  3034. new client = data;
  3035. new var1;
  3036. if (!client || hndl)
  3037. {
  3038. return 0;
  3039. }
  3040. if (StatsDisabled())
  3041. {
  3042. return 0;
  3043. }
  3044. if (!IsClientInGame(client))
  3045. {
  3046. return 0;
  3047. }
  3048. if (!SQL_GetRowCount(hndl))
  3049. {
  3050. new String:SteamID[64];
  3051. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  3052. new String:query[512];
  3053. Format(query, 512, "INSERT IGNORE INTO players SET steamid = '%s'", SteamID);
  3054. SQL_TQuery(db, SQLErrorCheckCallback, query, any:0, DBPriority:1);
  3055. }
  3056. UpdatePlayer(client);
  3057. return 0;
  3058. }
  3059.  
  3060. public SendSQLUpdate(String:query[])
  3061. {
  3062. if (db)
  3063. {
  3064. SQL_TQuery(db, SQLErrorCheckCallback, query, any:0, DBPriority:1);
  3065. return 0;
  3066. }
  3067. return 0;
  3068. }
  3069.  
  3070. public SQLErrorCheckCallback(Handle:owner, Handle:hndl, String:error[], any:data)
  3071. {
  3072. if (db)
  3073. {
  3074. if (!StrEqual("", error, true))
  3075. {
  3076. LogError("SQL Error: %s", error);
  3077. }
  3078. return 0;
  3079. }
  3080. return 0;
  3081. }
  3082.  
  3083. public UpdatePlayer(client)
  3084. {
  3085. if (!IsClientConnected(client))
  3086. {
  3087. return 0;
  3088. }
  3089. decl String:SteamID[64];
  3090. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  3091. decl String:Name[64];
  3092. GetClientName(client, Name, 64);
  3093. ReplaceString(Name, 64, "<?php", "", true);
  3094. ReplaceString(Name, 64, "<?PHP", "", true);
  3095. ReplaceString(Name, 64, "?>", "", true);
  3096. ReplaceString(Name, 64, "\"", ", true);
  3097. ReplaceString(Name, 64, "\", "", true);
  3098. ReplaceString(Name, 64, "'", "", true);
  3099. ReplaceString(Name, 64, ";", "", true);
  3100. ReplaceString(Name, 64, "ґ", "", true);
  3101. ReplaceString(Name, 64, "`", "", true);
  3102. decl String:IP[16];
  3103. GetClientIP(client, IP, 16, true);
  3104. decl String:query[512];
  3105. Format(query, 512, "UPDATE players SET lastontime = UNIX_TIMESTAMP(), ip = '%s', points = points + 0, name = '%s' WHERE steamid = '%s'", IP, Name, SteamID);
  3106. SendSQLUpdate(query);
  3107. return 0;
  3108. }
  3109.  
  3110. public Action:Event_WitchKilled(Handle:hEvent, String:name[], bool:dontBroadcast)
  3111. {
  3112. new client = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
  3113. if (!IsValidEntity(client))
  3114. {
  3115. return Action:0;
  3116. }
  3117. if (!client)
  3118. {
  3119. return Action:0;
  3120. }
  3121. if (IsFakeClient(client))
  3122. {
  3123. return Action:0;
  3124. }
  3125. decl String:SteamID[64];
  3126. GetClientAuthId(client, AuthIdType:1, SteamID, 64, true);
  3127. new Score;
  3128. decl String:query2[512];
  3129. Score = GetConVarInt(cvar_Witch) + tystatsbalans + bonus;
  3130. Format(query2, 512, "UPDATE players SET kill_witch = kill_witch + 1 WHERE steamid = '%s'", SteamID);
  3131. if (IsMapFinished)
  3132. {
  3133. Score = 0;
  3134. }
  3135. SendSQLUpdate(query2);
  3136. AddScore(client, Score);
  3137. return Action:0;
  3138. }
  3139.  
  3140. public Action:Event_PlayerDeath(Handle:event, String:name[], bool:dontBroadcast)
  3141. {
  3142. new Attacker = GetClientOfUserId(GetEventInt(event, "attacker", 0));
  3143. new Victim = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3144. if (!IsValidEntity(Attacker))
  3145. {
  3146. return Action:0;
  3147. }
  3148. if (!Attacker)
  3149. {
  3150. return Action:0;
  3151. }
  3152. if (IsFakeClient(Attacker))
  3153. {
  3154. return Action:0;
  3155. }
  3156. if (Victim == Attacker)
  3157. {
  3158. return Action:0;
  3159. }
  3160. if (StatsDisabled())
  3161. {
  3162. return Action:0;
  3163. }
  3164. decl String:AttackerID[64];
  3165. GetClientAuthId(Attacker, AuthIdType:1, AttackerID, 64, true);
  3166. decl String:VictimName[64];
  3167. GetEventString(event, "victimname", VictimName, 64, "");
  3168. new Score;
  3169. decl String:query2[512];
  3170. new var1;
  3171. if (Victim > 0 && !IsFakeClient(Victim) && GetClientTeam(Victim) == 2 && GetClientTeam(Attacker) == 2)
  3172. {
  3173. Score = -50;
  3174. TKblockDamage[Attacker] = TKblockDamage[Attacker] + 30;
  3175. CPrintToChat(Victim, "%t", "%N attacked %N (%i TK)", Attacker, Victim, TKblockDamage[Attacker]);
  3176. CPrintToChat(Attacker, "%t", "%N attacked %N (%i TK)", Attacker, Victim, TKblockDamage[Attacker]);
  3177. PunishTeamkiller(Attacker);
  3178. Format(query2, 512, "UPDATE players SET award_teamkill = award_teamkill + 1 WHERE steamid = '%s'", AttackerID);
  3179. }
  3180. if (StrEqual(VictimName, "Infected", false))
  3181. {
  3182. KillsInfected[Attacker]++;
  3183. return Action:0;
  3184. }
  3185. if (!Victim)
  3186. {
  3187. return Action:0;
  3188. }
  3189. if (GetClientTeam(Victim) != 3)
  3190. {
  3191. return Action:0;
  3192. }
  3193. new iClass = GetEntProp(Victim, PropType:0, "m_zombieClass", 4, 0);
  3194. if (iClass == 3)
  3195. {
  3196. Score = GetConVarInt(cvar_Hunter) + tystatsbalans + bonus;
  3197. Format(query2, 512, "UPDATE players SET kill_hunter = kill_hunter + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3198. }
  3199. else
  3200. {
  3201. if (iClass == 1)
  3202. {
  3203. Score = GetConVarInt(cvar_Smoker) + tystatsbalans + bonus;
  3204. Format(query2, 512, "UPDATE players SET kill_smoker = kill_smoker + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3205. }
  3206. if (iClass == 2)
  3207. {
  3208. Score = GetConVarInt(cvar_Boomer) + tystatsbalans + bonus;
  3209. Format(query2, 512, "UPDATE players SET kill_boomer = kill_boomer + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3210. }
  3211. if (iClass == 5)
  3212. {
  3213. Score = GetConVarInt(cvar_Jockey) + tystatsbalans + bonus;
  3214. Format(query2, 512, "UPDATE players SET kill_jockey = kill_jockey + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3215. }
  3216. if (iClass == 6)
  3217. {
  3218. Score = GetConVarInt(cvar_Charger) + tystatsbalans + bonus;
  3219. Format(query2, 512, "UPDATE players SET kill_charger = kill_charger + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3220. }
  3221. if (iClass == 4)
  3222. {
  3223. Score = GetConVarInt(cvar_Spitter) + tystatsbalans + bonus;
  3224. Format(query2, 512, "UPDATE players SET kill_spitter = kill_spitter + 1, kills = kills + 1 WHERE steamid = '%s'", AttackerID);
  3225. }
  3226. if (iClass == 8)
  3227. {
  3228. Score = GetConVarInt(cvar_Tank) + tystatsbalans + bonus;
  3229. Format(query2, 512, "UPDATE players SET award_tankkill = award_tankkill + 1 WHERE steamid = '%s'", AttackerID);
  3230. }
  3231. return Action:0;
  3232. }
  3233. if (IsMapFinished)
  3234. {
  3235. if (0 < Score)
  3236. {
  3237. Score = 0;
  3238. }
  3239. }
  3240. SendSQLUpdate(query2);
  3241. AddScore(Attacker, Score);
  3242. return Action:0;
  3243. }
  3244.  
  3245. public Action:Event_PlayerIncap(Handle:event, String:name[], bool:dontBroadcast)
  3246. {
  3247. new Attacker = GetClientOfUserId(GetEventInt(event, "attacker", 0));
  3248. new userid = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3249. PlayerIncap(Attacker, userid);
  3250. if (!Attacker)
  3251. {
  3252. return Action:0;
  3253. }
  3254. new var1;
  3255. if (IsFakeClient(Attacker) || IsFakeClient(userid))
  3256. {
  3257. return Action:0;
  3258. }
  3259. if (userid == Attacker)
  3260. {
  3261. return Action:0;
  3262. }
  3263. new var2;
  3264. if (GetClientTeam(Attacker) == 2 && GetClientTeam(userid) == 2)
  3265. {
  3266. return Action:0;
  3267. }
  3268. TKblockDamage[Attacker] = TKblockDamage[Attacker] + 10;
  3269. CPrintToChat(userid, "%t", "%N attacked %N (%i TK)", Attacker, userid, TKblockDamage[Attacker]);
  3270. CPrintToChat(Attacker, "%t", "%N attacked %N (%i TK)", Attacker, userid, TKblockDamage[Attacker]);
  3271. PunishTeamkiller(Attacker);
  3272. if (StatsDisabled())
  3273. {
  3274. return Action:0;
  3275. }
  3276. decl String:AttackerID[64];
  3277. GetClientAuthId(Attacker, AuthIdType:1, AttackerID, 64, true);
  3278. decl String:query2[512];
  3279. Format(query2, 512, "UPDATE players SET award_fincap = award_fincap + 1 WHERE steamid = '%s'", AttackerID);
  3280. SendSQLUpdate(query2);
  3281. new Score = 10 * -1;
  3282. AddScore(Attacker, Score);
  3283. return Action:0;
  3284. }
  3285.  
  3286. public Action:Event_PlayerHurt(Handle:event, String:name[], bool:dontBroadcast)
  3287. {
  3288. new Attacker = GetClientOfUserId(GetEventInt(event, "attacker", 0));
  3289. new target = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3290. if (!Attacker)
  3291. {
  3292. return Action:0;
  3293. }
  3294. if (GetEventInt(event, "dmg_health", 0) < 1)
  3295. {
  3296. return Action:0;
  3297. }
  3298. if (target == Attacker)
  3299. {
  3300. return Action:0;
  3301. }
  3302. new var1;
  3303. if (IsFakeClient(Attacker) || IsFakeClient(target))
  3304. {
  3305. return Action:0;
  3306. }
  3307. new var2;
  3308. if (GetClientTeam(Attacker) == 2 && GetClientTeam(target) == 2)
  3309. {
  3310. return Action:0;
  3311. }
  3312. new Score = -GetEventInt(event, "dmg_health", 0) * Score / 3;
  3313. if (!Score)
  3314. {
  3315. Score = -1;
  3316. }
  3317. TKblockDamage[Attacker] = TKblockDamage[Attacker][Score * -1];
  3318. CPrintToChat(target, "%t", "%N attacked %N (%i TK)", Attacker, target, TKblockDamage[Attacker]);
  3319. CPrintToChat(Attacker, "%t", "%N attacked %N (%i TK)", Attacker, target, TKblockDamage[Attacker]);
  3320. PunishTeamkiller(Attacker);
  3321. if (StatsDisabled())
  3322. {
  3323. return Action:0;
  3324. }
  3325. AddScore(Attacker, Score);
  3326. return Action:0;
  3327. }
  3328.  
  3329. public Action:Event_HealPlayer(Handle:event, String:name[], bool:dontBroadcast)
  3330. {
  3331. new Recepient = GetClientOfUserId(GetEventInt(event, "subject", 0));
  3332. new Giver = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3333. new restored = GetEventInt(event, "health_restored", 0);
  3334. new var1;
  3335. if (IsFakeClient(Recepient) || IsFakeClient(Giver))
  3336. {
  3337. return Action:0;
  3338. }
  3339. decl String:query2[512];
  3340. decl String:GiverID[64];
  3341. GetClientAuthId(Giver, AuthIdType:1, GiverID, 64, true);
  3342. if (Giver == Recepient)
  3343. {
  3344. Format(query2, 512, "UPDATE players SET heal = heal + 1 WHERE steamid = '%s'", GiverID);
  3345. }
  3346. else
  3347. {
  3348. TKblockDamage[Giver] = TKblockDamage[Giver] + -16;
  3349. if (0 >= TKblockDamage[Giver])
  3350. {
  3351. TKblockDamage[Giver] = 0;
  3352. }
  3353. if (StatsDisabled())
  3354. {
  3355. return Action:0;
  3356. }
  3357. new Score = 4;
  3358. if (restored > 39)
  3359. {
  3360. Format(query2, 512, "UPDATE players SET award_medkit = award_medkit + 1 WHERE steamid = '%s'", GiverID);
  3361. }
  3362. AddScore(Giver, Score);
  3363. }
  3364. SendSQLUpdate(query2);
  3365. return Action:0;
  3366. }
  3367.  
  3368. public Action:Event_DefibPlayer(Handle:event, String:name[], bool:dontBroadcast)
  3369. {
  3370. new Recipient = GetClientOfUserId(GetEventInt(event, "subject", 0));
  3371. new Giver = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3372. new var1;
  3373. if (IsFakeClient(Recipient) || IsFakeClient(Giver))
  3374. {
  3375. return Action:0;
  3376. }
  3377. if (Giver == Recipient)
  3378. {
  3379. return Action:0;
  3380. }
  3381. if (StatsDisabled())
  3382. {
  3383. return Action:0;
  3384. }
  3385. new Score = 4;
  3386. decl String:GiverID[64];
  3387. GetClientAuthId(Giver, AuthIdType:1, GiverID, 64, true);
  3388. decl String:query2[1024];
  3389. Format(query2, 1024, "UPDATE players SET award_defib = award_defib + 1 WHERE steamid = '%s'", GiverID);
  3390. SendSQLUpdate(query2);
  3391. AddScore(Giver, Score);
  3392. return Action:0;
  3393. }
  3394.  
  3395. public OnDefibPlayerByMedkit(client, target)
  3396. {
  3397. if (IsFakeClient(target))
  3398. {
  3399. return 0;
  3400. }
  3401. if (StatsDisabled())
  3402. {
  3403. return 0;
  3404. }
  3405. new Score = 4;
  3406. decl String:clientID[64];
  3407. GetClientAuthId(client, AuthIdType:1, clientID, 64, true);
  3408. decl String:query2[1024];
  3409. Format(query2, 1024, "UPDATE players SET award_defib = award_defib + 1 WHERE steamid = '%s'", clientID);
  3410. SendSQLUpdate(query2);
  3411. AddScore(client, Score);
  3412. return 0;
  3413. }
  3414.  
  3415. public Action:Event_ReviveSuccess(Handle:event, String:name[], bool:dontBroadcast)
  3416. {
  3417. new target = GetClientOfUserId(GetEventInt(event, "subject", 0));
  3418. new client = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3419. new var1;
  3420. if (IsFakeClient(target) || IsFakeClient(client))
  3421. {
  3422. return Action:0;
  3423. }
  3424. if (client == target)
  3425. {
  3426. return Action:0;
  3427. }
  3428. TKblockDamage[client] = TKblockDamage[client] + -8;
  3429. if (0 >= TKblockDamage[client])
  3430. {
  3431. TKblockDamage[client] = 0;
  3432. }
  3433. if (StatsDisabled())
  3434. {
  3435. return Action:0;
  3436. }
  3437. new Score = 2;
  3438. decl String:GiverID[64];
  3439. GetClientAuthId(client, AuthIdType:1, GiverID, 64, true);
  3440. decl String:query2[1024];
  3441. Format(query2, 1024, "UPDATE players SET award_revive = award_revive + 1 WHERE steamid = '%s'", GiverID);
  3442. SendSQLUpdate(query2);
  3443. AddScore(client, Score);
  3444. GrantPlayerColor(target);
  3445. return Action:0;
  3446. }
  3447.  
  3448. public Action:Event_PlayerNowIt(Handle:event, String:name[], bool:dontBroadcast)
  3449. {
  3450. new target = GetClientOfUserId(GetEventInt(event, "userid", 0));
  3451. if (!IsValidClient(target))
  3452. {
  3453. return Action:0;
  3454. }
  3455. new attacker = GetClientOfUserId(GetEventInt(event, "attacker", 0));
  3456. if (StatsDisabled())
  3457. {
  3458. return Action:0;
  3459. }
  3460. new Score;
  3461. if (attacker)
  3462. {
  3463. new var1;
  3464. if (!IsClientConnected(attacker) || !IsClientInGame(attacker))
  3465. {
  3466. return Action:0;
  3467. }
  3468. if (IsFakeClient(attacker))
  3469. {
  3470. return Action:0;
  3471. }
  3472. if (GetClientTeam(attacker) != 2)
  3473. {
  3474. return Action:0;
  3475. }
  3476. if (attacker == target)
  3477. {
  3478. Score = 3;
  3479. }
  3480. else
  3481. {
  3482. if (GetClientTeam(target) == 3)
  3483. {
  3484. if (GetClientZC(target) == 8)
  3485. {
  3486. Score = 8;
  3487. CPrintToChatAll("\x04Player {blue}%N \x01vomit \x05Tank", attacker);
  3488. }
  3489. }
  3490. }
  3491. AddScore(attacker, Score);
  3492. return Action:0;
  3493. }
  3494. return Action:0;
  3495. }
  3496.  
  3497. public Action:Event_SurvivorRescued(Handle:event, String:name[], bool:dontBroadcast)
  3498. {
  3499. new client = GetClientOfUserId(GetEventInt(event, "rescuer", 0));
  3500. new target = GetClientOfUserId(GetEventInt(event, "victim", 0));
  3501. if (!IsValidClient(client))
  3502. {
  3503. return Action:0;
  3504. }
  3505. if (IsFakeClient(client))
  3506. {
  3507. return Action:0;
  3508. }
  3509. if (IsFakeClient(target))
  3510. {
  3511. return Action:0;
  3512. }
  3513. if (StatsDisabled())
  3514. {
  3515. return Action:0;
  3516. }
  3517. new Score = 1;
  3518. decl String:clientID[64];
  3519. GetClientAuthId(client, AuthIdType:1, clientID, 64, true);
  3520. decl String:query2[1024];
  3521. Format(query2, 1024, "UPDATE players SET award_rescue = award_rescue + 1 WHERE steamid = '%s'", clientID);
  3522. SendSQLUpdate(query2);
  3523. AddScore(client, Score);
  3524. return Action:0;
  3525. }
  3526.  
  3527. public Action:Event_Award_L4D2(Handle:event, String:name[], bool:dontBroadcast)
  3528. {
  3529. if (StatsDisabled())
  3530. {
  3531. return Action:0;
  3532. }
  3533. new PlayerID = GetEventInt(event, "userid", 0);
  3534. if (!PlayerID)
  3535. {
  3536. return Action:0;
  3537. }
  3538. new client = GetClientOfUserId(PlayerID);
  3539. if (IsFakeClient(client))
  3540. {
  3541. return Action:0;
  3542. }
  3543. new target = GetEventInt(event, "subjectentid", 0);
  3544. new Recipient;
  3545. new String:AwardSQL[128];
  3546. new AwardID = GetEventInt(event, "award", 0);
  3547. decl String:UserID[64];
  3548. GetClientAuthId(client, AuthIdType:1, UserID, 64, true);
  3549. if (AwardID == 67)
  3550. {
  3551. if (!target)
  3552. {
  3553. return Action:0;
  3554. }
  3555. ProtectedFriendlyCounter[client]++;
  3556. return Action:0;
  3557. }
  3558. if (AwardID == 68)
  3559. {
  3560. if (!target)
  3561. {
  3562. return Action:0;
  3563. }
  3564. Recipient = GetClientOfUserId(GetClientUserId(target));
  3565. GivePills(client, Recipient, -1);
  3566. return Action:0;
  3567. }
  3568. if (AwardID == 69)
  3569. {
  3570. if (!target)
  3571. {
  3572. return Action:0;
  3573. }
  3574. Recipient = GetClientOfUserId(GetClientUserId(target));
  3575. GiveAdrenaline(client, Recipient, -1);
  3576. return Action:0;
  3577. }
  3578. if (AwardID == 85)
  3579. {
  3580. if (!target)
  3581. {
  3582. return Action:0;
  3583. }
  3584. Recipient = GetClientOfUserId(GetClientUserId(target));
  3585. PlayerIncap(client, Recipient);
  3586. return Action:0;
  3587. }
  3588. if (AwardID == 81)
  3589. {
  3590. Format(AwardSQL, 128, "award_tankkillnodeaths = award_tankkillnodeaths + 1");
  3591. }
  3592. else
  3593. {
  3594. if (AwardID == 86)
  3595. {
  3596. Format(AwardSQL, 128, "award_left4dead = award_left4dead + 1");
  3597. }
  3598. if (AwardID == 95)
  3599. {
  3600. Format(AwardSQL, 128, "award_letinsafehouse = award_letinsafehouse + 1");
  3601. }
  3602. return Action:0;
  3603. }
  3604. decl String:query[1024];
  3605. Format(query, 1024, "UPDATE players SET %s WHERE steamid = '%s'", AwardSQL, UserID);
  3606. SendSQLUpdate(query);
  3607. return Action:0;
  3608. }
  3609.  
  3610. GivePills(Giver, Recipient, PillsID)
  3611. {
  3612. if (0 > PillsID)
  3613. {
  3614. PillsID = GetPlayerWeaponSlot(Recipient, 4);
  3615. }
  3616. new var1;
  3617. if (PillsID < 0 || Pills[PillsID] == 1)
  3618. {
  3619. return 0;
  3620. }
  3621. Pills[PillsID] = 1;
  3622. if (IsFakeClient(Giver))
  3623. {
  3624. return 0;
  3625. }
  3626. decl String:GiverID[64];
  3627. GetClientAuthId(Giver, AuthIdType:1, GiverID, 64, true);
  3628. decl String:query2[1024];
  3629. Format(query2, 1024, "UPDATE players SET award_pills = award_pills + 1 WHERE steamid = '%s'", GiverID);
  3630. SendSQLUpdate(query2);
  3631. return 0;
  3632. }
  3633.  
  3634. GiveAdrenaline(Giver, Recipient, AdrenalineID)
  3635. {
  3636. if (0 > AdrenalineID)
  3637. {
  3638. AdrenalineID = GetPlayerWeaponSlot(Recipient, 4);
  3639. }
  3640. new var1;
  3641. if (AdrenalineID < 0 || Adrenaline[AdrenalineID] == 1)
  3642. {
  3643. return 0;
  3644. }
  3645. Adrenaline[AdrenalineID] = 1;
  3646. if (IsFakeClient(Giver))
  3647. {
  3648. return 0;
  3649. }
  3650. decl String:GiverID[64];
  3651. GetClientAuthId(Giver, AuthIdType:1, GiverID, 64, true);
  3652. decl String:query2[1024];
  3653. Format(query2, 1024, "UPDATE players SET award_adrenaline = award_adrenaline + 1 WHERE steamid = '%s'", GiverID);
  3654. SendSQLUpdate(query2);
  3655. return 0;
  3656. }
  3657.  
  3658. PlayerIncap(Attacker, Victim)
  3659. {
  3660. if (0 >= Victim)
  3661. {
  3662. return 0;
  3663. }
  3664. if (Attacker == Victim)
  3665. {
  3666. return 0;
  3667. }
  3668. new var1;
  3669. if (!Attacker || IsFakeClient(Attacker))
  3670. {
  3671. return 0;
  3672. }
  3673. new AttackerTeam = GetClientTeam(Attacker);
  3674. new VictimTeam = GetClientTeam(Victim);
  3675. new var2;
  3676. if (AttackerTeam == 2 && VictimTeam == 2)
  3677. {
  3678. decl String:AttackerID[64];
  3679. GetClientAuthId(Attacker, AuthIdType:1, AttackerID, 64, true);
  3680. decl String:query2[1024];
  3681. Format(query2, 1024, "UPDATE players SET award_fincap = award_fincap + 1 WHERE steamid = '%s'", AttackerID);
  3682. SendSQLUpdate(query2);
  3683. }
  3684. return 0;
  3685. }
  3686.  
  3687. public PunishTeamkiller(client)
  3688. {
  3689. if (GetUserFlagBits(client))
  3690. {
  3691. return 0;
  3692. }
  3693. new BonusTK;
  3694. new var1;
  3695. if (ClientRank[client] > 1000 || ClientRank[client])
  3696. {
  3697. BonusTK = -45;
  3698. }
  3699. else
  3700. {
  3701. new var2;
  3702. if (ClientRank[client] > 100 && ClientRank[client] < 1001)
  3703. {
  3704. BonusTK = 0;
  3705. }
  3706. new var3;
  3707. if (ClientRank[client] > 0 && ClientRank[client] < 101)
  3708. {
  3709. BonusTK = 30;
  3710. }
  3711. }
  3712. if (BonusTK + TKblockmin < TKblockDamage[client])
  3713. {
  3714. if (BonusTK + TKblockmax < TKblockDamage[client])
  3715. {
  3716. if (BonusTK + TKblockmax > TKblockPunishment[client])
  3717. {
  3718. new var4;
  3719. if (IsValidEntity(client) && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client))
  3720. {
  3721. decl String:steamId[64];
  3722. GetClientAuthId(client, AuthIdType:1, steamId, 64, true);
  3723. PrintToChatAll("%t", "%N (%s) has been banned [%i TK]", client, steamId, TKblockDamage[client]);
  3724. TKblockPunishment[client] = TKblockDamage[client];
  3725. if (ClientPoints[client] <= -1000)
  3726. {
  3727. if (GetTime({0,0}) <= LastVotebanTIME[client][1])
  3728. {
  3729. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 40320, "Team Killer");
  3730. }
  3731. else
  3732. {
  3733. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 20160, "Team Killer");
  3734. }
  3735. }
  3736. else
  3737. {
  3738. new var5;
  3739. if (ClientPoints[client] > -1000 && ClientPoints[client] <= -300)
  3740. {
  3741. if (GetTime({0,0}) <= LastVotebanTIME[client][1])
  3742. {
  3743. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 40320, "Team Killer");
  3744. }
  3745. else
  3746. {
  3747. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 10080, "Team Killer");
  3748. }
  3749. }
  3750. new var6;
  3751. if (ClientPoints[client] > -300 && ClientPoints[client] <= 0)
  3752. {
  3753. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 4320, "Team Killer");
  3754. }
  3755. if (0 < ClientPoints[client])
  3756. {
  3757. ServerCommand("sm_ban \"#%d\" \"%i\" \"%s\"", GetClientUserId(client), 720, "Team Killer");
  3758. }
  3759. }
  3760. ServerCommand("sm_cancelvote");
  3761. }
  3762. }
  3763. }
  3764. if (BonusTK + TKblockmin < TKblockDamage[client] - TKblockPunishment[client])
  3765. {
  3766. new var7;
  3767. if (IsValidEntity(client) && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client))
  3768. {
  3769. TKblockPunishment[client] = TKblockDamage[client];
  3770. CPrintToChatAll("%t {blue}%N %t", "Auto Voteban", client, "%i TK. (Rank: %d Points: %d)", TKblockDamage[client], ClientRank[client], ClientPoints[client]);
  3771. ServerCommand("sm_voteban #%d TeamKiller", GetClientUserId(client));
  3772. LastVotebanTIME[client] = GetTime({0,0});
  3773. }
  3774. }
  3775. }
  3776. return 0;
  3777. }
  3778.  
  3779. public Action:cmd_ShowRank(client, args)
  3780. {
  3781. if (!client)
  3782. {
  3783. return Action:3;
  3784. }
  3785. if (!IsClientInGame(client))
  3786. {
  3787. return Action:3;
  3788. }
  3789. if (StatsDisabled())
  3790. {
  3791. PrintToChat(client, "%t", "Failed to connect to database");
  3792. return Action:3;
  3793. }
  3794. if (IsFakeClient(client))
  3795. {
  3796. return Action:3;
  3797. }
  3798. KnowRankPoints(client);
  3799. KnowRankKills(client);
  3800. KnowRankPlaytime(client);
  3801. CreateTimer(1.2, TimerDisplayRank, client, 0);
  3802. return Action:3;
  3803. }
  3804.  
  3805. public Action:TimerDisplayRank(Handle:timer, any:client)
  3806. {
  3807. if (!client)
  3808. {
  3809. return Action:4;
  3810. }
  3811. if (!IsClientInGame(client))
  3812. {
  3813. return Action:4;
  3814. }
  3815. if (IsFakeClient(client))
  3816. {
  3817. return Action:4;
  3818. }
  3819. new Handle:RankPanel = CreatePanel(Handle:0);
  3820. new String:Value[64];
  3821. new String:URL[64];
  3822. GetConVarString(cvar_SiteURL, URL, 64);
  3823. new theTime = ClientPlaytime[client];
  3824. new days = theTime / 60 / 60 / 24;
  3825. new hours = theTime / 60 / 60 % 24;
  3826. new minutes = theTime / 60 % 60;
  3827. new String:playtime[128];
  3828. new var1;
  3829. if (hours && days)
  3830. {
  3831. Format(playtime, 128, "%d min", minutes);
  3832. }
  3833. else
  3834. {
  3835. if (days)
  3836. {
  3837. Format(playtime, 128, "%d day %d hour %d min", days, hours, minutes);
  3838. }
  3839. Format(playtime, 128, "%d hour %d min", hours, minutes);
  3840. }
  3841. new BonusTK;
  3842. new var2;
  3843. if (ClientRank[client] > 1000 || ClientRank[client])
  3844. {
  3845. BonusTK = -45;
  3846. }
  3847. else
  3848. {
  3849. new var3;
  3850. if (ClientRank[client] > 100 && ClientRank[client] < 1001)
  3851. {
  3852. BonusTK = 0;
  3853. }
  3854. new var4;
  3855. if (ClientRank[client] > 0 && ClientRank[client] < 101)
  3856. {
  3857. BonusTK = 30;
  3858. }
  3859. }
  3860. new TKblockminReal = BonusTK + TKblockmin;
  3861. new TKblockmaxReal = BonusTK + TKblockmax;
  3862. Format(Value, 64, "Ranking of %N", client);
  3863. DrawPanelText(RankPanel, Value);
  3864. Format(Value, 64, "========================");
  3865. DrawPanelText(RankPanel, Value);
  3866. Format(Value, 64, "Rank: %i of %i", ClientRank[client], RankTotal);
  3867. DrawPanelText(RankPanel, Value);
  3868. if (NewPoints[client])
  3869. {
  3870. if (0 < NewPoints[client])
  3871. {
  3872. if (0 < GetConVarInt(hm_count_fails))
  3873. {
  3874. Format(Value, 64, "Points: %i + %i(%i)", ClientPoints[client], NewPoints[client], CalculatePoints(NewPoints[client]));
  3875. }
  3876. else
  3877. {
  3878. Format(Value, 64, "Points: %i + %i", ClientPoints[client], NewPoints[client]);
  3879. }
  3880. }
  3881. else
  3882. {
  3883. Format(Value, 64, "Points: %i %i", ClientPoints[client], NewPoints[client]);
  3884. }
  3885. }
  3886. else
  3887. {
  3888. Format(Value, 64, "Points: %i", ClientPoints[client]);
  3889. }
  3890. DrawPanelText(RankPanel, Value);
  3891. Format(Value, 64, "Killed Bosses: %i", ClientKills[client]);
  3892. DrawPanelText(RankPanel, Value);
  3893. Format(Value, 64, "Playtime: %s", playtime);
  3894. DrawPanelText(RankPanel, Value);
  3895. Format(Value, 64, "TK: %i", TKblockDamage[client]);
  3896. DrawPanelText(RankPanel, Value);
  3897. Format(Value, 64, "Voteban TK: %i", TKblockminReal);
  3898. DrawPanelText(RankPanel, Value);
  3899. Format(Value, 64, "Ban TK: %i", TKblockmaxReal);
  3900. DrawPanelText(RankPanel, Value);
  3901. if (!StrEqual(URL, "", false))
  3902. {
  3903. Format(Value, 64, "For full stats visit:\nhttp://%s", URL);
  3904. DrawPanelText(RankPanel, Value);
  3905. Format(Value, 64, "========================");
  3906. DrawPanelText(RankPanel, Value);
  3907. DrawPanelItem(RankPanel, "Show full stats", 0);
  3908. }
  3909. DrawPanelItem(RankPanel, "Next Rank", 0);
  3910. DrawPanelItem(RankPanel, "Top 20 Players", 0);
  3911. DrawPanelItem(RankPanel, "Show Player Ranks", 0);
  3912. DrawPanelItem(RankPanel, "Close", 0);
  3913. SendPanelToClient(RankPanel, client, RankPanelHandlerOption, 30);
  3914. CloseHandle(RankPanel);
  3915. CreateTimer(1.0, TimedGrantPlayerColor, client, 0);
  3916. return Action:4;
  3917. }
  3918.  
  3919. public RankPanelHandlerOption(Handle:menu, MenuAction:action, param1, param2)
  3920. {
  3921. if (action == MenuAction:4)
  3922. {
  3923. new String:URL[64];
  3924. GetConVarString(cvar_SiteURL, URL, 64);
  3925. if (!StrEqual(URL, "", false))
  3926. {
  3927. if (param2 == 1)
  3928. {
  3929. FakeClientCommand(param1, "sm_browse %s", URL);
  3930. }
  3931. else
  3932. {
  3933. if (param2 == 2)
  3934. {
  3935. cmd_NextRank(param1, 0);
  3936. }
  3937. if (param2 == 3)
  3938. {
  3939. cmd_ShowTop20(param1, 0);
  3940. }
  3941. if (param2 == 4)
  3942. {
  3943. DisplayRankTargetMenu(param1);
  3944. }
  3945. }
  3946. }
  3947. else
  3948. {
  3949. if (param2 == 1)
  3950. {
  3951. cmd_NextRank(param1, 0);
  3952. }
  3953. if (param2 == 2)
  3954. {
  3955. cmd_ShowTop20(param1, 0);
  3956. }
  3957. if (param2 == 3)
  3958. {
  3959. DisplayRankTargetMenu(param1);
  3960. }
  3961. }
  3962. }
  3963. return 0;
  3964. }
  3965.  
  3966. DisplayRankTargetMenu(client)
  3967. {
  3968. new Handle:menu = CreateMenu(MenuHandler_Rank, MenuAction:28);
  3969. decl String:title[100];
  3970. new String:playername[128];
  3971. new String:identifier[64];
  3972. decl String:DisplayName[64];
  3973. Format(title, 100, "%s", "Player Ranks:");
  3974. SetMenuTitle(menu, title);
  3975. SetMenuExitBackButton(menu, true);
  3976. new i = 1;
  3977. while (GetMaxClients() > i)
  3978. {
  3979. new var1;
  3980. if (IsClientInGame(i) && !IsFakeClient(i))
  3981. {
  3982. GetClientName(i, playername, 128);
  3983. Format(DisplayName, 64, "%s (%i points)", playername, ClientPoints[i]);
  3984. Format(identifier, 64, "%i", i);
  3985. AddMenuItem(menu, identifier, DisplayName, 0);
  3986. }
  3987. i++;
  3988. }
  3989. DisplayMenu(menu, client, 0);
  3990. return 0;
  3991. }
  3992.  
  3993. public MenuHandler_Rank(Handle:menu, MenuAction:action, param1, param2)
  3994. {
  3995. if (action == MenuAction:16)
  3996. {
  3997. CloseHandle(menu);
  3998. }
  3999. else
  4000. {
  4001. if (action == MenuAction:4)
  4002. {
  4003. decl String:info[32];
  4004. decl String:name[32];
  4005. new target;
  4006. GetMenuItem(menu, param2, info, 32, 0, name, 32);
  4007. target = StringToInt(info, 10);
  4008. if (target)
  4009. {
  4010. KnowRankKills(target);
  4011. KnowRankPlaytime(target);
  4012. DisplayRank(target, param1);
  4013. }
  4014. else
  4015. {
  4016. PrintToChat(param1, "[SM] %s", "Player no longer available");
  4017. }
  4018. }
  4019. }
  4020. return 0;
  4021. }
  4022.  
  4023. DisplayRank(target, sender)
  4024. {
  4025. new Handle:RankPanel = CreatePanel(Handle:0);
  4026. new String:Value[64];
  4027. new String:URL[64];
  4028. GetConVarString(cvar_SiteURL, URL, 64);
  4029. new theTime = ClientPlaytime[target];
  4030. new days = theTime / 60 / 60 / 24;
  4031. new hours = theTime / 60 / 60 % 24;
  4032. new minutes = theTime / 60 % 60;
  4033. new String:playtime[128];
  4034. new var1;
  4035. if (hours && days)
  4036. {
  4037. Format(playtime, 128, "%d min", minutes);
  4038. }
  4039. else
  4040. {
  4041. if (days)
  4042. {
  4043. Format(playtime, 128, "%d day %d hour %d min", days, hours, minutes);
  4044. }
  4045. Format(playtime, 128, "%d hour %d min", hours, minutes);
  4046. }
  4047. new BonusTK;
  4048. new var2;
  4049. if (ClientRank[target] > 1000 || ClientRank[target])
  4050. {
  4051. BonusTK = -45;
  4052. }
  4053. else
  4054. {
  4055. new var3;
  4056. if (ClientRank[target] > 100 && ClientRank[target] < 1001)
  4057. {
  4058. BonusTK = 0;
  4059. }
  4060. new var4;
  4061. if (ClientRank[target] > 0 && ClientRank[target] < 101)
  4062. {
  4063. BonusTK = 30;
  4064. }
  4065. }
  4066. new TKblockminReal = BonusTK + TKblockmin;
  4067. new TKblockmaxReal = BonusTK + TKblockmax;
  4068. Format(Value, 64, "Ranking of %N", target);
  4069. DrawPanelText(RankPanel, Value);
  4070. Format(Value, 64, "========================");
  4071. DrawPanelText(RankPanel, Value);
  4072. Format(Value, 64, "Rank: %i of %i", ClientRank[target], RankTotal);
  4073. DrawPanelText(RankPanel, Value);
  4074. if (NewPoints[target])
  4075. {
  4076. if (0 < NewPoints[target])
  4077. {
  4078. if (0 < GetConVarInt(hm_count_fails))
  4079. {
  4080. Format(Value, 64, "Points: %i + %i(%i)", ClientPoints[target], NewPoints[target], CalculatePoints(NewPoints[target]));
  4081. }
  4082. else
  4083. {
  4084. Format(Value, 64, "Points: %i + %i", ClientPoints[target], NewPoints[target]);
  4085. }
  4086. }
  4087. else
  4088. {
  4089. Format(Value, 64, "Points: %i %i", ClientPoints[target], NewPoints[target]);
  4090. }
  4091. }
  4092. else
  4093. {
  4094. Format(Value, 64, "Points: %i", ClientPoints[target]);
  4095. }
  4096. DrawPanelText(RankPanel, Value);
  4097. Format(Value, 64, "Killed Bosses: %i", ClientKills[target]);
  4098. DrawPanelText(RankPanel, Value);
  4099. Format(Value, 64, "Playtime: %s", playtime);
  4100. DrawPanelText(RankPanel, Value);
  4101. Format(Value, 64, "TK: %i", TKblockDamage[target]);
  4102. DrawPanelText(RankPanel, Value);
  4103. Format(Value, 64, "Voteban TK: %i", TKblockminReal);
  4104. DrawPanelText(RankPanel, Value);
  4105. Format(Value, 64, "Ban TK: %i", TKblockmaxReal);
  4106. DrawPanelText(RankPanel, Value);
  4107. if (!StrEqual(URL, "", false))
  4108. {
  4109. Format(Value, 64, "For full stats visit:\nhttp://%s", URL);
  4110. DrawPanelText(RankPanel, Value);
  4111. Format(Value, 64, "========================");
  4112. DrawPanelText(RankPanel, Value);
  4113. DrawPanelItem(RankPanel, "Show full stats", 0);
  4114. }
  4115. DrawPanelItem(RankPanel, "Next Rank", 0);
  4116. DrawPanelItem(RankPanel, "Top 20 Players", 0);
  4117. DrawPanelItem(RankPanel, "Show Player Ranks", 0);
  4118. DrawPanelItem(RankPanel, "Close", 0);
  4119. SendPanelToClient(RankPanel, sender, RankPanelHandlerOption, 30);
  4120. CloseHandle(RankPanel);
  4121. return 0;
  4122. }
  4123.  
  4124. public Action:cmd_ShowTop10(client, args)
  4125. {
  4126. if (!client)
  4127. {
  4128. return Action:3;
  4129. }
  4130. if (!IsClientInGame(client))
  4131. {
  4132. return Action:3;
  4133. }
  4134. if (StatsDisabled())
  4135. {
  4136. PrintToChat(client, "%t", "Failed to connect to database");
  4137. return Action:3;
  4138. }
  4139. if (IsFakeClient(client))
  4140. {
  4141. return Action:3;
  4142. }
  4143. decl String:query[256];
  4144. Format(query, 256, "SELECT name, points FROM players ORDER BY points DESC LIMIT 10");
  4145. SQL_TQuery(db, DisplayTop10, query, client, DBPriority:1);
  4146. return Action:3;
  4147. }
  4148.  
  4149. public Action:cmd_ShowTop15(client, args)
  4150. {
  4151. if (!client)
  4152. {
  4153. return Action:3;
  4154. }
  4155. if (!IsClientInGame(client))
  4156. {
  4157. return Action:3;
  4158. }
  4159. if (StatsDisabled())
  4160. {
  4161. PrintToChat(client, "%t", "Failed to connect to database");
  4162. return Action:3;
  4163. }
  4164. if (IsFakeClient(client))
  4165. {
  4166. return Action:3;
  4167. }
  4168. decl String:query[256];
  4169. Format(query, 256, "SELECT name, points FROM players ORDER BY points DESC LIMIT 15");
  4170. SQL_TQuery(db, DisplayTop15, query, client, DBPriority:1);
  4171. return Action:3;
  4172. }
  4173.  
  4174. public Action:cmd_ShowTop20(client, args)
  4175. {
  4176. if (!client)
  4177. {
  4178. return Action:3;
  4179. }
  4180. if (!IsClientInGame(client))
  4181. {
  4182. return Action:3;
  4183. }
  4184. if (StatsDisabled())
  4185. {
  4186. PrintToChat(client, "%t", "Failed to connect to database");
  4187. return Action:3;
  4188. }
  4189. if (IsFakeClient(client))
  4190. {
  4191. return Action:3;
  4192. }
  4193. decl String:query[256];
  4194. Format(query, 256, "SELECT name, points FROM players ORDER BY points DESC LIMIT 20");
  4195. SQL_TQuery(db, DisplayTop20, query, client, DBPriority:1);
  4196. return Action:3;
  4197. }
  4198.  
  4199. public DisplayTop10(Handle:owner, Handle:hndl, String:error[], any:client)
  4200. {
  4201. new var1;
  4202. if (!client || hndl)
  4203. {
  4204. return 0;
  4205. }
  4206. new String:Name[32];
  4207. new Handle:Top10Panel = CreatePanel(Handle:0);
  4208. new String:Value[64];
  4209. new points;
  4210. new number;
  4211. SetPanelTitle(Top10Panel, "Top 10 Players", false);
  4212. while (SQL_FetchRow(hndl))
  4213. {
  4214. SQL_FetchString(hndl, 0, Name, 32, 0);
  4215. points = SQL_FetchInt(hndl, 1, 0);
  4216. ReplaceString(Name, 32, "&lt;", "<", true);
  4217. ReplaceString(Name, 32, "&gt;", ">", true);
  4218. ReplaceString(Name, 32, "&#37;", "%", true);
  4219. ReplaceString(Name, 32, "&#61;", "=", true);
  4220. ReplaceString(Name, 32, "&#42;", "*", true);
  4221. number++;
  4222. Format(Value, 64, "%i_ %s %i Points", number, Name, points);
  4223. DrawPanelText(Top10Panel, Value);
  4224. }
  4225. DrawPanelItem(Top10Panel, "Close", 0);
  4226. SendPanelToClient(Top10Panel, client, RankPanelHandler, 30);
  4227. CloseHandle(Top10Panel);
  4228. return 0;
  4229. }
  4230.  
  4231. public DisplayTop15(Handle:owner, Handle:hndl, String:error[], any:client)
  4232. {
  4233. new var1;
  4234. if (!client || hndl)
  4235. {
  4236. return 0;
  4237. }
  4238. new String:Name[32];
  4239. new Handle:Top15Panel = CreatePanel(Handle:0);
  4240. new String:Value[64];
  4241. new points;
  4242. new number;
  4243. SetPanelTitle(Top15Panel, "Top 15 Players", false);
  4244. while (SQL_FetchRow(hndl))
  4245. {
  4246. SQL_FetchString(hndl, 0, Name, 32, 0);
  4247. points = SQL_FetchInt(hndl, 1, 0);
  4248. ReplaceString(Name, 32, "&lt;", "<", true);
  4249. ReplaceString(Name, 32, "&gt;", ">", true);
  4250. ReplaceString(Name, 32, "&#37;", "%", true);
  4251. ReplaceString(Name, 32, "&#61;", "=", true);
  4252. ReplaceString(Name, 32, "&#42;", "*", true);
  4253. number++;
  4254. Format(Value, 64, "%i_ %s %i Points", number, Name, points);
  4255. DrawPanelText(Top15Panel, Value);
  4256. }
  4257. DrawPanelItem(Top15Panel, "Close", 0);
  4258. SendPanelToClient(Top15Panel, client, RankPanelHandler, 30);
  4259. CloseHandle(Top15Panel);
  4260. return 0;
  4261. }
  4262.  
  4263. public DisplayTop20(Handle:owner, Handle:hndl, String:error[], any:client)
  4264. {
  4265. new var1;
  4266. if (!client || hndl)
  4267. {
  4268. return 0;
  4269. }
  4270. new String:Name[32];
  4271. new Handle:Top20Panel = CreatePanel(Handle:0);
  4272. new String:Value[64];
  4273. new points;
  4274. new number;
  4275. SetPanelTitle(Top20Panel, "Top 20 Players", false);
  4276. while (SQL_FetchRow(hndl))
  4277. {
  4278. SQL_FetchString(hndl, 0, Name, 32, 0);
  4279. points = SQL_FetchInt(hndl, 1, 0);
  4280. ReplaceString(Name, 32, "&lt;", "<", true);
  4281. ReplaceString(Name, 32, "&gt;", ">", true);
  4282. ReplaceString(Name, 32, "&#37;", "%", true);
  4283. ReplaceString(Name, 32, "&#61;", "=", true);
  4284. ReplaceString(Name, 32, "&#42;", "*", true);
  4285. number++;
  4286. Format(Value, 64, "%i_ %s %i", number, Name, points);
  4287. DrawPanelText(Top20Panel, Value);
  4288. }
  4289. DrawPanelItem(Top20Panel, "Close", 0);
  4290. SendPanelToClient(Top20Panel, client, RankPanelHandler, 30);
  4291. CloseHandle(Top20Panel);
  4292. return 0;
  4293. }
  4294.  
  4295. public Action:cmd_NextRank(client, args)
  4296. {
  4297. if (!client)
  4298. {
  4299. return Action:3;
  4300. }
  4301. if (!IsClientInGame(client))
  4302. {
  4303. return Action:3;
  4304. }
  4305. if (StatsDisabled())
  4306. {
  4307. PrintToChat(client, "%t", "Failed to connect to database");
  4308. return Action:3;
  4309. }
  4310. if (IsFakeClient(client))
  4311. {
  4312. return Action:3;
  4313. }
  4314. KnowRankPoints(client);
  4315. CreateTimer(1.2, TimerDisplayNextRank, client, 0);
  4316. return Action:3;
  4317. }
  4318.  
  4319. public Action:TimerDisplayNextRank(Handle:timer, any:client)
  4320. {
  4321. if (!client)
  4322. {
  4323. return Action:4;
  4324. }
  4325. if (!IsClientInGame(client))
  4326. {
  4327. return Action:4;
  4328. }
  4329. if (IsFakeClient(client))
  4330. {
  4331. return Action:4;
  4332. }
  4333. if (StatsDisabled())
  4334. {
  4335. return Action:4;
  4336. }
  4337. decl String:steamId[64];
  4338. GetClientAuthId(client, AuthIdType:1, steamId, 64, true);
  4339. decl String:query[1024];
  4340. Format(query, 1024, "SELECT points FROM players WHERE points > %i AND steamid <> '%s' ORDER BY points LIMIT 1", ClientPoints[client], steamId);
  4341. SQL_TQuery(db, DisplayNextRank, query, client, DBPriority:1);
  4342. return Action:4;
  4343. }
  4344.  
  4345. public Action:TimerDisplayFullNextRank(Handle:timer, any:client)
  4346. {
  4347. if (!client)
  4348. {
  4349. return Action:4;
  4350. }
  4351. if (!IsClientInGame(client))
  4352. {
  4353. return Action:4;
  4354. }
  4355. if (IsFakeClient(client))
  4356. {
  4357. return Action:4;
  4358. }
  4359. if (StatsDisabled())
  4360. {
  4361. return Action:4;
  4362. }
  4363. decl String:steamId[64];
  4364. GetClientAuthId(client, AuthIdType:1, steamId, 64, true);
  4365. decl String:query[2048];
  4366. decl String:query1[1024];
  4367. decl String:query2[256];
  4368. decl String:query3[1024];
  4369. Format(query1, 1024, "SELECT name,points FROM players WHERE points > %i AND steamid <> '%s' ORDER BY points ASC LIMIT 3", ClientPoints[client], steamId);
  4370. Format(query2, 256, "SELECT name,points FROM players WHERE steamid = '%s'", steamId);
  4371. Format(query3, 1024, "SELECT name,points FROM players WHERE points < %i AND steamid <> '%s' ORDER BY points DESC LIMIT 3", ClientPoints[client], steamId);
  4372. Format(query, 2048, "(%s) UNION (%s) UNION (%s) ORDER BY points DESC", query1, query2, query3);
  4373. SQL_TQuery(db, DisplayFullNextRank, query, client, DBPriority:1);
  4374. return Action:4;
  4375. }
  4376.  
  4377. public DisplayNextRank(Handle:owner, Handle:hndl, String:error[], any:client)
  4378. {
  4379. new var1;
  4380. if (!client || hndl)
  4381. {
  4382. return 0;
  4383. }
  4384. new Points;
  4385. while (SQL_FetchRow(hndl))
  4386. {
  4387. Points = SQL_FetchInt(hndl, 0, 0);
  4388. }
  4389. new Handle:NextRankPanel = CreatePanel(Handle:0);
  4390. new String:Value[64];
  4391. SetPanelTitle(NextRankPanel, "Next Rank:", false);
  4392. if (ClientRank[client] == 1)
  4393. {
  4394. Format(Value, 64, "You are 1st");
  4395. DrawPanelText(NextRankPanel, Value);
  4396. }
  4397. else
  4398. {
  4399. Format(Value, 64, "Points required: %i", Points - ClientPoints[client]);
  4400. DrawPanelText(NextRankPanel, Value);
  4401. }
  4402. DrawPanelItem(NextRankPanel, "More...", 0);
  4403. DrawPanelItem(NextRankPanel, "Close", 0);
  4404. SendPanelToClient(NextRankPanel, client, NextRankPanelHandler, 30);
  4405. CloseHandle(NextRankPanel);
  4406. return 0;
  4407. }
  4408.  
  4409. public DisplayFullNextRank(Handle:owner, Handle:hndl, String:error[], any:client)
  4410. {
  4411. new var1;
  4412. if (!client || hndl)
  4413. {
  4414. return 0;
  4415. }
  4416. new String:Name[32];
  4417. new Points;
  4418. new Handle:FullNextRankPanel = CreatePanel(Handle:0);
  4419. new String:Value[64];
  4420. SetPanelTitle(FullNextRankPanel, "Next Rank List:", false);
  4421. while (SQL_FetchRow(hndl))
  4422. {
  4423. SQL_FetchString(hndl, 0, Name, 32, 0);
  4424. Points = SQL_FetchInt(hndl, 1, 0);
  4425. ReplaceString(Name, 32, "&lt;", "<", true);
  4426. ReplaceString(Name, 32, "&gt;", ">", true);
  4427. ReplaceString(Name, 32, "&#37;", "%", true);
  4428. ReplaceString(Name, 32, "&#61;", "=", true);
  4429. ReplaceString(Name, 32, "&#42;", "*", true);
  4430. Format(Value, 64, "%i points: %s", Points, Name);
  4431. DrawPanelText(FullNextRankPanel, Value);
  4432. }
  4433. DrawPanelItem(FullNextRankPanel, "Close", 0);
  4434. SendPanelToClient(FullNextRankPanel, client, RankPanelHandler, 30);
  4435. CloseHandle(FullNextRankPanel);
  4436. return 0;
  4437. }
  4438.  
  4439. public RankPanelHandler(Handle:menu, MenuAction:action, param1, param2)
  4440. {
  4441. return 0;
  4442. }
  4443.  
  4444. public NextRankPanelHandler(Handle:panel, MenuAction:action, client, option)
  4445. {
  4446. if (action != MenuAction:4)
  4447. {
  4448. return 0;
  4449. }
  4450. if (option == 1)
  4451. {
  4452. CreateTimer(1.2, TimerDisplayFullNextRank, client, 0);
  4453. return 0;
  4454. }
  4455. return 0;
  4456. }
  4457.  
  4458. GetRealtyClientCount(bool:inGameOnly)
  4459. {
  4460. new clients;
  4461. new i = 1;
  4462. while (GetMaxClients() >= i)
  4463. {
  4464. new var1;
  4465. if (IsClientInGame(i) && !IsFakeClient(i))
  4466. {
  4467. clients++;
  4468. }
  4469. i++;
  4470. }
  4471. return clients;
  4472. }
  4473.  
  4474. StatsDisabled()
  4475. {
  4476. if (db)
  4477. {
  4478. return 0;
  4479. }
  4480. return 1;
  4481. }
  4482.  
  4483. public Action:cmd_ShowRankTarget(client, args)
  4484. {
  4485. new Target = GetClientAimTarget(client, false);
  4486. if (!IsRealClient(Target))
  4487. {
  4488. return Action:0;
  4489. }
  4490. new var1;
  4491. if (IsClientConnected(Target) && IsClientInGame(Target) && GetClientTeam(Target) == 2)
  4492. {
  4493. CPrintToChat(client, "%t {blue}%N %t", "Player", Target, "Rank: %d Points: %d Map points: %d", ClientRank[Target], ClientPoints[Target], NewPoints[Target]);
  4494. }
  4495. return Action:0;
  4496. }
  4497.  
  4498. public Action:Command_totalPoints_to_all(client, args)
  4499. {
  4500. PrintTotalPointsToAll(client);
  4501. return Action:0;
  4502. }
  4503.  
  4504. PrintTotalPointsToAll(client)
  4505. {
  4506. CPrintToChatAll("%t {blue}%N %t", "Player", client, "Rank: %d Points: %d", ClientRank[client], ClientPoints[client]);
  4507. return 0;
  4508. }
  4509.  
  4510. public Action:Command_Points(client, args)
  4511. {
  4512. PrintPoints(client);
  4513. return Action:0;
  4514. }
  4515.  
  4516. PrintPoints(client)
  4517. {
  4518. PrintToChat(client, "%t", "Your points: %d , Your map points: %d", ClientPoints[client], NewPoints[client]);
  4519. return 0;
  4520. }
  4521.  
  4522. public Action:Command_Playtime(client, args)
  4523. {
  4524. PrintPlaytime(client);
  4525. return Action:0;
  4526. }
  4527.  
  4528. PrintPlaytime(client)
  4529. {
  4530. PrintToChat(client, "%t", "Your playtime on this map: %d", Playtime[client]);
  4531. return 0;
  4532. }
  4533.  
  4534. public Action:Command_MapTop(client, args)
  4535. {
  4536. PrintMapTop(client);
  4537. return Action:0;
  4538. }
  4539.  
  4540. PrintMapTop(client)
  4541. {
  4542. new var1 = 0;
  4543. new var2 = 0;
  4544. new String:NameBuffer[32] = "";
  4545. new String:WorseNameBuffer[32] = "";
  4546. new count;
  4547. new totalpoints;
  4548. new j;
  4549. new worse;
  4550. j = -100000;
  4551. worse = 100000;
  4552. count = 0;
  4553. totalpoints = 0;
  4554. new topplayerrank;
  4555. new worseplayerrank;
  4556. new i = 1;
  4557. while (i <= MaxClients)
  4558. {
  4559. if (IsRealClient(i))
  4560. {
  4561. new String:clientname[32];
  4562. GetClientName(i, clientname, 32);
  4563. var1[i] = i;
  4564. var1[i][1] = NewPoints[i];
  4565. if (NewPoints[i] > j)
  4566. {
  4567. j = NewPoints[i];
  4568. topplayerrank = ClientRank[i];
  4569. }
  4570. if (NewPoints[i] < worse)
  4571. {
  4572. worse = NewPoints[i];
  4573. worseplayerrank = ClientRank[i];
  4574. }
  4575. count++;
  4576. totalpoints = NewPoints[i][totalpoints];
  4577. }
  4578. i++;
  4579. }
  4580. if (0 < GetConVarInt(hm_count_fails))
  4581. {
  4582. PrintToChat(client, "%t", "Map total points: %d (%d)", totalpoints, CalculatePoints(totalpoints));
  4583. CPrintToChat(client, "%t {blue}%s %t", "Map best player:", NameBuffer, "(rank: %d; points: %d (%d))", topplayerrank, j, CalculatePoints(j));
  4584. }
  4585. else
  4586. {
  4587. PrintToChat(client, "%t", "Map total points: %d", totalpoints);
  4588. CPrintToChat(client, "%t {blue}%s %t", "Map best player:", NameBuffer, "(rank: %d; points: %d)", topplayerrank, j);
  4589. }
  4590. if (0 > worse)
  4591. {
  4592. CPrintToChat(client, "%t {blue}%s %t", "Map worst player:", WorseNameBuffer, "(rank: %d; points: %d)", worseplayerrank, worse);
  4593. }
  4594. if (0 < GetConVarInt(hm_count_fails))
  4595. {
  4596. if (round_end_repeats)
  4597. {
  4598. if (!IsPrint)
  4599. {
  4600. IsPrint = true;
  4601. new prct = 100 - round_end_repeats * 10;
  4602. PrintToChatAll("%t", "It took %d attempts to finish this map!", round_end_repeats);
  4603. PrintToChatAll("%t", "All players will receive %d%%%% of their points earned for this map.", prct);
  4604. }
  4605. }
  4606. else
  4607. {
  4608. if (!IsPrint)
  4609. {
  4610. IsPrint = true;
  4611. PrintToChatAll("%t", "The map was passed on the first try!");
  4612. PrintToChatAll("%t", "All players will receive 100%%%% of their points earned for this map.");
  4613. }
  4614. }
  4615. PrintToChat(client, "%t", "Your map points: %d (%d)", NewPoints[client], CalculatePoints(NewPoints[client]));
  4616. }
  4617. else
  4618. {
  4619. PrintToChat(client, "%t", "Your map points: %d", NewPoints[client]);
  4620. }
  4621. return 0;
  4622. }
  4623.  
  4624. CalculatePoints(points)
  4625. {
  4626. if (0 < GetConVarInt(hm_count_fails))
  4627. {
  4628. points = RoundToZero(1065353216 * points * 100 - round_end_repeats * 10 / 100);
  4629. }
  4630. return points;
  4631. }
  4632.  
  4633. GrantPlayerColor(client)
  4634. {
  4635. if (GetConVarInt(hm_stats_colors) < 1)
  4636. {
  4637. return 0;
  4638. }
  4639. if (!IsValidClient(client))
  4640. {
  4641. return 0;
  4642. }
  4643. new var1;
  4644. if (!IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) == 2)
  4645. {
  4646. return 0;
  4647. }
  4648. if (!IsPlayerAlive(client))
  4649. {
  4650. return 0;
  4651. }
  4652. if (IsFakeClient(client))
  4653. {
  4654. if (GetConVarInt(hm_stats_bot_colors) < 1)
  4655. {
  4656. SetEntityRenderColor(client, 255, 255, 255, 255);
  4657. }
  4658. else
  4659. {
  4660. SetEntityRenderColor(client, 175, 175, 175, 255);
  4661. }
  4662. return 0;
  4663. }
  4664. if (GetConVarInt(hm_stats_colors) == 1)
  4665. {
  4666. new var2;
  4667. if (ClientRank[client] > 0 && ClientRank[client] < 51)
  4668. {
  4669. if (ClientRank[client] < 4)
  4670. {
  4671. SetEntityRenderColor(client, 160, 32, 240, 255);
  4672. }
  4673. else
  4674. {
  4675. if (ClientRank[client] < 11)
  4676. {
  4677. SetEntityRenderColor(client, 255, 0, 0, 255);
  4678. }
  4679. if (ClientRank[client] < 21)
  4680. {
  4681. SetEntityRenderColor(client, 0, 0, 255, 255);
  4682. }
  4683. if (ClientRank[client] < 31)
  4684. {
  4685. SetEntityRenderColor(client, 255, 255, 0, 255);
  4686. }
  4687. if (ClientRank[client] < 41)
  4688. {
  4689. SetEntityRenderColor(client, 0, 255, 0, 255);
  4690. }
  4691. SetEntityRenderColor(client, 173, 255, 47, 255);
  4692. }
  4693. }
  4694. else
  4695. {
  4696. SetEntityRenderColor(client, 255, 255, 255, 255);
  4697. }
  4698. return 0;
  4699. }
  4700. if (GetConVarInt(hm_stats_colors) == 2)
  4701. {
  4702. if (ClientPoints[client] > 5000)
  4703. {
  4704. new var3;
  4705. if (ClientPoints[client] > 5000 && ClientPoints[client] < 10001)
  4706. {
  4707. SetEntityRenderColor(client, 173, 255, 47, 255);
  4708. }
  4709. else
  4710. {
  4711. new var4;
  4712. if (ClientPoints[client] > 10000 && ClientPoints[client] < 20001)
  4713. {
  4714. SetEntityRenderColor(client, 255, 255, 0, 255);
  4715. }
  4716. new var5;
  4717. if (ClientPoints[client] > 20000 && ClientPoints[client] < 40001)
  4718. {
  4719. SetEntityRenderColor(client, 0, 0, 255, 255);
  4720. }
  4721. new var6;
  4722. if (ClientPoints[client] > 40000 && ClientPoints[client] < 80001)
  4723. {
  4724. SetEntityRenderColor(client, 0, 139, 0, 255);
  4725. }
  4726. new var7;
  4727. if (ClientPoints[client] > 80000 && ClientPoints[client] < 160001)
  4728. {
  4729. SetEntityRenderColor(client, 102, 25, 140, 255);
  4730. }
  4731. new var8;
  4732. if (ClientPoints[client] > 160000 && ClientPoints[client] < 320001)
  4733. {
  4734. SetEntityRenderColor(client, 255, 104, 240, 255);
  4735. }
  4736. new var9;
  4737. if (ClientPoints[client] > 320000 && ClientPoints[client] < 640001)
  4738. {
  4739. SetEntityRenderColor(client, 255, 0, 0, 255);
  4740. }
  4741. if (ClientPoints[client] > 640000)
  4742. {
  4743. SetEntityRenderColor(client, 255, 97, 3, 255);
  4744. }
  4745. }
  4746. }
  4747. else
  4748. {
  4749. SetEntityRenderColor(client, 255, 255, 255, 255);
  4750. }
  4751. return 0;
  4752. }
  4753. SetEntityRenderColor(client, 255, 255, 255, 255);
  4754. return 0;
  4755. }
  4756.  
  4757. public Action:Event_PlayerSpawn(Handle:event, String:name[], bool:dontBroadcast)
  4758. {
  4759. ADPlayerSpawn(event);
  4760. new client = GetClientOfUserId(GetEventInt(event, "userid", 0));
  4761. CreateTimer(6.0, TimedGrantPlayerColor, client, 0);
  4762. return Action:0;
  4763. }
  4764.  
  4765. public L4D2_Supercoop_PlayerOnUnfreezed(client)
  4766. {
  4767. GrantPlayerColor(client);
  4768. return 0;
  4769. }
  4770.  
  4771. public Action:TimedGrantPlayerColor(Handle:timer, any:client)
  4772. {
  4773. if (!IsClientInGame(client))
  4774. {
  4775. return Action:0;
  4776. }
  4777. if (GetClientHealth(client) < 1)
  4778. {
  4779. return Action:0;
  4780. }
  4781. GrantPlayerColor(client);
  4782. return Action:0;
  4783. }
  4784.  
  4785. IsRealClient(client)
  4786. {
  4787. if (!IsValidClient(client))
  4788. {
  4789. return 0;
  4790. }
  4791. new var1;
  4792. if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
  4793. {
  4794. if (IsClientInGame(client))
  4795. {
  4796. if (!IsFakeClient(client))
  4797. {
  4798. return 1;
  4799. }
  4800. }
  4801. }
  4802. return 0;
  4803. }
  4804.  
  4805. IsValidClient(client)
  4806. {
  4807. if (!IsValidEntity(client))
  4808. {
  4809. return 0;
  4810. }
  4811. new var1;
  4812. if (client < 1 || client > MaxClients)
  4813. {
  4814. return 0;
  4815. }
  4816. return 1;
  4817. }
  4818.  
  4819. public GetClientZC(client)
  4820. {
  4821. new var1;
  4822. if (!IsValidEntity(client) || !IsValidEdict(client))
  4823. {
  4824. return 0;
  4825. }
  4826. return GetEntProp(client, PropType:0, "m_zombieClass", 4, 0);
  4827. }
  4828.  
  4829. ADPlayerTeam()
  4830. {
  4831. new count;
  4832. new i = 1;
  4833. while (i <= MaxClients)
  4834. {
  4835. new var1;
  4836. if (IsClientInGame(i) && GetClientTeam(i) == 2)
  4837. {
  4838. count++;
  4839. }
  4840. i++;
  4841. }
  4842. if (count != playerscount)
  4843. {
  4844. playerscount = count;
  4845. if (IsTimeAutodifficulty)
  4846. {
  4847. Autodifficulty();
  4848. }
  4849. }
  4850. updateptystatslayers();
  4851. return 0;
  4852. }
  4853.  
  4854. public Action:Event_PlayerTeam(Handle:event, String:name[], bool:dontBroadcast)
  4855. {
  4856. if (GetEventBool(event, "disconnect", false))
  4857. {
  4858. return Action:0;
  4859. }
  4860. new client = GetClientOfUserId(GetEventInt(event, "userid", 0));
  4861. new var1;
  4862. if (!client || !IsClientInGame(client))
  4863. {
  4864. return Action:0;
  4865. }
  4866. ADPlayerTeam();
  4867. return Action:0;
  4868. }
  4869.  
  4870. Float:Calculate_Rank_Mod()
  4871. {
  4872. new Float:local_result = 1.0;
  4873. switch (GetConVarInt(l4d2_rankmod_mode))
  4874. {
  4875. case 0, 1, 2:
  4876. {
  4877. if (RankTotal < cvar_maxplayers)
  4878. {
  4879. return GetConVarFloat(SDifficultyMultiplier);
  4880. }
  4881. new Float:sum_low = 0.0;
  4882. new Float:sum_high = 0.0;
  4883. new i = 1;
  4884. while (i <= cvar_maxplayers)
  4885. {
  4886. sum_low += Sum_Function(1065353216 * i);
  4887. sum_high += Sum_Function(1065353216 * RankTotal + 1.0 - 1065353216 * i);
  4888. i++;
  4889. }
  4890. sum_low *= 1065353216 / cvar_maxplayers * 1.0;
  4891. sum_high *= 1065353216 / cvar_maxplayers * 1.0;
  4892. new Float:sum_current = 0.0;
  4893. new Float:current_player_rank = 0.0;
  4894. new Float:current_players_count = 0.0;
  4895. new i = 1;
  4896. while (i <= MaxClients)
  4897. {
  4898. if (IsClientInGame(i))
  4899. {
  4900. if (!IsFakeClient(i))
  4901. {
  4902. if (GetClientTeam(i) == 2)
  4903. {
  4904. current_players_count += 1.0;
  4905. current_player_rank = 1.0 * ClientRank[i];
  4906. if (current_player_rank < 1.0)
  4907. {
  4908. current_player_rank = 0.5 * RankTotal;
  4909. }
  4910. sum_current += Sum_Function(1065353216 + RankTotal - current_player_rank);
  4911. }
  4912. }
  4913. }
  4914. i++;
  4915. }
  4916. if (current_players_count < 1.4E-45)
  4917. {
  4918. return local_result;
  4919. }
  4920. sum_current *= 1.0 / current_players_count * 1.0;
  4921. new Float:k = GetConVarFloat(l4d2_rankmod_max) - GetConVarFloat(l4d2_rankmod_min) / sum_high - sum_low;
  4922. new Float:p = GetConVarFloat(l4d2_rankmod_max) - k * sum_high;
  4923. local_result = k * sum_current + p;
  4924. if (local_result < GetConVarFloat(l4d2_rankmod_min))
  4925. {
  4926. local_result = GetConVarFloat(l4d2_rankmod_min);
  4927. }
  4928. else
  4929. {
  4930. if (local_result > GetConVarFloat(l4d2_rankmod_max))
  4931. {
  4932. local_result = GetConVarFloat(l4d2_rankmod_max);
  4933. }
  4934. }
  4935. if (GetConVarInt(l4d2_rankmod_mode) == 1)
  4936. {
  4937. local_result += GetConVarFloat(SDifficultyMultiplier);
  4938. }
  4939. if (GetConVarInt(l4d2_rankmod_mode) == 2)
  4940. {
  4941. local_result *= GetConVarFloat(SDifficultyMultiplier);
  4942. }
  4943. return local_result;
  4944. }
  4945. case 3, 4, 5:
  4946. {
  4947. if (RankTotal < 3600)
  4948. {
  4949. return GetConVarFloat(SDifficultyMultiplier);
  4950. }
  4951. rank_sum = 0.0;
  4952. new players_count;
  4953. new i = 1;
  4954. while (i <= MaxClients)
  4955. {
  4956. if (IsClientInGame(i))
  4957. {
  4958. if (!IsFakeClient(i))
  4959. {
  4960. if (GetClientTeam(i) == 2)
  4961. {
  4962. if (ClientRank[i])
  4963. {
  4964. if (ClientRank[i] <= 10)
  4965. {
  4966. rank_sum = rank_sum + 5.0;
  4967. }
  4968. if (ClientRank[i] <= 25)
  4969. {
  4970. rank_sum = rank_sum + 4.4;
  4971. }
  4972. if (ClientRank[i] <= 50)
  4973. {
  4974. rank_sum = rank_sum + 3.8;
  4975. }
  4976. if (ClientRank[i] <= 100)
  4977. {
  4978. rank_sum = rank_sum + 3.2;
  4979. }
  4980. if (ClientRank[i] <= 200)
  4981. {
  4982. rank_sum = rank_sum + 2.6;
  4983. }
  4984. if (ClientRank[i] <= 400)
  4985. {
  4986. rank_sum = rank_sum + 2.0;
  4987. }
  4988. if (ClientRank[i] <= 800)
  4989. {
  4990. rank_sum = rank_sum + 1.4;
  4991. }
  4992. if (ClientRank[i] <= 1600)
  4993. {
  4994. rank_sum = rank_sum + 0.8;
  4995. }
  4996. if (ClientRank[i] <= 3200)
  4997. {
  4998. rank_sum = rank_sum + 0.2;
  4999. }
  5000. }
  5001. else
  5002. {
  5003. rank_sum = rank_sum + 0.0;
  5004. }
  5005. players_count++;
  5006. }
  5007. }
  5008. }
  5009. i++;
  5010. }
  5011. if (players_count < 1)
  5012. {
  5013. players_count = 1;
  5014. }
  5015. local_result = rank_sum * 1.0 - 1069547520 * players_count / 1065353216 * players_count / 6.0 + 0.75;
  5016. if (local_result < GetConVarFloat(l4d2_rankmod_min))
  5017. {
  5018. local_result = GetConVarFloat(l4d2_rankmod_min);
  5019. }
  5020. else
  5021. {
  5022. if (local_result > GetConVarFloat(l4d2_rankmod_max))
  5023. {
  5024. local_result = GetConVarFloat(l4d2_rankmod_max);
  5025. }
  5026. }
  5027. if (GetConVarInt(l4d2_rankmod_mode) == 4)
  5028. {
  5029. local_result += GetConVarFloat(SDifficultyMultiplier);
  5030. }
  5031. if (GetConVarInt(l4d2_rankmod_mode) == 5)
  5032. {
  5033. local_result *= GetConVarFloat(SDifficultyMultiplier);
  5034. }
  5035. return local_result;
  5036. }
  5037. default:
  5038. {
  5039. return GetConVarFloat(SDifficultyMultiplier);
  5040. }
  5041. }
  5042. }
  5043.  
  5044. Float:Sum_Function(Float:input_value)
  5045. {
  5046. if (0.0 == input_value)
  5047. {
  5048. return 0.0;
  5049. }
  5050. new Float:cvar_rankmod_logarithm = GetConVarFloat(l4d2_rankmod_logarithm);
  5051. if (cvar_rankmod_logarithm >= 1.0)
  5052. {
  5053. return Logarithm(input_value, cvar_rankmod_logarithm);
  5054. }
  5055. new var1;
  5056. if (cvar_rankmod_logarithm >= 0.0 && cvar_rankmod_logarithm < 1.0)
  5057. {
  5058. return input_value * cvar_rankmod_logarithm;
  5059. }
  5060. if (0.0 == cvar_rankmod_logarithm)
  5061. {
  5062. return input_value;
  5063. }
  5064. if (-1.0 == cvar_rankmod_logarithm)
  5065. {
  5066. new Float:x = Logarithm(input_value, 10.0);
  5067. return x * x;
  5068. }
  5069. if (-2.0 == cvar_rankmod_logarithm)
  5070. {
  5071. return input_value * input_value / input_value + RankTotal * 4 / 1103626240 * RankTotal / 10.0;
  5072. }
  5073. if (-3.0 == cvar_rankmod_logarithm)
  5074. {
  5075. new Float:x = Logarithm(input_value, 10.0);
  5076. return x * x / x * 0.001 + 1.11;
  5077. }
  5078. return input_value;
  5079. }
  5080.  
  5081. public Action:Command_RankSum(client, args)
  5082. {
  5083. if (client)
  5084. {
  5085. PrintToChat(client, "\x05Rank Sum: \x04%f", rank_sum);
  5086. }
  5087. else
  5088. {
  5089. PrintToServer("Rank Sum: %f", rank_sum);
  5090. }
  5091. return Action:0;
  5092. }
  5093.  
  5094. public Action:Command_MapFinished(client, args)
  5095. {
  5096. if (!IsMapFinished)
  5097. {
  5098. IsMapFinished = true;
  5099. }
  5100. return Action:0;
  5101. }
  5102.  
  5103. public Action:Command_MapNotFinished(client, args)
  5104. {
  5105. if (IsMapFinished)
  5106. {
  5107. IsMapFinished = false;
  5108. }
  5109. return Action:0;
  5110. }
  5111.  
  5112. public Action:Command_Bonus(client, args)
  5113. {
  5114. bonus = GetConVarInt(cvar_Bonus);
  5115. return Action:0;
  5116. }
  5117.  
  5118. public Action:Event_MapTransition(Handle:event, String:name[], bool:dontBroadcast)
  5119. {
  5120. ADOnMapStart();
  5121. IsTimeAutodifficulty = false;
  5122. PrintMapPoints();
  5123. StopMapTiming();
  5124. return Action:0;
  5125. }
  5126.  
  5127. public Action:Event_FinalWin(Handle:event, String:name[], bool:dontBroadcast)
  5128. {
  5129. PrintMapPoints();
  5130. StopMapTiming();
  5131. return Action:0;
  5132. }
  5133.  
  5134. PrintMapPoints()
  5135. {
  5136. IsPrint = false;
  5137. new i = 1;
  5138. while (i <= MaxClients)
  5139. {
  5140. if (IsRealClient(i))
  5141. {
  5142. PrintMapTop(i);
  5143. }
  5144. i++;
  5145. }
  5146. return 0;
  5147. }
  5148.  
  5149. public Action:Command_GivePoints(client, args)
  5150. {
  5151. if (IsMapFinished)
  5152. {
  5153. return Action:3;
  5154. }
  5155. if (args == 2)
  5156. {
  5157. decl String:arg[68];
  5158. decl String:arg2[32];
  5159. GetCmdArg(1, arg, 65);
  5160. GetCmdArg(2, arg2, 32);
  5161. decl String:target_name[64];
  5162. decl target_list[65];
  5163. decl target_count;
  5164. decl bool:tn_is_ml;
  5165. new targetclient;
  5166. new Score = StringToInt(arg2, 10);
  5167. if (0 >= (target_count = ProcessTargetString(arg, client, target_list, 65, 0, target_name, 64, tn_is_ml)))
  5168. {
  5169. ReplyToTargetError(client, target_count);
  5170. return Action:3;
  5171. }
  5172. ReplyToCommand(client, "Point for player: %s set to: %d", target_name, Score);
  5173. new i;
  5174. while (i < target_count)
  5175. {
  5176. targetclient = target_list[i];
  5177. AddScore(targetclient, Score);
  5178. i++;
  5179. }
  5180. return Action:3;
  5181. }
  5182. ReplyToCommand(client, "sm_givepoints <#userid|name> [Score]");
  5183. return Action:3;
  5184. }
  5185.  
  5186. public AddScore(client, Score)
  5187. {
  5188. if (0 < Score)
  5189. {
  5190. PrintToChat(client, "\x04+%i", Score);
  5191. new var1 = NewPoints[client];
  5192. var1 = var1[Score];
  5193. }
  5194. else
  5195. {
  5196. if (0 > Score)
  5197. {
  5198. PrintToChat(client, "\x05%i", Score);
  5199. new var2 = NewPoints[client];
  5200. var2 = var2[Score];
  5201. }
  5202. }
  5203. return Score;
  5204. }
  5205.  
  5206. public Action:Command_RankPlayer(client, args)
  5207. {
  5208. if (args)
  5209. {
  5210. if (args == 1)
  5211. {
  5212. decl String:arg[68];
  5213. GetCmdArg(1, arg, 65);
  5214. decl String:target_name[64];
  5215. decl target_list[65];
  5216. decl target_count;
  5217. decl bool:tn_is_ml;
  5218. new targetclient;
  5219. if (0 >= (target_count = ProcessTargetString(arg, client, target_list, 65, 0, target_name, 64, tn_is_ml)))
  5220. {
  5221. ReplyToTargetError(client, target_count);
  5222. return Action:3;
  5223. }
  5224. ReplyToCommand(client, "Вы просматриваете статистику игрока %s", target_name);
  5225. new i;
  5226. while (i < target_count)
  5227. {
  5228. targetclient = target_list[i];
  5229. KnowRankKills(targetclient);
  5230. KnowRankPlaytime(targetclient);
  5231. DisplayRank(targetclient, client);
  5232. i++;
  5233. }
  5234. return Action:3;
  5235. }
  5236. ReplyToCommand(client, "sm_rankplayer <#userid|name>");
  5237. return Action:3;
  5238. }
  5239. cmd_ShowRank(client, 0);
  5240. return Action:3;
  5241. }
  5242.  
  5243. public Action:Command_Refresh(client, args)
  5244. {
  5245. ConnectDB();
  5246. return Action:0;
  5247. }
  5248.  
  5249. bool:IsPlayerIncapped(client)
  5250. {
  5251. if (GetEntProp(client, PropType:0, "m_isIncapacitated", 1, 0))
  5252. {
  5253. return true;
  5254. }
  5255. return false;
  5256. }
  5257.  
  5258. IsMissionAllowed(String:map_name[128])
  5259. {
  5260. new result = 1;
  5261. new Handle:file = OpenFile(CV_FileName, "r", false, "GAME");
  5262. if (file)
  5263. {
  5264. FileSeek(file, 0, 0);
  5265. new String:CV_StoredMap[128];
  5266. while (!IsEndOfFile(file))
  5267. {
  5268. if (ReadFileLine(file, CV_StoredMap, 128))
  5269. {
  5270. TrimString(CV_StoredMap);
  5271. if (StrEqual(map_name, CV_StoredMap, false))
  5272. {
  5273. result = 0;
  5274. CloseHandle(file);
  5275. return result;
  5276. }
  5277. }
  5278. CloseHandle(file);
  5279. return result;
  5280. }
  5281. CloseHandle(file);
  5282. return result;
  5283. }
  5284. return result;
  5285. }
  5286.  
  5287. public Action:Callvote_Handler(client, args)
  5288. {
  5289. if (client)
  5290. {
  5291. decl String:voteName[32];
  5292. decl String:initiatorName[32];
  5293. GetClientName(client, initiatorName, 32);
  5294. GetCmdArg(1, voteName, 32);
  5295. if (strcmp(voteName, "Kick", false))
  5296. {
  5297. if (strcmp(voteName, "ReturnToLobby", false))
  5298. {
  5299. new var1;
  5300. if (strcmp(voteName, "ChangeMission", false) && strcmp(voteName, "ChangeChapter", false))
  5301. {
  5302. decl String:map_name[128];
  5303. GetCmdArg(2, map_name, 128);
  5304. if (!IsMissionAllowed(map_name))
  5305. {
  5306. new AdminId:ClientAdminId = GetUserAdmin(client);
  5307. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5308. new var2;
  5309. if (flags & 1024 || flags & 64)
  5310. {
  5311. CPrintToChat(client, "%t", "Warning! This campaign is forbidden!\n\"Vote\" access granted");
  5312. return Action:0;
  5313. }
  5314. PrintToChat(client, "%t", "Vote access denied [this campaign is forbidden]");
  5315. return Action:3;
  5316. }
  5317. new var3;
  5318. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5319. {
  5320. PrintToChat(client, "%t", "Vote access granted");
  5321. PrintToChatAll("%t", "%N started the voting", client);
  5322. return Action:0;
  5323. }
  5324. if (GetConVarInt(hm_blockvote_map) == 1)
  5325. {
  5326. new AdminId:ClientAdminId = GetUserAdmin(client);
  5327. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5328. new var4;
  5329. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1 || flags & 1024 || flags & 64))
  5330. {
  5331. PrintToChat(client, "%t", "Vote access granted");
  5332. PrintToChatAll("%t", "%N started the voting", client);
  5333. return Action:0;
  5334. }
  5335. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5336. return Action:3;
  5337. }
  5338. }
  5339. if (strcmp(voteName, "RestartGame", false))
  5340. {
  5341. if (strcmp(voteName, "ChangeDifficulty", false))
  5342. {
  5343. return Action:0;
  5344. }
  5345. if (0 < GetConVarInt(hm_blockvote_difficulty))
  5346. {
  5347. new AdminId:ClientAdminId = GetUserAdmin(client);
  5348. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5349. new var8;
  5350. if (flags & 1024 & 128 || flags & 16384)
  5351. {
  5352. PrintToChat(client, "%t", "Vote access granted");
  5353. PrintToChatAll("%t", "%N started the voting", client);
  5354. return Action:0;
  5355. }
  5356. PrintToChat(client, "%t", "Vote access denied");
  5357. return Action:3;
  5358. }
  5359. PrintToChat(client, "%t", "Vote access granted");
  5360. PrintToChatAll("%t", "%N started the voting", client);
  5361. return Action:0;
  5362. }
  5363. if (GetConVarInt(hm_blockvote_restart))
  5364. {
  5365. if (GetConVarInt(hm_blockvote_restart) == 1)
  5366. {
  5367. new AdminId:ClientAdminId = GetUserAdmin(client);
  5368. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5369. new var7;
  5370. if (flags & 8192 || flags & 16384 || (ClientRank[client] < 21 && ClientRank[client]))
  5371. {
  5372. PrintToChat(client, "%t", "Vote access granted");
  5373. PrintToChatAll("%t", "%N started the voting", client);
  5374. return Action:0;
  5375. }
  5376. PrintToChat(client, "%t", "Vote access denied");
  5377. return Action:3;
  5378. }
  5379. PrintToChat(client, "%t", "Vote access denied");
  5380. return Action:3;
  5381. }
  5382. PrintToChat(client, "%t", "Vote access granted");
  5383. return Action:0;
  5384. }
  5385. if (0 < GetConVarInt(hm_blockvote_lobby))
  5386. {
  5387. PrintToChat(client, "%t", "Vote access denied");
  5388. return Action:3;
  5389. }
  5390. PrintToChat(client, "%t", "Vote access granted");
  5391. PrintToChatAll("%t", "%N started the voting", client);
  5392. return Action:0;
  5393. }
  5394. return Kick_Vote_Logic(client, args);
  5395. }
  5396. return Action:0;
  5397. }
  5398.  
  5399. public Action:Kick_Vote_Logic(client, args)
  5400. {
  5401. decl String:initiatorName[32];
  5402. GetClientName(client, initiatorName, 32);
  5403. decl String:arg2[12];
  5404. GetCmdArg(2, arg2, 12);
  5405. new target = GetClientOfUserId(StringToInt(arg2, 10));
  5406. if (!target)
  5407. {
  5408. return Action:3;
  5409. }
  5410. if (g_votekick[client] > 3)
  5411. {
  5412. PrintToChat(client, "\x05Вы уже голосовали 3 раза за карту!");
  5413. PrintToChat(client, "%t", "Vote access denied");
  5414. return Action:3;
  5415. }
  5416. new AdminId:ClientAdminId = GetUserAdmin(client);
  5417. new AdminId:TargetAdminId = GetUserAdmin(target);
  5418. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5419. if (GetConVarInt(hm_blockvote_kick))
  5420. {
  5421. if (GetConVarInt(hm_blockvote_kick) == 1)
  5422. {
  5423. new var1;
  5424. if (flags & 1024 || flags & 1 || flags & 16384 || ClientRank[client] < 51)
  5425. {
  5426. if (ClientRank[target] > ClientRank[client][GetConVarInt(hm_blockvote_difference)])
  5427. {
  5428. new flags2 = GetAdminFlags(TargetAdminId, AdmAccessMode:1);
  5429. new var2;
  5430. if (flags2 & 2 || flags2 & 16384)
  5431. {
  5432. PrintToChat(client, "%t", "Vote access denied. Target is Admin");
  5433. return Action:3;
  5434. }
  5435. PrintToChat(client, "%t", "Vote access granted");
  5436. g_votekick[client] = g_votekick[client] + 1;
  5437. }
  5438. PrintToChat(client, "%t", "Vote access denied");
  5439. PrintToChat(client, "%t \x04[\x03%d \x05>=\x03 %d\x04]", "Vote access denied", ClientRank[client], ClientRank[target]);
  5440. return Action:3;
  5441. }
  5442. PrintToChat(client, "%t \x04[\x03%d \x05>\x03 50\x04]", "Vote access denied", ClientRank[client]);
  5443. return Action:3;
  5444. }
  5445. PrintToChatAll("%t", "%N started the voting", client);
  5446. return Action:0;
  5447. }
  5448. PrintToChat(client, "%t", "Vote access granted");
  5449. g_votekick[client] = g_votekick[client] + 1;
  5450. return Action:0;
  5451. }
  5452.  
  5453. public Action:Command_city17l4d2(client, args)
  5454. {
  5455. if (client < 1)
  5456. {
  5457. return Action:3;
  5458. }
  5459. new var1;
  5460. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) <= GetRealClientCount(true))
  5461. {
  5462. PrintToChat(client, "%t", "Vote access granted");
  5463. PrintToChatAll("%t", "%N started the voting", client);
  5464. ServerCommand("sm_votemap l4d2_city17_01");
  5465. if (bStandartMap())
  5466. {
  5467. SaveMap();
  5468. }
  5469. return Action:0;
  5470. }
  5471. if (GetConVarInt(hm_blockvote_map) == 1)
  5472. {
  5473. new AdminId:ClientAdminId = GetUserAdmin(client);
  5474. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5475. new var2;
  5476. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5477. {
  5478. PrintToChat(client, "%t", "Vote access granted");
  5479. PrintToChatAll("%t", "%N started the voting", client);
  5480. ServerCommand("sm_votemap l4d2_city17_01");
  5481. if (bStandartMap())
  5482. {
  5483. SaveMap();
  5484. }
  5485. return Action:0;
  5486. }
  5487. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5488. return Action:3;
  5489. }
  5490. return Action:0;
  5491. }
  5492.  
  5493. public Action:Command_warcelona(client, args)
  5494. {
  5495. if (client < 1)
  5496. {
  5497. return Action:3;
  5498. }
  5499. new var1;
  5500. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5501. {
  5502. PrintToChat(client, "%t", "Vote access granted");
  5503. PrintToChatAll("%t", "%N started the voting", client);
  5504. ServerCommand("sm_votemap srocchurch");
  5505. if (bStandartMap())
  5506. {
  5507. SaveMap();
  5508. }
  5509. return Action:0;
  5510. }
  5511. if (GetConVarInt(hm_blockvote_map) == 1)
  5512. {
  5513. new AdminId:ClientAdminId = GetUserAdmin(client);
  5514. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5515. new var2;
  5516. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5517. {
  5518. PrintToChat(client, "%t", "Vote access granted");
  5519. PrintToChatAll("%t", "%N started the voting", client);
  5520. ServerCommand("sm_votemap srocchurch");
  5521. if (bStandartMap())
  5522. {
  5523. SaveMap();
  5524. }
  5525. return Action:0;
  5526. }
  5527. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5528. return Action:3;
  5529. }
  5530. return Action:0;
  5531. }
  5532.  
  5533. public Action:Command_ravenholm(client, args)
  5534. {
  5535. if (client < 1)
  5536. {
  5537. return Action:3;
  5538. }
  5539. new var1;
  5540. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5541. {
  5542. PrintToChat(client, "%t", "Vote access granted");
  5543. PrintToChatAll("%t", "%N started the voting", client);
  5544. ServerCommand("sm_votemap l4d2_ravenholmwar_1");
  5545. if (bStandartMap())
  5546. {
  5547. SaveMap();
  5548. }
  5549. return Action:0;
  5550. }
  5551. if (GetConVarInt(hm_blockvote_map) == 1)
  5552. {
  5553. new AdminId:ClientAdminId = GetUserAdmin(client);
  5554. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5555. new var2;
  5556. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5557. {
  5558. PrintToChat(client, "%t", "Vote access granted");
  5559. PrintToChatAll("%t", "%N started the voting", client);
  5560. ServerCommand("sm_votemap l4d2_ravenholmwar_1");
  5561. if (bStandartMap())
  5562. {
  5563. SaveMap();
  5564. }
  5565. return Action:0;
  5566. }
  5567. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5568. return Action:3;
  5569. }
  5570. return Action:0;
  5571. }
  5572.  
  5573. public Action:Command_lastsummer(client, args)
  5574. {
  5575. if (client < 1)
  5576. {
  5577. return Action:3;
  5578. }
  5579. new var1;
  5580. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5581. {
  5582. PrintToChat(client, "%t", "Vote access granted");
  5583. PrintToChatAll("%t", "%N started the voting", client);
  5584. ServerCommand("sm_votemap campanar_coop_vs");
  5585. if (bStandartMap())
  5586. {
  5587. SaveMap();
  5588. }
  5589. return Action:0;
  5590. }
  5591. if (GetConVarInt(hm_blockvote_map) == 1)
  5592. {
  5593. new AdminId:ClientAdminId = GetUserAdmin(client);
  5594. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5595. new var2;
  5596. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5597. {
  5598. PrintToChat(client, "%t", "Vote access granted");
  5599. PrintToChatAll("%t", "%N started the voting", client);
  5600. ServerCommand("sm_votemap campanar_coop_vs");
  5601. if (bStandartMap())
  5602. {
  5603. SaveMap();
  5604. }
  5605. return Action:0;
  5606. }
  5607. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5608. return Action:3;
  5609. }
  5610. return Action:0;
  5611. }
  5612.  
  5613. public Action:Command_yama(client, args)
  5614. {
  5615. if (client < 1)
  5616. {
  5617. return Action:3;
  5618. }
  5619. new var1;
  5620. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5621. {
  5622. PrintToChat(client, "%t", "Vote access granted");
  5623. PrintToChatAll("%t", "%N started the voting", client);
  5624. ServerCommand("sm_votemap l4d_yama_1");
  5625. if (bStandartMap())
  5626. {
  5627. SaveMap();
  5628. }
  5629. return Action:0;
  5630. }
  5631. if (GetConVarInt(hm_blockvote_map) == 1)
  5632. {
  5633. new AdminId:ClientAdminId = GetUserAdmin(client);
  5634. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5635. new var2;
  5636. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5637. {
  5638. PrintToChat(client, "%t", "Vote access granted");
  5639. PrintToChatAll("%t", "%N started the voting", client);
  5640. ServerCommand("sm_votemap l4d_yama_1");
  5641. if (bStandartMap())
  5642. {
  5643. SaveMap();
  5644. }
  5645. return Action:0;
  5646. }
  5647. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5648. return Action:3;
  5649. }
  5650. return Action:0;
  5651. }
  5652.  
  5653. public Action:Command_one4nine(client, args)
  5654. {
  5655. if (client < 1)
  5656. {
  5657. return Action:3;
  5658. }
  5659. new var1;
  5660. if (GetConVarInt(hm_blockvote_map) && GetConVarInt(hm_allowvote_map_players) >= GetRealClientCount(true))
  5661. {
  5662. PrintToChat(client, "%t", "Vote access granted");
  5663. PrintToChatAll("%t", "%N started the voting", client);
  5664. ServerCommand("sm_votemap l4d_149_1");
  5665. if (bStandartMap())
  5666. {
  5667. SaveMap();
  5668. }
  5669. return Action:0;
  5670. }
  5671. if (GetConVarInt(hm_blockvote_map) == 1)
  5672. {
  5673. new AdminId:ClientAdminId = GetUserAdmin(client);
  5674. new flags = GetAdminFlags(ClientAdminId, AdmAccessMode:1);
  5675. new var2;
  5676. if ((ClientRank[client] < GetConVarInt(hm_allowvote_mission) && ClientRank[client]) || (flags & 1024 || flags & 64))
  5677. {
  5678. PrintToChat(client, "%t", "Vote access granted");
  5679. PrintToChatAll("%t", "%N started the voting", client);
  5680. ServerCommand("sm_votemap l4d_149_1");
  5681. if (bStandartMap())
  5682. {
  5683. SaveMap();
  5684. }
  5685. return Action:0;
  5686. }
  5687. PrintToChat(client, "%t", "Vote access denied [%d > %d]", ClientRank[client], GetConVarInt(hm_allowvote_mission));
  5688. return Action:3;
  5689. }
  5690. return Action:0;
  5691. }
  5692.  
  5693. SaveMap()
  5694. {
  5695. if (!FileExists("mapfinalnext_recover.txt", false, "GAME"))
  5696. {
  5697. new Handle:dataFileHandle = OpenFile("mapfinalnext_recover.txt", "a", false, "GAME");
  5698. WriteFileLine(dataFileHandle, "c1m1_hotel");
  5699. CloseHandle(dataFileHandle);
  5700. }
  5701. else
  5702. {
  5703. if (FileExists("mapfinalnext_recover.txt", false, "GAME"))
  5704. {
  5705. if (!DeleteFile("mapfinalnext_recover.txt", false, "DEFAULT_WRITE_PATH"))
  5706. {
  5707. LogError("[Mapfinalnext Map Recovery] Warning: Failed to delete \"%s\" possibly due to lacking permissions.", "mapfinalnext_recover.txt");
  5708. }
  5709. }
  5710. }
  5711. new Handle:inf = OpenFile("mapfinalnext_recover.txt", "w+", false, "GAME");
  5712. if (inf)
  5713. {
  5714. decl String:CurrentMap[256];
  5715. GetCurrentMap(CurrentMap, 256);
  5716. if (bStandartMapOfCampaign())
  5717. {
  5718. WriteFileLine(inf, CurrentMap);
  5719. }
  5720. CloseHandle(inf);
  5721. return 0;
  5722. }
  5723. LogError("[Mapfinalnext Map Recovery] Failed to open/create file '%s'", "mapfinalnext_recover.txt");
  5724. return 0;
  5725. }
  5726.  
  5727. public bool:bStandartMapOfCampaign()
  5728. {
  5729. decl String:MapName[128];
  5730. GetCurrentMap(MapName, 128);
  5731. new var1;
  5732. if (StrContains(MapName, "c1m1", true) > -1 || StrContains(MapName, "c1m2", true) > -1 || StrContains(MapName, "c1m3", true) > -1 || StrContains(MapName, "c1m4", true) > -1 || StrContains(MapName, "c2m1", true) > -1 || StrContains(MapName, "c2m2", true) > -1 || StrContains(MapName, "c2m3", true) > -1 || StrContains(MapName, "c2m4", true) > -1 || StrContains(MapName, "c2m5", true) > -1 || StrContains(MapName, "c3m1", true) > -1 || StrContains(MapName, "c3m2", true) > -1 || StrContains(MapName, "c3m3", true) > -1 || StrContains(MapName, "c3m4", true) > -1 || StrContains(MapName, "c4m1", true) > -1 || StrContains(MapName, "c4m2", true) > -1 || StrContains(MapName, "c4m3", true) > -1 || StrContains(MapName, "c4m4", true) > -1 || StrContains(MapName, "c4m5", true) > -1 || StrContains(MapName, "c5m1", true) > -1 || StrContains(MapName, "c5m2", true) > -1 || StrContains(MapName, "c5m3", true) > -1 || StrContains(MapName, "c5m4", true) > -1 || StrContains(MapName, "c5m5", true) > -1 || StrContains(MapName, "c6m1", true) > -1 || StrContains(MapName, "c6m2", true) > -1 || StrContains(MapName, "c6m3", true) > -1 || StrContains(MapName, "c7m1", true) > -1 || StrContains(MapName, "c7m2", true) > -1 || StrContains(MapName, "c7m3", true) > -1 || StrContains(MapName, "c8m1", true) > -1 || StrContains(MapName, "c8m2", true) > -1 || StrContains(MapName, "c8m3", true) > -1 || StrContains(MapName, "c8m4", true) > -1 || StrContains(MapName, "c8m5", true) > -1 || StrContains(MapName, "c9m1", true) > -1 || StrContains(MapName, "c9m2", true) > -1 || StrContains(MapName, "c10m1", true) > -1 || StrContains(MapName, "c10m2", true) > -1 || StrContains(MapName, "c10m3", true) > -1 || StrContains(MapName, "c10m4", true) > -1 || StrContains(MapName, "c10m5", true) > -1 || StrContains(MapName, "c11m1", true) > -1 || StrContains(MapName, "c11m2", true) > -1 || StrContains(MapName, "c11m3", true) > -1 || StrContains(MapName, "c11m4", true) > -1 || StrContains(MapName, "c11m5", true) > -1 || StrContains(MapName, "c12m1", true) > -1 || StrContains(MapName, "c12m2", true) > -1 || StrContains(MapName, "c12m3", true) > -1 || StrContains(MapName, "c12m4", true) > -1 || StrContains(MapName, "c12m5", true) > -1 || StrContains(MapName, "c13m1", true) > -1 || StrContains(MapName, "c13m2", true) > -1 || StrContains(MapName, "c13m3", true) > -1 || StrContains(MapName, "c13m4", true) > -1)
  5733. {
  5734. return true;
  5735. }
  5736. return false;
  5737. }
  5738.  
  5739. public Action:steam_command(client, args)
  5740. {
  5741. if (0 < client <= MaxClients)
  5742. {
  5743. wS_ShowMenu(client, 0);
  5744. }
  5745. return Action:3;
  5746. }
  5747.  
  5748. wS_ShowMenu(client, item)
  5749. {
  5750. new Handle:menu = CreateMenu(Menu_CallBack, MenuAction:28);
  5751. SetMenuTitle(menu, "Detect SteaM\n \n");
  5752. decl String:Text[68];
  5753. new i = 1;
  5754. while (i <= MaxClients)
  5755. {
  5756. new var1;
  5757. if (IsClientInGame(i) && !IsFakeClient(i))
  5758. {
  5759. new var2;
  5760. if (g_HaveSteam[i])
  5761. {
  5762. var2[0] = 92368;
  5763. }
  5764. else
  5765. {
  5766. if (g_Socket[i])
  5767. {
  5768. var2[0] = 92376;
  5769. }
  5770. var2[0] = 92384;
  5771. }
  5772. Format(Text, 65, "%N (%s)", i, var2);
  5773. if (g_HaveSteam[i])
  5774. {
  5775. AddMenuItem(menu, g_ProfileID[i], Text, 0);
  5776. }
  5777. AddMenuItem(menu, "", Text, 1);
  5778. }
  5779. i++;
  5780. }
  5781. DisplayMenuAtItem(menu, client, item, 0);
  5782. return 0;
  5783. }
  5784.  
  5785. public Menu_CallBack(Handle:menu, MenuAction:action, client, item)
  5786. {
  5787. if (action != MenuAction:4)
  5788. {
  5789. return 0;
  5790. }
  5791. decl String:info[100];
  5792. if (!GetMenuItem(menu, item, info, 100, 0, "", 0))
  5793. {
  5794. return 0;
  5795. }
  5796. Format(info, 100, "http://steamcommunity.com/profiles/%s", info);
  5797. ShowMOTDPanel(client, "SteaM ProfiLe", info, 2);
  5798. PrintToChat(client, "\x04%s", info);
  5799. wS_ShowMenu(client, GetMenuSelectionPosition());
  5800. return 0;
  5801. }
  5802.  
  5803. wS_GetProfileId(client, String:steamid[])
  5804. {
  5805. decl String:var3[3][11];
  5806. if (ExplodeString(steamid, ":", var3, 3, 11, false) != 3)
  5807. {
  5808. return 0;
  5809. }
  5810. new String:Identifier[20] = "76561197960265728";
  5811. new Current;
  5812. decl CarryOver;
  5813. CarryOver = var3[1][0] == '1';
  5814. new i = 16;
  5815. decl j;
  5816. j = strlen(var3[2]) + -1;
  5817. new k = strlen(Identifier) + -1;
  5818. while (0 <= i)
  5819. {
  5820. new var1;
  5821. if (j >= 0)
  5822. {
  5823. var1 = var3[2][j] + -12 * 2;
  5824. }
  5825. else
  5826. {
  5827. var1 = 0;
  5828. }
  5829. new var2;
  5830. if (k >= 0)
  5831. {
  5832. var2 = Identifier[k] + -48 * 1;
  5833. }
  5834. else
  5835. {
  5836. var2 = 0;
  5837. }
  5838. Current = var2 + var1 + CarryOver;
  5839. CarryOver = Current / 10;
  5840. g_ProfileID[client][i] = Current % 10 + 48;
  5841. i--;
  5842. j--;
  5843. k--;
  5844. }
  5845. g_ProfileID[client][4] = MissingTAG:0;
  5846. new Handle:socket = SocketCreate(SocketType:1, OnSocketError);
  5847. SocketSetArg(socket, GetClientUserId(client));
  5848. SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "steamcommunity.com", 80);
  5849. return 0;
  5850. }
  5851.  
  5852. public OnSocketError(Handle:socket, errorType, errorNum, any:id)
  5853. {
  5854. CloseHandle(socket);
  5855. LogError("SocketError -> errorType: %d, errorNum: %d", errorType, errorNum);
  5856. return 0;
  5857. }
  5858.  
  5859. public OnSocketConnected(Handle:socket, any:id)
  5860. {
  5861. new client = GetClientOfUserId(id);
  5862. if (client < 1)
  5863. {
  5864. CloseHandle(socket);
  5865. return 0;
  5866. }
  5867. decl String:info[200];
  5868. Format(info, 200, "GET /profiles/%s HTTP/1.0\r\nHost: steamcommunity.com\r\nConnection: close\r\n\r\n", g_ProfileID[client]);
  5869. SocketSend(socket, info, -1);
  5870. return 0;
  5871. }
  5872.  
  5873. public OnSocketReceive(Handle:socket, String:receiveData[], dataSize, any:id)
  5874. {
  5875. new var1;
  5876. if (dataSize > 0 && StrContains(receiveData, "user has not yet set", false) != -1)
  5877. {
  5878. wS_ClientAuthorized(socket, id, false);
  5879. }
  5880. return 0;
  5881. }
  5882.  
  5883. public OnSocketDisconnected(Handle:socket, any:id)
  5884. {
  5885. wS_ClientAuthorized(socket, id, true);
  5886. return 0;
  5887. }
  5888.  
  5889. wS_ClientAuthorized(Handle:socket, id, bool:steam_client)
  5890. {
  5891. CloseHandle(socket);
  5892. new client = GetClientOfUserId(id);
  5893. if (client < 1)
  5894. {
  5895. return 0;
  5896. }
  5897. g_HaveSteam[client] = steam_client;
  5898. g_Socket[client] = 1;
  5899. SetTrieValue(g_HaveSteam_Trie, g_SteamID[client], steam_client, true);
  5900. return 0;
  5901. }
  5902.  
  5903. public void:OnConfigsExecuted()
  5904. {
  5905. ReadDb();
  5906. return void:0;
  5907. }
  5908.  
  5909. ReadDb()
  5910. {
  5911. ReadDbMotd();
  5912. return 0;
  5913. }
  5914.  
  5915. ReadDbMotd()
  5916. {
  5917. decl String:query[512];
  5918. Format(query, 512, "SELECT svalue FROM server_settings WHERE sname = 'motdmessage' LIMIT 1");
  5919. SQL_TQuery(db, ReadDbMotdCallback, query, any:0, DBPriority:1);
  5920. return 0;
  5921. }
  5922.  
  5923. public ReadDbMotdCallback(Handle:owner, Handle:hndl, String:error[], any:data)
  5924. {
  5925. if (hndl)
  5926. {
  5927. if (SQL_FetchRow(hndl))
  5928. {
  5929. SQL_FetchString(hndl, 0, MessageOfTheDay, 1024, 0);
  5930. }
  5931. return 0;
  5932. }
  5933. LogError("ReadDbMotdCallback Query failed: %s", error);
  5934. return 0;
  5935. }
  5936.  
  5937. public Action:Command_SetMotd(client, args)
  5938. {
  5939. decl String:arg[1024];
  5940. GetCmdArgString(arg, 1024);
  5941. UpdateServerSettings(client, "motdmessage", arg, MOTD_TITLE);
  5942. return Action:3;
  5943. }
  5944.  
  5945. bool:UpdateServerSettings(Client, String:Key[], String:Value[], String:Desc[])
  5946. {
  5947. new Handle:statement;
  5948. decl String:error[1024];
  5949. decl String:query[2048];
  5950. if (!DoFastQuery(Client, "INSERT IGNORE INTO server_settings SET sname = '%s', svalue = ''", Key))
  5951. {
  5952. PrintToConsole(Client, "[RANK] %s: Setting a new MOTD value failure!", Desc);
  5953. return false;
  5954. }
  5955. Format(query, 2048, "UPDATE server_settings SET svalue = ? WHERE sname = '%s'", Key);
  5956. statement = SQL_PrepareQuery(db, query, error, 1024);
  5957. if (statement)
  5958. {
  5959. new bool:retval = 1;
  5960. SQL_BindParamString(statement, 0, Value, false);
  5961. if (!SQL_Execute(statement))
  5962. {
  5963. if (SQL_GetError(db, error, 1024))
  5964. {
  5965. PrintToConsole(Client, "[RANK] %s: Update failed! (Error = \"%s\")", Desc, error);
  5966. LogError("%s: Update failed! (Error = \"%s\")", Desc, error);
  5967. }
  5968. else
  5969. {
  5970. PrintToConsole(Client, "[RANK] %s: Update failed!", Desc);
  5971. LogError("%s: Update failed!", Desc);
  5972. }
  5973. retval = false;
  5974. }
  5975. else
  5976. {
  5977. PrintToConsole(Client, "[RANK] %s: Update successful!", Desc);
  5978. if (StrEqual(Key, "motdmessage", false))
  5979. {
  5980. strcopy(MessageOfTheDay, 1024, Value);
  5981. }
  5982. }
  5983. CloseHandle(statement);
  5984. return retval;
  5985. }
  5986. PrintToConsole(Client, "[RANK] %s: Update failed! (Reason: Cannot create SQL statement)");
  5987. return false;
  5988. }
  5989.  
  5990. bool:DoFastQuery(Client, String:Query[])
  5991. {
  5992. new String:FormattedQuery[4096];
  5993. VFormat(FormattedQuery, 4096, Query, 3);
  5994. new String:Error[1024];
  5995. if (!SQL_FastQuery(db, FormattedQuery, -1))
  5996. {
  5997. if (SQL_GetError(db, Error, 1024))
  5998. {
  5999. PrintToConsole(Client, "[RANK] Fast query failed! (Error = \"%s\") Query = \"%s\"", Error, FormattedQuery);
  6000. LogError("Fast query failed! (Error = \"%s\") Query = \"%s\"", Error, FormattedQuery);
  6001. }
  6002. else
  6003. {
  6004. PrintToConsole(Client, "[RANK] Fast query failed! Query = \"%s\"", FormattedQuery);
  6005. LogError("Fast query failed! Query = \"%s\"", FormattedQuery);
  6006. }
  6007. return false;
  6008. }
  6009. return true;
  6010. }
  6011.  
  6012. public Action:Event_StartArea(Handle:event, String:name[], bool:dontBroadcast)
  6013. {
  6014. if (bFirstMapOfCampaign())
  6015. {
  6016. StartMapTiming();
  6017. return Action:0;
  6018. }
  6019. return Action:0;
  6020. }
  6021.  
  6022. public OnEntityCreated(entity, String:classname[])
  6023. {
  6024. if (StrEqual(classname, "prop_door_rotating_checkpoint", true))
  6025. {
  6026. if (!(GetEntProp(entity, PropType:0, "m_eDoorState", 4, 0)))
  6027. {
  6028. HookSingleEntityOutput(entity, "OnFullyOpen", OnStartSFDoorFullyOpened, true);
  6029. }
  6030. }
  6031. return 0;
  6032. }
  6033.  
  6034. public OnStartSFDoorFullyOpened(String:output[], caller, activator, Float:delay)
  6035. {
  6036. StartMapTiming();
  6037. return 0;
  6038. }
  6039.  
  6040. public StartMapTiming()
  6041. {
  6042. if (0.0 != MapTimingStartTime)
  6043. {
  6044. return 0;
  6045. }
  6046. MapTimingStartTime = GetEngineTime();
  6047. new i = 1;
  6048. while (i <= MaxClients)
  6049. {
  6050. new var1;
  6051. if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  6052. {
  6053. EmitSoundToClient(i, "level/countdown.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
  6054. }
  6055. i++;
  6056. }
  6057. return 0;
  6058. }
  6059.  
  6060. public StopMapTiming()
  6061. {
  6062. if (MapTimingStartTime <= 0.0)
  6063. {
  6064. return 0;
  6065. }
  6066. new Float:TotalTime = GetEngineTime() - MapTimingStartTime;
  6067. MapTimingStartTime = -1.0;
  6068. decl String:TimeLabel[32];
  6069. SetTimeLabel(TotalTime, TimeLabel, 32);
  6070. new i = 1;
  6071. while (i <= MaxClients)
  6072. {
  6073. new var1;
  6074. if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  6075. {
  6076. EmitSoundToClient(i, "level/bell_normal.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
  6077. PrintToChat(i, "%t", "It took %s to finish this map!", TimeLabel);
  6078. }
  6079. i++;
  6080. }
  6081. return 0;
  6082. }
  6083.  
  6084. public SetTimeLabel(Float:TheSeconds, String:TimeLabel[], maxsize)
  6085. {
  6086. new FlooredSeconds = RoundToFloor(TheSeconds);
  6087. new FlooredSecondsMod = FlooredSeconds % 60;
  6088. new Float:Seconds = TheSeconds - float(FlooredSeconds) + float(FlooredSecondsMod);
  6089. decl Minutes;
  6090. new var1;
  6091. if (TheSeconds < 60.0)
  6092. {
  6093. var1 = 0;
  6094. }
  6095. else
  6096. {
  6097. var1 = RoundToNearest(float(FlooredSeconds - FlooredSecondsMod) / 60);
  6098. }
  6099. Minutes = var1;
  6100. new MinutesMod = Minutes % 60;
  6101. decl Hours;
  6102. new var2;
  6103. if (Minutes < 60)
  6104. {
  6105. var2 = 0;
  6106. }
  6107. else
  6108. {
  6109. var2 = RoundToNearest(float(Minutes - MinutesMod) / 60);
  6110. }
  6111. Hours = var2;
  6112. Minutes = MinutesMod;
  6113. if (0 < Hours)
  6114. {
  6115. Format(TimeLabel, maxsize, "%t", "%ih %im %.1fs", Hours, Minutes, Seconds);
  6116. }
  6117. else
  6118. {
  6119. if (0 < Minutes)
  6120. {
  6121. Format(TimeLabel, maxsize, "%t", "%i min %.1f sec", Minutes, Seconds);
  6122. }
  6123. Format(TimeLabel, maxsize, "%t", "%.1f seconds", Seconds);
  6124. }
  6125. return 0;
  6126. }
  6127.  
  6128. public bool:bFirstMapOfCampaign()
  6129. {
  6130. decl String:MapName[128];
  6131. GetCurrentMap(MapName, 128);
  6132. new var1;
  6133. if (StrContains(MapName, "c1m1", true) > -1 || StrContains(MapName, "c2m1", true) > -1 || StrContains(MapName, "c3m1", true) > -1 || StrContains(MapName, "c4m1", true) > -1 || StrContains(MapName, "c5m1", true) > -1 || StrContains(MapName, "c6m1", true) > -1 || StrContains(MapName, "c7m1", true) > -1 || StrContains(MapName, "c8m1", true) > -1 || StrContains(MapName, "c9m1", true) > -1 || StrContains(MapName, "c10m1", true) > -1 || StrContains(MapName, "c11m1", true) > -1 || StrContains(MapName, "c12m1", true) > -1 || StrContains(MapName, "c13m1", true) > -1 || StrContains(MapName, "l4d_zero01_base", true) > -1 || StrContains(MapName, "l4d_viennacalling2_1", true) > -1 || StrContains(MapName, "eu01_residential_b16", true) > -1 || StrContains(MapName, "bloodtracks_01", true) > -1 || StrContains(MapName, "l4d2_darkblood01_tanker", true) > -1 || StrContains(MapName, "l4d_dbd2dc_anna_is_gone", true) > -1 || StrContains(MapName, "cdta_01detour", true) > -1 || StrContains(MapName, "l4d_ihm01_forest", true) > -1 || StrContains(MapName, "l4d2_diescraper1_apartment_31", true) > -1 || StrContains(MapName, "l4d_149_1", true) > -1 || StrContains(MapName, "gr-mapone-7", true) > -1 || StrContains(MapName, "qe_1_cliche", true) > -1 || StrContains(MapName, "l4d2_stadium1_apartment", true) > -1 || StrContains(MapName, "eu01_residential_b09", true) > -1 || StrContains(MapName, "wth_1", true) > -1 || StrContains(MapName, "2ee_01", true) > -1 || StrContains(MapName, "l4d2_city17_01", true) > -1 || StrContains(MapName, "l4d_deathaboard01_prison", true) > -1 || StrContains(MapName, "cwm1_intro", true) > -1 || StrContains(MapName, "2ee_01_deadlybeggining", true) > -1 || StrContains(MapName, "l4d_orange01_first", true) > -1 || StrContains(MapName, "hf01_theforest", true) > -1 || StrContains(MapName, "l4d2_deadcity01_riverside", true) > -1 || StrContains(MapName, "tutorial01", true) > -1 || StrContains(MapName, "tutorial_standards", true) > -1 || StrContains(MapName, "srocchurch", true) > -1 || StrContains(MapName, "l4d2_ravenholmwar_1", true) > -1)
  6134. {
  6135. return true;
  6136. }
  6137. return false;
  6138. }
  6139.  
  6140. public bool:bStandartMap()
  6141. {
  6142. decl String:MapName[128];
  6143. GetCurrentMap(MapName, 128);
  6144. new var1;
  6145. if (StrContains(MapName, "c1m", true) > -1 || StrContains(MapName, "c2m", true) > -1 || StrContains(MapName, "c3m", true) > -1 || StrContains(MapName, "c4m", true) > -1 || StrContains(MapName, "c5m", true) > -1 || StrContains(MapName, "c6m", true) > -1 || StrContains(MapName, "c7m", true) > -1 || StrContains(MapName, "c8m", true) > -1 || StrContains(MapName, "c9m", true) > -1 || StrContains(MapName, "c10m", true) > -1 || StrContains(MapName, "c11m", true) > -1 || StrContains(MapName, "c12m", true) > -1 || StrContains(MapName, "c13m", true) > -1)
  6146. {
  6147. return true;
  6148. }
  6149. return false;
  6150. }
  6151.  
  6152.  
Add Comment
Please, Sign In to add comment