HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*================================================================================
  2.  
  3. --------------------------------
  4. -*- [ZP] Sub-Plugin: Rewards -*-
  5. --------------------------------
  6.  
  7. ~~~~~~~~~~~~~~~
  8. - Description -
  9. ~~~~~~~~~~~~~~~
  10.  
  11. This plugin offers certain amounts of ammo packs
  12. to those who frag their enemies or win the round.
  13. Everything is configurable by cvar values.
  14. This is a plugin that shouldn't be missing
  15. from any Zombie Plague server out there...
  16. Enjoy it and have fun!
  17.  
  18. Original forum thread: http://forums.alliedmods.net/showthread.php?p=1156585
  19.  
  20. ~~~~~~~~~~~~~
  21. - Thanks to -
  22. ~~~~~~~~~~~~~
  23.  
  24. MeRcyLeZZ - For such an awesome mod like Zombie Plague
  25. and for some code i used from it...once again
  26. XxAvalanchexX - For some code i used from his GunGame Mod
  27. Fry! and bmann_420 - For not ignoring me when i
  28. needed help the most (like other 'friends' do)
  29. suNx - For helping me with the plugin tests
  30. abdul-rehman - For being a good friend
  31. And all my real friends...
  32.  
  33. ~~~~~~~~~~~~~
  34. - Changelog -
  35. ~~~~~~~~~~~~~
  36.  
  37. * v1.0 (21 Apr 2010)
  38. - First release
  39.  
  40. * v1.1 (21 Apr 2010)
  41. - Fixed plugin turning off when
  42. the toggle cvar is set to 1
  43. - Added rewards for surviving
  44. the round as Nemesis or Survivor
  45. - Removed unuseful cvars
  46.  
  47. * v1.2 (22 Apr 2010)
  48. - Fixed players not getting ammo packs when fragging a enemy
  49. (rescripted the Player Killed part in the plugin)
  50. This wasn't showing up because i was testing the plugin
  51. with bots and it seems that just human players count
  52. - Added giving the players rewards in other rounds
  53.  
  54. * v1.3 (10 May 2010)
  55. - Fixed bug where a player that killed Nemesis got packs for
  56. a Zombie frag too. Well, Nemesis is just a fancy Zombie...
  57. - Fixed players not getting awards for winning
  58. other rounds than Nemesis or Survivor
  59. - Added knife kill rewards for Survivors and Humans
  60. - Added chat text to notify when a Nemesis
  61. or a Zombie kills or infects a Human
  62. - Fixed chat multiple print bug
  63. - Fixed tons of other chat print bugs
  64.  
  65. * v1.4 (23 Jun 2010)
  66. - Made the plugin multi-lingual
  67. - Added rewards for killing the first and last Zombie
  68. - Added reward giving for killing the last Human
  69. - Improved some code
  70. - Fixed some chat print errors
  71. - Fixed bug where sometimes bazooka kills
  72. were considered knife kills
  73.  
  74. ================================================================================*/
  75.  
  76. #include <amxmodx>
  77. #include <fakemeta>
  78. #include <hamsandwich>
  79. #include <zombieplague>
  80.  
  81. // Cvars
  82. new cvar_toggle, cvar_nks_ampks, cvar_nks_round, cvar_nem_round, cvar_skn_ampks,
  83. cvar_sknk_ampks, cvar_skn_round, cvar_skz_ampks, cvar_skzk_ampks, cvar_surv_round,
  84. cvar_zks_ampks, cvar_zks_round, cvar_zklh_ampks, cvar_zm_round, cvar_hkn_ampks,
  85. cvar_hknk_ampks, cvar_hkn_round, cvar_hkz_ampks, cvar_hkzk_ampks, cvar_hkfz_ampks,
  86. cvar_hkfzk_ampks, cvar_hklz_ampks, cvar_hklzk_ampks, cvar_hum_round, cvar_nzkih_show,
  87. cvar_nzkih_ampks
  88.  
  89. // Get server's max players | Create custom chat print
  90. new g_maxplayers, g_msgSayText
  91.  
  92. public plugin_init()
  93. {
  94. register_plugin("[ZP] Sub-Plugin: Rewards", "1.4", "93()|29!/<")
  95. register_dictionary("zp_rewards.txt")
  96.  
  97. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  98.  
  99. g_maxplayers = get_maxplayers()
  100. g_msgSayText = get_user_msgid("SayText")
  101. }
  102.  
  103. public plugin_precache()
  104. {
  105. cvar_toggle = register_cvar("zp_rewards", "1") // Turned on/off
  106. cvar_nks_ampks = register_cvar("zp_rewards_nks", "3") // Nemesis kills Survivor
  107. cvar_nks_round = register_cvar("zp_rewards_nks_round", "0") // Only in Plague round
  108. cvar_nem_round = register_cvar("zp_rewards_nem_round", "35") // Nemesis wins the round
  109. cvar_skn_ampks = register_cvar("zp_rewards_skn", "3") // Survivor kills Nemesis
  110. cvar_sknk_ampks = register_cvar("zp_rewards_sknk", "25") // Survivor kills Nemesis with knife
  111. cvar_skn_round = register_cvar("zp_rewards_skn_round", "0") // Only in Plague round
  112. cvar_skz_ampks = register_cvar("zp_rewards_skz", "1") // Survivor kills Zombie
  113. cvar_skzk_ampks = register_cvar("zp_rewards_skzk", "15") // Survivor kills Zombie with knife
  114. cvar_surv_round = register_cvar("zp_rewards_surv_round", "35") // Survivor wins the round
  115. cvar_zks_ampks = register_cvar("zp_rewards_zks", "35") // Zombie Kills Survivor
  116. cvar_zks_round = register_cvar("zp_rewards_zks_round", "0") // Only in Survivor Round
  117. cvar_zklh_ampks = register_cvar("zp_rewards_zklh", "1") // Zombie kills last Human
  118. cvar_zm_round = register_cvar("zp_rewards_zm_round", "1") // Zombies win the round
  119. cvar_hkn_ampks = register_cvar("zp_rewards_hkn", "35") // Human kills Nemesis
  120. cvar_hknk_ampks = register_cvar("zp_rewards_hknk", "75") // Human kills Nemesis with knife
  121. cvar_hkn_round = register_cvar("zp_rewards_hkn_round", "0") // Only in Nemesis round
  122. cvar_hkz_ampks = register_cvar("zp_rewards_hkz", "1") // Human kills Zombie
  123. cvar_hkzk_ampks = register_cvar("zp_rewards_hkzk", "25") // Human kills Zombie with knife
  124. cvar_hkfz_ampks = register_cvar("zp_rewards_hkfz", "3") // Human kills first Zombie
  125. cvar_hkfzk_ampks = register_cvar("zp_rewards_hkfzk", "25") // Human kills first Zombie with knife
  126. cvar_hklz_ampks = register_cvar("zp_rewards_hklz", "1") // Human kills last Zombie
  127. cvar_hklzk_ampks = register_cvar("zp_rewards_hklzk", "25") // Human kills last Zombie with knife
  128. cvar_hum_round = register_cvar("zp_rewards_hum_round", "3") // Humans win the round
  129. cvar_nzkih_show = register_cvar("zp_rewards_nzkih_show", "1") // Nemesis/Zombie kills/infects a Human
  130. cvar_nzkih_ampks = get_cvar_num("zp_zombie_infect_reward") // Find out how many ammo packs a Nemesis/Zombie gets for killing/infecting a Human
  131. }
  132.  
  133. public plugin_cfg()
  134. {
  135. // Plugin is disabled
  136. if (!get_pcvar_num(cvar_toggle))
  137. return;
  138.  
  139. // Get configs dir
  140. new cfgdir[32]
  141. get_configsdir(cfgdir, charsmax(cfgdir))
  142.  
  143. // Execute config file (zp_rewards.cfg)
  144. server_cmd("exec %s/zp_rewards.cfg", cfgdir)
  145. }
  146.  
  147. // Ham Player Killed Forward
  148. public fw_PlayerKilled(victim, attacker, shouldgib)
  149. {
  150. // Plugin is disabled
  151. if (!get_pcvar_num(cvar_toggle))
  152. return;
  153.  
  154. // Get deathmatch mode status and whether the player killed himself
  155. static selfkill
  156. selfkill = (victim == attacker || !is_user_connected(attacker)) ? true : false
  157.  
  158. // Killed by a non-player entity or self killed
  159. if (selfkill) return;
  160.  
  161. // Get attacker and victim's name
  162. static aname[32], vname[32]
  163. get_user_name(attacker, aname, 31)
  164. get_user_name(victim, vname, 31)
  165.  
  166. // A Zombie was killed
  167. if (zp_get_user_zombie(victim))
  168. {
  169. // Get the fragger's current weapon
  170. static wpnName[24]
  171. get_killer_weapon(attacker, pev(victim, pev_dmg_inflictor), wpnName, 23)
  172.  
  173. // Victim was Nemesis. What?! He's a Zombie too, you know?
  174. if (zp_get_user_nemesis(victim))
  175. {
  176. // Survivor's frag
  177. if (zp_get_user_survivor(attacker))
  178. {
  179. // He gets enough ammo packs allready
  180. if (!zp_is_plague_round() && get_pcvar_num(cvar_skn_round))
  181. return;
  182.  
  183. // He knifed the Nemesis
  184. if (equal(wpnName, "knife"))
  185. {
  186. // Option disabled
  187. if (!get_pcvar_num(cvar_sknk_ampks))
  188. return;
  189.  
  190. // Award him
  191. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_sknk_ampks))
  192. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_SKNK", aname, get_pcvar_num(cvar_sknk_ampks), vname)
  193. }
  194. // Just a normal kill
  195. else
  196. {
  197. // Option disabled
  198. if (!get_pcvar_num(cvar_skn_ampks))
  199. return;
  200.  
  201. // Award him
  202. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_skn_ampks))
  203. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_SKN", aname, get_pcvar_num(cvar_skn_ampks), vname)
  204. }
  205. }
  206. // Human makes the kill
  207. else
  208. {
  209. // But he won't be so happy
  210. if (!zp_is_nemesis_round() && get_pcvar_num(cvar_hkn_round))
  211. return;
  212.  
  213. // He knifed the Nemesis
  214. if (equal(wpnName, "knife"))
  215. {
  216. // Option disabled
  217. if (!get_pcvar_num(cvar_hknk_ampks))
  218. return;
  219.  
  220. // Award him
  221. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hknk_ampks))
  222. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKNK", aname, get_pcvar_num(cvar_hknk_ampks), vname)
  223. }
  224. // Just a normal kill
  225. else
  226. {
  227. // Option disabled
  228. if (!get_pcvar_num(cvar_hkn_ampks))
  229. return;
  230.  
  231. // Award him
  232. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hkn_ampks))
  233. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKN", aname, get_pcvar_num(cvar_hkn_ampks), vname)
  234. }
  235. }
  236. }
  237. // Well this time it was just a Zombie
  238. else
  239. {
  240. // Survivor strikes again
  241. if (zp_get_user_survivor(attacker))
  242. {
  243. // He knifed the Zombie
  244. if (equal(wpnName, "knife"))
  245. {
  246. // Option disabled
  247. if (!get_pcvar_num(cvar_skzk_ampks))
  248. return;
  249.  
  250. // Award him
  251. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_skzk_ampks))
  252. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_SKZK", aname, get_pcvar_num(cvar_skzk_ampks), vname)
  253. }
  254. // Just a normal kill
  255. else
  256. {
  257. // Option disabled
  258. if (!get_pcvar_num(cvar_skz_ampks))
  259. return;
  260.  
  261. // Award him
  262. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_skz_ampks))
  263. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_SKZ", aname, get_pcvar_num(cvar_skz_ampks), vname)
  264. }
  265. }
  266. // Human wants some ammo packs
  267. else
  268. {
  269. // He knifed the Zombie
  270. if (equal(wpnName, "knife"))
  271. {
  272. // Victim was the first Zombie
  273. if (zp_get_user_first_zombie(victim))
  274. {
  275. // No rewards for this kind of kill
  276. if (!get_pcvar_num(cvar_hkfzk_ampks))
  277. return;
  278.  
  279. // Award the killer
  280. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hkfzk_ampks))
  281. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKFZK", aname, get_pcvar_num(cvar_hkfzk_ampks), vname)
  282. }
  283. // Last Zombie
  284. else if (zp_get_user_last_zombie(victim))
  285. {
  286. // No rewards for this kind of kill
  287. if (!get_pcvar_num(cvar_hklzk_ampks))
  288. return;
  289.  
  290. // Award the killer
  291. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hklzk_ampks))
  292. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKLZK", aname, get_pcvar_num(cvar_hklzk_ampks), vname)
  293. }
  294. // Just one of those Zombies
  295. else
  296. {
  297. // Option disabled
  298. if (!get_pcvar_num(cvar_hkzk_ampks))
  299. return;
  300.  
  301. // Award him
  302. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hkzk_ampks))
  303. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKZK", aname, get_pcvar_num(cvar_hkzk_ampks), vname)
  304. }
  305. }
  306. // Just a normal kill
  307. else
  308. {
  309. // Victim was the first Zombie
  310. if (zp_get_user_first_zombie(victim))
  311. {
  312. // No rewards for this kind of kill
  313. if (!get_pcvar_num(cvar_hkfz_ampks))
  314. return;
  315.  
  316. // Award the killer
  317. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hkfz_ampks))
  318. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKFZ", aname, get_pcvar_num(cvar_hkfz_ampks), vname)
  319. }
  320. // Last Zombie
  321. else if (zp_get_user_last_zombie(victim))
  322. {
  323. // No rewards for this kind of kill
  324. if (!get_pcvar_num(cvar_hklz_ampks))
  325. return;
  326.  
  327. // Award the killer
  328. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hklz_ampks))
  329. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKLZ", aname, get_pcvar_num(cvar_hklz_ampks), vname)
  330. }
  331. // Just one of those Zombies
  332. else
  333. {
  334. // Option disabled
  335. if (!get_pcvar_num(cvar_hkz_ampks))
  336. return;
  337.  
  338. // Award him
  339. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_hkz_ampks))
  340. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_HKZ", aname, get_pcvar_num(cvar_hkz_ampks), vname)
  341. }
  342. }
  343. }
  344. }
  345. }
  346. // Survivor or Human
  347. else
  348. {
  349. // Killed player was Survivor
  350. if (zp_get_user_survivor(victim))
  351. {
  352. // Nemesis is the killer
  353. if (zp_get_user_nemesis(attacker))
  354. {
  355. // And?
  356. if (!get_pcvar_num(cvar_nks_ampks) || !zp_is_plague_round() && get_pcvar_num(cvar_nks_round))
  357. return;
  358.  
  359. // And he deserves a treat
  360. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_nks_ampks))
  361. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_NKS", aname, get_pcvar_num(cvar_nks_ampks), vname)
  362. }
  363. // Killer is a Zombie
  364. else
  365. {
  366. // So what?
  367. if (!get_pcvar_num(cvar_zks_ampks) || !zp_is_survivor_round() && get_pcvar_num(cvar_zks_round))
  368. return;
  369.  
  370. // So let's give him something... Paulie want a cracker?
  371. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_zks_ampks))
  372. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_ZKS", aname, get_pcvar_num(cvar_zks_ampks), vname)
  373. }
  374. }
  375. // A Human got killed
  376. else
  377. {
  378. // Last Human
  379. if (zp_get_user_last_human(victim))
  380. {
  381. // Feature disabled
  382. if (!get_pcvar_num(cvar_zklh_ampks))
  383. return;
  384.  
  385. // Reward the killer
  386. zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_zklh_ampks))
  387. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_ZKLH", aname, get_pcvar_num(cvar_zklh_ampks), vname)
  388. }
  389. // Just a random Human
  390. else
  391. {
  392. // Showing this isn't allowed
  393. if (!get_pcvar_num(cvar_nzkih_show) || !cvar_nzkih_ampks)
  394. return;
  395.  
  396. // Nemesis' frag
  397. if (zp_get_user_nemesis(attacker))
  398. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_NKH", aname, cvar_nzkih_ampks, vname)
  399. // Zombies are good at killing too
  400. else
  401. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_ZKH", aname, cvar_nzkih_ampks, vname)
  402. }
  403. }
  404. }
  405. }
  406.  
  407. // ZP User Infected Forward
  408. public zp_user_infected_post(id, infector, nemesis)
  409. {
  410. // Plugin is disabled | Option disabled | No ammo packs to receive | Not infected by a player | Turned into Nemesis
  411. if (!get_pcvar_num(cvar_toggle) || !get_pcvar_num(cvar_nzkih_show) || !cvar_nzkih_ampks || !infector || nemesis)
  412. return;
  413.  
  414. // Get infector and infected's name
  415. static aname[32], vname[32]
  416. get_user_name(infector, aname, 31)
  417. get_user_name(id, vname, 31)
  418.  
  419. // Spread the word
  420. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "REWARDS_ZIH", aname, cvar_nzkih_ampks, vname)
  421. }
  422.  
  423. // ZP Round Ended Forward
  424. public zp_round_ended(winteam)
  425. {
  426. // Plugin is disabled | No one won...
  427. if (!get_pcvar_num(cvar_toggle) || winteam == WIN_NO_ONE)
  428. return;
  429.  
  430. // Loop trough all the players
  431. static id
  432. for (id = 1; id <= g_maxplayers; id++)
  433. {
  434. // Zombies have conquered the world
  435. if (winteam == WIN_ZOMBIES)
  436. {
  437. // Was Nemesis round
  438. if (zp_is_nemesis_round())
  439. {
  440. // Option turned off
  441. if (!get_pcvar_num(cvar_nem_round))
  442. return;
  443.  
  444. // Is Nemesis
  445. if (zp_get_user_nemesis(id))
  446. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_nem_round))
  447.  
  448. if (zp_get_nemesis_count() > 1)
  449. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_NEM_ROUND2", get_pcvar_num(cvar_nem_round))
  450. else
  451. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_NEM_ROUND1", get_pcvar_num(cvar_nem_round))
  452. }
  453. // Other rounds
  454. else
  455. {
  456. // Option turned off
  457. if (!get_pcvar_num(cvar_zm_round))
  458. return;
  459.  
  460. // Is Zombie
  461. if (zp_get_user_zombie(id))
  462. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_zm_round))
  463.  
  464. // No Nemesis was found
  465. if (!zp_get_nemesis_count())
  466. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_ZM_ROUND", get_pcvar_num(cvar_zm_round))
  467. // One or more Nemesis were present
  468. else
  469. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_NEM_ZM_ROUND", get_pcvar_num(cvar_zm_round))
  470. }
  471. }
  472.  
  473. // Humans survived
  474. if (winteam == WIN_HUMANS)
  475. {
  476. // Was Survivor round
  477. if (zp_is_survivor_round())
  478. {
  479. // Option turned off
  480. if (!get_pcvar_num(cvar_surv_round))
  481. return;
  482.  
  483. // Is Survivor
  484. if (zp_get_user_survivor(id))
  485. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_surv_round))
  486.  
  487. // More than one Survivor
  488. if (zp_get_survivor_count() > 1)
  489. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_SURV_ROUND2", get_pcvar_num(cvar_surv_round))
  490. // Only one Survivor
  491. else
  492. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_SURV_ROUND1", get_pcvar_num(cvar_surv_round))
  493. }
  494. // Other rounds
  495. else
  496. {
  497. // Option turned on
  498. if (!get_pcvar_num(cvar_hum_round))
  499. return;
  500.  
  501. // Isn't Zombie
  502. if (!zp_get_user_zombie(id))
  503. zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_hum_round))
  504.  
  505. // No Survivors
  506. if (!zp_get_survivor_count())
  507. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_HUM_ROUND", get_pcvar_num(cvar_hum_round))
  508. // There are Survivors too
  509. else
  510. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "REWARDS_SURV_HUM_ROUND", get_pcvar_num(cvar_hum_round))
  511. }
  512. }
  513. }
  514. }
  515.  
  516. // Colored chat print. Thanks to MeRcyLeZZ
  517. zp_colored_print(target, const message[], any:...)
  518. {
  519. static buffer[512], i, argscount
  520. argscount = numargs()
  521.  
  522. // Send to everyone
  523. if (!target)
  524. {
  525. static player
  526. for (player = 1; player <= g_maxplayers; player++)
  527. {
  528. // Not connected
  529. if (!is_user_connected(player))
  530. continue;
  531.  
  532. // Remember changed arguments
  533. static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
  534. changedcount = 0
  535.  
  536. // Replace LANG_PLAYER with player id
  537. for (i = 2; i < argscount; i++)
  538. {
  539. if (getarg(i) == LANG_PLAYER)
  540. {
  541. setarg(i, 0, player)
  542. changed[changedcount] = i
  543. changedcount++
  544. }
  545. }
  546.  
  547. // Format message for player
  548. vformat(buffer, charsmax(buffer), message, 3)
  549.  
  550. // Send it
  551. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
  552. write_byte(player)
  553. write_string(buffer)
  554. message_end()
  555.  
  556. // Replace back player id's with LANG_PLAYER
  557. for (i = 0; i < changedcount; i++)
  558. setarg(changed[i], 0, LANG_PLAYER)
  559. }
  560. }
  561. // Send to specific target
  562. else
  563. {
  564. // Not connected
  565. if (!is_user_connected(target))
  566. return;
  567.  
  568. // Format message for player
  569. vformat(buffer, charsmax(buffer), message, 3)
  570.  
  571. // Send it
  572. message_begin(MSG_ONE, g_msgSayText, _, target)
  573. write_byte(target)
  574. write_string(buffer)
  575. message_end()
  576. }
  577. }
  578.  
  579. // Stock from AmxMisc
  580. stock get_configsdir(name[], len)
  581. {
  582. return get_localinfo("amxx_configsdir", name, len);
  583. }
  584.  
  585. // Gets the weapon that the killer used
  586. stock get_killer_weapon(killer, inflictor, retVar[], retLen)
  587. {
  588. static killer_weapon_name[32];
  589. killer_weapon_name = "world"; // by default, the player is killed by the world
  590.  
  591. if (pev_valid(killer) && (pev(killer, pev_flags) & FL_CLIENT))
  592. {
  593. if (pev_valid(inflictor))
  594. {
  595. if (inflictor == killer)
  596. {
  597. // if the inflictor is the killer, then it must be their current weapon doing the damage
  598. new weapon = get_user_weapon(killer);
  599. get_weaponname(weapon, killer_weapon_name, 31);
  600. }
  601. else pev(inflictor, pev_classname, killer_weapon_name, 31); // it's just that easy
  602. }
  603. }
  604. else
  605. {
  606. if (pev_valid(killer)) pev(inflictor, pev_classname, killer_weapon_name, 31);
  607. else if (killer == 0) killer_weapon_name = "worldspawn";
  608. }
  609.  
  610. // Strip the monster_* or weapon_* from the inflictor's classname
  611. if (equal(killer_weapon_name, "weapon_", 7))
  612. format(killer_weapon_name, 31, "%s", killer_weapon_name[7]);
  613. else if (equal(killer_weapon_name, "monster_", 8))
  614. format(killer_weapon_name, 31, "%s", killer_weapon_name[8]);
  615. else if (equal(killer_weapon_name, "func_", 5))
  616. format(killer_weapon_name, 31, "%s", killer_weapon_name[5]);
  617.  
  618. // Output
  619. formatex(retVar, retLen, "%s", killer_weapon_name);
  620. }
  621.