HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /****************************************************************************\
  2. ========================================
  3. * || Zombie Plague Advance v1.6.1 || *
  4. ========================================
  5.  
  6. ------------------------
  7. *|| Licensing Info ||*
  8. ------------------------
  9.  
  10. Zombie Plague Advance v1.6.1
  11. Copyright (C) 2009-2010 by MeRcyLeZZ & @bdul! & 93()|29!/<
  12.  
  13. This program is free software: you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation, either version 3 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program. If not, see <http://www.gnu.org/licenses/>.
  25.  
  26. In addition, as a special exception, the author gives permission to
  27. link the code of this program with the Half-Life Game Engine ("HL
  28. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  29. L.L.C ("Valve"). You must obey the GNU General Public License in all
  30. respects for all of the code used other than the HL Engine and MODs
  31. from Valve. If you modify this file, you may extend this exception
  32. to your version of the file, but you are not obligated to do so. If
  33. you do not wish to do so, delete this exception statement from your
  34. version.
  35.  
  36. ---------------------
  37. *|| Description ||*
  38. ---------------------
  39.  
  40. Zombie Plague Advance v1.6.1 is an editted version of the original
  41. Zombie Plague Mod by MeRcyLeZZ. The difference is that it takes
  42. the original Zombie Plague to an Advance level by introducing:
  43.  
  44. ** New Built in Game modes: Assassin mode, Sniper mode and finally
  45. Armageddon mode.
  46. ** New features for these game modes like snipers customizable aura's
  47. size and color as well as other stuff which can be found in the
  48. customization files.
  49. ** New and improved features from the orignal Zombie Plague Mod.
  50. ** New and extended API Capabilities such as new natives and forwards.
  51. ** New custom game modes system through which game modes can be added
  52. externally without the need of editting the main plugin.
  53. ** New forwards for manipulating custom game mode's functions easily.
  54. ** A new and organized admin menu with the power of listing custom
  55. game modes automatically.
  56. ** An optimized and organised code for supporting all these functions.
  57.  
  58. ----------------------
  59. *|| Requirements ||*
  60. ----------------------
  61.  
  62. ** Mods: Counter-Strike 1.6 or Condition-Zero
  63. ** AMXX: Version 1.8.1 or later
  64. ** AMXX Modules: FakeMeta, Cstrike and Hamsandwich modules
  65.  
  66. ----------------------
  67. *|| Installation ||*
  68. ----------------------
  69.  
  70. 1- Extract the contents from the .zip file to your server's mod
  71. directory ("cstrike" or "czero").
  72. 2- Make sure to keep folder structure.
  73.  
  74. -----------------------------
  75. *|| New Game Play Modes ||*
  76. -----------------------------
  77.  
  78. ** Sniper Mode: [By my friend, 93()|29!/<]
  79. Everyone becomes a zombie except him. The sniper gets an Awp
  80. Magnum Sniper with unlimited BP ammo and has to stop the never
  81. ending army of undead. Its one shot, one kill !
  82.  
  83. ** Assassin Mode:
  84. The first zombie may turn into an Assassin, a powerful fast-moving
  85. beast without glow and aura. His goal is to kill every human while
  86. sustaining the gunfire. In this round all Flare Nades decrease in
  87. size and all lights (Including Triggered lights) go down.
  88.  
  89. ** Armageddon Mode:
  90. This is the final fight. A hot duel between half players as Survivors
  91. and half players as Nemesis.
  92.  
  93. ----------------------
  94. *|| Contact Info ||*
  95. ----------------------
  96.  
  97. For reporting bugs and for getting support you may visit the official
  98. Zombie Plague Advance thread located here:
  99. http://forums.alliedmods.net/showthread.php?t=118684
  100.  
  101. For personal contact you can send me an email at:
  102. dude_ab99@yahoo.com
  103. But i usually dont look at my emails =)
  104.  
  105. --------------------
  106. *|| Plugin API ||*
  107. --------------------
  108.  
  109. For developing sub-plugins you may use the Zombie Plague Advance include
  110. file located here:
  111. amxmodx\scripting\include
  112.  
  113. There you will find a full documented list of natives and forwards which
  114. may help you.
  115.  
  116. --------------------------------
  117. *|| Custom Game Play Modes ||*
  118. --------------------------------
  119.  
  120. From now on it is possible to add an unlimited amount of custom game modes
  121. with out editting the main plugin
  122.  
  123. If you want to make a custom, fully working game mode you may search for
  124. this file:
  125. zp_game_mode_example.sma
  126. In this folder:
  127. amxmodx\scripting
  128.  
  129. Just open the file using a note pad and then follow the instructions.
  130.  
  131. -----------------
  132. *|| Credits ||*
  133. -----------------
  134.  
  135. ** MeRcyLeZZ
  136. For the original Zombie Plague Mod and for his talent which made
  137. me capable of coding plugins.
  138.  
  139. ** 93()|29!/<
  140. For providing me with his sniper mode and for his talent which not
  141. only encouraged me but also laid the basis for Zombie Plague Advance.
  142.  
  143. ** _Speed_
  144. For his Zombie Mutilation plugin which proved to be very helpful for
  145. making the assassin mode.
  146.  
  147. ** NiHiLaNTh
  148. For giving me suggestions regarding the new native with which game
  149. modes can be registered externally.
  150.  
  151. ** AfteR. / yokomo / Kiryu Zero
  152. For some useful suggestions which i implemented in the code.
  153.  
  154. ** Zloj / Vechta
  155. For there valuable feed backs and testing.
  156.  
  157. ** fiendshard / artos / zombiiiizzz / re333 / vaan123
  158. For supporting my work and for encouraging me.
  159.  
  160. ------------------
  161. *||Change Log||*
  162. ------------------
  163.  
  164. ** v1.0 [Feb 2010]
  165. - Added Sniper Mode.
  166. - Added Assassin Mode.
  167. - Fixed various bugs which were disturbing the game play.
  168.  
  169. ** v1.1 [Feb 2010]
  170. - Fixed assassin bugs with napalm grenade.
  171. - Added seperate pain sounds for assassin.
  172.  
  173. ** v1.2 [Feb 2010]
  174. - Fixed a bug which could have caused most of the sub-plugins based
  175. on assassin mode to crash.
  176. - Added a second admin menu.
  177. - Added Armageddon mode.
  178.  
  179. ** v1.3 [Feb 2010]
  180. - Fixed the runtime error "ArrayGetString".
  181. - Added two new cvars for Armageddon mode respawn.
  182.  
  183. ** v1.4 [March 2010]
  184. - Optimized code to a great extent.
  185. - Removed Anti Block plugin because it was causing bugs.
  186. - Organized the admin menu.
  187.  
  188. ** v1.5 [April 2010]
  189. - Optimized code to a great extent.
  190. - Removed stamina plugin because it was causing bugs.
  191. - Organized and optimized the admin menu.
  192. - Fixed server crashing issues.
  193.  
  194. ** v1.6 [Release date: 29th June 2010]
  195. - Optimized sniper's gore code which will hopefully reduce server crashes.
  196. - Optimized assassin's gore affect to reduce lag.
  197. - Fixed survivor leap not working even though it was enabled.
  198. - Fixed ML file problems.
  199. - Extended admin menu's functionalities by adding a new menu for listing
  200. custom game mode's automatically.
  201. - Fixed players not respawning after they have comitted suicide even though
  202. the required cvar was on.
  203. - Fixed death match mode not working for custom game modes.
  204. - Added an example custom game mode for helping scripters in making custom
  205. game modes.
  206.  
  207. ** v1.6.1 [Release date: 11th September 2010]
  208. - Fixed ML file bugs which were caused by wrongly formated string.
  209. - Fixed the incorrect pattern according to which custom game mode forwards
  210. were executed.
  211. - Fixed sniper gore affect causing server crashes, by changing the gore
  212.   message's destination (Changed MSG_BROADCAST to MSG_PVS).
  213. - Fixed a bug due to which players were unable to switch triggered lights
  214.   after assassin round.
  215. - Fixed admins knife p_ model not bieng shown when the cvar
  216. zp_admin_knife_models_human was enabled.
  217. - Fixed zp_sniper_damage cvar bieng set to an integar value although it
  218. was supposed to be a float value.
  219. - Fixed Assassin's aura displaying wrong colors.
  220. - Fixed wrong fade color bieng displayed to Assassin on infection attempts.
  221. - Optimized code according to which ammo packs were awarded to players.
  222. - Optimized nemesis, assassin and sniper's weapon/knife damage code.
  223. - Optimized the player list menu code.
  224. - Optimized the aim info code to a great extent.
  225. - Optimized flashlight and aura message's codes.
  226. - Added more features in the aim info code.
  227. - Added a cvar for turning the aim info message on/off.
  228. - Added a cvar for configuring Nemesis/Assassin's aura radius.
  229. - Added 2 new natives for setting and retrieving players' models properly.
  230.  
  231. \************************************************************************************/
  232.  
  233. /*================================================================================
  234.  [Plugin Customization]
  235. =================================================================================*/
  236. new const ZP_CUSTOMIZATION_FILE[] = "zombie_plague_advance.ini"
  237. new const ZP_EXTRAITEMS_FILE[] = "zpa_extraitems.ini"
  238. new const ZP_ZOMBIECLASSES_FILE[] = "zpa_zombieclasses.ini"
  239.  
  240. // Limiters for stuff not worth making dynamic arrays out of (increase if needed)
  241. const MAX_CSDM_SPAWNS = 128
  242. const MAX_STATS_SAVED = 64
  243.  
  244. /*================================================================================
  245.  Customization ends here! Yes, that's it. Editing anything beyond
  246.  here is not officially supported. Proceed at your own risk...
  247. =================================================================================*/
  248.  
  249. #include <amxmodx>
  250. #include <amxmisc>
  251. #include <cstrike>
  252. #include <fakemeta>
  253. #include <hamsandwich>
  254. #include <xs>
  255.  
  256. /*================================================================================
  257.  [Constants, Offsets, Macros]
  258. =================================================================================*/
  259.  
  260. // Customization file sections
  261. enum
  262. {
  263. SECTION_NONE = 0,
  264. SECTION_ACCESS_FLAGS,
  265. SECTION_PLAYER_MODELS,
  266. SECTION_WEAPON_MODELS,
  267. SECTION_GRENADE_SPRITES,
  268. SECTION_SOUNDS,
  269. SECTION_AMBIENCE_SOUNDS,
  270. SECTION_BUY_MENU_WEAPONS,
  271. SECTION_EXTRA_ITEMS_WEAPONS,
  272. SECTION_HARD_CODED_ITEMS_COSTS,
  273. SECTION_WEATHER_EFFECTS,
  274. SECTION_SKY,
  275. SECTION_LIGHTNING,
  276. SECTION_ZOMBIE_DECALS,
  277. SECTION_KNOCKBACK,
  278. SECTION_OBJECTIVE_ENTS,
  279. SECTION_SVC_BAD
  280. }
  281.  
  282. // Access flags
  283. enum
  284. {
  285. ACCESS_ENABLE_MOD = 0,
  286. ACCESS_ADMIN_MENU,
  287. ACCESS_ADMIN_MENU2,
  288. ACCESS_ADMIN_MENU3,
  289. ACCESS_MODE_INFECTION,
  290. ACCESS_MODE_NEMESIS,
  291. ACCESS_MODE_SURVIVOR,
  292. ACCESS_MODE_SWARM,
  293. ACCESS_MODE_MULTI,
  294. ACCESS_MODE_PLAGUE,
  295. ACCESS_MAKE_ZOMBIE,
  296. ACCESS_MAKE_HUMAN,
  297. ACCESS_MAKE_NEMESIS,
  298. ACCESS_MAKE_SURVIVOR,
  299. ACCESS_RESPAWN_PLAYERS,
  300. ACCESS_ADMIN_MODELS,
  301. ACCESS_MODE_SNIPER,
  302. ACCESS_MAKE_SNIPER,
  303. ACCESS_MODE_ASSASSIN,
  304. ACCESS_MAKE_ASSASSIN,
  305. ACCESS_MODE_LNJ,
  306. MAX_ACCESS_FLAGS
  307. }
  308.  
  309. // Task offsets
  310. enum (+= 100)
  311. {
  312. TASK_MODEL = 2000,
  313. TASK_TEAM,
  314. TASK_SPAWN,
  315. TASK_BLOOD,
  316. TASK_AURA,
  317. TASK_BURN,
  318. TASK_NVISION,
  319. TASK_FLASH,
  320. TASK_CHARGE,
  321. TASK_SHOWHUD,
  322. TASK_MAKEZOMBIE,
  323. TASK_WELCOMEMSG,
  324. TASK_THUNDER_PRE,
  325. TASK_THUNDER,
  326. TASK_AMBIENCESOUNDS
  327. }
  328.  
  329. // IDs inside tasks
  330. #define ID_MODEL (taskid - TASK_MODEL)
  331. #define ID_TEAM (taskid - TASK_TEAM)
  332. #define ID_SPAWN (taskid - TASK_SPAWN)
  333. #define ID_BLOOD (taskid - TASK_BLOOD)
  334. #define ID_AURA (taskid - TASK_AURA)
  335. #define ID_BURN (taskid - TASK_BURN)
  336. #define ID_NVISION (taskid - TASK_NVISION)
  337. #define ID_FLASH (taskid - TASK_FLASH)
  338. #define ID_CHARGE (taskid - TASK_CHARGE)
  339. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  340.  
  341. // BP Ammo Refill task
  342. #define REFILL_WEAPONID args[0]
  343.  
  344. // For weapon buy menu handlers
  345. #define WPN_STARTID g_menu_data[id][1]
  346. #define WPN_MAXIDS ArraySize(g_primary_items)
  347. #define WPN_SELECTION (g_menu_data[id][1]+key)
  348. #define WPN_AUTO_ON g_menu_data[id][2]
  349. #define WPN_AUTO_PRI g_menu_data[id][3]
  350. #define WPN_AUTO_SEC g_menu_data[id][4]
  351.  
  352. // For player list menu handlers
  353. #define PL_ACTION g_menu_data[id][0]
  354.  
  355. // For extra items menu handlers
  356. #define EXTRAS_CUSTOM_STARTID (EXTRA_WEAPONS_STARTID + ArraySize(g_extraweapon_names))
  357.  
  358. // Menu selections
  359. const MENU_KEY_AUTOSELECT = 7
  360. const MENU_KEY_BACK = 7
  361. const MENU_KEY_NEXT = 8
  362. const MENU_KEY_EXIT = 9
  363.  
  364. // Hard coded extra items
  365. enum
  366. {
  367. EXTRA_NVISION = 0,
  368. EXTRA_ANTIDOTE,
  369. EXTRA_MADNESS,
  370. EXTRA_INFBOMB,
  371. EXTRA_WEAPONS_STARTID
  372. }
  373.  
  374. // Game mode settings
  375. new const MODE_SET = 1
  376.  
  377. // Game modes
  378. enum
  379. {
  380. MODE_NONE = 0,
  381. MODE_INFECTION,
  382. MODE_NEMESIS,
  383. MODE_ASSASSIN,
  384. MODE_SURVIVOR,
  385. MODE_SNIPER,
  386. MODE_SWARM,
  387. MODE_MULTI,
  388. MODE_PLAGUE,
  389. MODE_LNJ,
  390. MAX_GAME_MODES
  391. }
  392.  
  393. // ZP Teams
  394. const ZP_TEAM_NO_ONE = 0
  395. const ZP_TEAM_ANY = 0
  396. const ZP_TEAM_ZOMBIE = (1<<0) // 1
  397. const ZP_TEAM_HUMAN = (1<<1) // 2
  398. const ZP_TEAM_NEMESIS = (1<<2) // 4
  399. const ZP_TEAM_SURVIVOR = (1<<3) // 8
  400. const ZP_TEAM_SNIPER = (1<<4) // 16
  401. const ZP_TEAM_ASSASSIN = (1<<5) // 32
  402. new const ZP_TEAM_NAMES[][] =
  403. {
  404. "ZOMBIE , HUMAN",
  405. "ZOMBIE",
  406. "HUMAN",
  407. "ZOMBIE , HUMAN",
  408. "NEMESIS",
  409. "ZOMBIE , NEMESIS",
  410. "HUMAN , NEMESIS",
  411. "ZOMBIE , HUMAN , NEMESIS",
  412. "SURVIVOR",
  413. "ZOMBIE , SURVIVOR",
  414. "HUMAN , SURVIVOR",
  415. "ZOMBIE, HUMAN, SURVIVOR",
  416. "NEMESIS , SURVIVOR",
  417. "ZOMBIE , NEMESIS , SURVIVOR",
  418. "HUMAN, NEMESIS, SURVIVOR",
  419. "ZOMBIE , HUMAN , NEMESIS , SURVIVOR",
  420. "SNIPER",
  421. "ZOMBIE, SNIPER",
  422. "HUMAN, SNIPER",
  423. "ZOMBIE, HUMAN, SNIPER",
  424. "NEMESIS , SNIPER",
  425. "ZOMBIE , NEMESIS , SNIPER",
  426. "HUMAN , NEMESIS , SNIPER",
  427. "ZOMBIE , HUMAN , NEMESIS , SNIPER",
  428. "SURVIVOR, SNIPER",
  429. "ZOMBIE, SURVIVOR, SNIPER",
  430. "HUMAN, SURVIVOR, SNIPER",
  431. "ZOMBIE, HUMAN, SURVIVOR, SNIPER",
  432. "NEMESIS, SURVIVOR, SNIPER",
  433. "ZOMBIE, NEMESIS, SURVIVOR, SNIPER",
  434. "HUMAN, NEMESIS, SURVIVOR, SNIPER",
  435. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, SNIPER",
  436. "ASSASSIN",
  437. "ZOMBIE, ASSASSIN",
  438. "HUMAN, ASSASSIN",
  439. "ZOMBIE, HUMAN, ASSASSIN",
  440. "NEMESIS, ASSASSIN",
  441. "ZOMBIE, NEMESIS, ASSASSIN",
  442. "HUMAN, NEMESIS, ASSASSIN",
  443. "ZOMBIE, HUMAN, NEMESIS, ASSASSIN",
  444. "SURVIVOR, ASSASSIN",
  445. "ZOMBIE, SURVIVOR, ASSASSIN",
  446. "HUMAN, SURVIVOR, ASSASSIN",
  447. "ZOMBIE, HUMAN, SURVIVOR, ASSASSIN",
  448. "NEMESIS, SURVIVOR, ASSASSIN",
  449. "ZOMBIE, NEMESIS, SURVIVOR, ASSASSIN",
  450. "HUMAN, NEMESIS, SURVIVOR, ASSASSIN",
  451. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, ASSASSIN",
  452. "SNIPER, ASSASSIN",
  453. "ZOMBIE, SNIPER, ASSASSIN",
  454. "HUMAN, SNIPER, ASSASSIN",
  455. "ZOMBIE, HUMAN, SNIPER, ASSASSIN",
  456. "NEMESIS, SNIPER, ASSASSIN",
  457. "ZOMBIE, NEMESIS, SNIPER, ASSASSIN",
  458. "HUMAN, NEMESIS, SNIPER, ASSASSIN",
  459. "ZOMBIE, HUMAN, NEMESIS, SNIPER, ASSASSIN",
  460. "SURVIVOR, SNIPER, ASSASSIN",
  461. "ZOMBIE, SURVIVOR, SNIPER, ASSASSIN",
  462. "HUMAN, SURVIVOR, SNIPER, ASSASSIN",
  463. "ZOMBIE, HUMAN, SURVIVOR, SNIPER, ASSASSIN",
  464. "NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  465. "ZOMBIE, NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  466. "HUMAN, NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  467. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, SNIPER, ASSASSIN"
  468. }
  469.  
  470. // Zombie classes
  471. const ZCLASS_NONE = -1
  472.  
  473. // HUD messages
  474. const Float:HUD_EVENT_X = -1.0
  475. const Float:HUD_EVENT_Y = 0.17
  476. const Float:HUD_INFECT_X = 0.05
  477. const Float:HUD_INFECT_Y = 0.45
  478. const Float:HUD_SPECT_X = -1.0
  479. const Float:HUD_SPECT_Y = 0.8
  480. const Float:HUD_STATS_X = 0.02
  481. const Float:HUD_STATS_Y = 0.9
  482.  
  483. // CS Player PData Offsets (win32)
  484. const OFFSET_PAINSHOCK = 108 // ConnorMcLeod
  485. const OFFSET_CSTEAMS = 114
  486. const OFFSET_CSMONEY = 115
  487. const OFFSET_FLASHLIGHT_BATTERY = 244
  488. const OFFSET_CSDEATHS = 444
  489. const OFFSET_MODELINDEX = 491 // Orangutanz
  490.  
  491. // CS Player CBase Offsets (win32)
  492. const OFFSET_ACTIVE_ITEM = 373
  493.  
  494. // CS Weapon CBase Offsets (win32)
  495. const OFFSET_WEAPONOWNER = 41
  496.  
  497. // Linux diff's
  498. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  499. const OFFSET_LINUX_WEAPONS = 4 // weapon offsets are only 4 steps higher on Linux
  500.  
  501. // CS Teams
  502. enum
  503. {
  504. FM_CS_TEAM_UNASSIGNED = 0,
  505. FM_CS_TEAM_T,
  506. FM_CS_TEAM_CT,
  507. FM_CS_TEAM_SPECTATOR
  508. }
  509. new const CS_TEAM_NAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
  510.  
  511. // Some constants
  512. const HIDE_MONEY = (1<<5)
  513. const UNIT_SECOND = (1<<12)
  514. const DMG_HEGRENADE = (1<<24)
  515. const IMPULSE_FLASHLIGHT = 100
  516. const USE_USING = 2
  517. const USE_STOPPED = 0
  518. const STEPTIME_SILENT = 999
  519. const BREAK_GLASS = 0x01
  520. const FFADE_IN = 0x0000
  521. const FFADE_STAYOUT = 0x0004
  522. const PEV_SPEC_TARGET = pev_iuser2
  523.  
  524. // Max BP ammo for weapons
  525. new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
  526. 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }
  527.  
  528. // Max Clip for weapons
  529. new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
  530. 10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 }
  531.  
  532. // Amount of ammo to give when buying additional clips for weapons
  533. new const BUYAMMO[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
  534. 10, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }
  535.  
  536. // Ammo IDs for weapons
  537. new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
  538. 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }
  539.  
  540. // Ammo Type Names for weapons
  541. new const AMMOTYPE[][] = { "", "357sig", "", "762nato", "", "buckshot", "", "45acp", "556nato", "", "9mm", "57mm", "45acp",
  542. "556nato", "556nato", "556nato", "45acp", "9mm", "338magnum", "9mm", "556natobox", "buckshot",
  543. "556nato", "9mm", "762nato", "", "50ae", "556nato", "762nato", "", "57mm" }
  544.  
  545. // Weapon IDs for ammo types
  546. new const AMMOWEAPON[] = { 0, CSW_AWP, CSW_SCOUT, CSW_M249, CSW_AUG, CSW_XM1014, CSW_MAC10, CSW_FIVESEVEN, CSW_DEAGLE,
  547. CSW_P228, CSW_ELITE, CSW_FLASHBANG, CSW_HEGRENADE, CSW_SMOKEGRENADE, CSW_C4 }
  548.  
  549. // Primary and Secondary Weapon Names
  550. new const WEAPONNAMES[][] = { "", "P228 Compact", "", "Schmidt Scout", "", "XM1014 M4", "", "Ingram MAC-10", "Steyr AUG A1",
  551. "", "Dual Elite Berettas", "FiveseveN", "UMP 45", "SG-550 Auto-Sniper", "IMI Galil", "Famas",
  552. "USP .45 ACP Tactical", "Glock 18C", "AWP Magnum Sniper", "MP5 Navy", "M249 Para Machinegun",
  553. "M3 Super 90", "M4A1 Carbine", "Schmidt TMP", "G3SG1 Auto-Sniper", "", "Desert Eagle .50 AE",
  554. "SG-552 Commando", "AK-47 Kalashnikov", "", "ES P90" }
  555.  
  556. // Weapon entity names
  557. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  558. "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  559. "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  560. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  561. "weapon_ak47", "weapon_knife", "weapon_p90" }
  562.  
  563. // CS sounds
  564. new const sound_flashlight[] = "items/flashlight1.wav"
  565. new const sound_buyammo[] = "items/9mmclip1.wav"
  566. new const sound_armorhit[] = "player/bhit_helmet-1.wav"
  567.  
  568. // Explosion radius for custom grenades
  569. const Float:NADE_EXPLOSION_RADIUS = 240.0
  570.  
  571. // HACK: pev_ field used to store additional ammo on weapons
  572. const PEV_ADDITIONAL_AMMO = pev_iuser1
  573.  
  574. // HACK: pev_ field used to store custom nade types and their values
  575. const PEV_NADE_TYPE = pev_flTimeStepSound
  576. const NADE_TYPE_INFECTION = 1111
  577. const NADE_TYPE_NAPALM = 2222
  578. const NADE_TYPE_FROST = 3333
  579. const NADE_TYPE_FLARE = 4444
  580. const PEV_FLARE_COLOR = pev_punchangle
  581. const PEV_FLARE_DURATION = pev_flSwimTime
  582.  
  583. // Weapon bitsums
  584. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  585. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  586.  
  587. // Allowed weapons for zombies (added grenades/bomb for sub-plugin support, since they shouldn't be getting them anyway)
  588. const ZOMBIE_ALLOWED_WEAPONS_BITSUM = (1<<CSW_KNIFE)|(1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_C4)
  589.  
  590. // Classnames for separate model entities
  591. new const MODEL_ENT_CLASSNAME[] = "player_model"
  592. new const WEAPON_ENT_CLASSNAME[] = "weapon_model"
  593.  
  594. // Menu keys
  595. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  596.  
  597. // Ambience Sounds
  598. enum
  599. {
  600. AMBIENCE_SOUNDS_INFECTION = 0,
  601. AMBIENCE_SOUNDS_NEMESIS,
  602. AMBIENCE_SOUNDS_SURVIVOR,
  603. AMBIENCE_SOUNDS_SWARM,
  604. AMBIENCE_SOUNDS_LNJ,
  605. AMBIENCE_SOUNDS_PLAGUE,
  606. AMBIENCE_SOUNDS_SNIPER,
  607. AMBIENCE_SOUNDS_ASSASSIN,
  608. MAX_AMBIENCE_SOUNDS
  609. }
  610.  
  611. // Admin menu actions
  612. enum
  613. {
  614. ACTION_ZOMBIEFY_HUMANIZE = 0,
  615. ACTION_MAKE_NEMESIS,
  616. ACTION_MAKE_SURVIVOR,
  617. ACTION_MAKE_SNIPER,
  618. ACTION_MAKE_ASSASSIN,
  619. ACTION_RESPAWN_PLAYER
  620. }
  621.  
  622. // Custom forward return values
  623. const ZP_PLUGIN_HANDLED = 97
  624.  
  625. /*================================================================================
  626.  [Global Variables]
  627. =================================================================================*/
  628.  
  629. // Player vars
  630. new g_zombie[33] // is zombie
  631. new g_nemesis[33] // is nemesis
  632. new g_survivor[33] // is survivor
  633. new g_firstzombie[33] // is first zombie
  634. new g_lastzombie[33] // is last zombie
  635. new g_lasthuman[33] // is last human
  636. new g_frozen[33] // is frozen (can't move)
  637. new g_nodamage[33] // has spawn protection/zombie madness
  638. new g_respawn_as_zombie[33] // should respawn as zombie
  639. new g_nvision[33] // has night vision
  640. new g_nvisionenabled[33] // has night vision turned on
  641. new g_zombieclass[33] // zombie class
  642. new g_zombieclassnext[33] // zombie class for next infection
  643. new g_flashlight[33] // has custom flashlight turned on
  644. new g_flashbattery[33] = { 100, ... } // custom flashlight battery
  645. new g_canbuy[33] // is allowed to buy a new weapon through the menu
  646. new g_ammopacks[33] // ammo pack count
  647. new g_damagedealt[33] // damage dealt to zombies (used to calculate ammo packs reward)
  648. new Float:g_lastleaptime[33] // time leap was last used
  649. new Float:g_lastflashtime[33] // time flashlight was last toggled
  650. new g_playermodel[33][32] // current model's short name [player][model]
  651. new g_menu_data[33][5] // data for some menu handlers
  652. new g_ent_playermodel[33] // player model entity
  653. new g_ent_weaponmodel[33] // weapon model entity
  654. new g_burning_duration[33] // burning task duration
  655. new g_sniper[33] // is sniper
  656. new g_assassin[33] // is assassin
  657.  
  658. // Game vars
  659. new g_pluginenabled // ZPA enabled
  660. new g_newround // new round starting
  661. new g_endround // round ended
  662. new g_nemround // nemesis round
  663. new g_sniperround // sniper round
  664. new g_assassinround // assasin round
  665. new g_lnjround // LNJ round
  666. new g_swarmround // swarm round
  667. new g_plagueround // plague round
  668. new g_survround // survivor round
  669. new g_modestarted // mode fully started
  670. new g_allowinfection // whether infection is allowed in a game mode
  671. new g_deathmatchmode // death match mode
  672. new g_currentmode // current mode which is bieng played
  673. new g_lastmode // last played mode
  674. new g_scorezombies, g_scorehumans // team scores
  675. new g_spawnCount, g_spawnCount2 // available spawn points counter
  676. new Float:g_spawns[MAX_CSDM_SPAWNS][3], Float:g_spawns2[MAX_CSDM_SPAWNS][3] // spawn points data
  677. new g_lights_i // lightning current lights counter
  678. new g_lights_cycle[32] // current lightning cycle
  679. new g_lights_cycle_len // lightning cycle length
  680. new Float:g_models_targettime // for adding delays between Model Change messages
  681. new Float:g_teams_targettime // for adding delays between Team Change messages
  682. new g_MsgSync, g_MsgSync2 , g_MsgSync3// message sync objects
  683. new g_trailSpr, g_exploSpr, g_flameSpr, g_smokeSpr, g_glassSpr // grenade sprites
  684. new g_modname[32] // for formatting the mod name
  685. new g_freezetime // whether CS's freeze time is on
  686. new g_maxplayers // max players counter
  687. new g_czero // whether we are running on a CZ server
  688. new g_hamczbots // whether ham forwards are registered for CZ bots
  689. new g_fwSpawn, g_fwPrecacheSound // spawn and precache sound forward handles
  690. new g_infbombcounter, g_antidotecounter, g_madnesscounter // to limit buying some items
  691. new g_arrays_created // to prevent stuff from being registered before initializing arrays
  692. new g_lastplayerleaving // flag for whenever a player leaves and another takes his place
  693. new g_switchingteam // flag for whenever a player's team change emessage is sent
  694. new g_time // Used for the server shut down count
  695.  
  696. // Message IDs vars
  697. new g_msgScoreInfo, g_msgNVGToggle, g_msgScoreAttrib, g_msgAmmoPickup, g_msgScreenFade,
  698. g_msgDeathMsg, g_msgSetFOV, g_msgFlashlight, g_msgFlashBat, g_msgTeamInfo, g_msgDamage,
  699. g_msgHideWeapon, g_msgCrosshair, g_msgSayText, g_msgScreenShake, g_msgCurWeapon
  700.  
  701. // Some forward handlers
  702. new g_fwRoundStart, g_fwRoundStart_pre, g_fwRoundEnd, g_fwUserInfected_pre, g_fwUserInfected_post,
  703. g_fwUserHumanized_pre, g_fwUserHumanized_post, g_fwUserInfect_attempt,
  704. g_fwUserHumanize_attempt, g_fwExtraItemSelected, g_fwUserUnfrozen,
  705. g_fwUserLastZombie, g_fwUserLastHuman, g_fwGameModeSelected, g_fwPlayerSpawnPost, g_fwDummyResult
  706.  
  707. // Temporary Database vars (used to restore players stats in case they get disconnected)
  708. new db_name[MAX_STATS_SAVED][32] // player name
  709. new db_ammopacks[MAX_STATS_SAVED] // ammo pack count
  710. new db_zombieclass[MAX_STATS_SAVED] // zombie class
  711. new db_slot_i // additional saved slots counter (should start on maxplayers+1)
  712.  
  713. // Game Modes vars
  714. new Array:g_gamemode_name // caption
  715. new Array:g_gamemode_flag // access flag
  716. new Array:g_gamemode_chance // game modes chance
  717. new Array:g_gamemode_allow // allow infection
  718. new Array:g_gamemode_dm // death match mode
  719. new g_gamemodes_i = MAX_GAME_MODES // loaded game modes counter
  720.  
  721. // Extra Items vars
  722. new Array:g_extraitem_name // caption
  723. new Array:g_extraitem_cost // cost
  724. new Array:g_extraitem_team // team
  725. new g_extraitem_i // loaded extra items counter
  726.  
  727. // For extra items file parsing
  728. new Array:g_extraitem2_realname, Array:g_extraitem2_name, Array:g_extraitem2_cost,
  729. Array:g_extraitem2_team, Array:g_extraitem_new
  730.  
  731. // Zombie Classes vars
  732. new Array:g_zclass_name // caption
  733. new Array:g_zclass_info // description
  734. new Array:g_zclass_modelsstart // start position in models array
  735. new Array:g_zclass_modelsend // end position in models array
  736. new Array:g_zclass_playermodel // player models array
  737. new Array:g_zclass_modelindex // model indices array
  738. new Array:g_zclass_clawmodel // claw model
  739. new Array:g_zclass_hp // health
  740. new Array:g_zclass_spd // speed
  741. new Array:g_zclass_grav // gravity
  742. new Array:g_zclass_kb // knockback
  743. new g_zclass_i // loaded zombie classes counter
  744.  
  745. // For zombie classes file parsing
  746. new Array:g_zclass2_realname, Array:g_zclass2_name, Array:g_zclass2_info,
  747. Array:g_zclass2_modelsstart, Array:g_zclass2_modelsend, Array:g_zclass2_playermodel,
  748. Array:g_zclass2_modelindex, Array:g_zclass2_clawmodel, Array:g_zclass2_hp,
  749. Array:g_zclass2_spd, Array:g_zclass2_grav, Array:g_zclass2_kb, Array:g_zclass_new
  750.  
  751. // Customization vars
  752. new g_access_flag[MAX_ACCESS_FLAGS], Array:model_nemesis, Array:model_survivor, Array:model_human,
  753. Array:model_admin_zombie, Array:model_admin_human, Array:g_modelindex_human,
  754. Array:g_modelindex_nemesis, Array:g_modelindex_survivor, g_same_models_for_all,
  755. Array:g_modelindex_admin_zombie, Array:g_modelindex_admin_human, model_vknife_human[64],
  756. model_vknife_nemesis[64], model_vm249_survivor[64], model_grenade_infect[64],
  757. model_grenade_fire[64], model_grenade_frost[64], model_grenade_flare[64],
  758. model_vknife_admin_human[64], model_vknife_admin_zombie[64],
  759. sprite_grenade_trail[64], sprite_grenade_ring[64], sprite_grenade_fire[64],
  760. sprite_grenade_smoke[64], sprite_grenade_glass[64], Array:sound_win_zombies,
  761. Array:sound_win_humans, Array:sound_win_no_one, Array:zombie_infect, Array:zombie_idle,
  762. Array:zombie_pain, Array:nemesis_pain, Array:assassin_pain, Array:zombie_die, Array:zombie_fall,
  763. Array:zombie_miss_wall, Array:zombie_hit_normal, Array:zombie_hit_stab, g_ambience_rain,
  764. Array:zombie_idle_last, Array:zombie_madness, Array:sound_nemesis, Array:sound_survivor,
  765. Array:sound_swarm, Array:sound_multi, Array:sound_plague, Array:grenade_infect,
  766. Array:grenade_infect_player, Array:grenade_fire, Array:grenade_fire_player,
  767. Array:grenade_frost, Array:grenade_frost_player, Array:grenade_frost_break,
  768. Array:grenade_flare, Array:sound_antidote, Array:sound_thunder, g_ambience_sounds[MAX_AMBIENCE_SOUNDS],
  769. Array:sound_ambience1, Array:sound_ambience2, Array:sound_ambience3, Array:sound_ambience4,
  770. Array:sound_ambience5, Array:sound_ambience1_duration, Array:sound_ambience2_duration,
  771. Array:sound_ambience3_duration, Array:sound_ambience4_duration,
  772. Array:sound_ambience5_duration, Array:sound_ambience1_ismp3, Array:sound_ambience2_ismp3,
  773. Array:sound_ambience3_ismp3, Array:sound_ambience4_ismp3, Array:sound_ambience5_ismp3,
  774. Array:g_primary_items, Array:g_secondary_items, Array:g_additional_items,
  775. Array:g_primary_weaponids, Array:g_secondary_weaponids, Array:g_extraweapon_names,
  776. Array:g_extraweapon_items, Array:g_extraweapon_costs, g_extra_costs2[EXTRA_WEAPONS_STARTID],
  777. g_ambience_snow, g_ambience_fog, g_fog_density[10], g_fog_color[12], g_sky_enable,
  778. Array:g_sky_names, Array:lights_thunder, Array:zombie_decals, Array:g_objective_ents,
  779. Float:g_modelchange_delay, g_set_modelindex_offset, g_handle_models_on_separate_ent,
  780. Float:kb_weapon_power[31] = { -1.0, ... }, Array:zombie_miss_slash, g_force_consistency,
  781. Array:model_sniper, Array:g_modelindex_sniper, model_vawp_sniper[64],
  782. Array:sound_sniper, Array:sound_ambience6, Array:sound_ambience6_duration,
  783. Array:sound_ambience6_ismp3,
  784. Array:model_assassin, Array:g_modelindex_assassin, model_vknife_assassin[64],
  785. Array:sound_assassin, Array:sound_ambience7, Array:sound_ambience7_duration,
  786. Array:sound_ambience7_ismp3,
  787. Array:sound_lnj, Array:sound_ambience8, Array:sound_ambience8_duration, Array:sound_ambience8_ismp3
  788.  
  789. // CVAR pointers
  790. new cvar_lighting, cvar_zombiefov, cvar_plague, cvar_plaguechance, cvar_zombiefirsthp,
  791. cvar_removemoney, cvar_thunder, cvar_zombiebonushp, cvar_nemhp, cvar_nem, cvar_surv,
  792. cvar_nemchance, cvar_deathmatch, cvar_nemglow, cvar_customnvg, cvar_hitzones, cvar_humanhp,
  793. cvar_nemgravity, cvar_flashsize, cvar_ammodamage, cvar_zombiearmor, cvar_survpainfree,
  794. cvar_nempainfree, cvar_nemspd, cvar_survchance, cvar_survhp, cvar_survspd, cvar_humanspd,
  795. cvar_swarmchance, cvar_flashdrain, cvar_zombiebleeding, cvar_removedoors, cvar_customflash,
  796. cvar_randspawn, cvar_multi, cvar_multichance, cvar_infammo, cvar_swarm, cvar_ammoinfect,
  797. cvar_toggle, cvar_knockbackpower, cvar_freezeduration, cvar_triggered, cvar_flashcharge,
  798. cvar_firegrenades, cvar_frostgrenades, cvar_survgravity, cvar_logcommands, cvar_survglow,
  799. cvar_humangravity, cvar_spawnprotection, cvar_nvgsize, cvar_flareduration, cvar_zclasses,
  800. cvar_extraitems, cvar_showactivity, cvar_humanlasthp, cvar_nemignorefrags, cvar_warmup,
  801. cvar_flashdist, cvar_flarecolor, cvar_survignorefrags, cvar_fireduration, cvar_firedamage,
  802. cvar_flaregrenades, cvar_knockbackducking, cvar_knockbackdamage, cvar_knockbackzvel,
  803. cvar_multiratio, cvar_flaresize, cvar_spawndelay, cvar_extraantidote, cvar_extramadness,
  804. cvar_extraweapons, cvar_extranvision, cvar_nvggive, cvar_preventconsecutive, cvar_botquota,
  805. cvar_buycustom, cvar_zombiepainfree, cvar_fireslowdown, cvar_survbasehp, cvar_survaura,
  806. cvar_nemignoreammo, cvar_survignoreammo, cvar_nemaura, cvar_extrainfbomb, cvar_knockback,
  807. cvar_fragsinfect, cvar_fragskill, cvar_humanarmor, cvar_zombiesilent, cvar_removedropped,
  808. cvar_plagueratio, cvar_blocksuicide, cvar_knockbackdist, cvar_nemdamage, cvar_leapzombies,
  809. cvar_leapzombiesforce, cvar_leapzombiesheight, cvar_leapzombiescooldown, cvar_leapnemesis,
  810. cvar_leapnemesisforce, cvar_leapnemesisheight, cvar_leapnemesiscooldown, cvar_leapsurvivor,
  811. cvar_leapsurvivorforce, cvar_leapsurvivorheight, cvar_nemminplayers, cvar_survminplayers,
  812. cvar_respawnonsuicide, cvar_respawnafterlast, cvar_leapsurvivorcooldown, cvar_statssave,
  813. cvar_swarmminplayers, cvar_multiminplayers, cvar_plagueminplayers, cvar_adminmodelshuman,
  814. cvar_adminmodelszombie, cvar_nembasehp, cvar_blockpushables, cvar_respawnworldspawnkill,
  815. cvar_madnessduration, cvar_plaguenemnum, cvar_plaguenemhpmulti, cvar_plaguesurvhpmulti,
  816. cvar_survweapon, cvar_plaguesurvnum, cvar_infectionscreenfade, cvar_infectionscreenshake,
  817. cvar_infectionsparkle, cvar_infectiontracers, cvar_infectionparticles, cvar_infbomblimit,
  818. cvar_allowrespawnsurv, cvar_flashshowall, cvar_allowrespawninfection, cvar_allowrespawnnem,
  819. cvar_allowrespawnswarm, cvar_allowrespawnplague, cvar_survinfammo, cvar_nemknockback,
  820. cvar_hudicons, cvar_respawnzomb, cvar_respawnhum, cvar_respawnnem, cvar_respawnsurv,
  821. cvar_startammopacks, cvar_randweapons, cvar_antidotelimit, cvar_madnesslimit,
  822. cvar_adminknifemodelshuman, cvar_adminknifemodelszombie, cvar_keephealthondisconnect,
  823. cvar_sniper, cvar_sniperchance, cvar_sniperminplayers, cvar_sniperdamage, cvar_sniperhp,
  824. cvar_sniperglow, cvar_sniperbasehp, cvar_sniperpainfree, cvar_sniperinfammo, cvar_sniperspd,
  825. cvar_respawnsniper, cvar_snipergravity, cvar_sniperaura, cvar_sniperfraggore, cvar_nemfraggore,
  826. cvar_sniperignorefrags, cvar_sniperignoreammo, cvar_allowrespawnsniper,cvar_surv_aura_radius ,
  827. cvar_leapsniper, cvar_leapsniperforce, cvar_leapsniperheight, cvar_leapsnipercooldown, cvar_sniperauraradius,
  828. cvar_respawnassassin ,cvar_allowrespawnassassin,cvar_assassin,cvar_assassinchance ,cvar_assassinminplayers ,
  829. cvar_assassinhp , cvar_assassinbasehp ,cvar_assassinspd ,cvar_assassingravity ,cvar_assassindamage ,cvar_assassinknockback ,
  830. cvar_assassinglow ,cvar_assassinaura ,cvar_assassinpainfree ,cvar_assassinignorefrags , cvar_assassinignoreammo,
  831. cvar_leapassassin, cvar_leapassassinforce, cvar_leapassassinheight, cvar_leapassassincooldown, cvar_flaresize2, cvar_humansurvive,
  832. cvar_lnj, cvar_lnjchance, cvar_lnjminplayers, cvar_lnjnemhpmulti, cvar_lnjsurvhpmulti, cvar_allowrespawnlnj,
  833. cvar_lnjratio, cvar_lnjrespsurv, cvar_lnjrespnem , cvar_flashsize2, cvar_frozenhit, cvar_aiminfo, cvar_nemauraradius
  834.  
  835. // CVARS with arrays
  836. new cvar_nvgcolor[3], cvar_nemnvgcolor[3], cvar_humnvgcolor[3], cvar_flashcolor[3],
  837. cvar_snipercolor[3], cvar_surv_aura[3],cvar_assassinnvgcolor[3], cvar_flashcolor2[3]
  838.  
  839. // Cached stuff for players
  840. new g_isconnected[33] // whether player is connected
  841. new g_isalive[33] // whether player is alive
  842. new g_isbot[33] // whether player is a bot
  843. new g_currentweapon[33] // player's current weapon id
  844. new g_playername[33][32] // player's name
  845. new Float:g_zombie_spd[33] // zombie class speed
  846. new Float:g_zombie_knockback[33] // zombie class knockback
  847. new g_zombie_classname[33][32] // zombie class name
  848. #define is_user_valid_connected(%1) (1 <= %1 <= g_maxplayers && g_isconnected[%1])
  849. #define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && g_isalive[%1])
  850.  
  851. // Cached CVARs
  852. new g_cached_customflash, g_cached_zombiesilent, Float:g_cached_humanspd, Float:g_cached_nemspd,
  853. Float:g_cached_survspd, g_cached_leapzombies, Float:g_cached_leapzombiescooldown, g_cached_leapnemesis,
  854. Float:g_cached_leapnemesiscooldown, g_cached_leapsurvivor, Float:g_cached_leapsurvivorcooldown,
  855. Float:g_cached_sniperspd, g_cached_leapsniper, Float:g_cached_leapsnipercooldown,
  856. Float:g_cached_assassinspd, g_cached_leapassassin, Float:g_cached_leapassassincooldown
  857.  
  858. /*================================================================================
  859.  [Natives, Precache and Init]
  860. =================================================================================*/
  861.  
  862. public plugin_natives()
  863. {
  864. // Player specific natives
  865. register_native("zp_get_user_zombie", "native_get_user_zombie", 1)
  866. register_native("zp_get_user_nemesis", "native_get_user_nemesis", 1)
  867. register_native("zp_get_user_survivor", "native_get_user_survivor", 1)
  868. register_native("zp_get_user_first_zombie", "native_get_user_first_zombie", 1)
  869. register_native("zp_get_user_last_zombie", "native_get_user_last_zombie", 1)
  870. register_native("zp_get_user_last_human", "native_get_user_last_human", 1)
  871. register_native("zp_get_user_zombie_class", "native_get_user_zombie_class", 1)
  872. register_native("zp_get_user_next_class", "native_get_user_next_class", 1)
  873. register_native("zp_set_user_zombie_class", "native_set_user_zombie_class", 1)
  874. register_native("zp_get_user_ammo_packs", "native_get_user_ammo_packs", 1)
  875. register_native("zp_set_user_ammo_packs", "native_set_user_ammo_packs", 1)
  876. register_native("zp_get_zombie_maxhealth", "native_get_zombie_maxhealth", 1)
  877. register_native("zp_get_user_batteries", "native_get_user_batteries", 1)
  878. register_native("zp_set_user_batteries", "native_set_user_batteries", 1)
  879. register_native("zp_get_user_nightvision", "native_get_user_nightvision", 1)
  880. register_native("zp_set_user_nightvision", "native_set_user_nightvision", 1)
  881. register_native("zp_infect_user", "native_infect_user", 1)
  882. register_native("zp_disinfect_user", "native_disinfect_user", 1)
  883. register_native("zp_make_user_nemesis", "native_make_user_nemesis", 1)
  884. register_native("zp_make_user_survivor", "native_make_user_survivor", 1)
  885. register_native("zp_respawn_user", "native_respawn_user", 1)
  886. register_native("zp_force_buy_extra_item", "native_force_buy_extra_item", 1)
  887. register_native("zp_get_user_sniper", "native_get_user_sniper", 1)
  888. register_native("zp_make_user_sniper", "native_make_user_sniper", 1)
  889. register_native("zp_get_user_assassin", "native_get_user_assassin", 1)
  890. register_native("zp_make_user_assassin", "native_make_user_assassin", 1)
  891. register_native("zp_get_user_model", "native_get_user_model", 0)
  892. register_native("zp_set_user_model", "native_set_user_model", 1)
  893.  
  894. // Round natives
  895. register_native("zp_has_round_started", "native_has_round_started", 1)
  896. register_native("zp_is_nemesis_round", "native_is_nemesis_round", 1)
  897. register_native("zp_is_survivor_round", "native_is_survivor_round", 1)
  898. register_native("zp_is_swarm_round", "native_is_swarm_round", 1)
  899. register_native("zp_is_plague_round", "native_is_plague_round", 1)
  900. register_native("zp_get_zombie_count", "native_get_zombie_count", 1)
  901. register_native("zp_get_human_count", "native_get_human_count", 1)
  902. register_native("zp_get_nemesis_count", "native_get_nemesis_count", 1)
  903. register_native("zp_get_survivor_count", "native_get_survivor_count", 1)
  904. register_native("zp_is_sniper_round", "native_is_sniper_round", 1)
  905. register_native("zp_get_sniper_count", "native_get_sniper_count", 1)
  906. register_native("zp_is_assassin_round", "native_is_assassin_round", 1)
  907. register_native("zp_get_assassin_count", "native_get_assassin_count", 1)
  908. register_native("zp_is_lnj_round", "native_is_lnj_round", 1)
  909. register_native("zp_get_current_mode", "native_get_current_mode", 1)
  910.  
  911. // External additions natives
  912. register_native("zp_register_game_mode", "native_register_game_mode", 1)
  913. register_native("zp_register_extra_item", "native_register_extra_item", 1)
  914. register_native("zp_register_zombie_class", "native_register_zombie_class", 1)
  915. register_native("zp_get_extra_item_id", "native_get_extra_item_id", 1)
  916. register_native("zp_get_zombie_class_id", "native_get_zombie_class_id", 1)
  917. }
  918.  
  919. public plugin_precache()
  920. {
  921. // Register earlier to show up in plugins list properly after plugin disable/error at loading
  922. register_plugin("Zombie Plague Advance", "1.6.1", "MeRcyLeZZ, @bdul! ,93()|29!/<")
  923.  
  924. // To switch plugin on/off
  925. register_concmd("zp_toggle", "cmd_toggle", _, "<1/0> - Zombie Plague mod ki/bekapcsola (automata map start)", 0)
  926. cvar_toggle = register_cvar("zp_on", "1")
  927.  
  928. // Plugin disabled?
  929. if (!get_pcvar_num(cvar_toggle)) return;
  930. g_pluginenabled = true
  931.  
  932. // Initialize a few dynamically sized arrays (alright, maybe more than just a few...)
  933. model_human = ArrayCreate(32, 1)
  934. model_nemesis = ArrayCreate(32, 1)
  935. model_survivor = ArrayCreate(32, 1)
  936. model_admin_human = ArrayCreate(32, 1)
  937. model_admin_zombie = ArrayCreate(32, 1)
  938. g_modelindex_human = ArrayCreate(1, 1)
  939. g_modelindex_nemesis = ArrayCreate(1, 1)
  940. g_modelindex_survivor = ArrayCreate(1, 1)
  941. g_modelindex_admin_human = ArrayCreate(1, 1)
  942. g_modelindex_admin_zombie = ArrayCreate(1, 1)
  943. sound_win_zombies = ArrayCreate(64, 1)
  944. sound_win_humans = ArrayCreate(64, 1)
  945. sound_win_no_one = ArrayCreate(64, 1)
  946. zombie_infect = ArrayCreate(64, 1)
  947. zombie_pain = ArrayCreate(64, 1)
  948. nemesis_pain = ArrayCreate(64, 1)
  949. assassin_pain = ArrayCreate(64, 1)
  950. zombie_die = ArrayCreate(64, 1)
  951. zombie_fall = ArrayCreate(64, 1)
  952. zombie_miss_slash = ArrayCreate(64, 1)
  953. zombie_miss_wall = ArrayCreate(64, 1)
  954. zombie_hit_normal = ArrayCreate(64, 1)
  955. zombie_hit_stab = ArrayCreate(64, 1)
  956. zombie_idle = ArrayCreate(64, 1)
  957. zombie_idle_last = ArrayCreate(64, 1)
  958. zombie_madness = ArrayCreate(64, 1)
  959. sound_nemesis = ArrayCreate(64, 1)
  960. sound_survivor = ArrayCreate(64, 1)
  961. sound_swarm = ArrayCreate(64, 1)
  962. sound_multi = ArrayCreate(64, 1)
  963. sound_plague = ArrayCreate(64, 1)
  964. grenade_infect = ArrayCreate(64, 1)
  965. grenade_infect_player = ArrayCreate(64, 1)
  966. grenade_fire = ArrayCreate(64, 1)
  967. grenade_fire_player = ArrayCreate(64, 1)
  968. grenade_frost = ArrayCreate(64, 1)
  969. grenade_frost_player = ArrayCreate(64, 1)
  970. grenade_frost_break = ArrayCreate(64, 1)
  971. grenade_flare = ArrayCreate(64, 1)
  972. sound_antidote = ArrayCreate(64, 1)
  973. sound_thunder = ArrayCreate(64, 1)
  974. sound_ambience1 = ArrayCreate(64, 1)
  975. sound_ambience2 = ArrayCreate(64, 1)
  976. sound_ambience3 = ArrayCreate(64, 1)
  977. sound_ambience4 = ArrayCreate(64, 1)
  978. sound_ambience5 = ArrayCreate(64, 1)
  979. sound_ambience1_duration = ArrayCreate(1, 1)
  980. sound_ambience2_duration = ArrayCreate(1, 1)
  981. sound_ambience3_duration = ArrayCreate(1, 1)
  982. sound_ambience4_duration = ArrayCreate(1, 1)
  983. sound_ambience5_duration = ArrayCreate(1, 1)
  984. sound_ambience1_ismp3 = ArrayCreate(1, 1)
  985. sound_ambience2_ismp3 = ArrayCreate(1, 1)
  986. sound_ambience3_ismp3 = ArrayCreate(1, 1)
  987. sound_ambience4_ismp3 = ArrayCreate(1, 1)
  988. sound_ambience5_ismp3 = ArrayCreate(1, 1)
  989. g_primary_items = ArrayCreate(32, 1)
  990. g_secondary_items = ArrayCreate(32, 1)
  991. g_additional_items = ArrayCreate(32, 1)
  992. g_primary_weaponids = ArrayCreate(1, 1)
  993. g_secondary_weaponids = ArrayCreate(1, 1)
  994. g_extraweapon_names = ArrayCreate(32, 1)
  995. g_extraweapon_items = ArrayCreate(32, 1)
  996. g_extraweapon_costs = ArrayCreate(1, 1)
  997. g_sky_names = ArrayCreate(32, 1)
  998. lights_thunder = ArrayCreate(32, 1)
  999. zombie_decals = ArrayCreate(1, 1)
  1000. g_objective_ents = ArrayCreate(32, 1)
  1001. g_gamemode_name = ArrayCreate(32, 1)
  1002. g_gamemode_flag = ArrayCreate(1, 1)
  1003. g_gamemode_chance = ArrayCreate(1, 1)
  1004. g_gamemode_allow = ArrayCreate(1, 1)
  1005. g_gamemode_dm = ArrayCreate(1, 1)
  1006. g_extraitem_name = ArrayCreate(32, 1)
  1007. g_extraitem_cost = ArrayCreate(1, 1)
  1008. g_extraitem_team = ArrayCreate(1, 1)
  1009. g_extraitem2_realname = ArrayCreate(32, 1)
  1010. g_extraitem2_name = ArrayCreate(32, 1)
  1011. g_extraitem2_cost = ArrayCreate(1, 1)
  1012. g_extraitem2_team = ArrayCreate(1, 1)
  1013. g_extraitem_new = ArrayCreate(1, 1)
  1014. g_zclass_name = ArrayCreate(32, 1)
  1015. g_zclass_info = ArrayCreate(32, 1)
  1016. g_zclass_modelsstart = ArrayCreate(1, 1)
  1017. g_zclass_modelsend = ArrayCreate(1, 1)
  1018. g_zclass_playermodel = ArrayCreate(32, 1)
  1019. g_zclass_modelindex = ArrayCreate(1, 1)
  1020. g_zclass_clawmodel = ArrayCreate(32, 1)
  1021. g_zclass_hp = ArrayCreate(1, 1)
  1022. g_zclass_spd = ArrayCreate(1, 1)
  1023. g_zclass_grav = ArrayCreate(1, 1)
  1024. g_zclass_kb = ArrayCreate(1, 1)
  1025. g_zclass2_realname = ArrayCreate(32, 1)
  1026. g_zclass2_name = ArrayCreate(32, 1)
  1027. g_zclass2_info = ArrayCreate(32, 1)
  1028. g_zclass2_modelsstart = ArrayCreate(1, 1)
  1029. g_zclass2_modelsend = ArrayCreate(1, 1)
  1030. g_zclass2_playermodel = ArrayCreate(32, 1)
  1031. g_zclass2_modelindex = ArrayCreate(1, 1)
  1032. g_zclass2_clawmodel = ArrayCreate(32, 1)
  1033. g_zclass2_hp = ArrayCreate(1, 1)
  1034. g_zclass2_spd = ArrayCreate(1, 1)
  1035. g_zclass2_grav = ArrayCreate(1, 1)
  1036. g_zclass2_kb = ArrayCreate(1, 1)
  1037. g_zclass_new = ArrayCreate(1, 1)
  1038. model_sniper = ArrayCreate(32, 1)
  1039. g_modelindex_sniper = ArrayCreate(1, 1)
  1040. sound_sniper = ArrayCreate(64, 1)
  1041. sound_ambience6 = ArrayCreate(64, 1)
  1042. sound_ambience6_duration = ArrayCreate(1, 1)
  1043. sound_ambience6_ismp3 = ArrayCreate(1, 1)
  1044. sound_lnj = ArrayCreate(64, 1)
  1045. sound_ambience8 = ArrayCreate(64, 1)
  1046. sound_ambience8_duration = ArrayCreate(1, 1)
  1047. sound_ambience8_ismp3 = ArrayCreate(1, 1)
  1048. model_assassin = ArrayCreate(32, 1)
  1049. g_modelindex_assassin = ArrayCreate(1, 1)
  1050. sound_assassin = ArrayCreate(64, 1)
  1051. sound_ambience7 = ArrayCreate(64, 1)
  1052. sound_ambience7_duration = ArrayCreate(1, 1)
  1053. sound_ambience7_ismp3 = ArrayCreate(1, 1)
  1054.  
  1055. // Allow registering stuff now
  1056. g_arrays_created = true
  1057.  
  1058. // Load customization data
  1059. load_customization_from_files()
  1060.  
  1061. new i, buffer[100]
  1062.  
  1063. // Load up the hard coded extra items
  1064. native_register_extra_item2("NightVision", g_extra_costs2[EXTRA_NVISION], ZP_TEAM_HUMAN)
  1065. native_register_extra_item2("T-Virus Antidote", g_extra_costs2[EXTRA_ANTIDOTE], ZP_TEAM_ZOMBIE)
  1066. native_register_extra_item2("Zombie Madness", g_extra_costs2[EXTRA_MADNESS], ZP_TEAM_ZOMBIE)
  1067. native_register_extra_item2("Infection Bomb", g_extra_costs2[EXTRA_INFBOMB], ZP_TEAM_ZOMBIE)
  1068.  
  1069. // Extra weapons
  1070. for (i = 0; i < ArraySize(g_extraweapon_names); i++)
  1071. {
  1072. ArrayGetString(g_extraweapon_names, i, buffer, charsmax(buffer))
  1073. native_register_extra_item2(buffer, ArrayGetCell(g_extraweapon_costs, i), ZP_TEAM_HUMAN)
  1074. }
  1075.  
  1076. // Custom player models
  1077. for (i = 0; i < ArraySize(model_human); i++)
  1078. {
  1079. ArrayGetString(model_human, i, buffer, charsmax(buffer))
  1080. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1081. ArrayPushCell(g_modelindex_human, engfunc(EngFunc_PrecacheModel, buffer))
  1082. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1083. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1084. }
  1085. for (i = 0; i < ArraySize(model_nemesis); i++)
  1086. {
  1087. ArrayGetString(model_nemesis, i, buffer, charsmax(buffer))
  1088. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1089. ArrayPushCell(g_modelindex_nemesis, engfunc(EngFunc_PrecacheModel, buffer))
  1090. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1091. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1092. }
  1093. for (i = 0; i < ArraySize(model_survivor); i++)
  1094. {
  1095. ArrayGetString(model_survivor, i, buffer, charsmax(buffer))
  1096. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1097. ArrayPushCell(g_modelindex_survivor, engfunc(EngFunc_PrecacheModel, buffer))
  1098. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1099. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1100. }
  1101. for (i = 0; i < ArraySize(model_admin_zombie); i++)
  1102. {
  1103. ArrayGetString(model_admin_zombie, i, buffer, charsmax(buffer))
  1104. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1105. ArrayPushCell(g_modelindex_admin_zombie, engfunc(EngFunc_PrecacheModel, buffer))
  1106. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1107. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1108. }
  1109. for (i = 0; i < ArraySize(model_admin_human); i++)
  1110. {
  1111. ArrayGetString(model_admin_human, i, buffer, charsmax(buffer))
  1112. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1113. ArrayPushCell(g_modelindex_admin_human, engfunc(EngFunc_PrecacheModel, buffer))
  1114. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1115. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1116. }
  1117. for (i = 0; i < ArraySize(model_sniper); i++)
  1118. {
  1119. ArrayGetString(model_sniper, i, buffer, charsmax(buffer))
  1120. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1121. ArrayPushCell(g_modelindex_sniper, engfunc(EngFunc_PrecacheModel, buffer))
  1122. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1123. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1124. }
  1125. for (i = 0; i < ArraySize(model_assassin); i++)
  1126. {
  1127. ArrayGetString(model_assassin, i, buffer, charsmax(buffer))
  1128. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1129. ArrayPushCell(g_modelindex_assassin, engfunc(EngFunc_PrecacheModel, buffer))
  1130. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1131. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1132. }
  1133.  
  1134. // Custom weapon models
  1135. engfunc(EngFunc_PrecacheModel, model_vknife_human)
  1136. engfunc(EngFunc_PrecacheModel, model_vknife_nemesis)
  1137. engfunc(EngFunc_PrecacheModel, model_vm249_survivor)
  1138. engfunc(EngFunc_PrecacheModel, model_grenade_infect)
  1139. engfunc(EngFunc_PrecacheModel, model_grenade_fire)
  1140. engfunc(EngFunc_PrecacheModel, model_grenade_frost)
  1141. engfunc(EngFunc_PrecacheModel, model_grenade_flare)
  1142. engfunc(EngFunc_PrecacheModel, model_vknife_admin_human)
  1143. engfunc(EngFunc_PrecacheModel, model_vknife_admin_zombie)
  1144. engfunc(EngFunc_PrecacheModel, model_vawp_sniper)
  1145. engfunc(EngFunc_PrecacheModel, model_vknife_assassin)
  1146.  
  1147. // Custom sprites for grenades
  1148. g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
  1149. g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
  1150. g_flameSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_fire)
  1151. g_smokeSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_smoke)
  1152. g_glassSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_glass)
  1153.  
  1154. // Custom sounds
  1155. for (i = 0; i < ArraySize(sound_win_zombies); i++)
  1156. {
  1157. ArrayGetString(sound_win_zombies, i, buffer, charsmax(buffer))
  1158. engfunc(EngFunc_PrecacheSound, buffer)
  1159. }
  1160. for (i = 0; i < ArraySize(sound_win_humans); i++)
  1161. {
  1162. ArrayGetString(sound_win_humans, i, buffer, charsmax(buffer))
  1163. engfunc(EngFunc_PrecacheSound, buffer)
  1164. }
  1165. for (i = 0; i < ArraySize(sound_win_no_one); i++)
  1166. {
  1167. ArrayGetString(sound_win_no_one, i, buffer, charsmax(buffer))
  1168. engfunc(EngFunc_PrecacheSound, buffer)
  1169. }
  1170. for (i = 0; i < ArraySize(zombie_infect); i++)
  1171. {
  1172. ArrayGetString(zombie_infect, i, buffer, charsmax(buffer))
  1173. engfunc(EngFunc_PrecacheSound, buffer)
  1174. }
  1175. for (i = 0; i < ArraySize(zombie_pain); i++)
  1176. {
  1177. ArrayGetString(zombie_pain, i, buffer, charsmax(buffer))
  1178. engfunc(EngFunc_PrecacheSound, buffer)
  1179. }
  1180. for (i = 0; i < ArraySize(nemesis_pain); i++)
  1181. {
  1182. ArrayGetString(nemesis_pain, i, buffer, charsmax(buffer))
  1183. engfunc(EngFunc_PrecacheSound, buffer)
  1184. }
  1185. for (i = 0; i < ArraySize(assassin_pain); i++)
  1186. {
  1187. ArrayGetString(assassin_pain, i, buffer, charsmax(buffer))
  1188. engfunc(EngFunc_PrecacheSound, buffer)
  1189. }
  1190. for (i = 0; i < ArraySize(zombie_die); i++)
  1191. {
  1192. ArrayGetString(zombie_die, i, buffer, charsmax(buffer))
  1193. engfunc(EngFunc_PrecacheSound, buffer)
  1194. }
  1195. for (i = 0; i < ArraySize(zombie_fall); i++)
  1196. {
  1197. ArrayGetString(zombie_fall, i, buffer, charsmax(buffer))
  1198. engfunc(EngFunc_PrecacheSound, buffer)
  1199. }
  1200. for (i = 0; i < ArraySize(zombie_miss_slash); i++)
  1201. {
  1202. ArrayGetString(zombie_miss_slash, i, buffer, charsmax(buffer))
  1203. engfunc(EngFunc_PrecacheSound, buffer)
  1204. }
  1205. for (i = 0; i < ArraySize(zombie_miss_wall); i++)
  1206. {
  1207. ArrayGetString(zombie_miss_wall, i, buffer, charsmax(buffer))
  1208. engfunc(EngFunc_PrecacheSound, buffer)
  1209. }
  1210. for (i = 0; i < ArraySize(zombie_hit_normal); i++)
  1211. {
  1212. ArrayGetString(zombie_hit_normal, i, buffer, charsmax(buffer))
  1213. engfunc(EngFunc_PrecacheSound, buffer)
  1214. }
  1215. for (i = 0; i < ArraySize(zombie_hit_stab); i++)
  1216. {
  1217. ArrayGetString(zombie_hit_stab, i, buffer, charsmax(buffer))
  1218. engfunc(EngFunc_PrecacheSound, buffer)
  1219. }
  1220. for (i = 0; i < ArraySize(zombie_idle); i++)
  1221. {
  1222. ArrayGetString(zombie_idle, i, buffer, charsmax(buffer))
  1223. engfunc(EngFunc_PrecacheSound, buffer)
  1224. }
  1225. for (i = 0; i < ArraySize(zombie_idle_last); i++)
  1226. {
  1227. ArrayGetString(zombie_idle_last, i, buffer, charsmax(buffer))
  1228. engfunc(EngFunc_PrecacheSound, buffer)
  1229. }
  1230. for (i = 0; i < ArraySize(zombie_madness); i++)
  1231. {
  1232. ArrayGetString(zombie_madness, i, buffer, charsmax(buffer))
  1233. engfunc(EngFunc_PrecacheSound, buffer)
  1234. }
  1235. for (i = 0; i < ArraySize(sound_nemesis); i++)
  1236. {
  1237. ArrayGetString(sound_nemesis, i, buffer, charsmax(buffer))
  1238. engfunc(EngFunc_PrecacheSound, buffer)
  1239. }
  1240. for (i = 0; i < ArraySize(sound_survivor); i++)
  1241. {
  1242. ArrayGetString(sound_survivor, i, buffer, charsmax(buffer))
  1243. engfunc(EngFunc_PrecacheSound, buffer)
  1244. }
  1245. for (i = 0; i < ArraySize(sound_swarm); i++)
  1246. {
  1247. ArrayGetString(sound_swarm, i, buffer, charsmax(buffer))
  1248. engfunc(EngFunc_PrecacheSound, buffer)
  1249. }
  1250. for (i = 0; i < ArraySize(sound_multi); i++)
  1251. {
  1252. ArrayGetString(sound_multi, i, buffer, charsmax(buffer))
  1253. engfunc(EngFunc_PrecacheSound, buffer)
  1254. }
  1255. for (i = 0; i < ArraySize(sound_plague); i++)
  1256. {
  1257. ArrayGetString(sound_plague, i, buffer, charsmax(buffer))
  1258. engfunc(EngFunc_PrecacheSound, buffer)
  1259. }
  1260. for (i = 0; i < ArraySize(grenade_infect); i++)
  1261. {
  1262. ArrayGetString(grenade_infect, i, buffer, charsmax(buffer))
  1263. engfunc(EngFunc_PrecacheSound, buffer)
  1264. }
  1265. for (i = 0; i < ArraySize(grenade_infect_player); i++)
  1266. {
  1267. ArrayGetString(grenade_infect_player, i, buffer, charsmax(buffer))
  1268. engfunc(EngFunc_PrecacheSound, buffer)
  1269. }
  1270. for (i = 0; i < ArraySize(grenade_fire); i++)
  1271. {
  1272. ArrayGetString(grenade_fire, i, buffer, charsmax(buffer))
  1273. engfunc(EngFunc_PrecacheSound, buffer)
  1274. }
  1275. for (i = 0; i < ArraySize(grenade_fire_player); i++)
  1276. {
  1277. ArrayGetString(grenade_fire_player, i, buffer, charsmax(buffer))
  1278. engfunc(EngFunc_PrecacheSound, buffer)
  1279. }
  1280. for (i = 0; i < ArraySize(grenade_frost); i++)
  1281. {
  1282. ArrayGetString(grenade_frost, i, buffer, charsmax(buffer))
  1283. engfunc(EngFunc_PrecacheSound, buffer)
  1284. }
  1285. for (i = 0; i < ArraySize(grenade_frost_player); i++)
  1286. {
  1287. ArrayGetString(grenade_frost_player, i, buffer, charsmax(buffer))
  1288. engfunc(EngFunc_PrecacheSound, buffer)
  1289. }
  1290. for (i = 0; i < ArraySize(grenade_frost_break); i++)
  1291. {
  1292. ArrayGetString(grenade_frost_break, i, buffer, charsmax(buffer))
  1293. engfunc(EngFunc_PrecacheSound, buffer)
  1294. }
  1295. for (i = 0; i < ArraySize(grenade_flare); i++)
  1296. {
  1297. ArrayGetString(grenade_flare, i, buffer, charsmax(buffer))
  1298. engfunc(EngFunc_PrecacheSound, buffer)
  1299. }
  1300. for (i = 0; i < ArraySize(sound_antidote); i++)
  1301. {
  1302. ArrayGetString(sound_antidote, i, buffer, charsmax(buffer))
  1303. engfunc(EngFunc_PrecacheSound, buffer)
  1304. }
  1305. for (i = 0; i < ArraySize(sound_thunder); i++)
  1306. {
  1307. ArrayGetString(sound_thunder, i, buffer, charsmax(buffer))
  1308. engfunc(EngFunc_PrecacheSound, buffer)
  1309. }
  1310. for (i = 0; i < ArraySize(sound_sniper); i++)
  1311. {
  1312. ArrayGetString(sound_sniper, i, buffer, charsmax(buffer))
  1313. engfunc(EngFunc_PrecacheSound, buffer)
  1314. }
  1315. for (i = 0; i < ArraySize(sound_assassin); i++)
  1316. {
  1317. ArrayGetString(sound_assassin, i, buffer, charsmax(buffer))
  1318. engfunc(EngFunc_PrecacheSound, buffer)
  1319. }
  1320. for (i = 0; i < ArraySize(sound_lnj); i++)
  1321. {
  1322. ArrayGetString(sound_lnj, i, buffer, charsmax(buffer))
  1323. engfunc(EngFunc_PrecacheSound, buffer)
  1324. }
  1325.  
  1326. // Ambience Sounds
  1327. if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION])
  1328. {
  1329. for (i = 0; i < ArraySize(sound_ambience1); i++)
  1330. {
  1331. ArrayGetString(sound_ambience1, i, buffer, charsmax(buffer))
  1332.  
  1333. if (ArrayGetCell(sound_ambience1_ismp3, i))
  1334. {
  1335. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1336. engfunc(EngFunc_PrecacheGeneric, buffer)
  1337. }
  1338. else
  1339. {
  1340. engfunc(EngFunc_PrecacheSound, buffer)
  1341. }
  1342. }
  1343. }
  1344. if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS])
  1345. {
  1346. for (i = 0; i < ArraySize(sound_ambience2); i++)
  1347. {
  1348. ArrayGetString(sound_ambience2, i, buffer, charsmax(buffer))
  1349.  
  1350. if (ArrayGetCell(sound_ambience2_ismp3, i))
  1351. {
  1352. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1353. engfunc(EngFunc_PrecacheGeneric, buffer)
  1354. }
  1355. else
  1356. {
  1357. engfunc(EngFunc_PrecacheSound, buffer)
  1358. }
  1359. }
  1360. }
  1361. if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR])
  1362. {
  1363. for (i = 0; i < ArraySize(sound_ambience3); i++)
  1364. {
  1365. ArrayGetString(sound_ambience3, i, buffer, charsmax(buffer))
  1366.  
  1367. if (ArrayGetCell(sound_ambience3_ismp3, i))
  1368. {
  1369. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1370. engfunc(EngFunc_PrecacheGeneric, buffer)
  1371. }
  1372. else
  1373. {
  1374. engfunc(EngFunc_PrecacheSound, buffer)
  1375. }
  1376. }
  1377. }
  1378. if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM])
  1379. {
  1380. for (i = 0; i < ArraySize(sound_ambience4); i++)
  1381. {
  1382. ArrayGetString(sound_ambience4, i, buffer, charsmax(buffer))
  1383.  
  1384. if (ArrayGetCell(sound_ambience4_ismp3, i))
  1385. {
  1386. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1387. engfunc(EngFunc_PrecacheGeneric, buffer)
  1388. }
  1389. else
  1390. {
  1391. engfunc(EngFunc_PrecacheSound, buffer)
  1392. }
  1393. }
  1394. }
  1395. if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE])
  1396. {
  1397. for (i = 0; i < ArraySize(sound_ambience5); i++)
  1398. {
  1399. ArrayGetString(sound_ambience5, i, buffer, charsmax(buffer))
  1400.  
  1401. if (ArrayGetCell(sound_ambience5_ismp3, i))
  1402. {
  1403. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1404. engfunc(EngFunc_PrecacheGeneric, buffer)
  1405. }
  1406. else
  1407. {
  1408. engfunc(EngFunc_PrecacheSound, buffer)
  1409. }
  1410. }
  1411. }
  1412. if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER])
  1413. {
  1414. for (i = 0; i < ArraySize(sound_ambience6); i++)
  1415. {
  1416. ArrayGetString(sound_ambience6, i, buffer, charsmax(buffer))
  1417.  
  1418. if (ArrayGetCell(sound_ambience6_ismp3, i))
  1419. {
  1420. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1421. engfunc(EngFunc_PrecacheGeneric, buffer)
  1422. }
  1423. else
  1424. {
  1425. engfunc(EngFunc_PrecacheSound, buffer)
  1426. }
  1427. }
  1428. }
  1429. if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN])
  1430. {
  1431. for (i = 0; i < ArraySize(sound_ambience7); i++)
  1432. {
  1433. ArrayGetString(sound_ambience7, i, buffer, charsmax(buffer))
  1434.  
  1435. if (ArrayGetCell(sound_ambience7_ismp3, i))
  1436. {
  1437. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1438. engfunc(EngFunc_PrecacheGeneric, buffer)
  1439. }
  1440. else
  1441. {
  1442. engfunc(EngFunc_PrecacheSound, buffer)
  1443. }
  1444. }
  1445. }
  1446. if (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ])
  1447. {
  1448. for (i = 0; i < ArraySize(sound_ambience8); i++)
  1449. {
  1450. ArrayGetString(sound_ambience8, i, buffer, charsmax(buffer))
  1451.  
  1452. if (ArrayGetCell(sound_ambience8_ismp3, i))
  1453. {
  1454. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1455. engfunc(EngFunc_PrecacheGeneric, buffer)
  1456. }
  1457. else
  1458. {
  1459. engfunc(EngFunc_PrecacheSound, buffer)
  1460. }
  1461. }
  1462. }
  1463.  
  1464. // CS sounds (just in case)
  1465. engfunc(EngFunc_PrecacheSound, sound_flashlight)
  1466. engfunc(EngFunc_PrecacheSound, sound_buyammo)
  1467. engfunc(EngFunc_PrecacheSound, sound_armorhit)
  1468.  
  1469. new ent
  1470.  
  1471. // Fake Hostage (to force round ending)
  1472. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"))
  1473. if (pev_valid(ent))
  1474. {
  1475. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0,8192.0,8192.0})
  1476. dllfunc(DLLFunc_Spawn, ent)
  1477. }
  1478.  
  1479. // Weather/ambience effects
  1480. if (g_ambience_fog)
  1481. {
  1482. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  1483. if (pev_valid(ent))
  1484. {
  1485. fm_set_kvd(ent, "density", g_fog_density, "env_fog")
  1486. fm_set_kvd(ent, "rendercolor", g_fog_color, "env_fog")
  1487. }
  1488. }
  1489. if (g_ambience_rain) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain"))
  1490. if (g_ambience_snow) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_snow"))
  1491.  
  1492. // Prevent some entities from spawning
  1493. g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  1494.  
  1495. // Prevent hostage sounds from being precached
  1496. g_fwPrecacheSound = register_forward(FM_PrecacheSound, "fw_PrecacheSound")
  1497. }
  1498.  
  1499. public plugin_init()
  1500. {
  1501. // Plugin disabled?
  1502. if (!g_pluginenabled) return;
  1503.  
  1504. // No zombie classes?
  1505. if (!g_zclass_i) set_fail_state("Nem talalhato betolteni valo zombie class, ezert a mod leall!")
  1506.  
  1507. // Print the number of registered Game Modes (if any)
  1508. if (g_gamemodes_i > MAX_GAME_MODES)
  1509. server_print("[ZP] Egyeni jatek modok szama: %d", g_gamemodes_i - MAX_GAME_MODES)
  1510.  
  1511. // Print the number of registered Zombie Classes
  1512. server_print("[ZP] Zombie osztalyok szama: %d", g_zclass_i)
  1513.  
  1514. // Print the number of registered Extra Items
  1515. server_print("[ZP] Extra cuccok szama: %d", g_extraitem_i)
  1516.  
  1517. // Language files
  1518. register_dictionary("zombie_plague_advance.txt")
  1519.  
  1520. // Events
  1521. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  1522. register_event("StatusValue", "event_show_status", "be", "1=2", "2!0")
  1523. register_event("StatusValue", "event_hide_status", "be", "1=1", "2=0")
  1524. register_logevent("logevent_round_start",2, "1=Round_Start")
  1525. register_logevent("logevent_round_end", 2, "1=Round_End")
  1526. register_event("AmmoX", "event_ammo_x", "be")
  1527. if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] || g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] || g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] || g_ambience_sounds[AMBIENCE_SOUNDS_SWARM]
  1528. || g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] || g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] || g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] || g_ambience_sounds[AMBIENCE_SOUNDS_LNJ])
  1529. register_event("30", "event_intermission", "a")
  1530.  
  1531. // HAM Forwards
  1532. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  1533. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  1534. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
  1535. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  1536. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Post", 1)
  1537. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  1538. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary")
  1539. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary")
  1540. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary")
  1541. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary")
  1542. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  1543. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  1544. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  1545. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  1546. RegisterHam(Ham_Use, "func_pushable", "fw_UsePushable")
  1547. RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  1548. RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  1549. RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  1550. RegisterHam(Ham_AddPlayerItem, "player", "fw_AddPlayerItem")
  1551. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  1552. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  1553.  
  1554. // FM Forwards
  1555. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  1556. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect_Post", 1)
  1557. register_forward(FM_ClientKill, "fw_ClientKill")
  1558. register_forward(FM_EmitSound, "fw_EmitSound")
  1559. if (!g_handle_models_on_separate_ent) register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
  1560. register_forward(FM_ClientUserInfoChanged, "fw_ClientUserInfoChanged")
  1561. register_forward(FM_GetGameDescription, "fw_GetGameDescription")
  1562. register_forward(FM_SetModel, "fw_SetModel")
  1563. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  1564. register_forward(FM_CmdStart, "fw_CmdStart")
  1565. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  1566. unregister_forward(FM_Spawn, g_fwSpawn)
  1567. unregister_forward(FM_PrecacheSound, g_fwPrecacheSound)
  1568.  
  1569. // Client commands
  1570. register_clcmd("say zpmenu", "clcmd_saymenu")
  1571. register_clcmd("say /zpmenu", "clcmd_saymenu")
  1572. register_clcmd("say unstuck", "clcmd_sayunstuck")
  1573. register_clcmd("say /unstuck", "clcmd_sayunstuck")
  1574. register_clcmd("nightvision", "clcmd_nightvision")
  1575. register_clcmd("drop", "clcmd_drop")
  1576. register_clcmd("buyammo1", "clcmd_buyammo")
  1577. register_clcmd("buyammo2", "clcmd_buyammo")
  1578. register_clcmd("chooseteam", "clcmd_changeteam")
  1579. register_clcmd("jointeam", "clcmd_changeteam")
  1580.  
  1581. // Menus
  1582. register_menu("Game Menu", KEYSMENU, "menu_game")
  1583. register_menu("Buy Menu 1", KEYSMENU, "menu_buy1")
  1584. register_menu("Buy Menu 2", KEYSMENU, "menu_buy2")
  1585. register_menu("Mod Info", KEYSMENU, "menu_info")
  1586. register_menu("Admin Menu", KEYSMENU, "menu_admin")
  1587. register_menu("Menu2 Admin", KEYSMENU, "menu2_admin")
  1588. register_menu("Menu3 Admin", KEYSMENU, "menu3_admin")
  1589. register_menu("Menu4 Admin", KEYSMENU, "menu4_admin")
  1590.  
  1591. // Admin commands
  1592. register_concmd("zp_zombie", "cmd_zombie", _, "<nev> - Jatekos Zombie-va allitasa", 0)
  1593. register_concmd("zp_human", "cmd_human", _, "<nev> - Jatekos Emberre allitasa", 0)
  1594. register_concmd("zp_nemesis", "cmd_nemesis", _, "<nev> - Jatekos Nemesis-e allitasa", 0)
  1595. register_concmd("zp_survivor", "cmd_survivor", _, "<nev> - Jatekos Tulelo-ve allitasa", 0)
  1596. register_concmd("zp_respawn", "cmd_respawn", _, "<nev> - Jatekos respawnoltatasa", 0)
  1597. register_concmd("zp_swarm", "cmd_swarm", _, " - Swarm mod inditasa", 0)
  1598. register_concmd("zp_multi", "cmd_multi", _, " - Multiple Infection mod inditasa", 0)
  1599. register_concmd("zp_plague", "cmd_plague", _, " - Plague mod inditasa", 0)
  1600. register_concmd("zp_sniper", "cmd_sniper", _, "<nev> - Jatekos Sniper-re allitasa", 0)
  1601. register_concmd("zp_assassin", "cmd_assassin", _, "<nev> - Jatekos Assasin-e allitasa", 0)
  1602. register_concmd("zp_lnj", "cmd_lnj", _, " - Start Apocalypse Mode", 0)
  1603.  
  1604. // Message IDs
  1605. g_msgScoreInfo = get_user_msgid("ScoreInfo")
  1606. g_msgTeamInfo = get_user_msgid("TeamInfo")
  1607. g_msgDeathMsg = get_user_msgid("DeathMsg")
  1608. g_msgScoreAttrib = get_user_msgid("ScoreAttrib")
  1609. g_msgSetFOV = get_user_msgid("SetFOV")
  1610. g_msgScreenFade = get_user_msgid("ScreenFade")
  1611. g_msgScreenShake = get_user_msgid("ScreenShake")
  1612. g_msgNVGToggle = get_user_msgid("NVGToggle")
  1613. g_msgFlashlight = get_user_msgid("Flashlight")
  1614. g_msgFlashBat = get_user_msgid("FlashBat")
  1615. g_msgAmmoPickup = get_user_msgid("AmmoPickup")
  1616. g_msgDamage = get_user_msgid("Damage")
  1617. g_msgHideWeapon = get_user_msgid("HideWeapon")
  1618. g_msgCrosshair = get_user_msgid("Crosshair")
  1619. g_msgSayText = get_user_msgid("SayText")
  1620. g_msgCurWeapon = get_user_msgid("CurWeapon")
  1621.  
  1622. // Message hooks
  1623. register_message(g_msgCurWeapon, "message_cur_weapon")
  1624. register_message(get_user_msgid("Money"), "message_money")
  1625. register_message(get_user_msgid("Health"), "message_health")
  1626. register_message(g_msgFlashBat, "message_flashbat")
  1627. register_message(g_msgScreenFade, "message_screenfade")
  1628. register_message(g_msgNVGToggle, "message_nvgtoggle")
  1629. if (g_handle_models_on_separate_ent) register_message(get_user_msgid("ClCorpse"), "message_clcorpse")
  1630. register_message(get_user_msgid("WeapPickup"), "message_weappickup")
  1631. register_message(g_msgAmmoPickup, "message_ammopickup")
  1632. register_message(get_user_msgid("Scenario"), "message_scenario")
  1633. register_message(get_user_msgid("HostagePos"), "message_hostagepos")
  1634. register_message(get_user_msgid("TextMsg"), "message_textmsg")
  1635. register_message(get_user_msgid("SendAudio"), "message_sendaudio")
  1636. register_message(get_user_msgid("TeamScore"), "message_teamscore")
  1637. register_message(g_msgTeamInfo, "message_teaminfo")
  1638.  
  1639. // CVARS - General Purpose
  1640. cvar_warmup = register_cvar("zp_delay", "10")
  1641. cvar_lighting = register_cvar("zp_lighting", "a")
  1642. cvar_thunder = register_cvar("zp_thunderclap", "90")
  1643. cvar_triggered = register_cvar("zp_triggered_lights", "1")
  1644. cvar_removedoors = register_cvar("zp_remove_doors", "0")
  1645. cvar_blockpushables = register_cvar("zp_blockuse_pushables", "1")
  1646. cvar_blocksuicide = register_cvar("zp_block_suicide", "1")
  1647. cvar_randspawn = register_cvar("zp_random_spawn", "1")
  1648. cvar_respawnworldspawnkill = register_cvar("zp_respawn_on_worldspawn_kill", "1")
  1649. cvar_removedropped = register_cvar("zp_remove_dropped", "0")
  1650. cvar_removemoney = register_cvar("zp_remove_money", "1")
  1651. cvar_buycustom = register_cvar("zp_buy_custom", "1")
  1652. cvar_randweapons = register_cvar("zp_random_weapons", "0")
  1653. cvar_adminmodelshuman = register_cvar("zp_admin_models_human", "1")
  1654. cvar_adminknifemodelshuman = register_cvar("zp_admin_knife_models_human", "0")
  1655. cvar_adminmodelszombie = register_cvar("zp_admin_models_zombie", "1")
  1656. cvar_adminknifemodelszombie = register_cvar("zp_admin_knife_models_zombie", "0")
  1657. cvar_zclasses = register_cvar("zp_zombie_classes", "1")
  1658. cvar_statssave = register_cvar("zp_stats_save", "1")
  1659. cvar_startammopacks = register_cvar("zp_starting_ammo_packs", "5")
  1660. cvar_preventconsecutive = register_cvar("zp_prevent_consecutive_modes", "1")
  1661. cvar_keephealthondisconnect = register_cvar("zp_keep_health_on_disconnect", "1")
  1662. cvar_humansurvive = register_cvar("zp_human_survive", "0")
  1663. cvar_aiminfo = register_cvar("zp_aim_info", "1")
  1664.  
  1665. // CVARS - Deathmatch
  1666. cvar_deathmatch = register_cvar("zp_deathmatch", "0")
  1667. cvar_spawndelay = register_cvar("zp_spawn_delay", "5")
  1668. cvar_spawnprotection = register_cvar("zp_spawn_protection", "5")
  1669. cvar_respawnonsuicide = register_cvar("zp_respawn_on_suicide", "0")
  1670. cvar_respawnafterlast = register_cvar("zp_respawn_after_last_human", "1")
  1671. cvar_allowrespawninfection = register_cvar("zp_infection_allow_respawn", "1")
  1672. cvar_allowrespawnnem = register_cvar("zp_nem_allow_respawn", "0")
  1673. cvar_allowrespawnsurv = register_cvar("zp_surv_allow_respawn", "0")
  1674. cvar_allowrespawnswarm = register_cvar("zp_swarm_allow_respawn", "0")
  1675. cvar_allowrespawnplague = register_cvar("zp_plague_allow_respawn", "0")
  1676. cvar_respawnzomb = register_cvar("zp_respawn_zombies", "1")
  1677. cvar_respawnhum = register_cvar("zp_respawn_humans", "1")
  1678. cvar_respawnnem = register_cvar("zp_respawn_nemesis", "1")
  1679. cvar_respawnsurv = register_cvar("zp_respawn_survivors", "1")
  1680. cvar_allowrespawnsniper = register_cvar("zp_sniper_allow_respawn", "0")
  1681. cvar_respawnsniper = register_cvar("zp_respawn_snipers", "1")
  1682. cvar_allowrespawnassassin = register_cvar("zp_assassin_allow_respawn", "0")
  1683. cvar_respawnassassin = register_cvar("zp_respawn_assassins", "1")
  1684. cvar_allowrespawnlnj = register_cvar("zp_lnj_allow_respawn", "0")
  1685. cvar_lnjrespsurv = register_cvar("zp_lnj_respawn_surv", "0")
  1686. cvar_lnjrespnem = register_cvar("zp_lnj_respawn_nem", "0")
  1687.  
  1688. // CVARS - Extra Items
  1689. cvar_extraitems = register_cvar("zp_extra_items", "1")
  1690. cvar_extraweapons = register_cvar("zp_extra_weapons", "1")
  1691. cvar_extranvision = register_cvar("zp_extra_nvision", "1")
  1692. cvar_extraantidote = register_cvar("zp_extra_antidote", "1")
  1693. cvar_antidotelimit = register_cvar("zp_extra_antidote_limit", "999")
  1694. cvar_extramadness = register_cvar("zp_extra_madness", "1")
  1695. cvar_madnesslimit = register_cvar("zp_extra_madness_limit", "999")
  1696. cvar_madnessduration = register_cvar("zp_extra_madness_duration", "5.0")
  1697. cvar_extrainfbomb = register_cvar("zp_extra_infbomb", "1")
  1698. cvar_infbomblimit = register_cvar("zp_extra_infbomb_limit", "999")
  1699.  
  1700. // CVARS - Flashlight and Nightvision
  1701. cvar_nvggive = register_cvar("zp_nvg_give", "1")
  1702. cvar_customnvg = register_cvar("zp_nvg_custom", "1")
  1703. cvar_nvgsize = register_cvar("zp_nvg_size", "80")
  1704. cvar_nvgcolor[0] = register_cvar("zp_nvg_color_R", "0")
  1705. cvar_nvgcolor[1] = register_cvar("zp_nvg_color_G", "150")
  1706. cvar_nvgcolor[2] = register_cvar("zp_nvg_color_B", "0")
  1707. cvar_humnvgcolor[0] = register_cvar("zp_nvg_hum_color_R", "0")
  1708. cvar_humnvgcolor[1] = register_cvar("zp_nvg_hum_color_G", "150")
  1709. cvar_humnvgcolor[2] = register_cvar("zp_nvg_hum_color_B", "0")
  1710. cvar_nemnvgcolor[0] = register_cvar("zp_nvg_nem_color_R", "150")
  1711. cvar_nemnvgcolor[1] = register_cvar("zp_nvg_nem_color_G", "0")
  1712. cvar_nemnvgcolor[2] = register_cvar("zp_nvg_nem_color_B", "0")
  1713. cvar_assassinnvgcolor[0] = register_cvar("zp_nvg_assassin_color_R", "150")
  1714. cvar_assassinnvgcolor[1] = register_cvar("zp_nvg_assassin_color_G", "70")
  1715. cvar_assassinnvgcolor[2] = register_cvar("zp_nvg_assassin_color_B", "70")
  1716. cvar_customflash = register_cvar("zp_flash_custom", "0")
  1717. cvar_flashsize = register_cvar("zp_flash_size", "10")
  1718. cvar_flashsize2 = register_cvar("zp_flash_size_assassin", "7")
  1719. cvar_flashdrain = register_cvar("zp_flash_drain", "1")
  1720. cvar_flashcharge = register_cvar("zp_flash_charge", "5")
  1721. cvar_flashdist = register_cvar("zp_flash_distance", "1000")
  1722. cvar_flashcolor[0] = register_cvar("zp_flash_color_R", "100")
  1723. cvar_flashcolor[1] = register_cvar("zp_flash_color_G", "100")
  1724. cvar_flashcolor[2] = register_cvar("zp_flash_color_B", "100")
  1725. cvar_flashcolor2[0] = register_cvar("zp_flash_color_assassin_R", "100")
  1726. cvar_flashcolor2[1] = register_cvar("zp_flash_color_assassin_G", "0")
  1727. cvar_flashcolor2[2] = register_cvar("zp_flash_color_assassin_B", "0")
  1728. cvar_flashshowall = register_cvar("zp_flash_show_all", "1")
  1729.  
  1730. // CVARS - Knockback
  1731. cvar_knockback = register_cvar("zp_knockback", "0")
  1732. cvar_knockbackdamage = register_cvar("zp_knockback_damage", "1")
  1733. cvar_knockbackpower = register_cvar("zp_knockback_power", "1")
  1734. cvar_knockbackzvel = register_cvar("zp_knockback_zvel", "0")
  1735. cvar_knockbackducking = register_cvar("zp_knockback_ducking", "0.25")
  1736. cvar_knockbackdist = register_cvar("zp_knockback_distance", "500")
  1737. cvar_nemknockback = register_cvar("zp_knockback_nemesis", "0.25")
  1738. cvar_assassinknockback = register_cvar("zp_knockback_assassin", "0.25")
  1739.  
  1740. // CVARS - Leap
  1741. cvar_leapzombies = register_cvar("zp_leap_zombies", "0")
  1742. cvar_leapzombiesforce = register_cvar("zp_leap_zombies_force", "500")
  1743. cvar_leapzombiesheight = register_cvar("zp_leap_zombies_height", "300")
  1744. cvar_leapzombiescooldown = register_cvar("zp_leap_zombies_cooldown", "5.0")
  1745. cvar_leapnemesis = register_cvar("zp_leap_nemesis", "1")
  1746. cvar_leapnemesisforce = register_cvar("zp_leap_nemesis_force", "500")
  1747. cvar_leapnemesisheight = register_cvar("zp_leap_nemesis_height", "300")
  1748. cvar_leapnemesiscooldown = register_cvar("zp_leap_nemesis_cooldown", "5.0")
  1749. cvar_leapsurvivor = register_cvar("zp_leap_survivor", "0")
  1750. cvar_leapsurvivorforce = register_cvar("zp_leap_survivor_force", "500")
  1751. cvar_leapsurvivorheight = register_cvar("zp_leap_survivor_height", "300")
  1752. cvar_leapsurvivorcooldown = register_cvar("zp_leap_survivor_cooldown", "5.0")
  1753. cvar_leapsniper = register_cvar("zp_leap_sniper", "0")
  1754. cvar_leapsniperforce = register_cvar("zp_leap_sniper_force", "500")
  1755. cvar_leapsniperheight = register_cvar("zp_leap_sniper_height", "300")
  1756. cvar_leapsnipercooldown = register_cvar("zp_leap_sniper_cooldown", "5.0")
  1757. cvar_leapassassin = register_cvar("zp_leap_assassin", "0")
  1758. cvar_leapassassinforce = register_cvar("zp_leap_assassin_force", "500")
  1759. cvar_leapassassinheight = register_cvar("zp_leap_assassin_height", "300")
  1760. cvar_leapassassincooldown = register_cvar("zp_leap_assassin_cooldown", "5.0")
  1761.  
  1762. // CVARS - Humans
  1763. cvar_humanhp = register_cvar("zp_human_health", "100")
  1764. cvar_humanlasthp = register_cvar("zp_human_last_extrahp", "0")
  1765. cvar_humanspd = register_cvar("zp_human_speed", "240")
  1766. cvar_humangravity = register_cvar("zp_human_gravity", "1.0")
  1767. cvar_humanarmor = register_cvar("zp_human_armor_protect", "1")
  1768. cvar_infammo = register_cvar("zp_human_unlimited_ammo", "0")
  1769. cvar_ammodamage = register_cvar("zp_human_damage_reward", "500")
  1770. cvar_fragskill = register_cvar("zp_human_frags_for_kill", "1")
  1771.  
  1772. // CVARS - Custom Grenades
  1773. cvar_firegrenades = register_cvar("zp_fire_grenades", "1")
  1774. cvar_fireduration = register_cvar("zp_fire_duration", "10")
  1775. cvar_firedamage = register_cvar("zp_fire_damage", "5")
  1776. cvar_fireslowdown = register_cvar("zp_fire_slowdown", "0.5")
  1777. cvar_frostgrenades = register_cvar("zp_frost_grenades", "1")
  1778. cvar_freezeduration = register_cvar("zp_frost_duration", "3")
  1779. cvar_frozenhit = register_cvar("zp_frost_hit", "1")
  1780. cvar_flaregrenades = register_cvar("zp_flare_grenades","1")
  1781. cvar_flareduration = register_cvar("zp_flare_duration", "60")
  1782. cvar_flaresize = register_cvar("zp_flare_size", "25")
  1783. cvar_flarecolor = register_cvar("zp_flare_color", "5")
  1784. cvar_flaresize2 = register_cvar("zp_flare_size_assassin", "15")
  1785.  
  1786. // CVARS - Zombies
  1787. cvar_zombiefirsthp = register_cvar("zp_zombie_first_hp", "2.0")
  1788. cvar_zombiearmor = register_cvar("zp_zombie_armor", "0.75")
  1789. cvar_hitzones = register_cvar("zp_zombie_hitzones", "0")
  1790. cvar_zombiebonushp = register_cvar("zp_zombie_infect_health", "100")
  1791. cvar_zombiefov = register_cvar("zp_zombie_fov", "110")
  1792. cvar_zombiesilent = register_cvar("zp_zombie_silent", "1")
  1793. cvar_zombiepainfree = register_cvar("zp_zombie_painfree", "2")
  1794. cvar_zombiebleeding = register_cvar("zp_zombie_bleeding", "1")
  1795. cvar_ammoinfect = register_cvar("zp_zombie_infect_reward", "1")
  1796. cvar_fragsinfect = register_cvar("zp_zombie_frags_for_infect", "1")
  1797.  
  1798. // CVARS - Special Effects
  1799. cvar_infectionscreenfade = register_cvar("zp_infection_screenfade", "1")
  1800. cvar_infectionscreenshake = register_cvar("zp_infection_screenshake", "1")
  1801. cvar_infectionsparkle = register_cvar("zp_infection_sparkle", "1")
  1802. cvar_infectiontracers = register_cvar("zp_infection_tracers", "1")
  1803. cvar_infectionparticles = register_cvar("zp_infection_particles", "1")
  1804. cvar_hudicons = register_cvar("zp_hud_icons", "1")
  1805. cvar_sniperfraggore = register_cvar("zp_sniper_frag_gore", "1")
  1806. cvar_nemfraggore = register_cvar("zp_assassin_frag_gore", "1")
  1807. cvar_nemauraradius = register_cvar("zp_zombies_aura_size", "21")
  1808.  
  1809. // CVARS - Nemesis
  1810. cvar_nem = register_cvar("zp_nem_enabled", "1")
  1811. cvar_nemchance = register_cvar("zp_nem_chance", "20")
  1812. cvar_nemminplayers = register_cvar("zp_nem_min_players", "0")
  1813. cvar_nemhp = register_cvar("zp_nem_health", "0")
  1814. cvar_nembasehp = register_cvar("zp_nem_base_health", "0")
  1815. cvar_nemspd = register_cvar("zp_nem_speed", "250")
  1816. cvar_nemgravity = register_cvar("zp_nem_gravity", "0.5")
  1817. cvar_nemdamage = register_cvar("zp_nem_damage", "250")
  1818. cvar_nemglow = register_cvar("zp_nem_glow", "1")
  1819. cvar_nemaura = register_cvar("zp_nem_aura", "1")
  1820. cvar_nempainfree = register_cvar("zp_nem_painfree", "0")
  1821. cvar_nemignorefrags = register_cvar("zp_nem_ignore_frags", "1")
  1822. cvar_nemignoreammo = register_cvar("zp_nem_ignore_rewards", "1")
  1823.  
  1824. // CVARS - Survivor
  1825. cvar_surv = register_cvar("zp_surv_enabled", "1")
  1826. cvar_survchance = register_cvar("zp_surv_chance", "20")
  1827. cvar_survminplayers = register_cvar("zp_surv_min_players", "0")
  1828. cvar_survhp = register_cvar("zp_surv_health", "0")
  1829. cvar_survbasehp = register_cvar("zp_surv_base_health", "0")
  1830. cvar_survspd = register_cvar("zp_surv_speed", "230")
  1831. cvar_survgravity = register_cvar("zp_surv_gravity", "1.25")
  1832. cvar_survglow = register_cvar("zp_surv_glow", "1")
  1833. cvar_survaura = register_cvar("zp_surv_aura", "1")
  1834. cvar_surv_aura[0] = register_cvar("zp_surv_aura_R", "200")
  1835. cvar_surv_aura[1] = register_cvar("zp_surv_aura_G", "200")
  1836. cvar_surv_aura[2] = register_cvar("zp_surv_aura_B", "200")
  1837. cvar_survpainfree = register_cvar("zp_surv_painfree", "1")
  1838. cvar_survignorefrags = register_cvar("zp_surv_ignore_frags", "1")
  1839. cvar_survignoreammo = register_cvar("zp_surv_ignore_rewards", "1")
  1840. cvar_survweapon = register_cvar("zp_surv_weapon", "weapon_m249")
  1841. cvar_survinfammo = register_cvar("zp_surv_unlimited_ammo", "2")
  1842. cvar_surv_aura_radius = register_cvar("zp_surv_aura_size", "35")
  1843.  
  1844. // CVARS - Swarm Mode
  1845. cvar_swarm = register_cvar("zp_swarm_enabled", "1")
  1846. cvar_swarmchance = register_cvar("zp_swarm_chance", "20")
  1847. cvar_swarmminplayers = register_cvar("zp_swarm_min_players", "0")
  1848.  
  1849. // CVARS - Multi Infection
  1850. cvar_multi = register_cvar("zp_multi_enabled", "1")
  1851. cvar_multichance = register_cvar("zp_multi_chance", "20")
  1852. cvar_multiminplayers = register_cvar("zp_multi_min_players", "0")
  1853. cvar_multiratio = register_cvar("zp_multi_ratio", "0.15")
  1854.  
  1855. // CVARS - Plague Mode
  1856. cvar_plague = register_cvar("zp_plague_enabled", "1")
  1857. cvar_plaguechance = register_cvar("zp_plague_chance", "30")
  1858. cvar_plagueminplayers = register_cvar("zp_plague_min_players", "0")
  1859. cvar_plagueratio = register_cvar("zp_plague_ratio", "0.5")
  1860. cvar_plaguenemnum = register_cvar("zp_plague_nem_number", "1")
  1861. cvar_plaguenemhpmulti = register_cvar("zp_plague_nem_hp_multi", "0.5")
  1862. cvar_plaguesurvnum = register_cvar("zp_plague_surv_number", "1")
  1863. cvar_plaguesurvhpmulti = register_cvar("zp_plague_surv_hp_multi", "0.5")
  1864.  
  1865. // CVARS - Sniper
  1866. cvar_sniper = register_cvar("zp_sniper_enabled", "1")
  1867. cvar_sniperchance = register_cvar("zp_sniper_chance", "20")
  1868. cvar_sniperminplayers = register_cvar("zp_sniper_min_players", "0")
  1869. cvar_sniperhp = register_cvar("zp_sniper_health", "0")
  1870. cvar_sniperbasehp = register_cvar("zp_sniper_base_health", "0")
  1871. cvar_sniperspd = register_cvar("zp_sniper_speed", "230")
  1872. cvar_snipergravity = register_cvar("zp_sniper_gravity", "0.75")
  1873. cvar_sniperglow = register_cvar("zp_sniper_glow", "1")
  1874. cvar_sniperaura = register_cvar("zp_sniper_aura", "1")
  1875. cvar_sniperpainfree = register_cvar("zp_sniper_painfree", "1")
  1876. cvar_sniperignorefrags = register_cvar("zp_sniper_ignore_frags", "1")
  1877. cvar_sniperignoreammo = register_cvar("zp_sniper_ignore_rewards", "1")
  1878. cvar_sniperdamage = register_cvar("zp_sniper_damage", "5000.0")
  1879. cvar_sniperinfammo = register_cvar("zp_sniper_unlimited_ammo", "1")
  1880. cvar_sniperauraradius = register_cvar("zp_sniper_aura_size", "25")
  1881. cvar_snipercolor[0] = register_cvar("zp_sniper_aura_color_R", "200")
  1882. cvar_snipercolor[1] = register_cvar("zp_sniper_aura_color_G", "200")
  1883. cvar_snipercolor[2]= register_cvar("zp_sniper_aura_color_B", "0")
  1884.  
  1885. // CVARS - Assassin
  1886. cvar_assassin = register_cvar("zp_assassin_enabled", "1")
  1887. cvar_assassinchance = register_cvar("zp_assassin_chance", "20")
  1888. cvar_assassinminplayers = register_cvar("zp_assassin_min_players", "0")
  1889. cvar_assassinhp = register_cvar("zp_assassin_health", "0")
  1890. cvar_assassinbasehp = register_cvar("zp_assassin_base_health", "0")
  1891. cvar_assassinspd = register_cvar("zp_assassin_speed", "250")
  1892. cvar_assassingravity = register_cvar("zp_assassin_gravity", "0.5")
  1893. cvar_assassindamage = register_cvar("zp_assassin_damage", "250")
  1894. cvar_assassinglow = register_cvar("zp_assassin_glow", "1")
  1895. cvar_assassinaura = register_cvar("zp_assassin_aura", "1")
  1896. cvar_assassinpainfree = register_cvar("zp_assassin_painfree", "0")
  1897. cvar_assassinignorefrags = register_cvar("zp_assassin_ignore_frags", "1")
  1898. cvar_assassinignoreammo = register_cvar("zp_assassin_ignore_rewards", "1")
  1899.  
  1900. // CVARS - LNJ Mode
  1901. cvar_lnj = register_cvar("zp_lnj_enabled", "1")
  1902. cvar_lnjchance = register_cvar("zp_lnj_chance", "30")
  1903. cvar_lnjminplayers = register_cvar("zp_lnj_min_players", "0")
  1904. cvar_lnjnemhpmulti = register_cvar("zp_lnj_nem_hp_multi", "2.0")
  1905. cvar_lnjsurvhpmulti = register_cvar("zp_lnj_surv_hp_multi", "4.0")
  1906. cvar_lnjratio = register_cvar("zp_lnj_ratio", "0.5")
  1907.  
  1908. // CVARS - Others
  1909. cvar_logcommands = register_cvar("zp_logcommands", "1")
  1910. cvar_showactivity = get_cvar_pointer("amx_show_activity")
  1911. cvar_botquota = get_cvar_pointer("bot_quota")
  1912. register_cvar("zp_version_adv", "1.6.1", FCVAR_SERVER|FCVAR_SPONLY)
  1913. set_cvar_string("zp_version_adv", "1.6.1")
  1914.  
  1915. // Custom Forwards
  1916. g_fwRoundStart = CreateMultiForward("zp_round_started", ET_IGNORE, FP_CELL, FP_CELL)
  1917. g_fwRoundStart_pre = CreateMultiForward("zp_round_started_pre", ET_CONTINUE, FP_CELL)
  1918. g_fwRoundEnd = CreateMultiForward("zp_round_ended", ET_IGNORE, FP_CELL)
  1919. g_fwUserInfected_pre = CreateMultiForward("zp_user_infected_pre", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  1920. g_fwUserInfected_post = CreateMultiForward("zp_user_infected_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  1921. g_fwUserHumanized_pre = CreateMultiForward("zp_user_humanized_pre", ET_IGNORE, FP_CELL, FP_CELL)
  1922. g_fwUserHumanized_post = CreateMultiForward("zp_user_humanized_post", ET_IGNORE, FP_CELL, FP_CELL)
  1923. g_fwUserInfect_attempt = CreateMultiForward("zp_user_infect_attempt", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
  1924. g_fwUserHumanize_attempt = CreateMultiForward("zp_user_humanize_attempt", ET_CONTINUE, FP_CELL, FP_CELL)
  1925. g_fwExtraItemSelected = CreateMultiForward("zp_extra_item_selected", ET_CONTINUE, FP_CELL, FP_CELL)
  1926. g_fwUserUnfrozen = CreateMultiForward("zp_user_unfrozen", ET_IGNORE, FP_CELL)
  1927. g_fwUserLastZombie = CreateMultiForward("zp_user_last_zombie", ET_IGNORE, FP_CELL)
  1928. g_fwUserLastHuman = CreateMultiForward("zp_user_last_human", ET_IGNORE, FP_CELL)
  1929. g_fwGameModeSelected = CreateMultiForward("zp_game_mode_selected", ET_IGNORE, FP_CELL, FP_CELL)
  1930. g_fwPlayerSpawnPost = CreateMultiForward("zp_player_spawn_post", ET_IGNORE, FP_CELL)
  1931.  
  1932. // Collect random spawn points
  1933. load_spawns()
  1934.  
  1935. // Set a random skybox?
  1936. if (g_sky_enable)
  1937. {
  1938. new sky[32]
  1939. ArrayGetString(g_sky_names, random_num(0, ArraySize(g_sky_names) - 1), sky, charsmax(sky))
  1940. set_cvar_string("sv_skyname", sky)
  1941. }
  1942.  
  1943. // Disable sky lighting so it doesn't mess with our custom lighting
  1944. set_cvar_num("sv_skycolor_r", 0)
  1945. set_cvar_num("sv_skycolor_g", 0)
  1946. set_cvar_num("sv_skycolor_b", 0)
  1947.  
  1948. // Create the HUD Sync Objects
  1949. g_MsgSync = CreateHudSyncObj()
  1950. g_MsgSync2 = CreateHudSyncObj()
  1951. g_MsgSync3 = CreateHudSyncObj()
  1952.  
  1953. // Format mod name
  1954. formatex(g_modname, charsmax(g_modname), "Zombie Plague Advance 1.6.1")
  1955.  
  1956. // Get Max Players
  1957. g_maxplayers = get_maxplayers()
  1958.  
  1959. // Reserved saving slots starts on maxplayers+1
  1960. db_slot_i = g_maxplayers+1
  1961.  
  1962. // Check if it's a CZ server
  1963. new mymod[6]
  1964. get_modname(mymod, charsmax(mymod))
  1965. if (equal(mymod, "czero")) g_czero = 1
  1966. }
  1967.  
  1968. public plugin_cfg()
  1969. {
  1970. // Plugin disabled?
  1971. if (!g_pluginenabled) return;
  1972.  
  1973. // Get configs dir
  1974. new cfgdir[32]
  1975. get_configsdir(cfgdir, charsmax(cfgdir))
  1976.  
  1977. // Execute config file (zombie_plague_advance.cfg)
  1978. server_cmd("exec %s/zombie_plague_advance.cfg", cfgdir)
  1979.  
  1980. // Prevent any more stuff from registering
  1981. g_arrays_created = false
  1982.  
  1983. // Save customization data
  1984. save_customization()
  1985.  
  1986. // Lighting task
  1987. set_task(5.0, "lighting_effects", _, _, _, "b")
  1988.  
  1989. // Cache CVARs after configs are loaded / call roundstart manually
  1990. set_task(0.5, "cache_cvars")
  1991. set_task(0.5, "event_round_start")
  1992. set_task(0.5, "logevent_round_start")
  1993. }
  1994.  
  1995. /*================================================================================
  1996.  [Main Events]
  1997. =================================================================================*/
  1998.  
  1999. // Event Round Start
  2000. public event_round_start()
  2001. {
  2002. // Remove doors/lights?
  2003. set_task(0.1, "remove_stuff")
  2004.  
  2005. // New round starting
  2006. g_newround = true
  2007. g_endround = false
  2008. g_survround = false
  2009. g_nemround = false
  2010. g_swarmround = false
  2011. g_plagueround = false
  2012. g_sniperround = false
  2013. g_assassinround = false
  2014. g_modestarted = false
  2015. g_lnjround = false
  2016. g_allowinfection = false
  2017.  
  2018. // No present mode in progress ?
  2019. g_currentmode = MODE_NONE
  2020.  
  2021. // Reset bought infection bombs counter
  2022. g_infbombcounter = 0
  2023. g_antidotecounter = 0
  2024. g_madnesscounter = 0
  2025.  
  2026. // Freezetime begins
  2027. g_freezetime = true
  2028.  
  2029. // Show welcome message and T-Virus notice
  2030. remove_task(TASK_WELCOMEMSG)
  2031. set_task(2.0, "welcome_msg", TASK_WELCOMEMSG)
  2032.  
  2033. // Set a new "Make Zombie Task"
  2034. remove_task(TASK_MAKEZOMBIE)
  2035. set_task(2.0 + get_pcvar_float(cvar_warmup), "make_zombie_task", TASK_MAKEZOMBIE)
  2036. }
  2037.  
  2038. // Log Event Round Start
  2039. public logevent_round_start()
  2040. {
  2041. // Freezetime ends
  2042. g_freezetime = false
  2043. }
  2044.  
  2045. // Log Event Round End
  2046. public logevent_round_end()
  2047. {
  2048. // Prevent this from getting called twice when restarting (bugfix)
  2049. static Float:lastendtime, Float:current_time
  2050. current_time = get_gametime()
  2051. if (current_time - lastendtime < 0.5) return;
  2052. lastendtime = current_time
  2053.  
  2054. // Temporarily save player stats?
  2055. if (get_pcvar_num(cvar_statssave))
  2056. {
  2057. static id, team
  2058. for (id = 1; id <= g_maxplayers; id++)
  2059. {
  2060. // Not connected
  2061. if (!g_isconnected[id])
  2062. continue;
  2063.  
  2064. team = fm_cs_get_user_team(id)
  2065.  
  2066. // Not playing
  2067. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  2068. continue;
  2069.  
  2070. save_stats(id)
  2071. }
  2072. }
  2073.  
  2074. // Round ended
  2075. g_endround = true
  2076.  
  2077. // No infection allowed
  2078. g_allowinfection = false
  2079.  
  2080. // No current mode is bieng played
  2081. g_currentmode = MODE_NONE
  2082.  
  2083. // Stop old tasks (if any)
  2084. remove_task(TASK_WELCOMEMSG)
  2085. remove_task(TASK_MAKEZOMBIE)
  2086.  
  2087. // Stop ambience sounds
  2088. if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) || (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && g_plagueround)
  2089. || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround && !g_sniperround && !g_assassinround && !g_lnjround)
  2090. || (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && g_sniperround) || (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && g_assassinround) || (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] && g_lnjround))
  2091. {
  2092. remove_task(TASK_AMBIENCESOUNDS)
  2093. ambience_sound_stop()
  2094. }
  2095.  
  2096. // Show HUD notice, play win sound, update team scores...
  2097. static sound[64]
  2098. if (!fnGetZombies())
  2099. {
  2100. // Human team wins
  2101. set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2102. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN")
  2103.  
  2104. // Play win sound and increase score
  2105. ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound))
  2106. PlaySound(sound)
  2107. g_scorehumans++
  2108.  
  2109. // Round end forward
  2110. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_HUMAN);
  2111. }
  2112. else if (!fnGetHumans())
  2113. {
  2114. // Zombie team wins
  2115. set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2116. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_ZOMBIE")
  2117.  
  2118. // Play win sound and increase score
  2119. ArrayGetString(sound_win_zombies, random_num(0, ArraySize(sound_win_zombies) - 1), sound, charsmax(sound))
  2120. PlaySound(sound)
  2121. g_scorezombies++
  2122.  
  2123. // Round end forward
  2124. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_ZOMBIE);
  2125. }
  2126. else if (get_pcvar_num(cvar_humansurvive))
  2127. {
  2128. // Humans survived the plague
  2129. set_hudmessage(0, 200, 100, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2130. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN_SURVIVE")
  2131.  
  2132. // Play win sound and increase human score
  2133. ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound))
  2134. PlaySound(sound)
  2135. g_scorehumans++
  2136.  
  2137. // Round end forward (will remain same)
  2138. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE);
  2139. }
  2140. else
  2141. {
  2142. // No one wins
  2143. set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2144. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_NO_ONE")
  2145.  
  2146. // Play win sound and increase human score
  2147. ArrayGetString(sound_win_no_one, random_num(0, ArraySize(sound_win_no_one) - 1), sound, charsmax(sound))
  2148. PlaySound(sound)
  2149.  
  2150. // Round end forward
  2151. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE);
  2152. }
  2153.  
  2154. // Balance the teams
  2155. balance_teams()
  2156. }
  2157.  
  2158. // Event Map Ended
  2159. public event_intermission()
  2160. {
  2161. // Remove ambience sounds task
  2162. remove_task(TASK_AMBIENCESOUNDS)
  2163. }
  2164.  
  2165. // BP Ammo update
  2166. public event_ammo_x(id)
  2167. {
  2168. // Humans only
  2169. if (g_zombie[id])
  2170. return;
  2171.  
  2172. // Get ammo type
  2173. static type
  2174. type = read_data(1)
  2175.  
  2176. // Unknown ammo type
  2177. if (type >= sizeof AMMOWEAPON)
  2178. return;
  2179.  
  2180. // Get weapon's id
  2181. static weapon
  2182. weapon = AMMOWEAPON[type]
  2183.  
  2184. // Primary and secondary only
  2185. if (MAXBPAMMO[weapon] <= 2)
  2186. return;
  2187.  
  2188. // Get ammo amount
  2189. static amount
  2190. amount = read_data(2)
  2191.  
  2192. // Unlimited BP Ammo?
  2193. if (g_survivor[id] ? get_pcvar_num(cvar_survinfammo) : get_pcvar_num(cvar_infammo) || g_sniper[id] ? get_pcvar_num(cvar_sniperinfammo) : get_pcvar_num(cvar_infammo))
  2194. {
  2195. if (amount < MAXBPAMMO[weapon])
  2196. {
  2197. // The BP Ammo refill code causes the engine to send a message, but we
  2198. // can't have that in this forward or we risk getting some recursion bugs.
  2199. // For more info see: https://bugs.alliedmods.net/show_bug.cgi?id=3664
  2200. static args[1]
  2201. args[0] = weapon
  2202. set_task(0.1, "refill_bpammo", id, args, sizeof args)
  2203. }
  2204. }
  2205.  
  2206. // Bots automatically buy ammo when needed
  2207. if (g_isbot[id] && amount <= BUYAMMO[weapon])
  2208. {
  2209. // Task needed for the same reason as above
  2210. set_task(0.1, "clcmd_buyammo", id)
  2211. }
  2212. }
  2213.  
  2214. /*================================================================================
  2215.  [Main Forwards]
  2216. =================================================================================*/
  2217.  
  2218. // Entity Spawn Forward
  2219. public fw_Spawn(entity)
  2220. {
  2221. // Invalid entity
  2222. if (!pev_valid(entity)) return FMRES_IGNORED;
  2223.  
  2224. // Get classname
  2225. new classname[32], objective[32], size = ArraySize(g_objective_ents)
  2226. pev(entity, pev_classname, classname, charsmax(classname))
  2227.  
  2228. // Check whether it needs to be removed
  2229. for (new i = 0; i < size; i++)
  2230. {
  2231. ArrayGetString(g_objective_ents, i, objective, charsmax(objective))
  2232.  
  2233. if (equal(classname, objective))
  2234. {
  2235. engfunc(EngFunc_RemoveEntity, entity)
  2236. return FMRES_SUPERCEDE;
  2237. }
  2238. }
  2239.  
  2240. return FMRES_IGNORED;
  2241. }
  2242.  
  2243. // Sound Precache Forward
  2244. public fw_PrecacheSound(const sound[])
  2245. {
  2246. // Block all those unneeeded hostage sounds
  2247. if (equal(sound, "hostage", 7))
  2248. return FMRES_SUPERCEDE;
  2249.  
  2250. return FMRES_IGNORED;
  2251. }
  2252.  
  2253. // Ham Player Spawn Post Forward
  2254. public fw_PlayerSpawn_Post(id)
  2255. {
  2256. // Not alive or didn't join a team yet
  2257. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  2258. return;
  2259.  
  2260. // Player spawned
  2261. g_isalive[id] = true
  2262.  
  2263. // Remove previous tasks
  2264. remove_task(id+TASK_SPAWN)
  2265. remove_task(id+TASK_MODEL)
  2266. remove_task(id+TASK_BLOOD)
  2267. remove_task(id+TASK_AURA)
  2268. remove_task(id+TASK_BURN)
  2269. remove_task(id+TASK_CHARGE)
  2270. remove_task(id+TASK_FLASH)
  2271. remove_task(id+TASK_NVISION)
  2272.  
  2273. // Spawn at a random location?
  2274. if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
  2275.  
  2276. // Hide money?
  2277. if (get_pcvar_num(cvar_removemoney))
  2278. set_task(0.4, "task_hide_money", id+TASK_SPAWN)
  2279.  
  2280. // Respawn player if he dies because of a worldspawn kill?
  2281. if (get_pcvar_num(cvar_respawnworldspawnkill))
  2282. set_task(2.0, "respawn_player_task", id+TASK_SPAWN)
  2283.  
  2284. // Check whether to transform the player before spawning
  2285. if (!g_newround)
  2286. {
  2287. // Respawn as a zombie ?
  2288. if (g_respawn_as_zombie[id])
  2289. {
  2290. // Reset player vars
  2291. reset_vars(id, 0)
  2292.  
  2293. // Respawn as a nemesis on LNJ round ?
  2294. if (g_lnjround && get_pcvar_num(cvar_lnjrespnem))
  2295. {
  2296. // Make him nemesis right away
  2297. zombieme(id, 0, 1, 0, 0, 0)
  2298.  
  2299. // Apply the nemesis health multiplier
  2300. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjnemhpmulti)))
  2301. }
  2302. // Make him zombie right away
  2303. else zombieme(id, 0, 0, 0, 0, 0)
  2304. }
  2305. else
  2306. {
  2307. // Reset player vars
  2308. reset_vars(id, 0)
  2309.  
  2310. // Respawn as a survivor on LNJ round ?
  2311. if (g_lnjround && get_pcvar_num(cvar_lnjrespsurv))
  2312. {
  2313. // Make him survivor right away
  2314. humanme(id, 1, 0, 0)
  2315.  
  2316. // Apply the survivor health multiplier
  2317. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjsurvhpmulti)))
  2318. }
  2319. }
  2320.  
  2321. // Execute our player spawn post forward
  2322. if (g_zombie[id] || g_survivor[id])
  2323. {
  2324. ExecuteForward(g_fwPlayerSpawnPost, g_fwDummyResult, id);
  2325. return;
  2326. }
  2327. }
  2328.  
  2329. // Reset player vars
  2330. reset_vars(id, 0)
  2331.  
  2332. // Show custom buy menu?
  2333. if (get_pcvar_num(cvar_buycustom))
  2334. set_task(0.2, "show_menu_buy1", id+TASK_SPAWN)
  2335.  
  2336. // Set health and gravity
  2337. fm_set_user_health(id, get_pcvar_num(cvar_humanhp))
  2338. set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity))
  2339.  
  2340. // Switch to CT if spawning mid-round
  2341. if (!g_newround && fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  2342. {
  2343. remove_task(id+TASK_TEAM)
  2344. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  2345. fm_user_team_update(id)
  2346. }
  2347.  
  2348. // Custom models stuff
  2349. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  2350. already_has_model = false
  2351.  
  2352. if (g_handle_models_on_separate_ent)
  2353. {
  2354. // Set the right model
  2355. if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  2356. {
  2357. iRand = random_num(0, ArraySize(model_admin_human) - 1)
  2358. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  2359. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  2360. }
  2361. else
  2362. {
  2363. iRand = random_num(0, ArraySize(model_human) - 1)
  2364. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  2365. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  2366. }
  2367.  
  2368. // Set model on player model entity
  2369. fm_set_playermodel_ent(id)
  2370.  
  2371. // Remove glow on player model entity
  2372. fm_set_rendering(g_ent_playermodel[id])
  2373. }
  2374. else
  2375. {
  2376. // Get current model for comparing it with the current one
  2377. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  2378.  
  2379. // Set the right model, after checking that we don't already have it
  2380. if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  2381. {
  2382. size = ArraySize(model_admin_human)
  2383. for (i = 0; i < size; i++)
  2384. {
  2385. ArrayGetString(model_admin_human, i, tempmodel, charsmax(tempmodel))
  2386. if (equal(currentmodel, tempmodel)) already_has_model = true
  2387. }
  2388.  
  2389. if (!already_has_model)
  2390. {
  2391. iRand = random_num(0, size - 1)
  2392. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  2393. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  2394. }
  2395. }
  2396. else
  2397. {
  2398. size = ArraySize(model_human)
  2399. for (i = 0; i < size; i++)
  2400. {
  2401. ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
  2402. if (equal(currentmodel, tempmodel)) already_has_model = true
  2403. }
  2404.  
  2405. if (!already_has_model)
  2406. {
  2407. iRand = random_num(0, size - 1)
  2408. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  2409. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  2410. }
  2411. }
  2412.  
  2413. // Need to change the model?
  2414. if (!already_has_model)
  2415. {
  2416. // An additional delay is offset at round start
  2417. // since SVC_BAD is more likely to be triggered there
  2418. if (g_newround)
  2419. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  2420. else
  2421. fm_user_model_update(id+TASK_MODEL)
  2422. }
  2423.  
  2424. // Remove glow
  2425. fm_set_rendering(id)
  2426. }
  2427.  
  2428. // Bots stuff
  2429. if (g_isbot[id])
  2430. {
  2431. // Turn off NVG for bots
  2432. cs_set_user_nvg(id, 0)
  2433.  
  2434. // Automatically buy extra items/weapons after first zombie is chosen
  2435. if (get_pcvar_num(cvar_extraitems))
  2436. {
  2437. if (g_newround) set_task(10.0 + get_pcvar_float(cvar_warmup), "bot_buy_extras", id+TASK_SPAWN)
  2438. else set_task(10.0, "bot_buy_extras", id+TASK_SPAWN)
  2439. }
  2440. }
  2441.  
  2442. // Enable spawn protection for humans spawning mid-round
  2443. if (!g_newround && get_pcvar_float(cvar_spawnprotection) > 0.0)
  2444. {
  2445. // Do not take damage
  2446. g_nodamage[id] = true
  2447.  
  2448. // Make temporarily invisible
  2449. set_pev(id, pev_effects, pev(id, pev_effects) | EF_NODRAW)
  2450.  
  2451. // Set task to remove it
  2452. set_task(get_pcvar_float(cvar_spawnprotection), "remove_spawn_protection", id+TASK_SPAWN)
  2453. }
  2454.  
  2455. // Set the flashlight charge task to update battery status
  2456. if (g_cached_customflash)
  2457. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  2458.  
  2459. // Replace weapon models (bugfix)
  2460. static weapon_ent
  2461. weapon_ent = fm_cs_get_current_weapon_ent(id)
  2462. if (pev_valid(weapon_ent)) replace_weapon_models(id, cs_get_weapon_id(weapon_ent))
  2463.  
  2464. // Last Zombie Check
  2465. fnCheckLastZombie()
  2466.  
  2467. // Execute our player spawn post forward
  2468. ExecuteForward(g_fwPlayerSpawnPost, g_fwDummyResult, id);
  2469. }
  2470.  
  2471. // Ham Player Killed Forward
  2472. public fw_PlayerKilled(victim, attacker, shouldgib)
  2473. {
  2474. // Player killed
  2475. g_isalive[victim] = false
  2476.  
  2477. // Enable dead players nightvision
  2478. set_task(0.1, "spec_nvision", victim)
  2479.  
  2480. // Disable nightvision when killed (bugfix)
  2481. if (get_pcvar_num(cvar_nvggive) == 0 && g_nvision[victim])
  2482. {
  2483. if (get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
  2484. else if (g_nvisionenabled[victim]) set_user_gnvision(victim, 0)
  2485. g_nvision[victim] = false
  2486. g_nvisionenabled[victim] = false
  2487. }
  2488.  
  2489. // Turn off nightvision when killed (bugfix)
  2490. if (get_pcvar_num(cvar_nvggive) == 2 && g_nvision[victim] && g_nvisionenabled[victim])
  2491. {
  2492. if (get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
  2493. else set_user_gnvision(victim, 0)
  2494. g_nvisionenabled[victim] = false
  2495. }
  2496.  
  2497. // Turn off custom flashlight when killed
  2498. if (g_cached_customflash)
  2499. {
  2500. // Turn it off
  2501. g_flashlight[victim] = false
  2502. g_flashbattery[victim] = 100
  2503.  
  2504. // Remove previous tasks
  2505. remove_task(victim+TASK_CHARGE)
  2506. remove_task(victim+TASK_FLASH)
  2507. }
  2508.  
  2509. // Stop bleeding/burning/aura when killed
  2510. if (g_zombie[victim] || g_survivor[victim] || g_sniper[victim])
  2511. {
  2512. remove_task(victim+TASK_BLOOD)
  2513. remove_task(victim+TASK_AURA)
  2514. remove_task(victim+TASK_BURN)
  2515. }
  2516.  
  2517. // Nemesis and Assassin explode! or when killed by a Assassin victim is cut in pieces
  2518. if (g_nemesis[victim] || g_assassin[victim] || (g_assassin[attacker] && get_pcvar_num(cvar_nemfraggore)))
  2519. SetHamParamInteger(3, 2)
  2520.  
  2521. // Get deathmatch mode status and whether the player killed himself
  2522. static selfkill
  2523. selfkill = (victim == attacker || !is_user_valid_connected(attacker)) ? true : false
  2524.  
  2525. // Make sure that the player was not killed by a non-player entity or through self killing
  2526. if (!selfkill)
  2527. {
  2528. // Ignore Nemesis/Survivor/Sniper Frags?
  2529. if ((g_nemesis[attacker] && get_pcvar_num(cvar_nemignorefrags)) || (g_survivor[attacker] && get_pcvar_num(cvar_survignorefrags))
  2530. || (g_sniper[attacker] && get_pcvar_num(cvar_sniperignorefrags))|| (g_assassin[attacker] && get_pcvar_num(cvar_assassinignorefrags)))
  2531. RemoveFrags(attacker, victim)
  2532.  
  2533. // Zombie/nemesis/assassin killed human, reward ammo packs
  2534. if (g_zombie[attacker] && (!g_nemesis[attacker] || !get_pcvar_num(cvar_nemignoreammo)) && (!g_assassin[attacker] || !get_pcvar_num(cvar_assassinignoreammo)))
  2535. g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect)
  2536.  
  2537. // Human killed zombie, add up the extra frags for kill
  2538. if (!g_zombie[attacker] && get_pcvar_num(cvar_fragskill) > 1)
  2539. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragskill) - 1, 0, 0)
  2540.  
  2541. // Zombie killed human, add up the extra frags for kill
  2542. if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)
  2543. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect) - 1, 0, 0)
  2544.  
  2545. // When killed by a Sniper victim explodes
  2546. if (g_sniper[attacker] && (g_currentweapon[attacker] == CSW_AWP) && get_pcvar_num(cvar_sniperfraggore) && g_zombie[victim])
  2547. {
  2548. // Cut him into pieces
  2549. SetHamParamInteger(3, 2)
  2550.  
  2551. // Get his origin
  2552. static origin[3]
  2553. get_user_origin(victim, origin)
  2554.  
  2555. // Make some blood in the air
  2556. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  2557. write_byte(TE_LAVASPLASH) // TE id
  2558. write_coord(origin[0]) // origin x
  2559. write_coord(origin[1]) // origin y
  2560. write_coord(origin[2] - 26) // origin z
  2561. message_end()
  2562. }
  2563. }
  2564.  
  2565. // Respawn if deathmatch is enabled
  2566. if (get_pcvar_num(cvar_deathmatch) || ((g_currentmode > MODE_LNJ) && (g_deathmatchmode > 0)))
  2567. {
  2568. // Respawn on suicide?
  2569. if (selfkill && !get_pcvar_num(cvar_respawnonsuicide))
  2570. return;
  2571.  
  2572. // Respawn if only the last human is left?
  2573. if (!get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() <= 1)
  2574. return;
  2575.  
  2576. // Respawn if human/zombie/nemesis/assassin/survivor/sniper?
  2577. if ((g_zombie[victim] && !g_nemesis[victim] && !g_assassin[victim] && !get_pcvar_num(cvar_respawnzomb)) || (!g_zombie[victim] && !g_survivor[victim] && !g_sniper[victim] && !get_pcvar_num(cvar_respawnhum))
  2578. || (g_nemesis[victim] && !get_pcvar_num(cvar_respawnnem)) || (g_survivor[victim] && !get_pcvar_num(cvar_respawnsurv))
  2579. || (g_sniper[victim] && !get_pcvar_num(cvar_respawnsniper)) || (g_assassin[victim] && !get_pcvar_num(cvar_respawnassassin)))
  2580. return;
  2581.  
  2582. // Respawn as zombie?
  2583. if ((g_currentmode > MODE_LNJ) && (g_deathmatchmode > 0)) // Custom round ?
  2584. {
  2585. if(g_deathmatchmode == 2 || (g_deathmatchmode == 3 && random_num(0, 1)) || (g_deathmatchmode == 4 && (fnGetZombies() < (fnGetAlive()/2))))
  2586. g_respawn_as_zombie[victim] = true
  2587. }
  2588. else if (get_pcvar_num(cvar_deathmatch) > 0) // Normal round
  2589. {
  2590. if (get_pcvar_num(cvar_deathmatch) == 2 || (get_pcvar_num(cvar_deathmatch) == 3 && random_num(0, 1)) || (get_pcvar_num(cvar_deathmatch) == 4 && (fnGetZombies() < (fnGetAlive()/2))))
  2591. g_respawn_as_zombie[victim] = true
  2592. }
  2593.  
  2594. // Set the respawn task
  2595. set_task(get_pcvar_float(cvar_spawndelay), "respawn_player_task", victim+TASK_SPAWN)
  2596. }
  2597. }
  2598.  
  2599. // Ham Player Killed Post Forward
  2600. public fw_PlayerKilled_Post()
  2601. {
  2602. // Last Zombie Check
  2603. fnCheckLastZombie()
  2604. }
  2605.  
  2606. // Ham Take Damage Forward
  2607. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  2608. {
  2609. // Non-player damage or self damage
  2610. if (victim == attacker || !is_user_valid_connected(attacker))
  2611. return HAM_IGNORED;
  2612.  
  2613. // New round starting or round ended
  2614. if (g_newround || g_endround)
  2615. return HAM_SUPERCEDE;
  2616.  
  2617. // Victim shouldn't take damage or victim is frozen
  2618. if (g_nodamage[victim] || (g_frozen[victim] && !(get_pcvar_num(cvar_frozenhit))))
  2619. return HAM_SUPERCEDE;
  2620.  
  2621. // Prevent friendly fire
  2622. if (g_zombie[attacker] == g_zombie[victim])
  2623. return HAM_SUPERCEDE;
  2624.  
  2625. // Attacker is human...
  2626. if (!g_zombie[attacker])
  2627. {
  2628. // Armor multiplier for the final damage on normal zombies
  2629. if (!g_nemesis[victim] && !g_assassin[victim] && !g_sniper[attacker])
  2630. {
  2631. damage *= get_pcvar_float(cvar_zombiearmor)
  2632. SetHamParamFloat(4, damage)
  2633. }
  2634.  
  2635. // Reward ammo packs
  2636. if ((g_survivor[attacker] && !get_pcvar_num(cvar_survignoreammo)) || (g_sniper[attacker] && !get_pcvar_num(cvar_sniperignoreammo)) || (!g_survivor[attacker] && !g_sniper[attacker]))
  2637. {
  2638. // Store damage dealt
  2639. g_damagedealt[attacker] += floatround(damage)
  2640.  
  2641. // Reward ammo packs for every [ammo damage] dealt
  2642. while (g_damagedealt[attacker] > get_pcvar_num(cvar_ammodamage))
  2643. {
  2644. g_ammopacks[attacker]++
  2645. g_damagedealt[attacker] -= get_pcvar_num(cvar_ammodamage)
  2646. }
  2647. }
  2648.  
  2649. // Replace damage done by Sniper's weapon with the one set by the cvar
  2650. if (g_sniper[attacker] && g_currentweapon[attacker] == CSW_AWP)
  2651. SetHamParamFloat(4, get_pcvar_float(cvar_sniperdamage))
  2652.  
  2653. return HAM_IGNORED;
  2654. }
  2655.  
  2656. // Attacker is zombie...
  2657.  
  2658. // Prevent infection/damage by HE grenade (bugfix)
  2659. if (damage_type & DMG_HEGRENADE)
  2660. return HAM_SUPERCEDE;
  2661.  
  2662. // Nemesis/Assassin?
  2663. if (g_nemesis[attacker] || g_assassin[attacker])
  2664. {
  2665. // Ignore nemesis/assassin damage override if damage comes from a 3rd party entity
  2666. // (to prevent this from affecting a sub-plugin's rockets e.g.)
  2667. if (inflictor == attacker)
  2668. {
  2669. // Set proper damage
  2670. SetHamParamFloat(4, g_nemesis[attacker] ? get_pcvar_float(cvar_nemdamage) : get_pcvar_float(cvar_assassindamage))
  2671. }
  2672.  
  2673. return HAM_IGNORED;
  2674. }
  2675.  
  2676. // Last human or infection not allowed
  2677. if (!g_allowinfection || fnGetHumans() == 1)
  2678. return HAM_IGNORED; // human is killed
  2679.  
  2680. // Does human armor need to be reduced before infecting?
  2681. if (get_pcvar_num(cvar_humanarmor))
  2682. {
  2683. // Get victim armor
  2684. static Float:armor
  2685. pev(victim, pev_armorvalue, armor)
  2686.  
  2687. // Block the attack if he has some
  2688. if (armor > 0.0)
  2689. {
  2690. emit_sound(victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
  2691. set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage))
  2692. return HAM_SUPERCEDE;
  2693. }
  2694. }
  2695.  
  2696. // Infection allowed
  2697. zombieme(victim, attacker, 0, 0, 1, 0) // turn into zombie
  2698. return HAM_SUPERCEDE;
  2699. }
  2700.  
  2701. // Ham Take Damage Post Forward
  2702. public fw_TakeDamage_Post(victim)
  2703. {
  2704. // --- Check if victim should be Pain Shock Free ---
  2705.  
  2706. // Check if proper CVARs are enabled
  2707. if (g_zombie[victim])
  2708. {
  2709. // Nemesis
  2710. if (g_nemesis[victim])
  2711. {
  2712. if (!get_pcvar_num(cvar_nempainfree)) return;
  2713. }
  2714.  
  2715. // Assassin
  2716. else if (g_assassin[victim])
  2717. {
  2718. if (!get_pcvar_num(cvar_assassinpainfree)) return;
  2719. }
  2720.  
  2721. // Zombie
  2722. else
  2723. {
  2724. switch (get_pcvar_num(cvar_zombiepainfree))
  2725. {
  2726. case 0: return;
  2727. case 2: if (!g_lastzombie[victim]) return;
  2728. }
  2729. }
  2730. }
  2731. else
  2732. {
  2733. // Survivor
  2734. if (g_survivor[victim])
  2735. {
  2736. if (!get_pcvar_num(cvar_survpainfree)) return;
  2737. }
  2738.  
  2739. // Sniper
  2740. if (g_sniper[victim])
  2741. {
  2742. if (!get_pcvar_num(cvar_sniperpainfree)) return;
  2743. }
  2744.  
  2745. // Human
  2746. else return;
  2747. }
  2748.  
  2749. // Set pain shock free offset
  2750. set_pdata_float(victim, OFFSET_PAINSHOCK, 1.0, OFFSET_LINUX)
  2751. }
  2752.  
  2753. // Ham Trace Attack Forward
  2754. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  2755. {
  2756. // Non-player damage or self damage
  2757. if (victim == attacker || !is_user_valid_connected(attacker))
  2758. return HAM_IGNORED;
  2759.  
  2760. // New round starting or round ended
  2761. if (g_newround || g_endround)
  2762. return HAM_SUPERCEDE;
  2763.  
  2764. // Victim shouldn't take damage or victim is frozen
  2765. if (g_nodamage[victim] || (g_frozen[victim] && !get_pcvar_num(cvar_frozenhit)))
  2766. return HAM_SUPERCEDE;
  2767.  
  2768. // Prevent friendly fire
  2769. if (g_zombie[attacker] == g_zombie[victim])
  2770. return HAM_SUPERCEDE;
  2771.  
  2772. // Victim isn't a zombie or not bullet damage, nothing else to do here
  2773. if (!g_zombie[victim] || !(damage_type & DMG_BULLET))
  2774. return HAM_IGNORED;
  2775.  
  2776. // If zombie hitzones are enabled, check whether we hit an allowed one
  2777. if (get_pcvar_num(cvar_hitzones) && !g_nemesis[victim] && !g_assassin[victim] && !(get_pcvar_num(cvar_hitzones) & (1<<get_tr2(tracehandle, TR_iHitgroup))))
  2778. return HAM_SUPERCEDE;
  2779.  
  2780. // Knockback disabled, nothing else to do here
  2781. if (!get_pcvar_num(cvar_knockback))
  2782. return HAM_IGNORED;
  2783.  
  2784. // Nemesis knockback disabled, nothing else to do here
  2785. if (g_nemesis[victim] && get_pcvar_float(cvar_nemknockback) == 0.0)
  2786. return HAM_IGNORED;
  2787.  
  2788. // Assassin knockback disabled, nothing else to do here
  2789. if (g_assassin[victim] && get_pcvar_float(cvar_assassinknockback) == 0.0)
  2790. return HAM_IGNORED;
  2791.  
  2792. // Get whether the victim is in a crouch state
  2793. static ducking
  2794. ducking = pev(victim, pev_flags) & (FL_DUCKING | FL_ONGROUND) == (FL_DUCKING | FL_ONGROUND)
  2795.  
  2796. // Zombie knockback when ducking disabled
  2797. if (ducking && get_pcvar_float(cvar_knockbackducking) == 0.0)
  2798. return HAM_IGNORED;
  2799.  
  2800. // Get distance between players
  2801. static origin1[3], origin2[3]
  2802. get_user_origin(victim, origin1)
  2803. get_user_origin(attacker, origin2)
  2804.  
  2805. // Max distance exceeded
  2806. if (get_distance(origin1, origin2) > get_pcvar_num(cvar_knockbackdist))
  2807. return HAM_IGNORED;
  2808.  
  2809. // Get victim's velocity
  2810. static Float:velocity[3]
  2811. pev(victim, pev_velocity, velocity)
  2812.  
  2813. // Use damage on knockback calculation
  2814. if (get_pcvar_num(cvar_knockbackdamage))
  2815. xs_vec_mul_scalar(direction, damage, direction)
  2816.  
  2817. // Use weapon power on knockback calculation
  2818. if (get_pcvar_num(cvar_knockbackpower) && kb_weapon_power[g_currentweapon[attacker]] > 0.0)
  2819. xs_vec_mul_scalar(direction, kb_weapon_power[g_currentweapon[attacker]], direction)
  2820.  
  2821. // Apply ducking knockback multiplier
  2822. if (ducking)
  2823. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_knockbackducking), direction)
  2824.  
  2825. // Apply zombie class/nemesis knockback multiplier
  2826. if (g_nemesis[victim])
  2827. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_nemknockback), direction)
  2828. else if (g_assassin[victim])
  2829. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_assassinknockback), direction)
  2830. else if (!g_assassin[victim] && !g_nemesis[victim])
  2831. xs_vec_mul_scalar(direction, g_zombie_knockback[victim], direction)
  2832.  
  2833. // Add up the new vector
  2834. xs_vec_add(velocity, direction, direction)
  2835.  
  2836. // Should knockback also affect vertical velocity?
  2837. if (!get_pcvar_num(cvar_knockbackzvel))
  2838. direction[2] = velocity[2]
  2839.  
  2840. // Set the knockback'd victim's velocity
  2841. set_pev(victim, pev_velocity, direction)
  2842.  
  2843. return HAM_IGNORED;
  2844. }
  2845.  
  2846. // Ham Use Stationary Gun Forward
  2847. public fw_UseStationary(entity, caller, activator, use_type)
  2848. {
  2849. // Prevent zombies from using stationary guns
  2850. if (use_type == USE_USING && is_user_valid_connected(caller) && g_zombie[caller])
  2851. return HAM_SUPERCEDE;
  2852.  
  2853. return HAM_IGNORED;
  2854. }
  2855.  
  2856. // Ham Use Stationary Gun Post Forward
  2857. public fw_UseStationary_Post(entity, caller, activator, use_type)
  2858. {
  2859. // Someone stopped using a stationary gun
  2860. if (use_type == USE_STOPPED && is_user_valid_connected(caller))
  2861. replace_weapon_models(caller, g_currentweapon[caller]) // replace weapon models (bugfix)
  2862. }
  2863.  
  2864. // Ham Use Pushable Forward
  2865. public fw_UsePushable()
  2866. {
  2867. // Prevent speed bug with pushables?
  2868. if (get_pcvar_num(cvar_blockpushables))
  2869. return HAM_SUPERCEDE;
  2870.  
  2871. return HAM_IGNORED;
  2872. }
  2873.  
  2874. // Ham Weapon Touch Forward
  2875. public fw_TouchWeapon(weapon, id)
  2876. {
  2877. // Not a player
  2878. if (!is_user_valid_connected(id))
  2879. return HAM_IGNORED;
  2880.  
  2881. // Dont pickup weapons if zombie, survivor or sniper (+PODBot MM fix)
  2882. if (g_zombie[id] || (g_survivor[id] && !g_isbot[id]) || (g_sniper[id] && !g_isbot[id]))
  2883. return HAM_SUPERCEDE;
  2884.  
  2885. return HAM_IGNORED;
  2886. }
  2887.  
  2888. // Ham Weapon Pickup Forward
  2889. public fw_AddPlayerItem(id, weapon_ent)
  2890. {
  2891. // HACK: Retrieve our custom extra ammo from the weapon
  2892. static extra_ammo
  2893. extra_ammo = pev(weapon_ent, PEV_ADDITIONAL_AMMO)
  2894.  
  2895. // If present
  2896. if (extra_ammo)
  2897. {
  2898. // Get weapon's id
  2899. static weaponid
  2900. weaponid = cs_get_weapon_id(weapon_ent)
  2901.  
  2902. // Add to player's bpammo
  2903. ExecuteHamB(Ham_GiveAmmo, id, extra_ammo, AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  2904. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, 0)
  2905. }
  2906. }
  2907.  
  2908. // Ham Weapon Deploy Forward
  2909. public fw_Item_Deploy_Post(weapon_ent)
  2910. {
  2911. // Get weapon's owner
  2912. static owner
  2913. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  2914.  
  2915. // Get weapon's id
  2916. static weaponid
  2917. weaponid = cs_get_weapon_id(weapon_ent)
  2918.  
  2919. // Store current weapon's id for reference
  2920. g_currentweapon[owner] = weaponid
  2921.  
  2922. // Replace weapon models with custom ones
  2923. replace_weapon_models(owner, weaponid)
  2924.  
  2925. // Zombie not holding an allowed weapon for some reason
  2926. if (g_zombie[owner] && !((1<<weaponid) & ZOMBIE_ALLOWED_WEAPONS_BITSUM))
  2927. {
  2928. // Switch to knife
  2929. g_currentweapon[owner] = CSW_KNIFE
  2930. engclient_cmd(owner, "weapon_knife")
  2931. }
  2932. }
  2933.  
  2934. // WeaponMod bugfix
  2935. // forward wpn_gi_reset_weapon(id);
  2936. public wpn_gi_reset_weapon(id)
  2937. {
  2938. // Replace knife model
  2939. replace_weapon_models(id, CSW_KNIFE)
  2940. }
  2941.  
  2942. // Client joins the game
  2943. public client_putinserver(id)
  2944. {
  2945. // Plugin disabled?
  2946. if (!g_pluginenabled) return;
  2947.  
  2948. // Player joined
  2949. g_isconnected[id] = true
  2950.  
  2951. // Cache player's name
  2952. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  2953.  
  2954. // Initialize player vars
  2955. reset_vars(id, 1)
  2956.  
  2957. // Load player stats?
  2958. if (get_pcvar_num(cvar_statssave)) load_stats(id)
  2959.  
  2960. // Set some tasks for humans only
  2961. if (!is_user_bot(id))
  2962. {
  2963. // Set the custom HUD display task
  2964. set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
  2965.  
  2966. // Disable minmodels for clients to see zombies properly
  2967. set_task(5.0, "disable_minmodels", id)
  2968. }
  2969. else
  2970. {
  2971. // Set bot flag
  2972. g_isbot[id] = true
  2973.  
  2974. // CZ bots seem to use a different "classtype" for player entities
  2975. // (or something like that) which needs to be hooked separately
  2976. if (!g_hamczbots && cvar_botquota)
  2977. {
  2978. // Set a task to let the private data initialize
  2979. set_task(0.1, "register_ham_czbots", id)
  2980. }
  2981. }
  2982. }
  2983.  
  2984. // Client leaving
  2985. public fw_ClientDisconnect(id)
  2986. {
  2987. // Check that we still have both humans and zombies to keep the round going
  2988. if (g_isalive[id]) check_round(id)
  2989.  
  2990. // Temporarily save player stats?
  2991. if (get_pcvar_num(cvar_statssave)) save_stats(id)
  2992.  
  2993. // Remove previous tasks
  2994. remove_task(id+TASK_TEAM)
  2995. remove_task(id+TASK_MODEL)
  2996. remove_task(id+TASK_FLASH)
  2997. remove_task(id+TASK_CHARGE)
  2998. remove_task(id+TASK_SPAWN)
  2999. remove_task(id+TASK_BLOOD)
  3000. remove_task(id+TASK_AURA)
  3001. remove_task(id+TASK_BURN)
  3002. remove_task(id+TASK_NVISION)
  3003. remove_task(id+TASK_SHOWHUD)
  3004.  
  3005. if (g_handle_models_on_separate_ent)
  3006. {
  3007. // Remove custom model entities
  3008. fm_remove_model_ents(id)
  3009. }
  3010.  
  3011. // Player left, clear cached flags
  3012. g_isconnected[id] = false
  3013. g_isbot[id] = false
  3014. g_isalive[id] = false
  3015. }
  3016.  
  3017. // Client left
  3018. public fw_ClientDisconnect_Post()
  3019. {
  3020. // Last Zombie Check
  3021. fnCheckLastZombie()
  3022. }
  3023.  
  3024. // Client Kill Forward
  3025. public fw_ClientKill()
  3026. {
  3027. // Prevent players from killing themselves?
  3028. if (get_pcvar_num(cvar_blocksuicide))
  3029. return FMRES_SUPERCEDE;
  3030.  
  3031. return FMRES_IGNORED;
  3032. }
  3033.  
  3034. // Emit Sound Forward
  3035. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  3036. {
  3037. // Block all those unneeeded hostage sounds
  3038. if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
  3039. return FMRES_SUPERCEDE;
  3040.  
  3041. // Replace these next sounds for zombies only
  3042. if (!is_user_valid_connected(id) || !g_zombie[id])
  3043. return FMRES_IGNORED;
  3044.  
  3045. static sound[64]
  3046.  
  3047. // Zombie being hit
  3048. if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't')
  3049. {
  3050. if (g_nemesis[id])
  3051. {
  3052. ArrayGetString(nemesis_pain, random_num(0, ArraySize(nemesis_pain) - 1), sound, charsmax(sound))
  3053. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3054. }
  3055. else if (g_assassin[id])
  3056. {
  3057. ArrayGetString(assassin_pain, random_num(0, ArraySize(assassin_pain) - 1), sound, charsmax(sound))
  3058. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3059. }
  3060. else
  3061. {
  3062. ArrayGetString(zombie_pain, random_num(0, ArraySize(zombie_pain) - 1), sound, charsmax(sound))
  3063. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3064. }
  3065. return FMRES_SUPERCEDE;
  3066. }
  3067.  
  3068. // Zombie attacks with knife
  3069. if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
  3070. {
  3071. if (sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a') // slash
  3072. {
  3073. ArrayGetString(zombie_miss_slash, random_num(0, ArraySize(zombie_miss_slash) - 1), sound, charsmax(sound))
  3074. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3075. return FMRES_SUPERCEDE;
  3076. }
  3077. if (sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't') // hit
  3078. {
  3079. if (sample[17] == 'w') // wall
  3080. {
  3081. ArrayGetString(zombie_miss_wall, random_num(0, ArraySize(zombie_miss_wall) - 1), sound, charsmax(sound))
  3082. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3083. return FMRES_SUPERCEDE;
  3084. }
  3085. else
  3086. {
  3087. ArrayGetString(zombie_hit_normal, random_num(0, ArraySize(zombie_hit_normal) - 1), sound, charsmax(sound))
  3088. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3089. return FMRES_SUPERCEDE;
  3090. }
  3091. }
  3092. if (sample[14] == 's' && sample[15] == 't' && sample[16] == 'a') // stab
  3093. {
  3094. ArrayGetString(zombie_hit_stab, random_num(0, ArraySize(zombie_hit_stab) - 1), sound, charsmax(sound))
  3095. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3096. return FMRES_SUPERCEDE;
  3097. }
  3098. }
  3099.  
  3100. // Zombie dies
  3101. if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
  3102. {
  3103. ArrayGetString(zombie_die, random_num(0, ArraySize(zombie_die) - 1), sound, charsmax(sound))
  3104. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3105. return FMRES_SUPERCEDE;
  3106. }
  3107.  
  3108. // Zombie falls off
  3109. if (sample[10] == 'f' && sample[11] == 'a' && sample[12] == 'l' && sample[13] == 'l')
  3110. {
  3111. ArrayGetString(zombie_fall, random_num(0, ArraySize(zombie_fall) - 1), sound, charsmax(sound))
  3112. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  3113. return FMRES_SUPERCEDE;
  3114. }
  3115.  
  3116. return FMRES_IGNORED;
  3117. }
  3118.  
  3119. // Forward Set ClientKey Value -prevent CS from changing player models-
  3120. public fw_SetClientKeyValue(id, const infobuffer[], const key[])
  3121. {
  3122. // Block CS model changes
  3123. if (key[0] == 'm' && key[1] == 'o' && key[2] == 'd' && key[3] == 'e' && key[4] == 'l')
  3124. return FMRES_SUPERCEDE;
  3125.  
  3126. return FMRES_IGNORED;
  3127. }
  3128.  
  3129. // Forward Client User Info Changed -prevent players from changing models-
  3130. public fw_ClientUserInfoChanged(id)
  3131. {
  3132. // Cache player's name
  3133. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  3134.  
  3135. if (!g_handle_models_on_separate_ent)
  3136. {
  3137. // Get current model
  3138. static currentmodel[32]
  3139. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  3140.  
  3141. // If they're different, set model again
  3142. if (!equal(currentmodel, g_playermodel[id]) && !task_exists(id+TASK_MODEL))
  3143. fm_cs_set_user_model(id+TASK_MODEL)
  3144. }
  3145. }
  3146.  
  3147. // Forward Get Game Description
  3148. public fw_GetGameDescription()
  3149. {
  3150. // Return the mod name so it can be easily identified
  3151. forward_return(FMV_STRING, g_modname)
  3152.  
  3153. return FMRES_SUPERCEDE;
  3154. }
  3155.  
  3156. // Forward Set Model
  3157. public fw_SetModel(entity, const model[])
  3158. {
  3159. // We don't care
  3160. if (strlen(model) < 8)
  3161. return;
  3162.  
  3163. // Remove weapons?
  3164. if (get_pcvar_float(cvar_removedropped) > 0.0)
  3165. {
  3166. // Get entity's classname
  3167. static classname[10]
  3168. pev(entity, pev_classname, classname, charsmax(classname))
  3169.  
  3170. // Check if it's a weapon box
  3171. if (equal(classname, "weaponbox"))
  3172. {
  3173. // They get automatically removed when thinking
  3174. set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped))
  3175. return;
  3176. }
  3177. }
  3178.  
  3179. // Narrow down our matches a bit
  3180. if (model[7] != 'w' || model[8] != '_')
  3181. return;
  3182.  
  3183. // Get damage time of grenade
  3184. static Float:dmgtime
  3185. pev(entity, pev_dmgtime, dmgtime)
  3186.  
  3187. // Grenade not yet thrown
  3188. if (dmgtime == 0.0)
  3189. return;
  3190.  
  3191. // Get whether grenade's owner is a zombie
  3192. if (g_zombie[pev(entity, pev_owner)])
  3193. {
  3194. if (model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_extrainfbomb)) // Infection Bomb
  3195. {
  3196. // Give it a glow
  3197. fm_set_rendering(entity, kRenderFxGlowShell, 0, 250, 0, kRenderNormal, 16);
  3198.  
  3199. // And a colored trail
  3200. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3201. write_byte(TE_BEAMFOLLOW) // TE id
  3202. write_short(entity) // entity
  3203. write_short(g_trailSpr) // sprite
  3204. write_byte(10) // life
  3205. write_byte(10) // width
  3206. write_byte(0) // r
  3207. write_byte(250) // g
  3208. write_byte(0) // b
  3209. write_byte(200) // brightness
  3210. message_end()
  3211.  
  3212. // Set grenade type on the thrown grenade entity
  3213. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  3214. }
  3215. }
  3216. else if (model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_firegrenades)) // Napalm Grenade
  3217. {
  3218. // Give it a glow
  3219. fm_set_rendering(entity, kRenderFxGlowShell, 200, 0, 0, kRenderNormal, 16);
  3220.  
  3221. // And a colored trail
  3222. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3223. write_byte(TE_BEAMFOLLOW) // TE id
  3224. write_short(entity) // entity
  3225. write_short(g_trailSpr) // sprite
  3226. write_byte(10) // life
  3227. write_byte(10) // width
  3228. write_byte(200) // r
  3229. write_byte(0) // g
  3230. write_byte(0) // b
  3231. write_byte(200) // brightness
  3232. message_end()
  3233.  
  3234. // Set grenade type on the thrown grenade entity
  3235. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
  3236. }
  3237. else if (model[9] == 'f' && model[10] == 'l' && get_pcvar_num(cvar_frostgrenades)) // Frost Grenade
  3238. {
  3239. // Give it a glow
  3240. fm_set_rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
  3241.  
  3242. // And a colored trail
  3243. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3244. write_byte(TE_BEAMFOLLOW) // TE id
  3245. write_short(entity) // entity
  3246. write_short(g_trailSpr) // sprite
  3247. write_byte(10) // life
  3248. write_byte(10) // width
  3249. write_byte(0) // r
  3250. write_byte(100) // g
  3251. write_byte(200) // b
  3252. write_byte(200) // brightness
  3253. message_end()
  3254.  
  3255. // Set grenade type on the thrown grenade entity
  3256. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FROST)
  3257. }
  3258. else if (model[9] == 's' && model[10] == 'm' && get_pcvar_num(cvar_flaregrenades)) // Flare
  3259. {
  3260. // Build flare's color
  3261. static rgb[3]
  3262. switch (get_pcvar_num(cvar_flarecolor))
  3263. {
  3264. case 0: // white
  3265. {
  3266. rgb[0] = 255 // r
  3267. rgb[1] = 255 // g
  3268. rgb[2] = 255 // b
  3269. }
  3270. case 1: // red
  3271. {
  3272. rgb[0] = random_num(50,255) // r
  3273. rgb[1] = 0 // g
  3274. rgb[2] = 0 // b
  3275. }
  3276. case 2: // green
  3277. {
  3278. rgb[0] = 0 // r
  3279. rgb[1] = random_num(50,255) // g
  3280. rgb[2] = 0 // b
  3281. }
  3282. case 3: // blue
  3283. {
  3284. rgb[0] = 0 // r
  3285. rgb[1] = 0 // g
  3286. rgb[2] = random_num(50,255) // b
  3287. }
  3288. case 4: // random (all colors)
  3289. {
  3290. rgb[0] = random_num(50,200) // r
  3291. rgb[1] = random_num(50,200) // g
  3292. rgb[2] = random_num(50,200) // b
  3293. }
  3294. case 5: // random (r,g,b)
  3295. {
  3296. switch (random_num(1, 6))
  3297. {
  3298. case 1: // red
  3299. {
  3300. rgb[0] = 250 // r
  3301. rgb[1] = 0 // g
  3302. rgb[2] = 0 // b
  3303. }
  3304. case 2: // green
  3305. {
  3306. rgb[0] = 0 // r
  3307. rgb[1] = 250 // g
  3308. rgb[2] = 0 // b
  3309. }
  3310. case 3: // blue
  3311. {
  3312. rgb[0] = 0 // r
  3313. rgb[1] = 0 // g
  3314. rgb[2] = 250 // b
  3315. }
  3316. case 4: // cyan
  3317. {
  3318. rgb[0] = 0 // r
  3319. rgb[1] = 250 // g
  3320. rgb[2] = 250 // b
  3321. }
  3322. case 5: // pink
  3323. {
  3324. rgb[0] = 250 // r
  3325. rgb[1] = 0 // g
  3326. rgb[2] = 250 // b
  3327. }
  3328. case 6: // yellow
  3329. {
  3330. rgb[0] = 250 // r
  3331. rgb[1] = 250 // g
  3332. rgb[2] = 0 // b
  3333. }
  3334. }
  3335. }
  3336. }
  3337.  
  3338. // Give it a glow
  3339. fm_set_rendering(entity, kRenderFxGlowShell, rgb[0], rgb[1], rgb[2], kRenderNormal, 16);
  3340.  
  3341. // And a colored trail
  3342. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3343. write_byte(TE_BEAMFOLLOW) // TE id
  3344. write_short(entity) // entity
  3345. write_short(g_trailSpr) // sprite
  3346. write_byte(10) // life
  3347. write_byte(10) // width
  3348. write_byte(rgb[0]) // r
  3349. write_byte(rgb[1]) // g
  3350. write_byte(rgb[2]) // b
  3351. write_byte(200) // brightness
  3352. message_end()
  3353.  
  3354. // Set grenade type on the thrown grenade entity
  3355. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE)
  3356.  
  3357. // Set flare color on the thrown grenade entity
  3358. set_pev(entity, PEV_FLARE_COLOR, rgb)
  3359. }
  3360. }
  3361.  
  3362. // Ham Grenade Think Forward
  3363. public fw_ThinkGrenade(entity)
  3364. {
  3365. // Invalid entity
  3366. if (!pev_valid(entity)) return HAM_IGNORED;
  3367.  
  3368. // Get damage time of grenade
  3369. static Float:dmgtime, Float:current_time
  3370. pev(entity, pev_dmgtime, dmgtime)
  3371. current_time = get_gametime()
  3372.  
  3373. // Check if it's time to go off
  3374. if (dmgtime > current_time)
  3375. return HAM_IGNORED;
  3376.  
  3377. // Check if it's one of our custom nades
  3378. switch (pev(entity, PEV_NADE_TYPE))
  3379. {
  3380. case NADE_TYPE_INFECTION: // Infection Bomb
  3381. {
  3382. infection_explode(entity)
  3383. return HAM_SUPERCEDE;
  3384. }
  3385. case NADE_TYPE_NAPALM: // Napalm Grenade
  3386. {
  3387. fire_explode(entity)
  3388. return HAM_SUPERCEDE;
  3389. }
  3390. case NADE_TYPE_FROST: // Frost Grenade
  3391. {
  3392. frost_explode(entity)
  3393. return HAM_SUPERCEDE;
  3394. }
  3395. case NADE_TYPE_FLARE: // Flare
  3396. {
  3397. // Get its duration
  3398. static duration
  3399. duration = pev(entity, PEV_FLARE_DURATION)
  3400.  
  3401. // Already went off, do lighting loop for the duration of PEV_FLARE_DURATION
  3402. if (duration > 0)
  3403. {
  3404. // Check whether this is the last loop
  3405. if (duration == 1)
  3406. {
  3407. // Get rid of the flare entity
  3408. engfunc(EngFunc_RemoveEntity, entity)
  3409. return HAM_SUPERCEDE;
  3410. }
  3411.  
  3412. // Light it up!
  3413. flare_lighting(entity, duration)
  3414.  
  3415. // Set time for next loop
  3416. set_pev(entity, PEV_FLARE_DURATION, --duration)
  3417. set_pev(entity, pev_dmgtime, current_time + 5.0)
  3418. }
  3419. // Light up when it's stopped on ground
  3420. else if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10)
  3421. {
  3422. // Flare sound
  3423. static sound[64]
  3424. ArrayGetString(grenade_flare, random_num(0, ArraySize(grenade_flare) - 1), sound, charsmax(sound))
  3425. emit_sound(entity, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3426.  
  3427. // Set duration and start lightning loop on next think
  3428. set_pev(entity, PEV_FLARE_DURATION, 1 + get_pcvar_num(cvar_flareduration)/5)
  3429. set_pev(entity, pev_dmgtime, current_time + 0.1)
  3430. }
  3431. else
  3432. {
  3433. // Delay explosion until we hit ground
  3434. set_pev(entity, pev_dmgtime, current_time + 0.5)
  3435. }
  3436. }
  3437. }
  3438.  
  3439. return HAM_IGNORED;
  3440. }
  3441.  
  3442. // Forward CmdStart
  3443. public fw_CmdStart(id, handle)
  3444. {
  3445. // Not alive
  3446. if (!g_isalive[id])
  3447. return;
  3448.  
  3449. // This logic looks kinda weird, but it should work in theory...
  3450. // p = g_zombie[id], q = g_survivor[id], r = g_cached_customflash
  3451. // ¬(p v q v (¬p ^ r)) <==> ¬p ^ ¬q ^ (p v ¬r)
  3452. if (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && (g_zombie[id] || !g_cached_customflash))
  3453. return;
  3454.  
  3455. // Check if it's a flashlight impulse
  3456. if (get_uc(handle, UC_Impulse) != IMPULSE_FLASHLIGHT)
  3457. return;
  3458.  
  3459. // Block it I say!
  3460. set_uc(handle, UC_Impulse, 0)
  3461.  
  3462. // Should human's custom flashlight be turned on?
  3463. if (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && g_flashbattery[id] > 2 && get_gametime() - g_lastflashtime[id] > 1.2)
  3464. {
  3465. // Prevent calling flashlight too quickly (bugfix)
  3466. g_lastflashtime[id] = get_gametime()
  3467.  
  3468. // Toggle custom flashlight
  3469. g_flashlight[id] = !(g_flashlight[id])
  3470.  
  3471. // Play flashlight toggle sound
  3472. emit_sound(id, CHAN_ITEM, sound_flashlight, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3473.  
  3474. // Update flashlight status on the HUD
  3475. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  3476. write_byte(g_flashlight[id]) // toggle
  3477. write_byte(g_flashbattery[id]) // battery
  3478. message_end()
  3479.  
  3480. // Remove previous tasks
  3481. remove_task(id+TASK_CHARGE)
  3482. remove_task(id+TASK_FLASH)
  3483.  
  3484. // Set the flashlight charge task
  3485. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  3486.  
  3487. // Call our custom flashlight task if enabled
  3488. if (g_flashlight[id]) set_task(0.1, "set_user_flashlight", id+TASK_FLASH, _, _, "b")
  3489. }
  3490. }
  3491.  
  3492. // Forward Player PreThink
  3493. public fw_PlayerPreThink(id)
  3494. {
  3495. // Not alive
  3496. if (!g_isalive[id])
  3497. return;
  3498.  
  3499. // Silent footsteps for zombies/assassins ?
  3500. if ((g_cached_zombiesilent && g_zombie[id] && !g_nemesis[id] && !g_assassin[id]) || g_assassin[id])
  3501. set_pev(id, pev_flTimeStepSound, STEPTIME_SILENT)
  3502.  
  3503. // Set Player MaxSpeed
  3504. if (g_frozen[id])
  3505. {
  3506. set_pev(id, pev_velocity, Float:{0.0,0.0,0.0}) // stop motion
  3507. set_pev(id, pev_maxspeed, 1.0) // prevent from moving
  3508. return; // shouldn't leap while frozen
  3509. }
  3510. else if (g_freezetime)
  3511. {
  3512. return; // shouldn't leap while in freezetime
  3513. }
  3514. else
  3515. {
  3516. if (g_zombie[id])
  3517. {
  3518. if (g_nemesis[id])
  3519. set_pev(id, pev_maxspeed, g_cached_nemspd)
  3520. else if (g_assassin[id])
  3521. set_pev(id, pev_maxspeed, g_cached_assassinspd)
  3522. else
  3523. set_pev(id, pev_maxspeed, g_zombie_spd[id])
  3524. }
  3525. else
  3526. {
  3527. if (g_survivor[id])
  3528. set_pev(id, pev_maxspeed, g_cached_survspd)
  3529. else if (g_sniper[id])
  3530. set_pev(id, pev_maxspeed, g_cached_sniperspd)
  3531. else
  3532. set_pev(id, pev_maxspeed, g_cached_humanspd)
  3533. }
  3534. }
  3535.  
  3536. // --- Check if player should leap ---
  3537.  
  3538. // Check if proper CVARs are enabled and retrieve leap settings
  3539. static Float:cooldown, Float:current_time
  3540. if (g_zombie[id])
  3541. {
  3542. if (g_nemesis[id])
  3543. {
  3544. if (!g_cached_leapnemesis) return;
  3545. cooldown = g_cached_leapnemesiscooldown
  3546. }
  3547. else if (g_assassin[id])
  3548. {
  3549. if (!g_cached_leapassassin) return;
  3550. cooldown = g_cached_leapassassincooldown
  3551. }
  3552. else if (!g_assassin[id] && !g_nemesis[id])
  3553. {
  3554. switch (g_cached_leapzombies)
  3555. {
  3556. case 0: return;
  3557. case 2: if (!g_firstzombie[id]) return;
  3558. case 3: if (!g_lastzombie[id]) return;
  3559. }
  3560. cooldown = g_cached_leapzombiescooldown
  3561. }
  3562. }
  3563. else
  3564. {
  3565. if (g_survivor[id])
  3566. {
  3567. if (!g_cached_leapsurvivor) return;
  3568. cooldown = g_cached_leapsurvivorcooldown
  3569. }
  3570. else if (g_sniper[id])
  3571. {
  3572. if (!g_cached_leapsniper) return;
  3573. cooldown = g_cached_leapsnipercooldown
  3574. }
  3575. else return;
  3576. }
  3577.  
  3578. current_time = get_gametime()
  3579.  
  3580. // Cooldown not over yet
  3581. if (current_time - g_lastleaptime[id] < cooldown)
  3582. return;
  3583.  
  3584. // Not doing a longjump (don't perform check for bots, they leap automatically)
  3585. if (!g_isbot[id] && !(pev(id, pev_button) & (IN_JUMP | IN_DUCK) == (IN_JUMP | IN_DUCK)))
  3586. return;
  3587.  
  3588. // Not on ground or not enough speed
  3589. if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
  3590. return;
  3591.  
  3592. static Float:velocity[3]
  3593.  
  3594. if (g_survivor[id])
  3595. velocity_by_aim(id, get_pcvar_num(cvar_leapsurvivorforce), velocity)
  3596. else if (g_nemesis[id])
  3597. velocity_by_aim(id, get_pcvar_num(cvar_leapnemesisforce), velocity)
  3598. else if (g_assassin[id])
  3599. velocity_by_aim(id, get_pcvar_num(cvar_leapassassinforce), velocity)
  3600. else if (g_sniper[id])
  3601. velocity_by_aim(id, get_pcvar_num(cvar_leapsniperforce), velocity)
  3602. else if (g_zombie[id] && !g_assassin[id] && !g_nemesis[id])
  3603. velocity_by_aim(id, get_pcvar_num(cvar_leapzombiesforce), velocity)
  3604.  
  3605. // Set custom height
  3606. if (g_survivor[id])
  3607. velocity[2] = get_pcvar_float(cvar_leapsurvivorheight)
  3608. else if (g_nemesis[id])
  3609. velocity[2] = get_pcvar_float(cvar_leapnemesisheight)
  3610. else if (g_assassin[id])
  3611. velocity[2] = get_pcvar_float(cvar_leapassassinheight)
  3612. else if (g_sniper[id])
  3613. velocity[2] = get_pcvar_float(cvar_leapsniperheight)
  3614. else if (g_zombie[id] && !g_assassin[id] && !g_nemesis[id])
  3615. velocity[2] = get_pcvar_float(cvar_leapzombiesheight)
  3616.  
  3617. // Apply the new velocity
  3618. set_pev(id, pev_velocity, velocity)
  3619.  
  3620. // Update last leap time
  3621. g_lastleaptime[id] = current_time
  3622. }
  3623.  
  3624. /*================================================================================
  3625.  [Client Commands]
  3626. =================================================================================*/
  3627.  
  3628. // Say "/zpmenu"
  3629. public clcmd_saymenu(id)
  3630. {
  3631. show_menu_game(id) // show game menu
  3632. }
  3633.  
  3634. // Say "/unstuck"
  3635. public clcmd_sayunstuck(id)
  3636. {
  3637. menu_game(id, 3) // try to get unstuck
  3638. }
  3639.  
  3640. // Nightvision toggle
  3641. public clcmd_nightvision(id)
  3642. {
  3643. if (g_nvision[id])
  3644. {
  3645. // Enable-disable
  3646. g_nvisionenabled[id] = !(g_nvisionenabled[id])
  3647.  
  3648. // Custom nvg?
  3649. if (get_pcvar_num(cvar_customnvg))
  3650. {
  3651. remove_task(id+TASK_NVISION)
  3652. if (g_nvisionenabled[id]) set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  3653. }
  3654. else
  3655. set_user_gnvision(id, g_nvisionenabled[id])
  3656. }
  3657.  
  3658. return PLUGIN_HANDLED;
  3659. }
  3660.  
  3661. // Weapon Drop
  3662. public clcmd_drop(id)
  3663. {
  3664. // Survivor/Sniper should stick with its weapon
  3665. if (g_survivor[id] || g_sniper[id])
  3666. return PLUGIN_HANDLED
  3667.  
  3668. return PLUGIN_CONTINUE;
  3669. }
  3670.  
  3671. // Buy BP Ammo
  3672. public clcmd_buyammo(id)
  3673. {
  3674. // Not alive or infinite ammo setting enabled
  3675. if (!g_isalive[id] || get_pcvar_num(cvar_infammo))
  3676. return PLUGIN_HANDLED;
  3677.  
  3678. // Not human
  3679. if (g_zombie[id])
  3680. {
  3681. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_HUMAN_ONLY")
  3682. return PLUGIN_HANDLED;
  3683. }
  3684.  
  3685. // Not enough ammo packs
  3686. if (g_ammopacks[id] < 1)
  3687. {
  3688. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  3689. return PLUGIN_HANDLED;
  3690. }
  3691.  
  3692. // Get user weapons
  3693. static weapons[32], num, i, currentammo, weaponid, refilled
  3694. num = 0 // reset passed weapons count (bugfix)
  3695. refilled = false
  3696. get_user_weapons(id, weapons, num)
  3697.  
  3698. // Loop through them and give the right ammo type
  3699. for (i = 0; i < num; i++)
  3700. {
  3701. // Prevents re-indexing the array
  3702. weaponid = weapons[i]
  3703.  
  3704. // Primary and secondary only
  3705. if (MAXBPAMMO[weaponid] > 2)
  3706. {
  3707. // Get current ammo of the weapon
  3708. currentammo = cs_get_user_bpammo(id, weaponid)
  3709.  
  3710. // Give additional ammo
  3711. ExecuteHamB(Ham_GiveAmmo, id, BUYAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  3712.  
  3713. // Check whether we actually refilled the weapon's ammo
  3714. if (cs_get_user_bpammo(id, weaponid) - currentammo > 0) refilled = true
  3715. }
  3716. }
  3717.  
  3718. // Weapons already have full ammo
  3719. if (!refilled) return PLUGIN_HANDLED;
  3720.  
  3721. // Deduce ammo packs, play clip purchase sound, and notify player
  3722. g_ammopacks[id]--
  3723. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3724. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "AMMO_BOUGHT")
  3725.  
  3726. return PLUGIN_HANDLED;
  3727. }
  3728.  
  3729. // Block Team Change
  3730. public clcmd_changeteam(id)
  3731. {
  3732. static team
  3733. team = fm_cs_get_user_team(id)
  3734.  
  3735. // Unless it's a spectator joining the game
  3736. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  3737. return PLUGIN_CONTINUE;
  3738.  
  3739. // Pressing 'M' (chooseteam) ingame should show the main menu instead
  3740. show_menu_game(id)
  3741. return PLUGIN_HANDLED;
  3742. }
  3743.  
  3744. /*================================================================================
  3745.  [Menus]
  3746. =================================================================================*/
  3747.  
  3748. // Game Menu
  3749. show_menu_game(id)
  3750. {
  3751. static menu[250], len, userflags
  3752. len = 0
  3753. userflags = get_user_flags(id)
  3754.  
  3755. // Title
  3756. len += formatex(menu[len], charsmax(menu) - len, "\y%s^n^n", g_modname)
  3757.  
  3758. // 1. Buy weapons
  3759. if (get_pcvar_num(cvar_buycustom))
  3760. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_BUY")
  3761. else
  3762. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_BUY")
  3763.  
  3764. // 2. Extra items
  3765. if (get_pcvar_num(cvar_extraitems) && g_isalive[id])
  3766. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU_EXTRABUY")
  3767. else
  3768. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU_EXTRABUY")
  3769.  
  3770. // 3. Zombie class
  3771. if (get_pcvar_num(cvar_zclasses))
  3772. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n", id,"MENU_ZCLASS")
  3773. else
  3774. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n", id,"MENU_ZCLASS")
  3775.  
  3776. // 4. Unstuck
  3777. if (g_isalive[id])
  3778. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU_UNSTUCK")
  3779. else
  3780. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU_UNSTUCK")
  3781.  
  3782. // 5. Help
  3783. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n^n", id, "MENU_INFO")
  3784.  
  3785. // 6. Join spec
  3786. if (!g_isalive[id] || !get_pcvar_num(cvar_blocksuicide) || (userflags & g_access_flag[ACCESS_ADMIN_MENU]))
  3787. len += formatex(menu[len], charsmax(menu) - len, "\r6.\w %L^n^n", id, "MENU_SPECTATOR")
  3788. else
  3789. len += formatex(menu[len], charsmax(menu) - len, "\d6. %L^n^n", id, "MENU_SPECTATOR")
  3790.  
  3791. // 9. Admin menu
  3792. if (userflags & g_access_flag[ACCESS_ADMIN_MENU3])
  3793. len += formatex(menu[len], charsmax(menu) - len, "\r9.\w %L", id, "MENU3_ADMIN")
  3794. else
  3795. len += formatex(menu[len], charsmax(menu) - len, "\d9. %L", id, "MENU3_ADMIN")
  3796.  
  3797. // 0. Exit
  3798. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  3799.  
  3800. show_menu(id, KEYSMENU, menu, -1, "Game Menu")
  3801. }
  3802.  
  3803. // Buy Menu 1
  3804. public show_menu_buy1(taskid)
  3805. {
  3806. // Get player's id
  3807. static id
  3808. (taskid > g_maxplayers) ? (id = ID_SPAWN) : (id = taskid);
  3809.  
  3810. // Zombies, survivors or snipers get no guns
  3811. if (!g_isalive[id] || g_zombie[id] || g_survivor[id] || g_sniper[id])
  3812. return;
  3813.  
  3814. // Bots pick their weapons randomly / Random weapons setting enabled
  3815. if (get_pcvar_num(cvar_randweapons) || g_isbot[id])
  3816. {
  3817. buy_primary_weapon(id, random_num(0, ArraySize(g_primary_items) - 1))
  3818. menu_buy2(id, random_num(0, ArraySize(g_secondary_items) - 1))
  3819. return;
  3820. }
  3821.  
  3822. // Automatic selection enabled for player and menu called on spawn event
  3823. if (WPN_AUTO_ON && taskid > g_maxplayers)
  3824. {
  3825. buy_primary_weapon(id, WPN_AUTO_PRI)
  3826. menu_buy2(id, WPN_AUTO_SEC)
  3827. return;
  3828. }
  3829.  
  3830. static menu[300], len, weap, maxloops
  3831. len = 0
  3832. maxloops = min(WPN_STARTID+7, WPN_MAXIDS)
  3833.  
  3834. // Title
  3835. len += formatex(menu[len], charsmax(menu) - len, "\y%L \r[%d-%d]^n^n", id, "MENU_BUY1_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
  3836.  
  3837. // 1-7. Weapon List
  3838. for (weap = WPN_STARTID; weap < maxloops; weap++)
  3839. len += formatex(menu[len], charsmax(menu) - len, "\r%d.\w %s^n", weap-WPN_STARTID+1, WEAPONNAMES[ArrayGetCell(g_primary_weaponids, weap)])
  3840.  
  3841. // 8. Auto Select
  3842. len += formatex(menu[len], charsmax(menu) - len, "^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  3843.  
  3844. // 9. Next/Back - 0. Exit
  3845. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r9.\w %L/%L^n^n\r0.\w %L", id, "MENU_NEXT", id, "MENU_BACK", id, "MENU_EXIT")
  3846.  
  3847. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 1")
  3848. }
  3849.  
  3850. // Buy Menu 2
  3851. show_menu_buy2(id)
  3852. {
  3853. static menu[250], len, weap, maxloops
  3854. len = 0
  3855. maxloops = ArraySize(g_secondary_items)
  3856.  
  3857. // Title
  3858. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n", id, "MENU_BUY2_TITLE")
  3859.  
  3860. // 1-6. Weapon List
  3861. for (weap = 0; weap < maxloops; weap++)
  3862. len += formatex(menu[len], charsmax(menu) - len, "^n\r%d.\w %s", weap+1, WEAPONNAMES[ArrayGetCell(g_secondary_weaponids, weap)])
  3863.  
  3864. // 8. Auto Select
  3865. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  3866.  
  3867. // 0. Exit
  3868. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  3869.  
  3870. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 2")
  3871. }
  3872.  
  3873. // Extra Items Menu
  3874. show_menu_extras(id)
  3875. {
  3876. static menuid, menu[128], item, team, buffer[32]
  3877.  
  3878. // Title
  3879. if (g_zombie[id])
  3880. {
  3881. if (g_nemesis[id])
  3882. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_NEMESIS")
  3883. if (g_assassin[id])
  3884. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_ASSASSIN")
  3885. if (!g_assassin[id] && !g_nemesis[id])
  3886. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_ZOMBIE")
  3887. }
  3888. else
  3889. {
  3890. if (g_survivor[id])
  3891. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_SURVIVOR")
  3892. if (g_sniper[id])
  3893. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_SNIPER")
  3894. if (!g_survivor[id] && !g_sniper[id])
  3895. formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_HUMAN")
  3896. }
  3897. menuid = menu_create(menu, "menu_extras")
  3898.  
  3899. // Item List
  3900. for (item = 0; item < g_extraitem_i; item++)
  3901. {
  3902. // Retrieve item's team
  3903. team = ArrayGetCell(g_extraitem_team, item)
  3904.  
  3905. // Item not available to player's team/class
  3906. if ((g_zombie[id] && !g_nemesis[id] && !g_assassin[id] &&!(team & ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && !(team & ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS))
  3907. || (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)) || (g_sniper[id] && !(team & ZP_TEAM_SNIPER)) || (g_assassin[id] && !(team & ZP_TEAM_ASSASSIN)))
  3908. continue;
  3909.  
  3910. // Check if it's one of the hardcoded items, check availability, set translated caption
  3911. switch (item)
  3912. {
  3913. case EXTRA_NVISION:
  3914. {
  3915. if (!get_pcvar_num(cvar_extranvision)) continue;
  3916. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA1")
  3917. }
  3918. case EXTRA_ANTIDOTE:
  3919. {
  3920. if (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)) continue;
  3921. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA2")
  3922. }
  3923. case EXTRA_MADNESS:
  3924. {
  3925. if (!get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)) continue;
  3926. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA3")
  3927. }
  3928. case EXTRA_INFBOMB:
  3929. {
  3930. if (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)) continue;
  3931. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA4")
  3932. }
  3933. default:
  3934. {
  3935. if (item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)) continue;
  3936. ArrayGetString(g_extraitem_name, item, buffer, charsmax(buffer))
  3937. }
  3938. }
  3939.  
  3940. // Add Item Name and Cost
  3941. formatex(menu, charsmax(menu), "%s \y%d %L", buffer, ArrayGetCell(g_extraitem_cost, item), id, "AMMO_PACKS2")
  3942. buffer[0] = item
  3943. buffer[1] = 0
  3944. menu_additem(menuid, menu, buffer)
  3945. }
  3946.  
  3947. // No items to display?
  3948. if (menu_items(menuid) <= 0)
  3949. {
  3950. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"CMD_NOT_EXTRAS")
  3951. menu_destroy(menuid)
  3952. return;
  3953. }
  3954.  
  3955. // Back - Next - Exit
  3956. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  3957. menu_setprop(menuid, MPROP_BACKNAME, menu)
  3958. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  3959. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  3960. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  3961. menu_setprop(menuid, MPROP_EXITNAME, menu)
  3962.  
  3963. menu_display(id, menuid)
  3964. }
  3965.  
  3966. // Zombie Class Menu
  3967. public show_menu_zclass(id)
  3968. {
  3969. // Player disconnected
  3970. if (!g_isconnected[id])
  3971. return;
  3972.  
  3973. // Bots pick their zombie class randomly
  3974. if (g_isbot[id])
  3975. {
  3976. g_zombieclassnext[id] = random_num(0, g_zclass_i - 1)
  3977. return;
  3978. }
  3979.  
  3980. static menuid, menu[128], class, buffer[32], buffer2[32]
  3981.  
  3982. // Title
  3983. formatex(menu, charsmax(menu), "%L\r", id, "MENU_ZCLASS_TITLE")
  3984. menuid = menu_create(menu, "menu_zclass")
  3985.  
  3986. // Class List
  3987. for (class = 0; class < g_zclass_i; class++)
  3988. {
  3989. // Retrieve name and info
  3990. ArrayGetString(g_zclass_name, class, buffer, charsmax(buffer))
  3991. ArrayGetString(g_zclass_info, class, buffer2, charsmax(buffer2))
  3992.  
  3993. // Add to menu
  3994. if (class == g_zombieclassnext[id])
  3995. formatex(menu, charsmax(menu), "\d%s %s", buffer, buffer2)
  3996. else
  3997. formatex(menu, charsmax(menu), "%s \y%s", buffer, buffer2)
  3998.  
  3999. buffer[0] = class
  4000. buffer[1] = 0
  4001. menu_additem(menuid, menu, buffer)
  4002. }
  4003.  
  4004. // Back - Next - Exit
  4005. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  4006. menu_setprop(menuid, MPROP_BACKNAME, menu)
  4007. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  4008. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  4009. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  4010. menu_setprop(menuid, MPROP_EXITNAME, menu)
  4011.  
  4012. menu_display(id, menuid)
  4013. }
  4014.  
  4015. // Custom game mode menu
  4016. public show_menu_game_mode(id)
  4017. {
  4018. // Player disconnected
  4019. if (!g_isconnected[id])
  4020. return;
  4021.  
  4022. // No custom game modes registered ?
  4023. if (g_gamemodes_i == MAX_GAME_MODES)
  4024. {
  4025. // Print a message
  4026. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_GAME_MODES")
  4027.  
  4028. // Show the main admin menu and stop
  4029. show_menu3_admin(id)
  4030. return;
  4031. }
  4032.  
  4033. // Create vars necessary for displaying the game modes menu
  4034. static menuid, menu[128], game, buffer[32]
  4035.  
  4036. // Title
  4037. formatex(menu, charsmax(menu), "%L \r", id, "MENU_ADMIN_CUSTOM_TITLE")
  4038. menuid = menu_create(menu, "menu_mode")
  4039.  
  4040. // Game mode List
  4041. for (game = MAX_GAME_MODES; game < g_gamemodes_i; game++)
  4042. {
  4043. // Retrieve the game mode's name
  4044. ArrayGetString(g_gamemode_name, (game - MAX_GAME_MODES), buffer, charsmax(buffer))
  4045.  
  4046. // Check for access flags and other conditions
  4047. if ((get_user_flags(id) & ArrayGetCell(g_gamemode_flag, (game - MAX_GAME_MODES))) && allowed_custom_game())
  4048. formatex(menu, charsmax(menu), "%L %s ", id, "MENU_ADMIN1_CUSTOM", buffer)
  4049. else
  4050. formatex(menu, charsmax(menu), "\d%L %s", id, "MENU_ADMIN1_CUSTOM", buffer)
  4051.  
  4052. // Add the item to the menu
  4053. buffer[0] = game
  4054. buffer[1] = 0
  4055. menu_additem(menuid, menu, buffer)
  4056. }
  4057.  
  4058. // Back - Next - Exit
  4059. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  4060. menu_setprop(menuid, MPROP_BACKNAME, menu)
  4061. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  4062. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  4063. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  4064. menu_setprop(menuid, MPROP_EXITNAME, menu)
  4065.  
  4066. menu_display(id, menuid)
  4067.  
  4068. }
  4069. // Help Menu
  4070. show_menu_info(id)
  4071. {
  4072. static menu[150]
  4073.  
  4074. formatex(menu, charsmax(menu), "\y%L^n^n\r1.\w %L^n\r2.\w %L^n\r3.\w %L^n\r4.\w %L^n^n\r0.\w %L", id, "MENU_INFO_TITLE", id, "MENU_INFO1", id,"MENU_INFO2", id,"MENU_INFO3", id,"MENU_INFO4", id, "MENU_EXIT")
  4075. show_menu(id, KEYSMENU, menu, -1, "Mod Info")
  4076. }
  4077.  
  4078. // Admin Menu
  4079. show_menu_admin(id)
  4080. {
  4081. static menu[250], len, userflags
  4082. len = 0
  4083. userflags = get_user_flags(id)
  4084.  
  4085. // Title
  4086. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n^n", id, "MENU_ADMIN_TITLE")
  4087.  
  4088. // 1. Zombiefy/Humanize command
  4089. if (userflags & (g_access_flag[ACCESS_MODE_INFECTION] | g_access_flag[ACCESS_MAKE_ZOMBIE] | g_access_flag[ACCESS_MAKE_HUMAN]))
  4090. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_ADMIN1")
  4091. else
  4092. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_ADMIN1")
  4093.  
  4094. // 2. Nemesis command
  4095. if (userflags & (g_access_flag[ACCESS_MODE_NEMESIS] | g_access_flag[ACCESS_MAKE_NEMESIS]))
  4096. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU_ADMIN2")
  4097. else
  4098. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU_ADMIN2")
  4099.  
  4100. // 3. Survivor command
  4101. if (userflags & (g_access_flag[ACCESS_MODE_SURVIVOR] | g_access_flag[ACCESS_MAKE_SURVIVOR]))
  4102. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n", id, "MENU_ADMIN3")
  4103. else
  4104. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n", id, "MENU_ADMIN3")
  4105.  
  4106. // 4. Sniper command
  4107. if (userflags & (g_access_flag[ACCESS_MODE_SNIPER] | g_access_flag[ACCESS_MAKE_SNIPER]))
  4108. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU_ADMIN8")
  4109. else
  4110. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU_ADMIN8")
  4111.  
  4112. // 5. Assassin command
  4113. if (userflags & (g_access_flag[ACCESS_MODE_ASSASSIN] | g_access_flag[ACCESS_MAKE_ASSASSIN]))
  4114. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n", id, "MENU_ADMIN9")
  4115. else
  4116. len += formatex(menu[len], charsmax(menu) - len, "\d5. %L^n", id, "MENU_ADMIN9")
  4117.  
  4118. // 6. Respawn command
  4119. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  4120. len += formatex(menu[len], charsmax(menu) - len, "\r6.\w %L^n", id, "MENU_ADMIN4")
  4121. else
  4122. len += formatex(menu[len], charsmax(menu) - len, "\d6. %L^n", id, "MENU_ADMIN4")
  4123.  
  4124. // 9. Exit
  4125. len += formatex(menu[len], charsmax(menu) - len, "^n\r9.\w %L", id, "MENU_EXIT")
  4126.  
  4127. // 0. Back
  4128. len += formatex(menu[len], charsmax(menu) - len, "^n\r0.\w %L", id, "MENU_BACK")
  4129.  
  4130. show_menu(id, KEYSMENU, menu, -1, "Admin Menu")
  4131. }
  4132.  
  4133. // Admin Menu 2
  4134. show_menu2_admin(id)
  4135. {
  4136. static menu[250], len, userflags
  4137. len = 0
  4138. userflags = get_user_flags(id)
  4139.  
  4140. // Title
  4141. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n^n", id, "MENU2_ADMIN_TITLE")
  4142.  
  4143. // 1. Multi infection command
  4144. if ((userflags & g_access_flag[ACCESS_MODE_MULTI]) && allowed_multi())
  4145. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_ADMIN6")
  4146. else
  4147. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_ADMIN6")
  4148.  
  4149. // 2. Swarm mode command
  4150. if ((userflags & g_access_flag[ACCESS_MODE_SWARM]) && allowed_swarm())
  4151. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU_ADMIN5")
  4152. else
  4153. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU_ADMIN5")
  4154.  
  4155. // 3. Plague mode command
  4156. if ((userflags & g_access_flag[ACCESS_MODE_PLAGUE]) && allowed_plague())
  4157. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n", id, "MENU_ADMIN7")
  4158. else
  4159. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n", id, "MENU_ADMIN7")
  4160.  
  4161. // 4. Armageddon mode command
  4162. if ((userflags & g_access_flag[ACCESS_MODE_LNJ]) && allowed_lnj())
  4163. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU_ADMIN10")
  4164. else
  4165. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU_ADMIN10")
  4166.  
  4167. // 9. Exit
  4168. len += formatex(menu[len], charsmax(menu) - len, "^n\r9.\w %L", id, "MENU_EXIT")
  4169.  
  4170. // 0. Back
  4171. len += formatex(menu[len], charsmax(menu) - len, "^n\r0.\w %L", id, "MENU_BACK")
  4172.  
  4173. show_menu(id, KEYSMENU, menu, -1, "Menu2 Admin")
  4174. }
  4175.  
  4176. // Admin Menu 3
  4177. show_menu3_admin(id)
  4178. {
  4179. static menu[245], len, userflags
  4180. len = 0
  4181. userflags = get_user_flags(id)
  4182.  
  4183. // Title
  4184. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n^n", id, "MENU3_ADMIN_TITLE")
  4185.  
  4186. // 1. Admin menu of classes
  4187. if (userflags & g_access_flag[ACCESS_ADMIN_MENU])
  4188. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_ADMIN")
  4189. else
  4190. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_ADMIN")
  4191.  
  4192. // 2. Main Modes admin menu
  4193. if (userflags & g_access_flag[ACCESS_ADMIN_MENU2])
  4194. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU2_ADMIN")
  4195. else
  4196. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU2_ADMIN")
  4197.  
  4198. // 3. Custom modes admin menu
  4199. if (userflags & g_access_flag[ACCESS_ADMIN_MENU3])
  4200. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n^n", id, "MENU_ADMIN_CUSTOM")
  4201. else
  4202. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n^n", id, "MENU_ADMIN_CUSTOM")
  4203.  
  4204. // 4. Turn the Mod off
  4205. if (userflags & g_access_flag[ACCESS_ENABLE_MOD])
  4206. {
  4207. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU4_ADMIN")
  4208. len += formatex(menu[len], charsmax(menu) - len, "\r %L^n^n", id, "MENU4_ADMIN3")
  4209. }
  4210. else
  4211. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU4_ADMIN")
  4212.  
  4213.  
  4214. // 0. Exit
  4215. len += formatex(menu[len], charsmax(menu) - len, "^n\r0.\w %L", id, "MENU_EXIT")
  4216.  
  4217. show_menu(id, KEYSMENU, menu, -1, "Menu3 Admin")
  4218. }
  4219.  
  4220. // Mod turn off menu
  4221. show_menu4_admin(id)
  4222. {
  4223. static menu[240], len
  4224. len = 0
  4225.  
  4226. // Title
  4227. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n^n", id, "MENU4_ADMIN_TITLE")
  4228.  
  4229. // Items
  4230. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU4_ADMIN1")
  4231. len += formatex(menu[len], charsmax(menu) - len, "\r %L^n^n", id, "MENU4_ADMIN3")
  4232.  
  4233. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU4_ADMIN2")
  4234.  
  4235. // 0. Exit
  4236. len += formatex(menu[len], charsmax(menu) - len, "^n\r0.\w %L", id, "MENU_EXIT")
  4237.  
  4238. show_menu(id, KEYSMENU, menu, -1, "Menu4 Admin")
  4239. }
  4240.  
  4241.  
  4242. // Player List Menu
  4243. show_menu_player_list(id)
  4244. {
  4245. static menuid, menu[128], player, userflags, buffer[2]
  4246. userflags = get_user_flags(id)
  4247.  
  4248. // Title
  4249. switch (PL_ACTION)
  4250. {
  4251. case ACTION_ZOMBIEFY_HUMANIZE: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN1")
  4252. case ACTION_MAKE_NEMESIS: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN2")
  4253. case ACTION_MAKE_SURVIVOR: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN3")
  4254. case ACTION_MAKE_SNIPER: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN8")
  4255. case ACTION_MAKE_ASSASSIN: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN9")
  4256. case ACTION_RESPAWN_PLAYER: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN4")
  4257. }
  4258. menuid = menu_create(menu, "menu_player_list")
  4259.  
  4260. // Player List
  4261. for (player = 1; player <= g_maxplayers; player++)
  4262. {
  4263. // Skip if not connected
  4264. if (!g_isconnected[player])
  4265. continue;
  4266.  
  4267. // Format text depending on the action to take
  4268. switch (PL_ACTION)
  4269. {
  4270. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  4271. {
  4272. if (g_zombie[player])
  4273. {
  4274. if (allowed_human(player) && (userflags & g_access_flag[ACCESS_MAKE_HUMAN]))
  4275. {
  4276. if (g_nemesis[player])
  4277. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_NEMESIS")
  4278. else if (g_assassin[player])
  4279. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4280. else
  4281. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4282. }
  4283. else
  4284. {
  4285. if (g_nemesis[player])
  4286. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS")
  4287. else if (g_assassin[player])
  4288. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4289. else
  4290. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4291. }
  4292. }
  4293. else
  4294. {
  4295. if (allowed_zombie(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_INFECTION]) : (userflags & g_access_flag[ACCESS_MAKE_ZOMBIE])))
  4296. {
  4297. if (g_survivor[player])
  4298. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4299. else if (g_sniper[player])
  4300. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SNIPER")
  4301. else
  4302. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_HUMAN")
  4303. }
  4304. else
  4305. {
  4306. if (g_survivor[player])
  4307. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4308. else if (g_sniper[player])
  4309. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SNIPER")
  4310. else
  4311. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN")
  4312. }
  4313. }
  4314. }
  4315. case ACTION_MAKE_NEMESIS: // Nemesis command
  4316. {
  4317. if (allowed_nemesis(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_NEMESIS]) : (userflags & g_access_flag[ACCESS_MAKE_NEMESIS])))
  4318. {
  4319. if (g_zombie[player])
  4320. {
  4321. if (g_nemesis[player])
  4322. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_NEMESIS")
  4323. else if (g_assassin[player])
  4324. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4325. else
  4326. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4327. }
  4328. else
  4329. {
  4330. if (g_survivor[player])
  4331. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4332. else if (g_sniper[player])
  4333. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SNIPER")
  4334. else
  4335. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_HUMAN")
  4336. }
  4337. }
  4338. else
  4339. {
  4340. if (g_zombie[player])
  4341. {
  4342. if (g_nemesis[player])
  4343. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS")
  4344. else if (g_assassin[player])
  4345. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4346. else
  4347. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4348. }
  4349. else
  4350. {
  4351. if (g_survivor[player])
  4352. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4353. else if (g_sniper[player])
  4354. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SNIPER")
  4355. else
  4356. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN")
  4357. }
  4358. }
  4359. }
  4360. case ACTION_MAKE_SURVIVOR: // Survivor command
  4361. {
  4362. if (allowed_survivor(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SURVIVOR]) : (userflags & g_access_flag[ACCESS_MAKE_SURVIVOR])))
  4363. {
  4364. if (g_zombie[player])
  4365. {
  4366. if (g_nemesis[player])
  4367. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_NEMESIS")
  4368. else if (g_assassin[player])
  4369. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4370. else
  4371. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4372. }
  4373. else
  4374. {
  4375. if (g_survivor[player])
  4376. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4377. else if (g_sniper[player])
  4378. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SNIPER")
  4379. else
  4380. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_HUMAN")
  4381. }
  4382. }
  4383. else
  4384. {
  4385. if (g_zombie[player])
  4386. {
  4387. if (g_nemesis[player])
  4388. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS")
  4389. else if (g_assassin[player])
  4390. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4391. else
  4392. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4393. }
  4394. else
  4395. {
  4396. if (g_survivor[player])
  4397. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4398. else if (g_sniper[player])
  4399. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SNIPER")
  4400. else
  4401. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN")
  4402. }
  4403. }
  4404. }
  4405. case ACTION_MAKE_SNIPER: // Sniper command
  4406. {
  4407. if (allowed_sniper(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SNIPER]) : (userflags & g_access_flag[ACCESS_MAKE_SNIPER])))
  4408. {
  4409. if (g_zombie[player])
  4410. {
  4411. if (g_nemesis[player])
  4412. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_NEMESIS")
  4413. else if (g_assassin[player])
  4414. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4415. else
  4416. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4417. }
  4418. else
  4419. {
  4420. if (g_survivor[player])
  4421. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4422. else if (g_sniper[player])
  4423. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SNIPER")
  4424. else
  4425. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_HUMAN")
  4426. }
  4427. }
  4428. else
  4429. {
  4430. if (g_zombie[player])
  4431. {
  4432. if (g_nemesis[player])
  4433. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS")
  4434. else if (g_assassin[player])
  4435. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4436. else
  4437. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4438. }
  4439. else
  4440. {
  4441. if (g_survivor[player])
  4442. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4443. else if (g_sniper[player])
  4444. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SNIPER")
  4445. else
  4446. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN")
  4447. }
  4448. }
  4449. }
  4450. case ACTION_MAKE_ASSASSIN: // Nemesis command
  4451. {
  4452. if (allowed_assassin(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_ASSASSIN]) : (userflags & g_access_flag[ACCESS_MAKE_ASSASSIN])))
  4453. {
  4454. if (g_zombie[player])
  4455. {
  4456. if (g_nemesis[player])
  4457. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_NEMESIS")
  4458. else if (g_assassin[player])
  4459. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4460. else
  4461. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4462. }
  4463. else
  4464. {
  4465. if (g_survivor[player])
  4466. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4467. else if (g_sniper[player])
  4468. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_SNIPER")
  4469. else
  4470. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, "CLASS_HUMAN")
  4471. }
  4472. }
  4473. else
  4474. {
  4475. if (g_zombie[player])
  4476. {
  4477. if (g_nemesis[player])
  4478. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS")
  4479. else if (g_assassin[player])
  4480. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ASSASSIN")
  4481. else
  4482. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE")
  4483. }
  4484. else
  4485. {
  4486. if (g_survivor[player])
  4487. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR")
  4488. else if (g_sniper[player])
  4489. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SNIPER")
  4490. else
  4491. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN")
  4492. }
  4493. }
  4494. }
  4495. case ACTION_RESPAWN_PLAYER: // Respawn command
  4496. {
  4497. if (allowed_respawn(player) && (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS]))
  4498. formatex(menu, charsmax(menu), "%s", g_playername[player])
  4499. else
  4500. formatex(menu, charsmax(menu), "\d%s", g_playername[player])
  4501. }
  4502. }
  4503.  
  4504. // Add player
  4505. buffer[0] = player
  4506. buffer[1] = 0
  4507. menu_additem(menuid, menu, buffer)
  4508. }
  4509.  
  4510. // Back - Next - Exit
  4511. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  4512. menu_setprop(menuid, MPROP_BACKNAME, menu)
  4513. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  4514. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  4515. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  4516. menu_setprop(menuid, MPROP_EXITNAME, menu)
  4517.  
  4518. menu_display(id, menuid)
  4519. }
  4520.  
  4521. /*================================================================================
  4522.  [Menu Handlers]
  4523. =================================================================================*/
  4524.  
  4525. // Game Menu
  4526. public menu_game(id, key)
  4527. {
  4528. switch (key)
  4529. {
  4530. case 0: // Buy Weapons
  4531. {
  4532. // Custom buy menus enabled?
  4533. if (get_pcvar_num(cvar_buycustom))
  4534. {
  4535. // Disable the remember selection setting
  4536. WPN_AUTO_ON = 0
  4537. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "BUY_ENABLED")
  4538.  
  4539. // Show menu if player hasn't yet bought anything
  4540. if (g_canbuy[id]) show_menu_buy1(id)
  4541. }
  4542. else
  4543. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4544. }
  4545. case 1: // Extra Items
  4546. {
  4547. // Extra items enabled?
  4548. if (get_pcvar_num(cvar_extraitems))
  4549. {
  4550. // Check whether the player is able to buy anything
  4551. if (g_isalive[id])
  4552. show_menu_extras(id)
  4553. else
  4554. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4555. }
  4556. else
  4557. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_EXTRAS")
  4558. }
  4559. case 2: // Zombie Classes
  4560. {
  4561. // Zombie classes enabled?
  4562. if (get_pcvar_num(cvar_zclasses))
  4563. show_menu_zclass(id)
  4564. else
  4565. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ZCLASSES")
  4566. }
  4567. case 3: // Unstuck
  4568. {
  4569. // Check if player is stuck
  4570. if (g_isalive[id])
  4571. {
  4572. if (is_player_stuck(id))
  4573. {
  4574. // Move to an initial spawn
  4575. if (get_pcvar_num(cvar_randspawn))
  4576. do_random_spawn(id) // random spawn (including CSDM)
  4577. else
  4578. do_random_spawn(id, 1) // regular spawn
  4579. }
  4580. else
  4581. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_STUCK")
  4582. }
  4583. else
  4584. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4585. }
  4586. case 4: // Help Menu
  4587. {
  4588. show_menu_info(id)
  4589. }
  4590. case 5: // Join Spectator
  4591. {
  4592. // Player alive?
  4593. if (g_isalive[id])
  4594. {
  4595. // Prevent abuse by non-admins if block suicide setting is enabled
  4596. if (get_pcvar_num(cvar_blocksuicide) && !(get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU]))
  4597. {
  4598. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4599. return PLUGIN_HANDLED;
  4600. }
  4601.  
  4602. // Check that we still have both humans and zombies to keep the round going
  4603. check_round(id)
  4604.  
  4605. // Kill him before he switches team
  4606. dllfunc(DLLFunc_ClientKill, id)
  4607. }
  4608.  
  4609. // Temporarily save player stats?
  4610. if (get_pcvar_num(cvar_statssave)) save_stats(id)
  4611.  
  4612. // Remove previous tasks
  4613. remove_task(id+TASK_TEAM)
  4614. remove_task(id+TASK_MODEL)
  4615. remove_task(id+TASK_FLASH)
  4616. remove_task(id+TASK_CHARGE)
  4617. remove_task(id+TASK_SPAWN)
  4618. remove_task(id+TASK_BLOOD)
  4619. remove_task(id+TASK_AURA)
  4620. remove_task(id+TASK_BURN)
  4621.  
  4622. // Then move him to the spectator team
  4623. fm_cs_set_user_team(id, FM_CS_TEAM_SPECTATOR)
  4624. fm_user_team_update(id)
  4625. }
  4626. case 8: // Admin Menu
  4627. {
  4628. // Check if player has the required access
  4629. if (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU3])
  4630. show_menu3_admin(id)
  4631. else
  4632. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  4633. }
  4634. }
  4635.  
  4636. return PLUGIN_HANDLED;
  4637. }
  4638.  
  4639. // Buy Menu 1
  4640. public menu_buy1(id, key)
  4641. {
  4642. // Zombies, survivors or snipers get no guns
  4643. if (!g_isalive[id] || g_zombie[id] || g_survivor[id] || g_sniper[id])
  4644. return PLUGIN_HANDLED;
  4645.  
  4646. // Special keys / weapon list exceeded
  4647. if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
  4648. {
  4649. switch (key)
  4650. {
  4651. case MENU_KEY_AUTOSELECT: // toggle auto select
  4652. {
  4653. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  4654. }
  4655. case MENU_KEY_NEXT: // next/back
  4656. {
  4657. if (WPN_STARTID+7 < WPN_MAXIDS)
  4658. WPN_STARTID += 7
  4659. else
  4660. WPN_STARTID = 0
  4661. }
  4662. case MENU_KEY_EXIT: // exit
  4663. {
  4664. return PLUGIN_HANDLED;
  4665. }
  4666. }
  4667.  
  4668. // Show buy menu again
  4669. show_menu_buy1(id)
  4670. return PLUGIN_HANDLED;
  4671. }
  4672.  
  4673. // Store selected weapon id
  4674. WPN_AUTO_PRI = WPN_SELECTION
  4675.  
  4676. // Buy primary weapon
  4677. buy_primary_weapon(id, WPN_AUTO_PRI)
  4678.  
  4679. // Show pistols menu
  4680. show_menu_buy2(id)
  4681.  
  4682. return PLUGIN_HANDLED;
  4683. }
  4684.  
  4685. // Buy Primary Weapon
  4686. buy_primary_weapon(id, selection)
  4687. {
  4688. // Drop previous weapons
  4689. drop_weapons(id, 1)
  4690. drop_weapons(id, 2)
  4691.  
  4692. // Strip off from weapons
  4693. fm_strip_user_weapons(id)
  4694. fm_give_item(id, "weapon_knife")
  4695.  
  4696. // Get weapon's id and name
  4697. static weaponid, wname[32]
  4698. weaponid = ArrayGetCell(g_primary_weaponids, selection)
  4699. ArrayGetString(g_primary_items, selection, wname, charsmax(wname))
  4700.  
  4701. // Give the new weapon and full ammo
  4702. fm_give_item(id, wname)
  4703. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  4704.  
  4705. // Weapons bought
  4706. g_canbuy[id] = false
  4707.  
  4708. // Give additional items
  4709. static i
  4710. for (i = 0; i < ArraySize(g_additional_items); i++)
  4711. {
  4712. ArrayGetString(g_additional_items, i, wname, charsmax(wname))
  4713. fm_give_item(id, wname)
  4714. }
  4715. }
  4716.  
  4717. // Buy Menu 2
  4718. public menu_buy2(id, key)
  4719. {
  4720. // Zombies, survivors or snipers get no guns
  4721. if (!g_isalive[id] || g_zombie[id] || g_survivor[id] || g_sniper[id])
  4722. return PLUGIN_HANDLED;
  4723.  
  4724. // Special keys / weapon list exceeded
  4725. if (key >= ArraySize(g_secondary_items))
  4726. {
  4727. // Toggle autoselect
  4728. if (key == MENU_KEY_AUTOSELECT)
  4729. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  4730.  
  4731. // Reshow menu unless user exited
  4732. if (key != MENU_KEY_EXIT)
  4733. show_menu_buy2(id)
  4734.  
  4735. return PLUGIN_HANDLED;
  4736. }
  4737.  
  4738. // Store selected weapon
  4739. WPN_AUTO_SEC = key
  4740.  
  4741. // Drop secondary gun again, in case we picked another (bugfix)
  4742. drop_weapons(id, 2)
  4743.  
  4744. // Get weapon's id
  4745. static weaponid, wname[32]
  4746. weaponid = ArrayGetCell(g_secondary_weaponids, key)
  4747. ArrayGetString(g_secondary_items, key, wname, charsmax(wname))
  4748.  
  4749. // Give the new weapon and full ammo
  4750. fm_give_item(id, wname)
  4751. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  4752.  
  4753. return PLUGIN_HANDLED;
  4754. }
  4755.  
  4756. // Extra Items Menu
  4757. public menu_extras(id, menuid, item)
  4758. {
  4759. // Menu was closed
  4760. if (item == MENU_EXIT)
  4761. {
  4762. menu_destroy(menuid)
  4763. return PLUGIN_HANDLED;
  4764. }
  4765.  
  4766. // Dead players are not allowed to buy items
  4767. if (!g_isalive[id])
  4768. {
  4769. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4770. menu_destroy(menuid)
  4771. return PLUGIN_HANDLED;
  4772. }
  4773.  
  4774. // Retrieve extra item id
  4775. static buffer[2], dummy, itemid
  4776. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  4777. itemid = buffer[0]
  4778.  
  4779. // Attempt to buy the item
  4780. buy_extra_item(id, itemid)
  4781. menu_destroy(menuid)
  4782. return PLUGIN_HANDLED;
  4783. }
  4784.  
  4785. // Buy Extra Item
  4786. buy_extra_item(id, itemid, ignorecost = 0)
  4787. {
  4788. // Retrieve item's team
  4789. static team
  4790. team = ArrayGetCell(g_extraitem_team, itemid)
  4791.  
  4792. // Check for team/class specific items
  4793. if ((g_zombie[id] && !g_nemesis[id] && !g_assassin[id] && !(team & ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && !(team & ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS))
  4794. || (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)) || (g_sniper[id] && !(team & ZP_TEAM_SNIPER)) || (g_assassin[id] && !(team & ZP_TEAM_ASSASSIN)))
  4795. {
  4796. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4797. return;
  4798. }
  4799.  
  4800. // Check for unavailable items
  4801. if ((itemid == EXTRA_NVISION && !get_pcvar_num(cvar_extranvision))
  4802. || (itemid == EXTRA_ANTIDOTE && (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)))
  4803. || (itemid == EXTRA_MADNESS && (!get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)))
  4804. || (itemid == EXTRA_INFBOMB && (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)))
  4805. || (itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)))
  4806. {
  4807. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4808. return;
  4809. }
  4810.  
  4811. // Check for hard coded items with special conditions
  4812. if ((itemid == EXTRA_ANTIDOTE && (g_endround || g_swarmround || g_nemround || g_assassinround || g_survround || g_plagueround || g_sniperround || g_lnjround || fnGetZombies() <= 1 || (get_pcvar_num(cvar_deathmatch) && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() == 1)))
  4813. || (itemid == EXTRA_MADNESS && g_nodamage[id]) || (itemid == EXTRA_INFBOMB && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround || g_assassinround || g_sniperround || g_lnjround)))
  4814. {
  4815. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_CANTUSE")
  4816. return;
  4817. }
  4818.  
  4819. // Ignore item's cost?
  4820. if (!ignorecost)
  4821. {
  4822. // Check that we have enough ammo packs
  4823. if (g_ammopacks[id] < ArrayGetCell(g_extraitem_cost, itemid))
  4824. {
  4825. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  4826. return;
  4827. }
  4828.  
  4829. // Deduce item cost
  4830. g_ammopacks[id] -= ArrayGetCell(g_extraitem_cost, itemid)
  4831. }
  4832.  
  4833. // Check which kind of item we're buying
  4834. switch (itemid)
  4835. {
  4836. case EXTRA_NVISION: // Night Vision
  4837. {
  4838. g_nvision[id] = true
  4839.  
  4840. if (!g_isbot[id])
  4841. {
  4842. g_nvisionenabled[id] = true
  4843.  
  4844. // Custom nvg?
  4845. if (get_pcvar_num(cvar_customnvg))
  4846. {
  4847. remove_task(id+TASK_NVISION)
  4848. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  4849. }
  4850. else
  4851. set_user_gnvision(id, 1)
  4852. }
  4853. else
  4854. cs_set_user_nvg(id, 1)
  4855. }
  4856. case EXTRA_ANTIDOTE: // Antidote
  4857. {
  4858. // Increase antidote purchase count for this round
  4859. g_antidotecounter++
  4860.  
  4861. humanme(id, 0, 0, 0)
  4862. }
  4863. case EXTRA_MADNESS: // Zombie Madness
  4864. {
  4865. // Increase madness purchase count for this round
  4866. g_madnesscounter++
  4867.  
  4868. g_nodamage[id] = true
  4869. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  4870. set_task(get_pcvar_float(cvar_madnessduration), "madness_over", id+TASK_BLOOD)
  4871.  
  4872. static sound[64]
  4873. ArrayGetString(zombie_madness, random_num(0, ArraySize(zombie_madness) - 1), sound, charsmax(sound))
  4874. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4875. }
  4876. case EXTRA_INFBOMB: // Infection Bomb
  4877. {
  4878. // Increase infection bomb purchase count for this round
  4879. g_infbombcounter++
  4880.  
  4881. // Already own one
  4882. if (user_has_weapon(id, CSW_HEGRENADE))
  4883. {
  4884. // Increase BP ammo on it instead
  4885. cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1)
  4886.  
  4887. // Flash ammo in hud
  4888. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  4889. write_byte(AMMOID[CSW_HEGRENADE]) // ammo id
  4890. write_byte(1) // ammo amount
  4891. message_end()
  4892.  
  4893. // Play clip purchase sound
  4894. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4895.  
  4896. return; // stop here
  4897. }
  4898.  
  4899. // Give weapon to the player
  4900. fm_give_item(id, "weapon_hegrenade")
  4901. }
  4902. default:
  4903. {
  4904. if (itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1) // Weapons
  4905. {
  4906. // Get weapon's id and name
  4907. static weaponid, wname[32]
  4908. ArrayGetString(g_extraweapon_items, itemid - EXTRA_WEAPONS_STARTID, wname, charsmax(wname))
  4909. weaponid = cs_weapon_name_to_id(wname)
  4910.  
  4911. // If we are giving a primary/secondary weapon
  4912. if (MAXBPAMMO[weaponid] > 2)
  4913. {
  4914. // Make user drop the previous one
  4915. if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
  4916. drop_weapons(id, 1)
  4917. else
  4918. drop_weapons(id, 2)
  4919.  
  4920. // Give full BP ammo for the new one
  4921. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  4922. }
  4923. // If we are giving a grenade which the user already owns
  4924. else if (user_has_weapon(id, weaponid))
  4925. {
  4926. // Increase BP ammo on it instead
  4927. cs_set_user_bpammo(id, weaponid, cs_get_user_bpammo(id, weaponid) + 1)
  4928.  
  4929. // Flash ammo in hud
  4930. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  4931. write_byte(AMMOID[weaponid]) // ammo id
  4932. write_byte(1) // ammo amount
  4933. message_end()
  4934.  
  4935. // Play clip purchase sound
  4936. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4937.  
  4938. return; // stop here
  4939. }
  4940.  
  4941. // Give weapon to the player
  4942. fm_give_item(id, wname)
  4943. }
  4944. else // Custom additions
  4945. {
  4946. // Item selected forward
  4947. ExecuteForward(g_fwExtraItemSelected, g_fwDummyResult, id, itemid);
  4948.  
  4949. // Item purchase blocked, restore buyer's ammo packs
  4950. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && !ignorecost)
  4951. g_ammopacks[id] += ArrayGetCell(g_extraitem_cost, itemid)
  4952. }
  4953. }
  4954. }
  4955. }
  4956.  
  4957. // Zombie Class Menu
  4958. public menu_zclass(id, menuid, item)
  4959. {
  4960. // Menu was closed
  4961. if (item == MENU_EXIT)
  4962. {
  4963. menu_destroy(menuid)
  4964. return PLUGIN_HANDLED;
  4965. }
  4966.  
  4967. // Retrieve zombie class id
  4968. static buffer[2], dummy, classid
  4969. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  4970. classid = buffer[0]
  4971.  
  4972. // Store selection for the next infection
  4973. g_zombieclassnext[id] = classid
  4974.  
  4975. static name[32]
  4976. ArrayGetString(g_zclass_name, g_zombieclassnext[id], name, charsmax(name))
  4977.  
  4978. // Show selected zombie class info and stats
  4979. zp_colored_print(id, "^x04[ZP]^x01 %L^x01:^x04 %s", id, "ZOMBIE_SELECT", name)
  4980. zp_colored_print(id, "^x04[ZP]^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d^x01 |^x01 %L^x01:^x04 %d%%", id, "ZOMBIE_ATTRIB1", ArrayGetCell(g_zclass_hp, g_zombieclassnext[id]), id, "ZOMBIE_ATTRIB2", ArrayGetCell(g_zclass_spd, g_zombieclassnext[id]),
  4981. id, "ZOMBIE_ATTRIB3", floatround(Float:ArrayGetCell(g_zclass_grav, g_zombieclassnext[id]) * 800.0), id, "ZOMBIE_ATTRIB4", floatround(Float:ArrayGetCell(g_zclass_kb, g_zombieclassnext[id]) * 100.0))
  4982.  
  4983. menu_destroy(menuid)
  4984. return PLUGIN_HANDLED;
  4985. }
  4986.  
  4987. // Custom game mode menu
  4988. public menu_mode(id, menuid, item)
  4989. {
  4990. // Player wants to exit the menu
  4991. if (item == MENU_EXIT)
  4992. {
  4993. menu_destroy(menuid)
  4994. show_menu3_admin(id)
  4995. return PLUGIN_HANDLED;
  4996. }
  4997.  
  4998. // Create some necassary vars
  4999. static buffer[2], dummy , gameid
  5000.  
  5001. // Retrieve the id of the game mode which was chosen
  5002. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  5003. gameid = buffer[0]
  5004.  
  5005. // Check users access level
  5006. if (get_user_flags(id) & ArrayGetCell(g_gamemode_flag, (gameid - MAX_GAME_MODES)))
  5007. {
  5008. // Only allow the game mode to proceed after some checks
  5009. if (allowed_custom_game())
  5010. command_custom_game(gameid, id)
  5011. else
  5012. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5013.  
  5014. // Show the menu again
  5015. show_menu_game_mode(id)
  5016. return PLUGIN_HANDLED;
  5017. }
  5018. else
  5019. {
  5020. // Player deosnt haves the required access level
  5021. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5022.  
  5023. // Show the menu again
  5024. show_menu_game_mode(id)
  5025. return PLUGIN_HANDLED;
  5026. }
  5027.  
  5028. menu_destroy(menuid)
  5029. return PLUGIN_HANDLED;
  5030. }
  5031.  
  5032. // Info Menu
  5033. public menu_info(id, key)
  5034. {
  5035. static motd[1500], len
  5036. len = 0
  5037.  
  5038. switch (key)
  5039. {
  5040. case 0: // General
  5041. {
  5042. static weather, lighting[2]
  5043. weather = 0
  5044. get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
  5045. strtolower(lighting)
  5046.  
  5047. len += formatex(motd[len], charsmax(motd) - len, "%L ", id, "MOTD_INFO11", "Zombie Plague Advance 1.6.1 By MeRcyLeZZ , @bdul! And 93()|29!/<")
  5048. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO12")
  5049. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_A")
  5050.  
  5051. if (g_ambience_fog)
  5052. {
  5053. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_FOG")
  5054. weather++
  5055. }
  5056. if (g_ambience_rain)
  5057. {
  5058. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_RAIN")
  5059. weather++
  5060. }
  5061. if (g_ambience_snow)
  5062. {
  5063. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_SNOW")
  5064. weather++
  5065. }
  5066. if (weather < 1) len += formatex(motd[len], charsmax(motd) - len, " %L", id, "MOTD_DISABLED")
  5067.  
  5068. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_B", lighting)
  5069. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_C", id, get_pcvar_num(cvar_triggered) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5070. if (lighting[0] >= 'a' && lighting[0] <= 'd' && get_pcvar_float(cvar_thunder) > 0.0) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_D", floatround(get_pcvar_float(cvar_thunder)))
  5071. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_E", id, get_pcvar_num(cvar_removedoors) > 0 ? get_pcvar_num(cvar_removedoors) > 1 ? "MOTD_DOORS" : "MOTD_ROTATING" : "MOTD_ENABLED")
  5072. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_F", id, get_pcvar_num(cvar_deathmatch) > 0 ? get_pcvar_num(cvar_deathmatch) > 1 ? get_pcvar_num(cvar_deathmatch) > 2 ? "MOTD_ENABLED" : "MOTD_DM_ZOMBIE" : "MOTD_DM_HUMAN" : "MOTD_DISABLED")
  5073. if (get_pcvar_num(cvar_deathmatch)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_G", floatround(get_pcvar_float(cvar_spawnprotection)))
  5074. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_H", id, get_pcvar_num(cvar_randspawn) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5075. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_I", id, get_pcvar_num(cvar_extraitems) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5076. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_J", id, get_pcvar_num(cvar_zclasses) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5077. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_K", id, get_pcvar_num(cvar_customnvg) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5078. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_L", id, g_cached_customflash ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5079.  
  5080. show_motd(id, motd, "Zombie Plague Advance")
  5081. }
  5082. case 1: // Humans
  5083. {
  5084. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2")
  5085. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_A", get_pcvar_num(cvar_humanhp))
  5086. if (get_pcvar_num(cvar_humanlasthp) > 0) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_B", get_pcvar_num(cvar_humanlasthp))
  5087. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_C", floatround(g_cached_humanspd))
  5088. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_D", floatround(get_pcvar_float(cvar_humangravity) * 800.0))
  5089. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_E", id, get_pcvar_num(cvar_infammo) > 0 ? get_pcvar_num(cvar_infammo) > 1 ? "MOTD_AMMO_CLIP" : "MOTD_AMMO_BP" : "MOTD_LIMITED")
  5090. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_F", get_pcvar_num(cvar_ammodamage))
  5091. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_G", id, get_pcvar_num(cvar_firegrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5092. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_H", id, get_pcvar_num(cvar_frostgrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5093. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_I", id, get_pcvar_num(cvar_flaregrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5094. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_J", id, get_pcvar_num(cvar_knockback) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5095.  
  5096. show_motd(id, motd, "Zombie Plague Advance")
  5097. }
  5098. case 2: // Zombies
  5099. {
  5100. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3")
  5101. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_A", ArrayGetCell(g_zclass_hp, 0))
  5102. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_B", floatround(float(ArrayGetCell(g_zclass_hp, 0)) * get_pcvar_float(cvar_zombiefirsthp)))
  5103. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_C", floatround(get_pcvar_float(cvar_zombiearmor) * 100.0))
  5104. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_D", ArrayGetCell(g_zclass_spd, 0))
  5105. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_E", floatround(Float:ArrayGetCell(g_zclass_grav, 0) * 800.0))
  5106. if (get_pcvar_num(cvar_zombiebonushp)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_F", get_pcvar_num(cvar_zombiebonushp))
  5107. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_G", id, get_pcvar_num(cvar_zombiepainfree) > 0 ? get_pcvar_num(cvar_zombiepainfree) > 1 ? "MOTD_LASTZOMBIE" : "MOTD_ENABLED" : "MOTD_DISABLED")
  5108. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_H", id, get_pcvar_num(cvar_zombiebleeding) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5109. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_I", get_pcvar_num(cvar_ammoinfect))
  5110.  
  5111. show_motd(id, motd, "Zombie Plague Advance")
  5112. }
  5113. case 3: // Gameplay Modes
  5114. {
  5115. static nemhp[5], survhp[5], sniperhp[5], assassinhp[5]
  5116.  
  5117. // Get nemesis and survivor health
  5118. num_to_str(get_pcvar_num(cvar_nemhp), nemhp, charsmax(nemhp))
  5119. num_to_str(get_pcvar_num(cvar_survhp), survhp, charsmax(survhp))
  5120. num_to_str(get_pcvar_num(cvar_sniperhp), sniperhp, charsmax(sniperhp))
  5121. num_to_str(get_pcvar_num(cvar_assassinhp), assassinhp, charsmax(assassinhp))
  5122.  
  5123. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4")
  5124.  
  5125. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_A", id, get_pcvar_num(cvar_nem) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5126. if (get_pcvar_num(cvar_nem))
  5127. {
  5128. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_B", get_pcvar_num(cvar_nemchance))
  5129. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_C", get_pcvar_num(cvar_nemhp) > 0 ? nemhp : "[Auto]")
  5130. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_D", floatround(g_cached_nemspd))
  5131. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_E", floatround(get_pcvar_float(cvar_nemgravity) * 800.0))
  5132. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_F", id, g_cached_leapnemesis ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5133. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_G", id, get_pcvar_num(cvar_nempainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5134. }
  5135.  
  5136. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_H", id, get_pcvar_num(cvar_surv) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5137. if (get_pcvar_num(cvar_surv))
  5138. {
  5139. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_I", get_pcvar_num(cvar_survchance))
  5140. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_J", get_pcvar_num(cvar_survhp) > 0 ? survhp : "[Auto]")
  5141. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_K", floatround(g_cached_survspd))
  5142. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_L", floatround(get_pcvar_float(cvar_survgravity) * 800.0))
  5143. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_M", id, g_cached_leapsurvivor ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5144. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_N", id, get_pcvar_num(cvar_survpainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5145. }
  5146.  
  5147. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_O", id, get_pcvar_num(cvar_swarm) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5148. if (get_pcvar_num(cvar_swarm)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_P", get_pcvar_num(cvar_swarmchance))
  5149.  
  5150. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_Q", id, get_pcvar_num(cvar_multi) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5151. if (get_pcvar_num(cvar_multi))
  5152. {
  5153. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_R", get_pcvar_num(cvar_multichance))
  5154. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_S", floatround(get_pcvar_float(cvar_multiratio) * 100.0))
  5155. }
  5156.  
  5157. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_T", id, get_pcvar_num(cvar_plague) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5158. if (get_pcvar_num(cvar_plague))
  5159. {
  5160. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_U", get_pcvar_num(cvar_plaguechance))
  5161. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_V", floatround(get_pcvar_float(cvar_plagueratio) * 100.0))
  5162. }
  5163.  
  5164. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_A", id, get_pcvar_num(cvar_sniper) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5165. if (get_pcvar_num(cvar_sniper))
  5166. {
  5167. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_B", get_pcvar_num(cvar_sniperchance))
  5168. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_C", get_pcvar_num(cvar_sniperhp) > 0 ? sniperhp : "[Auto]")
  5169. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_D", floatround(g_cached_sniperspd))
  5170. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_E", floatround(get_pcvar_float(cvar_snipergravity) * 800.0))
  5171. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_F", id, g_cached_leapsniper ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5172. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_G", id, get_pcvar_num(cvar_sniperpainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5173. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO5_H", floatround(get_pcvar_float(cvar_sniperdamage)))
  5174. }
  5175.  
  5176. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_A", id, get_pcvar_num(cvar_assassin) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5177. if (get_pcvar_num(cvar_assassin))
  5178. {
  5179. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_B", get_pcvar_num(cvar_assassinchance))
  5180. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_C", get_pcvar_num(cvar_assassinhp) > 0 ? assassinhp : "[Auto]")
  5181. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_D", floatround(g_cached_assassinspd))
  5182. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_E", floatround(get_pcvar_float(cvar_assassingravity) * 800.0))
  5183. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_F", id, g_cached_leapassassin ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5184. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_G", id, get_pcvar_num(cvar_assassinpainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5185. }
  5186.  
  5187. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_H", id, get_pcvar_num(cvar_lnj) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5188. if (get_pcvar_num(cvar_lnj))
  5189. {
  5190. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_I", get_pcvar_num(cvar_lnjchance))
  5191. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO6_J", floatround(get_pcvar_float(cvar_lnjratio) * 100.0))
  5192. }
  5193.  
  5194. show_motd(id, motd, "Zombie Plague Advance")
  5195. }
  5196. default: return PLUGIN_HANDLED;
  5197. }
  5198.  
  5199. // Show help menu again if user wishes to read another topic
  5200. show_menu_info(id)
  5201.  
  5202. return PLUGIN_HANDLED;
  5203. }
  5204.  
  5205. // Admin Menu
  5206. public menu_admin(id, key)
  5207. {
  5208. static userflags
  5209. userflags = get_user_flags(id)
  5210.  
  5211. switch (key)
  5212. {
  5213. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  5214. {
  5215. if (userflags & (g_access_flag[ACCESS_MODE_INFECTION] | g_access_flag[ACCESS_MAKE_ZOMBIE] | g_access_flag[ACCESS_MAKE_HUMAN]))
  5216. {
  5217. // Show player list for admin to pick a target
  5218. PL_ACTION = ACTION_ZOMBIEFY_HUMANIZE
  5219. show_menu_player_list(id)
  5220. }
  5221. else
  5222. {
  5223. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5224. show_menu_admin(id)
  5225. }
  5226. }
  5227. case ACTION_MAKE_NEMESIS: // Nemesis command
  5228. {
  5229. if (userflags & (g_access_flag[ACCESS_MODE_NEMESIS] | g_access_flag[ACCESS_MAKE_NEMESIS]))
  5230. {
  5231. // Show player list for admin to pick a target
  5232. PL_ACTION = ACTION_MAKE_NEMESIS
  5233. show_menu_player_list(id)
  5234. }
  5235. else
  5236. {
  5237. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5238. show_menu_admin(id)
  5239. }
  5240. }
  5241. case ACTION_MAKE_SURVIVOR: // Survivor command
  5242. {
  5243. if (userflags & (g_access_flag[ACCESS_MODE_SURVIVOR] | g_access_flag[ACCESS_MAKE_SURVIVOR]))
  5244. {
  5245. // Show player list for admin to pick a target
  5246. PL_ACTION = ACTION_MAKE_SURVIVOR
  5247. show_menu_player_list(id)
  5248. }
  5249. else
  5250. {
  5251. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5252. show_menu_admin(id)
  5253. }
  5254. }
  5255. case ACTION_MAKE_SNIPER: // Sniper command
  5256. {
  5257. if (userflags & (g_access_flag[ACCESS_MODE_SNIPER] | g_access_flag[ACCESS_MAKE_SNIPER]))
  5258. {
  5259. // Show player list for admin to pick a target
  5260. PL_ACTION = ACTION_MAKE_SNIPER
  5261. show_menu_player_list(id)
  5262. }
  5263. else
  5264. {
  5265. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5266. show_menu_admin(id)
  5267. }
  5268. }
  5269. case ACTION_MAKE_ASSASSIN: // Assassin command
  5270. {
  5271. if (userflags & (g_access_flag[ACCESS_MODE_ASSASSIN] | g_access_flag[ACCESS_MAKE_ASSASSIN]))
  5272. {
  5273. // Show player list for admin to pick a target
  5274. PL_ACTION = ACTION_MAKE_ASSASSIN
  5275. show_menu_player_list(id)
  5276. }
  5277. else
  5278. {
  5279. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5280. show_menu_admin(id)
  5281. }
  5282. }
  5283. case ACTION_RESPAWN_PLAYER: // Respawn command
  5284. {
  5285. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  5286. {
  5287. // Show player list for admin to pick a target
  5288. PL_ACTION = ACTION_RESPAWN_PLAYER
  5289. show_menu_player_list(id)
  5290. }
  5291. else
  5292. {
  5293. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5294. show_menu_admin(id)
  5295. }
  5296. }
  5297. case 9: // Chose to return
  5298. {
  5299. show_menu3_admin(id)
  5300. }
  5301. }
  5302. return PLUGIN_HANDLED;
  5303. }
  5304.  
  5305. public menu2_admin(id, key)
  5306. {
  5307. static userflags
  5308. userflags = get_user_flags(id)
  5309.  
  5310. switch (key)
  5311. {
  5312. case 0: // Multiple Infection command
  5313. {
  5314. if (userflags & g_access_flag[ACCESS_MODE_MULTI])
  5315. {
  5316. if (allowed_multi())
  5317. command_multi(id)
  5318. else
  5319. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5320. }
  5321. else
  5322. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5323.  
  5324. show_menu2_admin(id)
  5325. }
  5326. case 1: // Swarm Mode command
  5327. {
  5328. if (userflags & g_access_flag[ACCESS_MODE_SWARM])
  5329. {
  5330. if (allowed_swarm())
  5331. command_swarm(id)
  5332. else
  5333. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5334. }
  5335. else
  5336. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5337.  
  5338. show_menu2_admin(id)
  5339. }
  5340. case 2: // Plague Mode command
  5341. {
  5342. if (userflags & g_access_flag[ACCESS_MODE_PLAGUE])
  5343. {
  5344. if (allowed_plague())
  5345. command_plague(id)
  5346. else
  5347. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5348. }
  5349. else
  5350. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5351.  
  5352. show_menu2_admin(id)
  5353. }
  5354. case 3: // Armageddon Mode command
  5355. {
  5356. if (userflags & g_access_flag[ACCESS_MODE_LNJ])
  5357. {
  5358. if (allowed_lnj())
  5359. command_lnj(id)
  5360. else
  5361. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5362. }
  5363. else
  5364. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5365.  
  5366. show_menu2_admin(id)
  5367. }
  5368. case 9: // Chose to return
  5369. {
  5370. show_menu3_admin(id)
  5371. }
  5372. }
  5373. return PLUGIN_HANDLED;
  5374. }
  5375.  
  5376. public menu3_admin(id, key)
  5377. {
  5378. switch (key)
  5379. {
  5380. case 0: // Admin Menu Mode
  5381. {
  5382. // Check if player has the required access
  5383. if (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU])
  5384. show_menu_admin(id)
  5385. else
  5386. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5387. }
  5388. case 1: // Admin Menu Class
  5389. {
  5390. // Check if player has the required access
  5391. if (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU2])
  5392. show_menu2_admin(id)
  5393. else
  5394. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5395. }
  5396. case 2: // Admin Menu of Custom Game modes
  5397. {
  5398. // Check if player has the required access
  5399. if (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU3])
  5400. show_menu_game_mode(id)
  5401. else
  5402. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5403. }
  5404. case 3: // Shut the mod
  5405. {
  5406. // Check if player has the required access
  5407. if (get_user_flags(id) & g_access_flag[ACCESS_ENABLE_MOD])
  5408. show_menu4_admin(id)
  5409. else
  5410. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5411. }
  5412. }
  5413. return PLUGIN_HANDLED;
  5414. }
  5415.  
  5416. public menu4_admin(id, key)
  5417. {
  5418. switch (key)
  5419. {
  5420. case 0: // Shut the mode
  5421. {
  5422. g_time = 5
  5423. shut_the_mode()
  5424. }
  5425. case 1: // Return
  5426. {
  5427. show_menu3_admin(id)
  5428. }
  5429. }
  5430. return PLUGIN_HANDLED;
  5431. }
  5432.  
  5433. // Player List Menu
  5434. public menu_player_list(id, menuid, item)
  5435. {
  5436. // Menu was closed
  5437. if (item == MENU_EXIT)
  5438. {
  5439. menu_destroy(menuid)
  5440. show_menu_admin(id)
  5441. return PLUGIN_HANDLED;
  5442. }
  5443.  
  5444. // Retrieve player id
  5445. static buffer[2], dummy, playerid
  5446. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  5447. playerid = buffer[0]
  5448.  
  5449. // Perform action on player
  5450.  
  5451. // Get admin flags
  5452. static userflags
  5453. userflags = get_user_flags(id)
  5454.  
  5455. // Make sure it's still connected
  5456. if (g_isconnected[playerid])
  5457. {
  5458. // Perform the right action if allowed
  5459. switch (PL_ACTION)
  5460. {
  5461. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  5462. {
  5463. if (g_zombie[playerid])
  5464. {
  5465. if (userflags & g_access_flag[ACCESS_MAKE_HUMAN])
  5466. {
  5467. if (allowed_human(playerid))
  5468. command_human(id, playerid)
  5469. else
  5470. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5471. }
  5472. else
  5473. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5474. }
  5475. else
  5476. {
  5477. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_INFECTION]) : (userflags & g_access_flag[ACCESS_MAKE_ZOMBIE]))
  5478. {
  5479. if (allowed_zombie(playerid))
  5480. command_zombie(id, playerid)
  5481. else
  5482. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5483. }
  5484. else
  5485. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5486. }
  5487. }
  5488. case ACTION_MAKE_NEMESIS: // Nemesis command
  5489. {
  5490. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_NEMESIS]) : (userflags & g_access_flag[ACCESS_MAKE_NEMESIS]))
  5491. {
  5492. if (allowed_nemesis(playerid))
  5493. command_nemesis(id, playerid)
  5494. else
  5495. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5496. }
  5497. else
  5498. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5499. }
  5500. case ACTION_MAKE_SURVIVOR: // Survivor command
  5501. {
  5502. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SURVIVOR]) : (userflags & g_access_flag[ACCESS_MAKE_SURVIVOR]))
  5503. {
  5504. if (allowed_survivor(playerid))
  5505. command_survivor(id, playerid)
  5506. else
  5507. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5508. }
  5509. else
  5510. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5511. }
  5512. case ACTION_MAKE_SNIPER: // Sniper command
  5513. {
  5514. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SNIPER]) : (userflags & g_access_flag[ACCESS_MAKE_SNIPER]))
  5515. {
  5516. if (allowed_sniper(playerid))
  5517. command_sniper(id, playerid)
  5518. else
  5519. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5520. }
  5521. else
  5522. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5523. }
  5524. case ACTION_MAKE_ASSASSIN: // Assassin command
  5525. {
  5526. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_ASSASSIN]) : (userflags & g_access_flag[ACCESS_MAKE_ASSASSIN]))
  5527. {
  5528. if (allowed_assassin(playerid))
  5529. command_assassin(id, playerid)
  5530. else
  5531. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5532. }
  5533. else
  5534. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5535. }
  5536. case ACTION_RESPAWN_PLAYER: // Respawn command
  5537. {
  5538. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  5539. {
  5540. if (allowed_respawn(playerid))
  5541. command_respawn(id, playerid)
  5542. else
  5543. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5544. }
  5545. else
  5546. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  5547. }
  5548. }
  5549. }
  5550. else
  5551. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5552.  
  5553. menu_destroy(menuid)
  5554. show_menu_player_list(id)
  5555. return PLUGIN_HANDLED;
  5556. }
  5557.  
  5558. /*================================================================================
  5559.  [Admin Commands]
  5560. =================================================================================*/
  5561.  
  5562. // zp_toggle [1/0]
  5563. public cmd_toggle(id, level, cid)
  5564. {
  5565. // Check for access flag - Enable/Disable Mod
  5566. if (!cmd_access(id, g_access_flag[ACCESS_ENABLE_MOD], cid, 2))
  5567. return PLUGIN_HANDLED;
  5568.  
  5569. // Retrieve arguments
  5570. new arg[2]
  5571. read_argv(1, arg, charsmax(arg))
  5572.  
  5573. // Mod already enabled/disabled
  5574. if (str_to_num(arg) == g_pluginenabled)
  5575. return PLUGIN_HANDLED;
  5576.  
  5577. // Set toggle cvar
  5578. set_pcvar_num(cvar_toggle, str_to_num(arg))
  5579. client_print(id, print_console, "Zombie Plague Advance %L.", id, str_to_num(arg) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5580.  
  5581. // Retrieve map name
  5582. new mapname[32]
  5583. get_mapname(mapname, charsmax(mapname))
  5584.  
  5585. // Restart current map
  5586. server_cmd("changelevel %s", mapname)
  5587.  
  5588. return PLUGIN_HANDLED;
  5589. }
  5590.  
  5591. // zp_zombie [target]
  5592. public cmd_zombie(id, level, cid)
  5593. {
  5594. // Check for access flag depending on the resulting action
  5595. if (g_newround)
  5596. {
  5597. // Start Mode Infection
  5598. if (!cmd_access(id, g_access_flag[ACCESS_MODE_INFECTION], cid, 2))
  5599. return PLUGIN_HANDLED;
  5600. }
  5601. else
  5602. {
  5603. // Make Zombie
  5604. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_ZOMBIE], cid, 2))
  5605. return PLUGIN_HANDLED;
  5606. }
  5607.  
  5608. // Retrieve arguments
  5609. static arg[32], player
  5610. read_argv(1, arg, charsmax(arg))
  5611. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5612.  
  5613. // Invalid target
  5614. if (!player) return PLUGIN_HANDLED;
  5615.  
  5616. // Target not allowed to be zombie
  5617. if (!allowed_zombie(player))
  5618. {
  5619. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5620. return PLUGIN_HANDLED
  5621. }
  5622.  
  5623. command_zombie(id, player)
  5624.  
  5625. return PLUGIN_HANDLED;
  5626. }
  5627.  
  5628. // zp_human [target]
  5629. public cmd_human(id, level, cid)
  5630. {
  5631. // Check for access flag - Make Human
  5632. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_HUMAN], cid, 2))
  5633. return PLUGIN_HANDLED;
  5634.  
  5635. // Retrieve arguments
  5636. static arg[32], player
  5637. read_argv(1, arg, charsmax(arg))
  5638. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5639.  
  5640. // Invalid target
  5641. if (!player) return PLUGIN_HANDLED;
  5642.  
  5643. // Target not allowed to be human
  5644. if (!allowed_human(player))
  5645. {
  5646. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5647. return PLUGIN_HANDLED;
  5648. }
  5649.  
  5650. command_human(id, player)
  5651.  
  5652. return PLUGIN_HANDLED;
  5653. }
  5654.  
  5655. // zp_survivor [target]
  5656. public cmd_survivor(id, level, cid)
  5657. {
  5658. // Check for access flag depending on the resulting action
  5659. if (g_newround)
  5660. {
  5661. // Start Mode Survivor
  5662. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SURVIVOR], cid, 2))
  5663. return PLUGIN_HANDLED;
  5664. }
  5665. else
  5666. {
  5667. // Make Survivor
  5668. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_SURVIVOR], cid, 2))
  5669. return PLUGIN_HANDLED;
  5670. }
  5671.  
  5672. // Retrieve arguments
  5673. static arg[32], player
  5674. read_argv(1, arg, charsmax(arg))
  5675. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5676.  
  5677. // Invalid target
  5678. if (!player) return PLUGIN_HANDLED;
  5679.  
  5680. // Target not allowed to be survivor
  5681. if (!allowed_survivor(player))
  5682. {
  5683. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5684. return PLUGIN_HANDLED;
  5685. }
  5686.  
  5687. command_survivor(id, player)
  5688.  
  5689. return PLUGIN_HANDLED;
  5690. }
  5691.  
  5692. // zp_nemesis [target]
  5693. public cmd_nemesis(id, level, cid)
  5694. {
  5695. // Check for access flag depending on the resulting action
  5696. if (g_newround)
  5697. {
  5698. // Start Mode Nemesis
  5699. if (!cmd_access(id, g_access_flag[ACCESS_MODE_NEMESIS], cid, 2))
  5700. return PLUGIN_HANDLED;
  5701. }
  5702. else
  5703. {
  5704. // Make Nemesis
  5705. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_NEMESIS], cid, 2))
  5706. return PLUGIN_HANDLED;
  5707. }
  5708.  
  5709. // Retrieve arguments
  5710. static arg[32], player
  5711. read_argv(1, arg, charsmax(arg))
  5712. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5713.  
  5714. // Invalid target
  5715. if (!player) return PLUGIN_HANDLED;
  5716.  
  5717. // Target not allowed to be nemesis
  5718. if (!allowed_nemesis(player))
  5719. {
  5720. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5721. return PLUGIN_HANDLED;
  5722. }
  5723.  
  5724. command_nemesis(id, player)
  5725.  
  5726. return PLUGIN_HANDLED;
  5727. }
  5728.  
  5729. // zp_respawn [target]
  5730. public cmd_respawn(id, level, cid)
  5731. {
  5732. // Check for access flag - Respawn
  5733. if (!cmd_access(id, g_access_flag[ACCESS_RESPAWN_PLAYERS], cid, 2))
  5734. return PLUGIN_HANDLED;
  5735.  
  5736. // Retrieve arguments
  5737. static arg[32], player
  5738. read_argv(1, arg, charsmax(arg))
  5739. player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  5740.  
  5741. // Invalid target
  5742. if (!player) return PLUGIN_HANDLED;
  5743.  
  5744. // Target not allowed to be respawned
  5745. if (!allowed_respawn(player))
  5746. {
  5747. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5748. return PLUGIN_HANDLED;
  5749. }
  5750.  
  5751. command_respawn(id, player)
  5752.  
  5753. return PLUGIN_HANDLED;
  5754. }
  5755.  
  5756. // zp_swarm
  5757. public cmd_swarm(id, level, cid)
  5758. {
  5759. // Check for access flag - Mode Swarm
  5760. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SWARM], cid, 2))
  5761. return PLUGIN_HANDLED;
  5762.  
  5763. // Swarm mode not allowed
  5764. if (!allowed_swarm())
  5765. {
  5766. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5767. return PLUGIN_HANDLED;
  5768. }
  5769.  
  5770. command_swarm(id)
  5771.  
  5772. return PLUGIN_HANDLED;
  5773. }
  5774.  
  5775. // zp_multi
  5776. public cmd_multi(id, level, cid)
  5777. {
  5778. // Check for access flag - Mode Multi
  5779. if (!cmd_access(id, g_access_flag[ACCESS_MODE_MULTI], cid, 2))
  5780. return PLUGIN_HANDLED;
  5781.  
  5782. // Multi infection mode not allowed
  5783. if (!allowed_multi())
  5784. {
  5785. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5786. return PLUGIN_HANDLED;
  5787. }
  5788.  
  5789. command_multi(id)
  5790.  
  5791. return PLUGIN_HANDLED;
  5792. }
  5793.  
  5794. // zp_plague
  5795. public cmd_plague(id, level, cid)
  5796. {
  5797. // Check for access flag - Mode Plague
  5798. if (!cmd_access(id, g_access_flag[ACCESS_MODE_PLAGUE], cid, 2))
  5799. return PLUGIN_HANDLED;
  5800.  
  5801. // Plague mode not allowed
  5802. if (!allowed_plague())
  5803. {
  5804. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5805. return PLUGIN_HANDLED;
  5806. }
  5807.  
  5808. command_plague(id)
  5809.  
  5810. return PLUGIN_HANDLED;
  5811. }
  5812.  
  5813. // zp_sniper [target]
  5814. public cmd_sniper(id, level, cid)
  5815. {
  5816. // Check for access flag depending on the resulting action
  5817. if (g_newround)
  5818. {
  5819. // Start Mode Sniper
  5820. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SNIPER], cid, 2))
  5821. return PLUGIN_HANDLED;
  5822. }
  5823. else
  5824. {
  5825. // Make Sniper
  5826. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_SNIPER], cid, 2))
  5827. return PLUGIN_HANDLED;
  5828. }
  5829.  
  5830. // Retrieve arguments
  5831. static arg[32], player
  5832. read_argv(1, arg, charsmax(arg))
  5833. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5834.  
  5835. // Invalid target
  5836. if (!player) return PLUGIN_HANDLED;
  5837.  
  5838. // Target not allowed to be sniper
  5839. if (!allowed_sniper(player))
  5840. {
  5841. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5842. return PLUGIN_HANDLED;
  5843. }
  5844.  
  5845. command_sniper(id, player)
  5846.  
  5847. return PLUGIN_HANDLED;
  5848. }
  5849. // zp_assassin [target]
  5850. public cmd_assassin(id, level, cid)
  5851. {
  5852. // Check for access flag depending on the resulting action
  5853. if (g_newround)
  5854. {
  5855. // Start Mode Assassin
  5856. if (!cmd_access(id, g_access_flag[ACCESS_MODE_ASSASSIN], cid, 2))
  5857. return PLUGIN_HANDLED;
  5858. }
  5859. else
  5860. {
  5861. // Make Assassin
  5862. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_ASSASSIN], cid, 2))
  5863. return PLUGIN_HANDLED;
  5864. }
  5865.  
  5866. // Retrieve arguments
  5867. static arg[32], player
  5868. read_argv(1, arg, charsmax(arg))
  5869. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  5870.  
  5871. // Invalid target
  5872. if (!player) return PLUGIN_HANDLED;
  5873.  
  5874. // Target not allowed to be assassin
  5875. if (!allowed_assassin(player))
  5876. {
  5877. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5878. return PLUGIN_HANDLED;
  5879. }
  5880.  
  5881. command_assassin(id, player)
  5882.  
  5883. return PLUGIN_HANDLED;
  5884. }
  5885.  
  5886. // zp_lnj
  5887. public cmd_lnj(id, level, cid)
  5888. {
  5889. // Check for access flag - Mode Apocalypse
  5890. if (!cmd_access(id, g_access_flag[ACCESS_MODE_LNJ], cid, 2))
  5891. return PLUGIN_HANDLED;
  5892.  
  5893. // Apocalypse mode not allowed
  5894. if (!allowed_lnj())
  5895. {
  5896. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5897. return PLUGIN_HANDLED;
  5898. }
  5899.  
  5900. command_lnj(id)
  5901.  
  5902. return PLUGIN_HANDLED;
  5903. }
  5904. /*================================================================================
  5905.  [Message Hooks]
  5906. =================================================================================*/
  5907.  
  5908. // Current Weapon info
  5909. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  5910. {
  5911. // Not alive or zombie
  5912. if (!g_isalive[msg_entity] || g_zombie[msg_entity])
  5913. return;
  5914.  
  5915. // Not an active weapon
  5916. if (get_msg_arg_int(1) != 1)
  5917. return;
  5918.  
  5919. // Unlimited clip disabled for class
  5920. if (g_survivor[msg_entity] ? get_pcvar_num(cvar_survinfammo) <= 1 : get_pcvar_num(cvar_infammo) <= 1 && g_sniper[msg_entity] ? get_pcvar_num(cvar_sniperinfammo) <= 1 : get_pcvar_num(cvar_infammo) <= 1)
  5921. return;
  5922.  
  5923. // Get weapon's id
  5924. static weapon
  5925. weapon = get_msg_arg_int(2)
  5926.  
  5927. // Unlimited Clip Ammo for this weapon?
  5928. if (MAXBPAMMO[weapon] > 2)
  5929. {
  5930. // Max out clip ammo
  5931. cs_set_weapon_ammo(fm_cs_get_current_weapon_ent(msg_entity), MAXCLIP[weapon])
  5932.  
  5933. // HUD should show full clip all the time
  5934. set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
  5935. }
  5936. }
  5937.  
  5938. // Take off player's money
  5939. public message_money(msg_id, msg_dest, msg_entity)
  5940. {
  5941. // Remove money setting enabled?
  5942. if (!get_pcvar_num(cvar_removemoney))
  5943. return PLUGIN_CONTINUE;
  5944.  
  5945. fm_cs_set_user_money(msg_entity, 0)
  5946. return PLUGIN_HANDLED;
  5947. }
  5948.  
  5949. // Fix for the HL engine bug when HP is multiples of 256
  5950. public message_health(msg_id, msg_dest, msg_entity)
  5951. {
  5952. // Get player's health
  5953. static health
  5954. health = get_msg_arg_int(1)
  5955.  
  5956. // Don't bother
  5957. if (health < 256) return;
  5958.  
  5959. // Check if we need to fix it
  5960. if (health % 256 == 0)
  5961. fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
  5962.  
  5963. // HUD can only show as much as 255 hp
  5964. set_msg_arg_int(1, get_msg_argtype(1), 255)
  5965. }
  5966.  
  5967. // Block flashlight battery messages if custom flashlight is enabled instead
  5968. public message_flashbat()
  5969. {
  5970. if (g_cached_customflash)
  5971. return PLUGIN_HANDLED;
  5972.  
  5973. return PLUGIN_CONTINUE;
  5974. }
  5975.  
  5976. // Flashbangs should only affect zombies
  5977. public message_screenfade(msg_id, msg_dest, msg_entity)
  5978. {
  5979. if (get_msg_arg_int(4) != 255 || get_msg_arg_int(5) != 255 || get_msg_arg_int(6) != 255 || get_msg_arg_int(7) < 200)
  5980. return PLUGIN_CONTINUE;
  5981.  
  5982. // Nemesis/Assassin shouldn't be FBed
  5983. if (g_zombie[msg_entity] && !g_nemesis[msg_entity] && !g_assassin[msg_entity])
  5984. {
  5985. // Set flash color to nighvision's
  5986. set_msg_arg_int(4, get_msg_argtype(4), get_pcvar_num(cvar_nvgcolor[0]))
  5987. set_msg_arg_int(5, get_msg_argtype(5), get_pcvar_num(cvar_nvgcolor[1]))
  5988. set_msg_arg_int(6, get_msg_argtype(6), get_pcvar_num(cvar_nvgcolor[2]))
  5989. return PLUGIN_CONTINUE;
  5990. }
  5991.  
  5992. return PLUGIN_HANDLED;
  5993. }
  5994.  
  5995. // Prevent spectators' nightvision from being turned off when switching targets, etc.
  5996. public message_nvgtoggle()
  5997. {
  5998. return PLUGIN_HANDLED;
  5999. }
  6000.  
  6001. // Set correct model on player corpses
  6002. public message_clcorpse()
  6003. {
  6004. set_msg_arg_string(1, g_playermodel[get_msg_arg_int(12)])
  6005. }
  6006.  
  6007. // Prevent zombies from seeing any weapon pickup icon
  6008. public message_weappickup(msg_id, msg_dest, msg_entity)
  6009. {
  6010. if (g_zombie[msg_entity])
  6011. return PLUGIN_HANDLED;
  6012.  
  6013. return PLUGIN_CONTINUE;
  6014. }
  6015.  
  6016. // Prevent zombies from seeing any ammo pickup icon
  6017. public message_ammopickup(msg_id, msg_dest, msg_entity)
  6018. {
  6019. if (g_zombie[msg_entity])
  6020. return PLUGIN_HANDLED;
  6021.  
  6022. return PLUGIN_CONTINUE;
  6023. }
  6024.  
  6025. // Block hostage HUD display
  6026. public message_scenario()
  6027. {
  6028. if (get_msg_args() > 1)
  6029. {
  6030. static sprite[8]
  6031. get_msg_arg_string(2, sprite, charsmax(sprite))
  6032.  
  6033. if (equal(sprite, "hostage"))
  6034. return PLUGIN_HANDLED;
  6035. }
  6036.  
  6037. return PLUGIN_CONTINUE;
  6038. }
  6039.  
  6040. // Block hostages from appearing on radar
  6041. public message_hostagepos()
  6042. {
  6043. return PLUGIN_HANDLED;
  6044. }
  6045.  
  6046. // Block some text messages
  6047. public message_textmsg()
  6048. {
  6049. static textmsg[22]
  6050. get_msg_arg_string(2, textmsg, charsmax(textmsg))
  6051.  
  6052. // Game restarting, reset scores and call round end to balance the teams
  6053. if (equal(textmsg, "#Game_will_restart_in"))
  6054. {
  6055. g_scorehumans = 0
  6056. g_scorezombies = 0
  6057. logevent_round_end()
  6058. }
  6059. // Block round end related messages
  6060. else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
  6061. {
  6062. return PLUGIN_HANDLED;
  6063. }
  6064.  
  6065. return PLUGIN_CONTINUE;
  6066. }
  6067.  
  6068. // Block CS round win audio messages, since we're playing our own instead
  6069. public message_sendaudio()
  6070. {
  6071. static audio[17]
  6072. get_msg_arg_string(2, audio, charsmax(audio))
  6073.  
  6074. if (equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
  6075. return PLUGIN_HANDLED;
  6076.  
  6077. return PLUGIN_CONTINUE;
  6078. }
  6079.  
  6080. // Send actual team scores (T = zombies // CT = humans)
  6081. public message_teamscore()
  6082. {
  6083. static team[2]
  6084. get_msg_arg_string(1, team, charsmax(team))
  6085.  
  6086. switch (team[0])
  6087. {
  6088. // CT
  6089. case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_scorehumans)
  6090. // Terrorist
  6091. case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_scorezombies)
  6092. }
  6093. }
  6094.  
  6095. // Team Switch (or player joining a team for first time)
  6096. public message_teaminfo(msg_id, msg_dest)
  6097. {
  6098. // Only hook global messages
  6099. if (msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
  6100.  
  6101. // Don't pick up our own TeamInfo messages for this player (bugfix)
  6102. if (g_switchingteam) return;
  6103.  
  6104. // Get player's id
  6105. static id
  6106. id = get_msg_arg_int(1)
  6107.  
  6108. // Enable spectators' nightvision if not spawning right away
  6109. set_task(0.2, "spec_nvision", id)
  6110.  
  6111. // Round didn't start yet, nothing to worry about
  6112. if (g_newround) return;
  6113.  
  6114. // Get his new team
  6115. static team[2]
  6116. get_msg_arg_string(2, team, charsmax(team))
  6117.  
  6118. // Perform some checks to see if they should join a different team instead
  6119. switch (team[0])
  6120. {
  6121. case 'C': // CT
  6122. {
  6123. if (g_survround && fnGetHumans() || g_sniperround && fnGetHumans()) // survivor or sniper alive --> switch to T and spawn as zombie
  6124. {
  6125. g_respawn_as_zombie[id] = true;
  6126. remove_task(id+TASK_TEAM)
  6127. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  6128. set_msg_arg_string(2, "TERRORIST")
  6129. }
  6130. else if (!fnGetZombies()) // no zombies alive --> switch to T and spawn as zombie
  6131. {
  6132. g_respawn_as_zombie[id] = true;
  6133. remove_task(id+TASK_TEAM)
  6134. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  6135. set_msg_arg_string(2, "TERRORIST")
  6136. }
  6137. }
  6138. case 'T': // Terrorist
  6139. {
  6140. if ((g_swarmround || g_survround || g_sniperround) && fnGetHumans()) // survivor/sniper alive or swarm round w\ humans --> spawn as zombie
  6141. {
  6142. g_respawn_as_zombie[id] = true;
  6143. }
  6144. else if (fnGetZombies()) // zombies alive --> switch to CT
  6145. {
  6146. remove_task(id+TASK_TEAM)
  6147. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6148. set_msg_arg_string(2, "CT")
  6149. }
  6150. }
  6151. }
  6152. }
  6153.  
  6154. /*================================================================================
  6155.  [Main Functions]
  6156. =================================================================================*/
  6157.  
  6158. // Make Zombie Task
  6159. public make_zombie_task()
  6160. {
  6161. /**
  6162. * Note:
  6163. * The make a zombie function has been totally changed
  6164. * and rewritten to suit the requirements of the new
  6165. * native for registering game modes externally.
  6166. */
  6167.  
  6168. // Get alive players count
  6169. static iPlayersnum
  6170. iPlayersnum = fnGetAlive()
  6171.  
  6172. // Not enough players, come back later!
  6173. if (iPlayersnum < 1)
  6174. {
  6175. set_task(2.0, "make_zombie_task", TASK_MAKEZOMBIE)
  6176. return;
  6177. }
  6178.  
  6179. // Start the game modes cycle
  6180. start_swarm_mode(0, MODE_NONE)
  6181. }
  6182.  
  6183. // Start swarm mode
  6184. start_swarm_mode(id, mode)
  6185. {
  6186. // Get alive players count
  6187. static iPlayersnum
  6188. iPlayersnum = fnGetAlive()
  6189.  
  6190. static sound[64]
  6191.  
  6192. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SWARM) && random_num(1, get_pcvar_num(cvar_swarmchance)) == get_pcvar_num(cvar_swarm) && iPlayersnum >= get_pcvar_num(cvar_swarmminplayers))
  6193. || mode == MODE_SET)
  6194. {
  6195. // Swarm Mode
  6196. g_swarmround = true
  6197. g_currentmode = MODE_SWARM
  6198. g_lastmode = MODE_SWARM
  6199.  
  6200. // Prevent Infection
  6201. g_allowinfection = false
  6202.  
  6203. // Make sure there are alive players on both teams (BUGFIX)
  6204. if (!fnGetAliveTs())
  6205. {
  6206. // Move random player to T team
  6207. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6208. remove_task(id+TASK_TEAM)
  6209. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  6210. fm_user_team_update(id)
  6211. }
  6212. else if (!fnGetAliveCTs())
  6213. {
  6214. // Move random player to CT team
  6215. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6216. remove_task(id+TASK_TEAM)
  6217. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6218. fm_user_team_update(id)
  6219. }
  6220.  
  6221. // Turn every T into a zombie
  6222. for (id = 1; id <= g_maxplayers; id++)
  6223. {
  6224. // Not alive
  6225. if (!g_isalive[id])
  6226. continue;
  6227.  
  6228. // Not a Terrorist
  6229. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
  6230. continue;
  6231.  
  6232. // Turn into a zombie
  6233. zombieme(id, 0, 0, 1, 0, 0)
  6234. }
  6235.  
  6236. // Play swarm sound
  6237. ArrayGetString(sound_swarm, random_num(0, ArraySize(sound_swarm) - 1), sound, charsmax(sound))
  6238. PlaySound(sound);
  6239.  
  6240. // Show Swarm HUD notice
  6241. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6242. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SWARM")
  6243.  
  6244. // Start ambience sounds
  6245. if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM])
  6246. {
  6247. remove_task(TASK_AMBIENCESOUNDS)
  6248. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6249. }
  6250.  
  6251. // Mode fully started!
  6252. g_modestarted = true
  6253. g_newround = false
  6254.  
  6255. // Round start forward
  6256. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SWARM, 0);
  6257.  
  6258. // Stop here [BUGFIX]
  6259. return;
  6260. }
  6261.  
  6262. // Give chance to another game mode
  6263. start_plague_mode(0, MODE_NONE)
  6264. }
  6265.  
  6266. // Start plague mode
  6267. start_plague_mode(id, mode)
  6268. {
  6269. // Get alive players count
  6270. static iPlayersnum
  6271. iPlayersnum = fnGetAlive()
  6272.  
  6273. static sound[64], iZombies, iMaxZombies
  6274.  
  6275. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_PLAGUE) && random_num(1, get_pcvar_num(cvar_plaguechance)) == get_pcvar_num(cvar_plague)
  6276. && floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) >= 1&&
  6277. iPlayersnum-(get_pcvar_num(cvar_plaguesurvnum)+get_pcvar_num(cvar_plaguenemnum)+floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)) >= 1
  6278. && iPlayersnum >= get_pcvar_num(cvar_plagueminplayers)) || mode == MODE_SET)
  6279. {
  6280. // Plague Mode
  6281. g_plagueround = true
  6282. g_currentmode = MODE_PLAGUE
  6283. g_lastmode = MODE_PLAGUE
  6284.  
  6285. // Prevent Infection
  6286. g_allowinfection = false
  6287.  
  6288. // Turn specified amount of players into Survivors
  6289. static iSurvivors, iMaxSurvivors
  6290. iMaxSurvivors = get_pcvar_num(cvar_plaguesurvnum)
  6291. iSurvivors = 0
  6292.  
  6293. while (iSurvivors < iMaxSurvivors)
  6294. {
  6295. // Choose random guy
  6296. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6297.  
  6298. // Already a survivor?
  6299. if (g_survivor[id])
  6300. continue;
  6301.  
  6302. // If not, turn him into one
  6303. humanme(id, 1, 0, 0)
  6304. iSurvivors++
  6305.  
  6306. // Apply survivor health multiplier
  6307. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguesurvhpmulti)))
  6308. }
  6309.  
  6310. // Turn specified amount of players into Nemesis
  6311. static iNemesis, iMaxNemesis
  6312. iMaxNemesis = get_pcvar_num(cvar_plaguenemnum)
  6313. iNemesis = 0
  6314.  
  6315. while (iNemesis < iMaxNemesis)
  6316. {
  6317. // Choose random guy
  6318. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6319.  
  6320. // Already a survivor or nemesis?
  6321. if (g_survivor[id] || g_nemesis[id])
  6322. continue;
  6323.  
  6324. // If not, turn him into one
  6325. zombieme(id, 0, 1, 0, 0, 0)
  6326. iNemesis++
  6327.  
  6328. // Apply nemesis health multiplier
  6329. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguenemhpmulti)))
  6330. }
  6331.  
  6332. // iMaxZombies is rounded up, in case there aren't enough players
  6333. iMaxZombies = floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)
  6334. iZombies = 0
  6335.  
  6336. // Randomly turn iMaxZombies players into zombies
  6337. while (iZombies < iMaxZombies)
  6338. {
  6339. // Keep looping through all players
  6340. if (++id > g_maxplayers) id = 1
  6341.  
  6342. // Dead or already a zombie or survivor
  6343. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  6344. continue;
  6345.  
  6346. // Random chance
  6347. if (random_num(0, 1))
  6348. {
  6349. // Turn into a zombie
  6350. zombieme(id, 0, 0, 1, 0, 0)
  6351. iZombies++
  6352. }
  6353. }
  6354.  
  6355. // Turn the remaining players into humans
  6356. for (id = 1; id <= g_maxplayers; id++)
  6357. {
  6358. // Only those of them who arent zombies or survivor
  6359. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  6360. continue;
  6361.  
  6362. // Switch to CT
  6363. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  6364. {
  6365. remove_task(id+TASK_TEAM)
  6366. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6367. fm_user_team_update(id)
  6368. }
  6369. }
  6370.  
  6371. // Play plague sound
  6372. ArrayGetString(sound_plague, random_num(0, ArraySize(sound_plague) - 1), sound, charsmax(sound))
  6373. PlaySound(sound);
  6374.  
  6375. // Show Plague HUD notice
  6376. set_hudmessage(0, 50, 200, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6377. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_PLAGUE")
  6378.  
  6379. // Start ambience sounds
  6380. if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE])
  6381. {
  6382. remove_task(TASK_AMBIENCESOUNDS)
  6383. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6384. }
  6385.  
  6386. // Mode fully started!
  6387. g_modestarted = true
  6388.  
  6389. // No more a new round
  6390. g_newround = false
  6391.  
  6392. // Round start forward
  6393. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_PLAGUE, 0);
  6394.  
  6395. // Stop here [BUGFIX]
  6396. return;
  6397. }
  6398.  
  6399. // Give chance to other game modes
  6400. start_multi_mode(0, MODE_NONE)
  6401. }
  6402.  
  6403. // Start multiple infection mode
  6404. start_multi_mode(id, mode)
  6405. {
  6406. // Get alive players count
  6407. static iPlayersnum
  6408. iPlayersnum = fnGetAlive()
  6409.  
  6410. static sound[64], iZombies, iMaxZombies
  6411.  
  6412. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_MULTI) && random_num(1, get_pcvar_num(cvar_multichance)) == get_pcvar_num(cvar_multi) &&
  6413. floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) >= 2 && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) < iPlayersnum && iPlayersnum >= get_pcvar_num(cvar_multiminplayers))
  6414. || mode == MODE_SET)
  6415. {
  6416.  
  6417. // Multi Infection Mode
  6418. g_currentmode = MODE_MULTI
  6419. g_lastmode = MODE_MULTI
  6420.  
  6421. // Allow Infection
  6422. g_allowinfection = true
  6423.  
  6424. // iMaxZombies is rounded up, in case there aren't enough players
  6425. iMaxZombies = floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil)
  6426. iZombies = 0
  6427.  
  6428. // Randomly turn iMaxZombies players into zombies
  6429. while (iZombies < iMaxZombies)
  6430. {
  6431. // Keep looping through all players
  6432. if (++id > g_maxplayers) id = 1
  6433.  
  6434. // Dead or already a zombie
  6435. if (!g_isalive[id] || g_zombie[id])
  6436. continue;
  6437.  
  6438. // Random chance
  6439. if (random_num(0, 1))
  6440. {
  6441. // Turn into a zombie
  6442. zombieme(id, 0, 0, 1, 0, 0)
  6443. iZombies++
  6444. }
  6445. }
  6446.  
  6447. // Turn the remaining players into humans
  6448. for (id = 1; id <= g_maxplayers; id++)
  6449. {
  6450. // Only those of them who aren't zombies
  6451. if (!g_isalive[id] || g_zombie[id])
  6452. continue;
  6453.  
  6454. // Switch to CT
  6455. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  6456. {
  6457. remove_task(id+TASK_TEAM)
  6458. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6459. fm_user_team_update(id)
  6460. }
  6461. }
  6462.  
  6463. // Play multi infection sound
  6464. ArrayGetString(sound_multi, random_num(0, ArraySize(sound_multi) - 1), sound, charsmax(sound))
  6465. PlaySound(sound);
  6466.  
  6467. // Show Multi Infection HUD notice
  6468. set_hudmessage(200, 50, 0, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6469. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_MULTI")
  6470.  
  6471. // Start ambience sounds
  6472. if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION])
  6473. {
  6474. remove_task(TASK_AMBIENCESOUNDS)
  6475. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6476. }
  6477.  
  6478. // Mode fully started!
  6479. g_modestarted = true
  6480.  
  6481. // No more a new round
  6482. g_newround = false
  6483.  
  6484. // Round start forward
  6485. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_MULTI, 0);
  6486.  
  6487. // Stop here
  6488. return;
  6489. }
  6490.  
  6491. // Give chance to other game modes
  6492. start_lnj_mode(0, MODE_NONE)
  6493. }
  6494.  
  6495. // Start LNJ mode
  6496. start_lnj_mode(id, mode)
  6497. {
  6498. // Get alive players count
  6499. static iPlayersnum
  6500. iPlayersnum = fnGetAlive()
  6501.  
  6502. static sound[64], iZombies, iMaxZombies
  6503.  
  6504. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_LNJ) && random_num(1, get_pcvar_num(cvar_lnjchance)) == get_pcvar_num(cvar_lnj) &&
  6505. iPlayersnum >= get_pcvar_num(cvar_lnjminplayers) && floatround(iPlayersnum*get_pcvar_float(cvar_lnjratio), floatround_ceil) >= 1 && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) < iPlayersnum )
  6506. || mode == MODE_SET)
  6507. {
  6508. // Armageddon Mode
  6509. g_lnjround = true
  6510. g_currentmode = MODE_LNJ
  6511. g_lastmode = MODE_LNJ
  6512.  
  6513. // Prevent Infection
  6514. g_allowinfection = false
  6515.  
  6516. // iMaxZombies is rounded up, in case there aren't enough players
  6517. iMaxZombies = floatround((iPlayersnum * get_pcvar_float(cvar_lnjratio)), floatround_ceil)
  6518. iZombies = 0
  6519.  
  6520. // Randomly turn iMaxZombies players into Nemesis
  6521. while (iZombies < iMaxZombies)
  6522. {
  6523. // Keep looping through all players
  6524. if (++id > g_maxplayers) id = 1
  6525.  
  6526. // Dead or already a zombie or survivor
  6527. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  6528. continue;
  6529.  
  6530. // Random chance
  6531. if (random_num(0, 1))
  6532. {
  6533. // Turn into a Nemesis
  6534. zombieme(id, 0, 1, 0, 0, 0)
  6535. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjnemhpmulti)))
  6536. iZombies++
  6537. }
  6538. }
  6539.  
  6540. // Turn the remaining players into survivors
  6541. for (id = 1; id <= g_maxplayers; id++)
  6542. {
  6543. // Only those of them who arent zombies or survivor
  6544. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  6545. continue;
  6546.  
  6547. // Turn into a Survivor
  6548. humanme(id, 1, 0, 0)
  6549. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjsurvhpmulti)))
  6550. }
  6551.  
  6552. // Play armageddon sound
  6553. ArrayGetString(sound_lnj, random_num(0, ArraySize(sound_lnj) - 1), sound, charsmax(sound))
  6554. PlaySound(sound);
  6555.  
  6556. // Show Armageddon HUD notice
  6557. set_hudmessage(181 , 62, 244, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6558. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_LNJ")
  6559.  
  6560. // Start ambience sounds
  6561. if (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ])
  6562. {
  6563. remove_task(TASK_AMBIENCESOUNDS)
  6564. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6565. }
  6566.  
  6567. // Mode fully started!
  6568. g_modestarted = true
  6569.  
  6570. // No more a new round
  6571. g_newround = false
  6572.  
  6573. // Round start forward
  6574. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_LNJ, 0);
  6575.  
  6576. // Stop Here
  6577. return;
  6578. }
  6579.  
  6580. // Give chance to other game modes
  6581. start_sniper_mode(0, MODE_NONE)
  6582. }
  6583.  
  6584. // Start sniper mode
  6585. start_sniper_mode(id, mode)
  6586. {
  6587. // Get alive players count
  6588. static iPlayersnum
  6589. iPlayersnum = fnGetAlive()
  6590.  
  6591. static forward_id, sound[64]
  6592.  
  6593. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SNIPER) && random_num(1, get_pcvar_num(cvar_sniperchance)) == get_pcvar_num(cvar_sniper) && iPlayersnum >= get_pcvar_num(cvar_sniperminplayers))
  6594. || mode == MODE_SET)
  6595. {
  6596. // Sniper Mode
  6597. g_sniperround = true
  6598. g_currentmode = MODE_SNIPER
  6599. g_lastmode = MODE_SNIPER
  6600.  
  6601. // Prevent Infection
  6602. g_allowinfection = false
  6603.  
  6604. // Choose player randomly?
  6605. if (mode == MODE_NONE)
  6606. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6607.  
  6608. // Remember id for calling our forward later
  6609. forward_id = id
  6610.  
  6611. // Make sniper
  6612. humanme(id, 0, 0, 1)
  6613.  
  6614. // Turn the remaining players into zombies
  6615. for (id = 1; id <= g_maxplayers; id++)
  6616. {
  6617. // Not alive
  6618. if (!g_isalive[id])
  6619. continue;
  6620.  
  6621. // Sniper or already a zombie
  6622. if (g_sniper[id] || g_zombie[id] )
  6623. continue;
  6624.  
  6625. // Turn into a zombie
  6626. zombieme(id, 0, 0, 1, 0, 0)
  6627. }
  6628.  
  6629. // Play sniper sound
  6630. ArrayGetString(sound_sniper, random_num(0, ArraySize(sound_sniper) - 1), sound, charsmax(sound))
  6631. PlaySound(sound);
  6632.  
  6633. // Show Sniper HUD notice
  6634. set_hudmessage(0 , 250, 250, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6635. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SNIPER", g_playername[forward_id])
  6636.  
  6637. // Start ambience sounds
  6638. if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER])
  6639. {
  6640. remove_task(TASK_AMBIENCESOUNDS)
  6641. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6642. }
  6643.  
  6644. // Mode fully started!
  6645. g_modestarted = true
  6646.  
  6647. // No more a new round
  6648. g_newround = false
  6649.  
  6650. // Round start forward
  6651. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SNIPER, forward_id);
  6652.  
  6653. // Stop here
  6654. return;
  6655. }
  6656.  
  6657. // Give a chance to other game modes
  6658. start_survivor_mode(0, MODE_NONE)
  6659. }
  6660.  
  6661. // Start survivor mode
  6662. start_survivor_mode(id, mode)
  6663. {
  6664. // Get alive players count
  6665. static iPlayersnum
  6666. iPlayersnum = fnGetAlive()
  6667.  
  6668. static forward_id, sound[64]
  6669.  
  6670. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SURVIVOR) && random_num(1, get_pcvar_num(cvar_survchance)) == get_pcvar_num(cvar_surv) && iPlayersnum >= get_pcvar_num(cvar_survminplayers))
  6671. || mode == MODE_SET)
  6672. {
  6673. // Survivor Mode
  6674. g_survround = true
  6675. g_currentmode = MODE_SURVIVOR
  6676. g_lastmode = MODE_SURVIVOR
  6677.  
  6678. // Prevent Infection
  6679. g_allowinfection = false
  6680.  
  6681. // Choose player randomly?
  6682. if (mode == MODE_NONE)
  6683. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6684.  
  6685. // Remember id for calling our forward later
  6686. forward_id = id
  6687.  
  6688. // Turn player into a survivor
  6689. humanme(id, 1, 0, 0)
  6690.  
  6691. // Turn the remaining players into zombies
  6692. for (id = 1; id <= g_maxplayers; id++)
  6693. {
  6694. // Not alive
  6695. if (!g_isalive[id])
  6696. continue;
  6697.  
  6698. // Survivor or already a zombie
  6699. if (g_survivor[id] || g_zombie[id] )
  6700. continue;
  6701.  
  6702. // Turn into a zombie
  6703. zombieme(id, 0, 0, 1, 0, 0)
  6704. }
  6705.  
  6706. // Play survivor sound
  6707. ArrayGetString(sound_survivor, random_num(0, ArraySize(sound_survivor) - 1), sound, charsmax(sound))
  6708. PlaySound(sound);
  6709.  
  6710. // Show Survivor HUD notice
  6711. set_hudmessage(0, 10, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6712. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SURVIVOR", g_playername[forward_id])
  6713.  
  6714. // Start ambience sounds
  6715. if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR])
  6716. {
  6717. remove_task(TASK_AMBIENCESOUNDS)
  6718. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6719. }
  6720.  
  6721. // Mode fully started!
  6722. g_modestarted = true
  6723.  
  6724. // No more a new round
  6725. g_newround = false
  6726.  
  6727. // Round start forward
  6728. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SURVIVOR, forward_id);
  6729.  
  6730. // Stop here
  6731. return;
  6732. }
  6733.  
  6734. // Give chance to other game modes
  6735. start_assassin_mode(0, MODE_NONE)
  6736. }
  6737.  
  6738. // Start assassin mode
  6739. start_assassin_mode(id, mode)
  6740. {
  6741. // Get alive players count
  6742. static iPlayersnum
  6743. iPlayersnum = fnGetAlive()
  6744.  
  6745. static forward_id, sound[64]
  6746.  
  6747. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_ASSASSIN) && random_num(1, get_pcvar_num(cvar_assassinchance)) == get_pcvar_num(cvar_assassin) && iPlayersnum >= get_pcvar_num(cvar_assassinminplayers))
  6748. || mode == MODE_SET)
  6749. {
  6750. // Assassin Mode
  6751. g_assassinround = true
  6752. g_currentmode = MODE_ASSASSIN
  6753. g_lastmode = MODE_ASSASSIN
  6754.  
  6755. // Prevent Infection
  6756. g_allowinfection = false
  6757.  
  6758. // Choose player randomly?
  6759. if (mode == MODE_NONE)
  6760. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6761.  
  6762. // Remember id for calling our forward later
  6763. forward_id = id
  6764.  
  6765. // Turn player into assassin
  6766. zombieme(id, 0, 0, 0, 0, 1)
  6767.  
  6768. // Turn off the lights [Taken From Speeds Zombie Mutilation]
  6769. static ent
  6770. ent = -1
  6771. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "light")) != 0)
  6772. {
  6773. dllfunc(DLLFunc_Use, ent, 0);
  6774. }
  6775.  
  6776. // Remaining players should be humans (CTs)
  6777. for (id = 1; id <= g_maxplayers; id++)
  6778. {
  6779. // Not alive
  6780. if (!g_isalive[id])
  6781. continue;
  6782.  
  6783. // First assassin
  6784. if (g_zombie[id])
  6785. continue;
  6786.  
  6787. // Switch to CT
  6788. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  6789. {
  6790. // Change team
  6791. remove_task(id+TASK_TEAM)
  6792. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6793. fm_user_team_update(id)
  6794. }
  6795.  
  6796. // Make a screen fade
  6797. message_begin(MSG_ONE, g_msgScreenFade, _, id)
  6798. write_short(UNIT_SECOND*5) // duration
  6799. write_short(0) // hold time
  6800. write_short(FFADE_IN) // fade type
  6801. write_byte(250) // red
  6802. write_byte(0) // green
  6803. write_byte(0) // blue
  6804. write_byte(255) // alpha
  6805. message_end()
  6806.  
  6807. // Make a screen shake [Make it horrorful]
  6808. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
  6809. write_short(UNIT_SECOND*75) // amplitude
  6810. write_short(UNIT_SECOND*7) // duration
  6811. write_short(UNIT_SECOND*75) // frequency
  6812. message_end()
  6813. }
  6814.  
  6815. // Play Assassin sound
  6816. ArrayGetString(sound_assassin, random_num(0, ArraySize(sound_assassin) - 1), sound, charsmax(sound))
  6817. PlaySound(sound);
  6818.  
  6819. // Show Assassin HUD notice
  6820. set_hudmessage(255, 150, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6821. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_ASSASSIN", g_playername[forward_id])
  6822.  
  6823. // Start ambience sounds
  6824. if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN])
  6825. {
  6826. remove_task(TASK_AMBIENCESOUNDS)
  6827. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6828. }
  6829.  
  6830. // Mode fully started!
  6831. g_modestarted = true
  6832.  
  6833. // No more a new round
  6834. g_newround = false
  6835.  
  6836. // Round start forward
  6837. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_ASSASSIN, forward_id);
  6838.  
  6839. // Stop here
  6840. return;
  6841. }
  6842.  
  6843. // Give chance to other game modes
  6844. start_nemesis_mode(0, MODE_NONE)
  6845. }
  6846.  
  6847. // Start nemesis mode
  6848. start_nemesis_mode(id, mode)
  6849. {
  6850. // Get alive players count
  6851. static iPlayersnum
  6852. iPlayersnum = fnGetAlive()
  6853.  
  6854. static forward_id, sound[64]
  6855.  
  6856. if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_NEMESIS) && random_num(1, get_pcvar_num(cvar_nemchance)) == get_pcvar_num(cvar_nem) && iPlayersnum >= get_pcvar_num(cvar_nemminplayers))
  6857. || mode == MODE_SET)
  6858. {
  6859. // Nemesis Mode
  6860. g_nemround = true
  6861. g_currentmode = MODE_NEMESIS
  6862. g_lastmode = MODE_NEMESIS
  6863.  
  6864. // Prevent Infection
  6865. g_allowinfection = false
  6866.  
  6867. // Choose player randomly?
  6868. if (mode == MODE_NONE)
  6869. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6870.  
  6871. // Remember id for calling our forward later
  6872. forward_id = id
  6873.  
  6874. // Turn player into nemesis
  6875. zombieme(id, 0, 1, 0, 0, 0)
  6876.  
  6877. // Remaining players should be humans (CTs)
  6878. for (id = 1; id <= g_maxplayers; id++)
  6879. {
  6880. // Not alive
  6881. if (!g_isalive[id])
  6882. continue;
  6883.  
  6884. // First nemesis
  6885. if (g_zombie[id])
  6886. continue;
  6887.  
  6888. // Switch to CT
  6889. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  6890. {
  6891. remove_task(id+TASK_TEAM)
  6892. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6893. fm_user_team_update(id)
  6894. }
  6895. }
  6896.  
  6897. // Play Nemesis sound
  6898. ArrayGetString(sound_nemesis, random_num(0, ArraySize(sound_nemesis) - 1), sound, charsmax(sound))
  6899. PlaySound(sound);
  6900.  
  6901. // Show Nemesis HUD notice
  6902. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6903. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_NEMESIS", g_playername[forward_id])
  6904.  
  6905. // Start ambience sounds
  6906. if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS])
  6907. {
  6908. remove_task(TASK_AMBIENCESOUNDS)
  6909. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  6910. }
  6911.  
  6912. // Mode fully started!
  6913. g_modestarted = true
  6914.  
  6915. // No more a new round
  6916. g_newround = false
  6917.  
  6918. // Round start forward
  6919. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_NEMESIS, forward_id);
  6920.  
  6921. // Stop here
  6922. return;
  6923. }
  6924.  
  6925. // Start some custom game modes
  6926. start_custom_mode()
  6927. }
  6928.  
  6929. // Start custom game mode
  6930. start_custom_mode()
  6931. {
  6932. // No custom game modes registered
  6933. if(g_gamemodes_i == MAX_GAME_MODES)
  6934. {
  6935. // Start our infection mode
  6936. start_infection_mode(0, MODE_NONE)
  6937. return;
  6938. }
  6939.  
  6940. // No more a new round
  6941. g_newround = false
  6942.  
  6943. // Loop through every custom game mode present
  6944. // This is to ensure that every game mode is given a chance
  6945. static game
  6946. for (game = MAX_GAME_MODES; game < g_gamemodes_i; game++)
  6947. {
  6948. // Apply chance level and check if the last played mode was not the same as this one
  6949. if ((random_num(1, ArrayGetCell(g_gamemode_chance, (game - MAX_GAME_MODES))) == 1) && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != game))
  6950. {
  6951. // Execute our round start pre forward
  6952. // This is were the game mode will decide whether to run itself or block it self
  6953. ExecuteForward(g_fwRoundStart_pre, g_fwDummyResult, game)
  6954.  
  6955. // The game mode didnt accept some conditions
  6956. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED)
  6957. {
  6958. // Give other game modes a chance
  6959. continue;
  6960. }
  6961. // Game mode has accepted the conditions
  6962. else
  6963. {
  6964. // Current game mode and last game mode are equal to the game mode id
  6965. g_currentmode = game
  6966. g_lastmode = game
  6967.  
  6968. // Check whether or not to allow infection during this game mode
  6969. g_allowinfection = (ArrayGetCell(g_gamemode_allow, (game - MAX_GAME_MODES)) == 1) ? true : false
  6970.  
  6971. // Check the death match mode required by the game mode
  6972. g_deathmatchmode = ArrayGetCell(g_gamemode_dm, (game - MAX_GAME_MODES))
  6973.  
  6974. // Our custom game mode has fully started
  6975. g_modestarted = true
  6976.  
  6977. // Execute our round start forward with the game mode id
  6978. ExecuteForward(g_fwRoundStart, g_fwDummyResult, game, 0)
  6979.  
  6980. // Turn the remaining players into humans [BUGFIX]
  6981. static id
  6982. for (id = 1; id <= g_maxplayers; id++)
  6983. {
  6984. // Only those of them who arent zombies or survivor
  6985. if (!g_isalive[id] || g_zombie[id] || g_survivor[id] || g_sniper[id])
  6986. continue;
  6987.  
  6988. // Switch to CT
  6989. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  6990. {
  6991. remove_task(id+TASK_TEAM)
  6992. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  6993. fm_user_team_update(id)
  6994. }
  6995. }
  6996.  
  6997. // Stop the loop and prevent other game modes from being given a chance [BUGFIX]
  6998. break;
  6999. }
  7000. }
  7001.  
  7002. // The game mode was not given a chance then continue the loop
  7003. else continue;
  7004. }
  7005.  
  7006. // No game mode has started then start our good old infection mode [BUGFIX]
  7007. if (!g_modestarted)
  7008. start_infection_mode(0, MODE_NONE)
  7009. }
  7010.  
  7011. // Start the default infection mode
  7012. start_infection_mode(id, mode)
  7013. {
  7014. // Get alive players count
  7015. static iPlayersnum
  7016. iPlayersnum = fnGetAlive()
  7017.  
  7018. static forward_id
  7019.  
  7020. // Single Infection Mode
  7021. g_currentmode = MODE_INFECTION
  7022. g_lastmode = MODE_INFECTION
  7023.  
  7024. // Allow Infection
  7025. g_allowinfection = true
  7026.  
  7027. // Choose player randomly?
  7028. if (mode == MODE_NONE)
  7029. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  7030.  
  7031. // Turn player into the first zombie
  7032. zombieme(id, 0, 0, 0, 0, 0)
  7033.  
  7034. // Remember id for calling our forward later
  7035. forward_id = id
  7036.  
  7037. // Remaining players should be humans (CTs)
  7038. for (id = 1; id <= g_maxplayers; id++)
  7039. {
  7040. // Not alive
  7041. if (!g_isalive[id])
  7042. continue;
  7043.  
  7044. // First zombie
  7045. if (g_zombie[id])
  7046. continue;
  7047.  
  7048. // Switch to CT
  7049. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  7050. {
  7051. remove_task(id+TASK_TEAM)
  7052. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  7053. fm_user_team_update(id)
  7054. }
  7055. }
  7056.  
  7057. // Show First Zombie HUD notice
  7058. set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  7059. ShowSyncHudMsg(0, g_MsgSync, "%L",LANG_PLAYER, "NOTICE_FIRST", g_playername[forward_id])
  7060.  
  7061. // Start ambience sounds
  7062. if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION])
  7063. {
  7064. remove_task(TASK_AMBIENCESOUNDS)
  7065. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  7066. }
  7067.  
  7068. // Mode fully started!
  7069. g_modestarted = true
  7070.  
  7071. // No more a new round
  7072. g_newround = false
  7073.  
  7074. // Round start forward
  7075. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_INFECTION, forward_id);
  7076. }
  7077.  
  7078. // Zombie Me Function (player id, infector, turn into a nemesis, silent mode, deathmsg and rewards, turn into assassin)
  7079. zombieme(id, infector, nemesis, silentmode, rewards, assassin)
  7080. {
  7081. // User infect attempt forward
  7082. ExecuteForward(g_fwUserInfect_attempt, g_fwDummyResult, id, infector, nemesis)
  7083.  
  7084. // One or more plugins blocked the infection. Only allow this after making sure it's
  7085. // not going to leave us with no zombies. Take into account a last player leaving case.
  7086. // BUGFIX: only allow after a mode has started, to prevent blocking first zombie e.g.
  7087. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetZombies() > g_lastplayerleaving)
  7088. return;
  7089.  
  7090. // Pre user infect forward
  7091. ExecuteForward(g_fwUserInfected_pre, g_fwDummyResult, id, infector, nemesis)
  7092.  
  7093. // Show zombie class menu if they haven't chosen any (e.g. just connected)
  7094. if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
  7095. set_task(0.2, "show_menu_zclass", id)
  7096.  
  7097. // Set selected zombie class
  7098. g_zombieclass[id] = g_zombieclassnext[id]
  7099.  
  7100. // If no class selected yet, use the first (default) one
  7101. if (g_zombieclass[id] == ZCLASS_NONE) g_zombieclass[id] = 0
  7102.  
  7103. // Way to go...
  7104. g_zombie[id] = true
  7105. g_nemesis[id] = false
  7106. g_assassin[id] = false
  7107. g_survivor[id] = false
  7108. g_firstzombie[id] = false
  7109. g_sniper[id] = false
  7110.  
  7111. // Remove aura (bugfix)
  7112. remove_task(id+TASK_AURA)
  7113.  
  7114. // Remove spawn protection (bugfix)
  7115. g_nodamage[id] = false
  7116. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  7117.  
  7118. // Reset burning duration counter (bugfix)
  7119. g_burning_duration[id] = 0
  7120.  
  7121. // Show deathmsg and reward infector?
  7122. if (rewards && infector)
  7123. {
  7124. // Send death notice and fix the "dead" attrib on scoreboard
  7125. SendDeathMsg(infector, id)
  7126. FixDeadAttrib(id)
  7127.  
  7128. // Reward frags, deaths, health, and ammo packs
  7129. UpdateFrags(infector, id, get_pcvar_num(cvar_fragsinfect), 1, 1)
  7130. g_ammopacks[infector] += get_pcvar_num(cvar_ammoinfect)
  7131. fm_set_user_health(infector, pev(infector, pev_health) + get_pcvar_num(cvar_zombiebonushp))
  7132. }
  7133.  
  7134. // Cache speed, knockback, and name for player's class
  7135. g_zombie_spd[id] = float(ArrayGetCell(g_zclass_spd, g_zombieclass[id]))
  7136. g_zombie_knockback[id] = Float:ArrayGetCell(g_zclass_kb, g_zombieclass[id])
  7137. ArrayGetString(g_zclass_name, g_zombieclass[id], g_zombie_classname[id], charsmax(g_zombie_classname[]))
  7138.  
  7139. // Set zombie attributes based on the mode
  7140. static sound[64]
  7141. if (!silentmode)
  7142. {
  7143. if (nemesis)
  7144. {
  7145. // Nemesis
  7146. g_nemesis[id] = true
  7147.  
  7148. // Set health [0 = auto]
  7149. if (get_pcvar_num(cvar_nemhp) == 0)
  7150. {
  7151. if (get_pcvar_num(cvar_nembasehp) == 0)
  7152. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, 0) * fnGetAlive())
  7153. else
  7154. fm_set_user_health(id, get_pcvar_num(cvar_nembasehp) * fnGetAlive())
  7155. }
  7156. else
  7157. fm_set_user_health(id, get_pcvar_num(cvar_nemhp))
  7158.  
  7159. // Set gravity, unless frozen
  7160. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_nemgravity))
  7161. }
  7162.  
  7163. else if (assassin)
  7164. {
  7165. // Assassin
  7166. g_assassin[id] = true
  7167.  
  7168. // Set health [0 = auto]
  7169. if (get_pcvar_num(cvar_assassinhp) == 0)
  7170. {
  7171. if (get_pcvar_num(cvar_assassinbasehp) == 0)
  7172. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, 0) * fnGetAlive())
  7173. else
  7174. fm_set_user_health(id, get_pcvar_num(cvar_assassinbasehp) * fnGetAlive())
  7175. }
  7176. else
  7177. fm_set_user_health(id, get_pcvar_num(cvar_assassinhp))
  7178.  
  7179. // Set gravity, unless frozen
  7180. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_assassingravity))
  7181. }
  7182.  
  7183. else if ((fnGetZombies() == 1) && !g_assassin[id] && !g_nemesis[id] )
  7184. {
  7185. // First zombie
  7186. g_firstzombie[id] = true
  7187.  
  7188. // Set health and gravity, unless frozen
  7189. fm_set_user_health(id, floatround(float(ArrayGetCell(g_zclass_hp, g_zombieclass[id])) * get_pcvar_float(cvar_zombiefirsthp)))
  7190. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  7191.  
  7192. // Infection sound
  7193. ArrayGetString(zombie_infect, random_num(0, ArraySize(zombie_infect) - 1), sound, charsmax(sound))
  7194. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  7195.  
  7196. }
  7197. else
  7198. {
  7199. // Infected by someone
  7200.  
  7201. // Set health and gravity, unless frozen
  7202. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, g_zombieclass[id]))
  7203. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  7204.  
  7205. // Infection sound
  7206. ArrayGetString(zombie_infect, random_num(0, ArraySize(zombie_infect) - 1), sound, charsmax(sound))
  7207. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  7208.  
  7209. // Show Infection HUD notice
  7210. set_hudmessage(255, 0, 0, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  7211.  
  7212. if (infector) // infected by someone?
  7213. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT2", g_playername[id], g_playername[infector])
  7214. else
  7215. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT", g_playername[id])
  7216. }
  7217. }
  7218. else
  7219. {
  7220. // Silent mode, no HUD messages, no infection sounds
  7221.  
  7222. // Set health and gravity, unless frozen
  7223. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, g_zombieclass[id]))
  7224. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  7225. }
  7226.  
  7227. // Remove previous tasks
  7228. remove_task(id+TASK_MODEL)
  7229. remove_task(id+TASK_BLOOD)
  7230. remove_task(id+TASK_AURA)
  7231. remove_task(id+TASK_BURN)
  7232.  
  7233. // Switch to T
  7234. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T) // need to change team?
  7235. {
  7236. remove_task(id+TASK_TEAM)
  7237. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  7238. fm_user_team_update(id)
  7239. }
  7240.  
  7241. // Custom models stuff
  7242. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  7243. already_has_model = false
  7244.  
  7245. if (g_handle_models_on_separate_ent)
  7246. {
  7247. // Set the right model
  7248. if (g_nemesis[id])
  7249. {
  7250. iRand = random_num(0, ArraySize(model_nemesis) - 1)
  7251. ArrayGetString(model_nemesis, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7252. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_nemesis, iRand))
  7253. }
  7254. else if (g_assassin[id])
  7255. {
  7256. iRand = random_num(0, ArraySize(model_assassin) - 1)
  7257. ArrayGetString(model_assassin, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7258. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_assassin, iRand))
  7259. }
  7260. else
  7261. {
  7262. if (get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  7263. {
  7264. iRand = random_num(0, ArraySize(model_admin_zombie) - 1)
  7265. ArrayGetString(model_admin_zombie, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7266. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_zombie, iRand))
  7267. }
  7268. else
  7269. {
  7270. iRand = random_num(ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]), ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]) - 1)
  7271. ArrayGetString(g_zclass_playermodel, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7272. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_zclass_modelindex, iRand))
  7273. }
  7274. }
  7275.  
  7276. // Set model on player model entity
  7277. fm_set_playermodel_ent(id)
  7278.  
  7279. // Nemesis glow / remove glow on player model entity, unless frozen
  7280. if (!g_frozen[id])
  7281. {
  7282. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  7283. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 250, 0 , 0, kRenderNormal, 25)
  7284. else if (g_nemesis[id] && !(get_pcvar_num(cvar_nemglow)))
  7285. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0 , 0, kRenderNormal, 25)
  7286.  
  7287. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  7288. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 250, 0 , 0, kRenderNormal, 25)
  7289. else if (g_assassin[id] && !(get_pcvar_num(cvar_assassinglow)))
  7290. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0 , 0, kRenderNormal, 25)
  7291.  
  7292. else if (!g_assassin[id] && !g_nemesis[id])
  7293. fm_set_rendering(g_ent_playermodel[id])
  7294. }
  7295. }
  7296. else
  7297. {
  7298. // Get current model for comparing it with the current one
  7299. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  7300.  
  7301. // Set the right model, after checking that we don't already have it
  7302. if (g_nemesis[id])
  7303. {
  7304. size = ArraySize(model_nemesis)
  7305. for (i = 0; i < size; i++)
  7306. {
  7307. ArrayGetString(model_nemesis, i, tempmodel, charsmax(tempmodel))
  7308. if (equal(currentmodel, tempmodel)) already_has_model = true
  7309. }
  7310.  
  7311. if (!already_has_model)
  7312. {
  7313. iRand = random_num(0, size - 1)
  7314. ArrayGetString(model_nemesis, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7315. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_nemesis, iRand))
  7316. }
  7317. }
  7318.  
  7319. else if (g_assassin[id])
  7320. {
  7321. size = ArraySize(model_assassin)
  7322. for (i = 0; i < size; i++)
  7323. {
  7324. ArrayGetString(model_assassin, i, tempmodel, charsmax(tempmodel))
  7325. if (equal(currentmodel, tempmodel)) already_has_model = true
  7326. }
  7327.  
  7328. if (!already_has_model)
  7329. {
  7330. iRand = random_num(0, size - 1)
  7331. ArrayGetString(model_assassin, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7332. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_assassin, iRand))
  7333. }
  7334. }
  7335.  
  7336. else
  7337. {
  7338. if (get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  7339. {
  7340. size = ArraySize(model_admin_zombie)
  7341. for (i = 0; i < size; i++)
  7342. {
  7343. ArrayGetString(model_admin_zombie, i, tempmodel, charsmax(tempmodel))
  7344. if (equal(currentmodel, tempmodel)) already_has_model = true
  7345. }
  7346.  
  7347. if (!already_has_model)
  7348. {
  7349. iRand = random_num(0, size - 1)
  7350. ArrayGetString(model_admin_zombie, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7351. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_zombie, iRand))
  7352. }
  7353. }
  7354. else
  7355. {
  7356. for (i = ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]); i < ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]); i++)
  7357. {
  7358. ArrayGetString(g_zclass_playermodel, i, tempmodel, charsmax(tempmodel))
  7359. if (equal(currentmodel, tempmodel)) already_has_model = true
  7360. }
  7361.  
  7362. if (!already_has_model)
  7363. {
  7364. iRand = random_num(ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]), ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]) - 1)
  7365. ArrayGetString(g_zclass_playermodel, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7366. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_zclass_modelindex, iRand))
  7367. }
  7368. }
  7369. }
  7370.  
  7371. // Need to change the model?
  7372. if (!already_has_model)
  7373. {
  7374. // An additional delay is offset at round start
  7375. // since SVC_BAD is more likely to be triggered there
  7376. if (g_newround)
  7377. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  7378. else
  7379. fm_user_model_update(id+TASK_MODEL)
  7380. }
  7381.  
  7382. // Nemesis glow / remove glow, unless frozen
  7383. if (!g_frozen[id])
  7384. {
  7385. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  7386. fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  7387. else if (g_nemesis[id] && !(get_pcvar_num(cvar_nemglow)))
  7388. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7389.  
  7390. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  7391. fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  7392. else if (g_assassin[id] && !(get_pcvar_num(cvar_assassinglow)))
  7393. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7394.  
  7395. else if (!g_assassin[id] && !g_nemesis[id])
  7396. fm_set_rendering(id)
  7397. }
  7398. }
  7399.  
  7400. // Remove any zoom (bugfix)
  7401. cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  7402.  
  7403. // Remove armor
  7404. set_pev(id, pev_armorvalue, 0.0)
  7405.  
  7406. // Drop weapons when infected
  7407. drop_weapons(id, 1)
  7408. drop_weapons(id, 2)
  7409.  
  7410. // Strip zombies from guns and give them a knife
  7411. fm_strip_user_weapons(id)
  7412. fm_give_item(id, "weapon_knife")
  7413.  
  7414. // Fancy effects
  7415. infection_effects(id)
  7416.  
  7417. // Nemesis aura task
  7418. if (g_nemesis[id] && get_pcvar_num(cvar_nemaura))
  7419. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  7420.  
  7421. // Assassin aura task
  7422. if (g_assassin[id] && get_pcvar_num(cvar_assassinaura))
  7423. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  7424.  
  7425. // Give Zombies Night Vision?
  7426. if (get_pcvar_num(cvar_nvggive))
  7427. {
  7428. g_nvision[id] = true
  7429.  
  7430. if (!g_isbot[id])
  7431. {
  7432. // Turn on Night Vision automatically?
  7433. if (get_pcvar_num(cvar_nvggive) == 1)
  7434. {
  7435. g_nvisionenabled[id] = true
  7436.  
  7437. // Custom nvg?
  7438. if (get_pcvar_num(cvar_customnvg))
  7439. {
  7440. remove_task(id+TASK_NVISION)
  7441. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  7442. }
  7443. else
  7444. set_user_gnvision(id, 1)
  7445. }
  7446. // Turn off nightvision when infected (bugfix)
  7447. else if (g_nvisionenabled[id])
  7448. {
  7449. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  7450. else set_user_gnvision(id, 0)
  7451. g_nvisionenabled[id] = false
  7452. }
  7453. }
  7454. else
  7455. cs_set_user_nvg(id, 1); // turn on NVG for bots
  7456. }
  7457. // Disable nightvision when infected (bugfix)
  7458. else if (g_nvision[id])
  7459. {
  7460. if (g_isbot[id]) cs_set_user_nvg(id, 0) // Turn off NVG for bots
  7461. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  7462. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  7463. g_nvision[id] = false
  7464. g_nvisionenabled[id] = false
  7465. }
  7466.  
  7467. // Set custom FOV?
  7468. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  7469. {
  7470. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  7471. write_byte(get_pcvar_num(cvar_zombiefov)) // fov angle
  7472. message_end()
  7473. }
  7474.  
  7475. // Call the bloody task
  7476. if (!g_nemesis[id] && !g_assassin[id] && get_pcvar_num(cvar_zombiebleeding))
  7477. set_task(0.7, "make_blood", id+TASK_BLOOD, _, _, "b")
  7478.  
  7479. // Idle sounds task
  7480. if (!g_nemesis[id] && !g_assassin[id])
  7481. set_task(random_float(50.0, 70.0), "zombie_play_idle", id+TASK_BLOOD, _, _, "b")
  7482.  
  7483. // Turn off zombie's flashlight
  7484. turn_off_flashlight(id)
  7485.  
  7486. // Post user infect forward
  7487. ExecuteForward(g_fwUserInfected_post, g_fwDummyResult, id, infector, nemesis)
  7488.  
  7489. // Last Zombie Check
  7490. fnCheckLastZombie()
  7491. }
  7492.  
  7493. // Function Human Me (player id, turn into a survivor, silent mode)
  7494. humanme(id, survivor, silentmode, sniper)
  7495. {
  7496. // User humanize attempt forward
  7497. ExecuteForward(g_fwUserHumanize_attempt, g_fwDummyResult, id, survivor)
  7498.  
  7499. // One or more plugins blocked the "humanization". Only allow this after making sure it's
  7500. // not going to leave us with no humans. Take into account a last player leaving case.
  7501. // BUGFIX: only allow after a mode has started, to prevent blocking first survivor e.g.
  7502. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetHumans() > g_lastplayerleaving)
  7503. return;
  7504.  
  7505. // Pre user humanize forward
  7506. ExecuteForward(g_fwUserHumanized_pre, g_fwDummyResult, id, survivor)
  7507.  
  7508. // Remove previous tasks
  7509. remove_task(id+TASK_MODEL)
  7510. remove_task(id+TASK_BLOOD)
  7511. remove_task(id+TASK_AURA)
  7512. remove_task(id+TASK_BURN)
  7513. remove_task(id+TASK_NVISION)
  7514.  
  7515. // Reset some vars
  7516. g_zombie[id] = false
  7517. g_nemesis[id] = false
  7518. g_survivor[id] = false
  7519. g_firstzombie[id] = false
  7520. g_canbuy[id] = true
  7521. g_nvision[id] = false
  7522. g_nvisionenabled[id] = false
  7523. g_sniper[id] = false
  7524. g_assassin[id] = false
  7525.  
  7526. // Remove survivor/sniper's aura (bugfix)
  7527. remove_task(id+TASK_AURA)
  7528.  
  7529. // Remove spawn protection (bugfix)
  7530. g_nodamage[id] = false
  7531. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  7532.  
  7533. // Reset burning duration counter (bugfix)
  7534. g_burning_duration[id] = 0
  7535.  
  7536. // Drop previous weapons
  7537. drop_weapons(id, 1)
  7538. drop_weapons(id, 2)
  7539.  
  7540. // Strip off from weapons
  7541. fm_strip_user_weapons(id)
  7542. fm_give_item(id, "weapon_knife")
  7543.  
  7544. // Set human attributes based on the mode
  7545. if (survivor)
  7546. {
  7547. // Survivor
  7548. g_survivor[id] = true
  7549.  
  7550. // Set Health [0 = auto]
  7551. if (get_pcvar_num(cvar_survhp) == 0)
  7552. {
  7553. if (get_pcvar_num(cvar_survbasehp) == 0)
  7554. fm_set_user_health(id, get_pcvar_num(cvar_humanhp) * fnGetAlive())
  7555. else
  7556. fm_set_user_health(id, get_pcvar_num(cvar_survbasehp) * fnGetAlive())
  7557. }
  7558. else
  7559. fm_set_user_health(id, get_pcvar_num(cvar_survhp))
  7560.  
  7561. // Set gravity, unless frozen
  7562. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_survgravity))
  7563.  
  7564. // Give survivor his own weapon
  7565. static survweapon[32]
  7566. get_pcvar_string(cvar_survweapon, survweapon, charsmax(survweapon))
  7567. fm_give_item(id, survweapon)
  7568. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[cs_weapon_name_to_id(survweapon)], AMMOTYPE[cs_weapon_name_to_id(survweapon)], MAXBPAMMO[cs_weapon_name_to_id(survweapon)])
  7569.  
  7570. // Turn off his flashlight
  7571. turn_off_flashlight(id)
  7572.  
  7573. // Give the survivor a nice aura
  7574. if (get_pcvar_num(cvar_survaura))
  7575. set_task(0.1, "human_aura", id+TASK_AURA, _, _, "b")
  7576.  
  7577. // Survivor bots will also need nightvision to see in the dark
  7578. if (g_isbot[id])
  7579. {
  7580. g_nvision[id] = true
  7581. cs_set_user_nvg(id, 1)
  7582. }
  7583. }
  7584. else if (sniper)
  7585. {
  7586. // Sniper
  7587. g_sniper[id] = true
  7588.  
  7589. // Set Health [0 = auto]
  7590. if (get_pcvar_num(cvar_sniperhp) == 0)
  7591. {
  7592. if (get_pcvar_num(cvar_sniperbasehp) == 0)
  7593. fm_set_user_health(id, get_pcvar_num(cvar_humanhp) * fnGetAlive())
  7594. else
  7595. fm_set_user_health(id, get_pcvar_num(cvar_sniperbasehp) * fnGetAlive())
  7596. }
  7597. else
  7598. fm_set_user_health(id, get_pcvar_num(cvar_sniperhp))
  7599.  
  7600. // Set gravity, unless frozen
  7601. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_snipergravity))
  7602.  
  7603. // Give sniper his own weapon and fill the ammo
  7604. fm_give_item(id, "weapon_awp")
  7605. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[CSW_AWP], AMMOTYPE[CSW_AWP], MAXBPAMMO[CSW_AWP])
  7606.  
  7607. // Turn off his flashlight
  7608. turn_off_flashlight(id)
  7609.  
  7610. // Give the sniper a nice aura
  7611. if (get_pcvar_num(cvar_sniperaura))
  7612. set_task(0.1, "human_aura", id+TASK_AURA, _, _, "b")
  7613.  
  7614. // Sniper bots will also need nightvision to see in the dark
  7615. if (g_isbot[id])
  7616. {
  7617. g_nvision[id] = true
  7618. cs_set_user_nvg(id, 1)
  7619. }
  7620. }
  7621. else
  7622. {
  7623. // Human taking an antidote
  7624.  
  7625. // Set health
  7626. fm_set_user_health(id, get_pcvar_num(cvar_humanhp))
  7627.  
  7628. // Set gravity, unless frozen
  7629. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity))
  7630.  
  7631. // Show custom buy menu?
  7632. if (get_pcvar_num(cvar_buycustom))
  7633. set_task(0.2, "show_menu_buy1", id+TASK_SPAWN)
  7634.  
  7635. // Silent mode = no HUD messages, no antidote sound
  7636. if (!silentmode)
  7637. {
  7638. // Antidote sound
  7639. static sound[64]
  7640. ArrayGetString(sound_antidote, random_num(0, ArraySize(sound_antidote) - 1), sound, charsmax(sound))
  7641. emit_sound(id, CHAN_ITEM, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  7642.  
  7643. // Show Antidote HUD notice
  7644. set_hudmessage(10, 255, 235, HUD_INFECT_X, HUD_INFECT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  7645. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_ANTIDOTE", g_playername[id])
  7646. }
  7647. }
  7648.  
  7649. // Switch to CT
  7650. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  7651. {
  7652. remove_task(id+TASK_TEAM)
  7653. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  7654. fm_user_team_update(id)
  7655. }
  7656.  
  7657. // Custom models stuff
  7658. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  7659. already_has_model = false
  7660.  
  7661. if (g_handle_models_on_separate_ent)
  7662. {
  7663. // Set the right model
  7664. if (g_survivor[id])
  7665. {
  7666. iRand = random_num(0, ArraySize(model_survivor) - 1)
  7667. ArrayGetString(model_survivor, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7668. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_survivor, iRand))
  7669. }
  7670. else if (g_sniper[id])
  7671. {
  7672. iRand = random_num(0, ArraySize(model_sniper) - 1)
  7673. ArrayGetString(model_sniper, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7674. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_sniper, iRand))
  7675. }
  7676. else
  7677. {
  7678. if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  7679. {
  7680. iRand = random_num(0, ArraySize(model_admin_human) - 1)
  7681. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7682. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  7683. }
  7684. else
  7685. {
  7686. iRand = random_num(0, ArraySize(model_human) - 1)
  7687. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7688. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  7689. }
  7690. }
  7691.  
  7692. // Set model on player model entity
  7693. fm_set_playermodel_ent(id)
  7694.  
  7695. // Set survivor glow / remove glow on player model entity, unless frozen
  7696. if (!g_frozen[id])
  7697. {
  7698. if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  7699. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 250, 250, kRenderNormal, 25)
  7700. else if (g_survivor[id] && !(get_pcvar_num(cvar_survglow)))
  7701. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7702.  
  7703. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  7704. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, get_pcvar_num(cvar_snipercolor[0]), get_pcvar_num(cvar_snipercolor[1]), get_pcvar_num(cvar_snipercolor[2]), kRenderNormal, 25)
  7705. else if (g_sniper[id] && !(get_pcvar_num(cvar_sniperglow)))
  7706. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7707.  
  7708. else if (!g_sniper[id] && !g_survivor[id])
  7709. fm_set_rendering(g_ent_playermodel[id])
  7710. }
  7711. }
  7712. else
  7713. {
  7714. // Get current model for comparing it with the current one
  7715. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  7716.  
  7717. // Set the right model, after checking that we don't already have it
  7718. if (g_survivor[id])
  7719. {
  7720. size = ArraySize(model_survivor)
  7721. for (i = 0; i < size; i++)
  7722. {
  7723. ArrayGetString(model_survivor, i, tempmodel, charsmax(tempmodel))
  7724. if (equal(currentmodel, tempmodel)) already_has_model = true
  7725. }
  7726.  
  7727. if (!already_has_model)
  7728. {
  7729. iRand = random_num(0, size - 1)
  7730. ArrayGetString(model_survivor, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7731. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_survivor, iRand))
  7732. }
  7733. }
  7734. else if (g_sniper[id])
  7735. {
  7736. size = ArraySize(model_sniper)
  7737. for (i = 0; i < size; i++)
  7738. {
  7739. ArrayGetString(model_sniper, i, tempmodel, charsmax(tempmodel))
  7740. if (equal(currentmodel, tempmodel)) already_has_model = true
  7741. }
  7742.  
  7743. if (!already_has_model)
  7744. {
  7745. iRand = random_num(0, size - 1)
  7746. ArrayGetString(model_sniper, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7747. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_sniper, iRand))
  7748. }
  7749. }
  7750. else
  7751. {
  7752. if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  7753. {
  7754. size = ArraySize(model_admin_human)
  7755. for (i = 0; i < size; i++)
  7756. {
  7757. ArrayGetString(model_admin_human, i, tempmodel, charsmax(tempmodel))
  7758. if (equal(currentmodel, tempmodel)) already_has_model = true
  7759. }
  7760.  
  7761. if (!already_has_model)
  7762. {
  7763. iRand = random_num(0, size - 1)
  7764. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7765. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  7766. }
  7767. }
  7768. else
  7769. {
  7770. size = ArraySize(model_human)
  7771. for (i = 0; i < size; i++)
  7772. {
  7773. ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
  7774. if (equal(currentmodel, tempmodel)) already_has_model = true
  7775. }
  7776.  
  7777. if (!already_has_model)
  7778. {
  7779. iRand = random_num(0, size - 1)
  7780. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  7781. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  7782. }
  7783. }
  7784. }
  7785.  
  7786. // Need to change the model?
  7787. if (!already_has_model)
  7788. {
  7789. // An additional delay is offset at round start
  7790. // since SVC_BAD is more likely to be triggered there
  7791. if (g_newround)
  7792. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  7793. else
  7794. fm_user_model_update(id+TASK_MODEL)
  7795. }
  7796.  
  7797. // Set survivor glow / remove glow, unless frozen
  7798. if (!g_frozen[id])
  7799. {
  7800. if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  7801. fm_set_rendering(id, kRenderFxGlowShell, 0, 250, 250, kRenderNormal, 25)
  7802. else if (g_survivor[id] && !(get_pcvar_num(cvar_survglow)))
  7803. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7804.  
  7805. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  7806. fm_set_rendering(id, kRenderFxGlowShell, get_pcvar_num(cvar_snipercolor[0]), get_pcvar_num(cvar_snipercolor[1]), get_pcvar_num(cvar_snipercolor[2]), kRenderNormal, 25)
  7807. else if (g_sniper[id] && !(get_pcvar_num(cvar_sniperglow)))
  7808. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  7809.  
  7810. else if (!g_sniper[id] && !g_survivor[id])
  7811. fm_set_rendering(id)
  7812. }
  7813. }
  7814.  
  7815. // Restore FOV?
  7816. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  7817. {
  7818. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  7819. write_byte(90) // angle
  7820. message_end()
  7821. }
  7822.  
  7823. // Disable nightvision
  7824. if (g_isbot[id]) cs_set_user_nvg(id, 0)
  7825. else if (!get_pcvar_num(cvar_customnvg) && g_nvisionenabled[id]) set_user_gnvision(id, 0)
  7826.  
  7827. // Post user humanize forward
  7828. ExecuteForward(g_fwUserHumanized_post, g_fwDummyResult, id, survivor)
  7829.  
  7830. // Last Zombie Check
  7831. fnCheckLastZombie()
  7832. }
  7833.  
  7834. /*================================================================================
  7835.  [Other Functions and Tasks]
  7836. =================================================================================*/
  7837.  
  7838. public cache_cvars()
  7839. {
  7840. g_cached_zombiesilent = get_pcvar_num(cvar_zombiesilent)
  7841. g_cached_customflash = get_pcvar_num(cvar_customflash)
  7842. g_cached_humanspd = get_pcvar_float(cvar_humanspd)
  7843. g_cached_nemspd = get_pcvar_float(cvar_nemspd)
  7844. g_cached_survspd = get_pcvar_float(cvar_survspd)
  7845. g_cached_leapzombies = get_pcvar_num(cvar_leapzombies)
  7846. g_cached_leapzombiescooldown = get_pcvar_float(cvar_leapzombiescooldown)
  7847. g_cached_leapnemesis = get_pcvar_num(cvar_leapnemesis)
  7848. g_cached_leapnemesiscooldown = get_pcvar_float(cvar_leapnemesiscooldown)
  7849. g_cached_leapsurvivor = get_pcvar_num(cvar_leapsurvivor)
  7850. g_cached_leapsurvivorcooldown = get_pcvar_float(cvar_leapsurvivorcooldown)
  7851. g_cached_sniperspd = get_pcvar_float(cvar_sniperspd)
  7852. g_cached_leapsniper = get_pcvar_num(cvar_leapsniper)
  7853. g_cached_leapsnipercooldown = get_pcvar_float(cvar_leapsnipercooldown)
  7854. g_cached_assassinspd = get_pcvar_float(cvar_assassinspd)
  7855. g_cached_leapassassin = get_pcvar_num(cvar_leapassassin)
  7856. g_cached_leapassassincooldown = get_pcvar_float(cvar_leapassassincooldown)
  7857. }
  7858.  
  7859. load_customization_from_files()
  7860. {
  7861. // Build customization file path
  7862. new path[64]
  7863. get_configsdir(path, charsmax(path))
  7864. format(path, charsmax(path), "%s/%s", path, ZP_CUSTOMIZATION_FILE)
  7865.  
  7866. // File not present
  7867. if (!file_exists(path))
  7868. {
  7869. new error[100]
  7870. formatex(error, charsmax(error), "Cannot load customization file %s!", path)
  7871. set_fail_state(error)
  7872. return;
  7873. }
  7874.  
  7875. // Set up some vars to hold parsing info
  7876. new linedata[1024], key[64], value[960], section, teams
  7877.  
  7878. // Open customization file for reading
  7879. new file = fopen(path, "rt")
  7880.  
  7881. while (file && !feof(file))
  7882. {
  7883. // Read one line at a time
  7884. fgets(file, linedata, charsmax(linedata))
  7885.  
  7886. // Replace newlines with a null character to prevent headaches
  7887. replace(linedata, charsmax(linedata), "^n", "")
  7888.  
  7889. // Blank line or comment
  7890. if (!linedata[0] || linedata[0] == ';') continue;
  7891.  
  7892. // New section starting
  7893. if (linedata[0] == '[')
  7894. {
  7895. section++
  7896. continue;
  7897. }
  7898.  
  7899. // Get key and value(s)
  7900. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  7901.  
  7902. // Trim spaces
  7903. trim(key)
  7904. trim(value)
  7905.  
  7906. switch (section)
  7907. {
  7908. case SECTION_ACCESS_FLAGS:
  7909. {
  7910. if (equal(key, "ENABLE/DISABLE MOD"))
  7911. g_access_flag[ACCESS_ENABLE_MOD] = read_flags(value)
  7912. else if (equal(key, "ADMIN MENU OF CLASSES"))
  7913. g_access_flag[ACCESS_ADMIN_MENU] = read_flags(value)
  7914. else if (equal(key, "ADMIN MENU OF MODES"))
  7915. g_access_flag[ACCESS_ADMIN_MENU2] = read_flags(value)
  7916. else if (equal(key, "ADMIN MENU MAIN ACCESS"))
  7917. g_access_flag[ACCESS_ADMIN_MENU3] = read_flags(value)
  7918. else if (equal(key, "START MODE INFECTION"))
  7919. g_access_flag[ACCESS_MODE_INFECTION] = read_flags(value)
  7920. else if (equal(key, "START MODE NEMESIS"))
  7921. g_access_flag[ACCESS_MODE_NEMESIS] = read_flags(value)
  7922. else if (equal(key, "START MODE SURVIVOR"))
  7923. g_access_flag[ACCESS_MODE_SURVIVOR] = read_flags(value)
  7924. else if (equal(key, "START MODE SWARM"))
  7925. g_access_flag[ACCESS_MODE_SWARM] = read_flags(value)
  7926. else if (equal(key, "START MODE MULTI"))
  7927. g_access_flag[ACCESS_MODE_MULTI] = read_flags(value)
  7928. else if (equal(key, "START MODE PLAGUE"))
  7929. g_access_flag[ACCESS_MODE_PLAGUE] = read_flags(value)
  7930. else if (equal(key, "MAKE ZOMBIE"))
  7931. g_access_flag[ACCESS_MAKE_ZOMBIE] = read_flags(value)
  7932. else if (equal(key, "MAKE HUMAN"))
  7933. g_access_flag[ACCESS_MAKE_HUMAN] = read_flags(value)
  7934. else if (equal(key, "MAKE NEMESIS"))
  7935. g_access_flag[ACCESS_MAKE_NEMESIS] = read_flags(value)
  7936. else if (equal(key, "MAKE SURVIVOR"))
  7937. g_access_flag[ACCESS_MAKE_SURVIVOR] = read_flags(value)
  7938. else if (equal(key, "RESPAWN PLAYERS"))
  7939. g_access_flag[ACCESS_RESPAWN_PLAYERS] = read_flags(value)
  7940. else if (equal(key, "ADMIN MODELS"))
  7941. g_access_flag[ACCESS_ADMIN_MODELS] = read_flags(value)
  7942. else if (equal(key, "START MODE SNIPER"))
  7943. g_access_flag[ACCESS_MODE_SNIPER] = read_flags(value)
  7944. else if (equal(key, "MAKE SNIPER"))
  7945. g_access_flag[ACCESS_MAKE_SNIPER] = read_flags(value)
  7946. else if (equal(key, "START MODE ASSASSIN"))
  7947. g_access_flag[ACCESS_MODE_ASSASSIN] = read_flags(value)
  7948. else if (equal(key, "MAKE ASSASSIN"))
  7949. g_access_flag[ACCESS_MAKE_ASSASSIN] = read_flags(value)
  7950. else if (equal(key, "START MODE LNJ"))
  7951. g_access_flag[ACCESS_MODE_LNJ] = read_flags(value)
  7952.  
  7953. }
  7954. case SECTION_PLAYER_MODELS:
  7955. {
  7956. if (equal(key, "HUMAN"))
  7957. {
  7958. // Parse models
  7959. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  7960. {
  7961. // Trim spaces
  7962. trim(key)
  7963. trim(value)
  7964.  
  7965. // Add to models array
  7966. ArrayPushString(model_human, key)
  7967. }
  7968. }
  7969. else if (equal(key, "NEMESIS"))
  7970. {
  7971. // Parse models
  7972. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  7973. {
  7974. // Trim spaces
  7975. trim(key)
  7976. trim(value)
  7977.  
  7978. // Add to models array
  7979. ArrayPushString(model_nemesis, key)
  7980. }
  7981. }
  7982. else if (equal(key, "SURVIVOR"))
  7983. {
  7984. // Parse models
  7985. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  7986. {
  7987. // Trim spaces
  7988. trim(key)
  7989. trim(value)
  7990.  
  7991. // Add to models array
  7992. ArrayPushString(model_survivor, key)
  7993. }
  7994. }
  7995. else if (equal(key, "ADMIN ZOMBIE"))
  7996. {
  7997. // Parse models
  7998. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  7999. {
  8000. // Trim spaces
  8001. trim(key)
  8002. trim(value)
  8003.  
  8004. // Add to models array
  8005. ArrayPushString(model_admin_zombie, key)
  8006. }
  8007. }
  8008. else if (equal(key, "ADMIN HUMAN"))
  8009. {
  8010. // Parse models
  8011. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8012. {
  8013. // Trim spaces
  8014. trim(key)
  8015. trim(value)
  8016.  
  8017. // Add to models array
  8018. ArrayPushString(model_admin_human, key)
  8019. }
  8020. }
  8021. else if (equal(key, "SNIPER"))
  8022. {
  8023. // Parse models
  8024. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8025. {
  8026. // Trim spaces
  8027. trim(key)
  8028. trim(value)
  8029.  
  8030. // Add to models array
  8031. ArrayPushString(model_sniper, key)
  8032. }
  8033. }
  8034. else if (equal(key, "ASSASSIN"))
  8035. {
  8036. // Parse models
  8037. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8038. {
  8039. // Trim spaces
  8040. trim(key)
  8041. trim(value)
  8042.  
  8043. // Add to models array
  8044. ArrayPushString(model_assassin, key)
  8045. }
  8046. }
  8047.  
  8048. else if (equal(key, "FORCE CONSISTENCY"))
  8049. g_force_consistency = str_to_num(value)
  8050. else if (equal(key, "SAME MODELS FOR ALL"))
  8051. g_same_models_for_all = str_to_num(value)
  8052. else if (g_same_models_for_all && equal(key, "ZOMBIE"))
  8053. {
  8054. // Parse models
  8055. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8056. {
  8057. // Trim spaces
  8058. trim(key)
  8059. trim(value)
  8060.  
  8061. // Add to models array
  8062. ArrayPushString(g_zclass_playermodel, key)
  8063.  
  8064. // Precache model and retrieve its modelindex
  8065. formatex(linedata, charsmax(linedata), "models/player/%s/%s.mdl", key, key)
  8066. ArrayPushCell(g_zclass_modelindex, engfunc(EngFunc_PrecacheModel, linedata))
  8067. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, linedata)
  8068. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, linedata)
  8069. }
  8070. }
  8071. }
  8072. case SECTION_WEAPON_MODELS:
  8073. {
  8074. if (equal(key, "V_KNIFE HUMAN"))
  8075. copy(model_vknife_human, charsmax(model_vknife_human), value)
  8076. else if (equal(key, "V_KNIFE NEMESIS"))
  8077. copy(model_vknife_nemesis, charsmax(model_vknife_nemesis), value)
  8078. else if (equal(key, "V_M249 SURVIVOR"))
  8079. copy(model_vm249_survivor, charsmax(model_vm249_survivor), value)
  8080. else if (equal(key, "GRENADE INFECT"))
  8081. copy(model_grenade_infect, charsmax(model_grenade_infect), value)
  8082. else if (equal(key, "GRENADE FIRE"))
  8083. copy(model_grenade_fire, charsmax(model_grenade_fire), value)
  8084. else if (equal(key, "GRENADE FROST"))
  8085. copy(model_grenade_frost, charsmax(model_grenade_frost), value)
  8086. else if (equal(key, "GRENADE FLARE"))
  8087. copy(model_grenade_flare, charsmax(model_grenade_flare), value)
  8088. else if (equal(key, "V_KNIFE ADMIN HUMAN"))
  8089. copy(model_vknife_admin_human, charsmax(model_vknife_admin_human), value)
  8090. else if (equal(key, "V_KNIFE ADMIN ZOMBIE"))
  8091. copy(model_vknife_admin_zombie, charsmax(model_vknife_admin_zombie), value)
  8092. else if (equal(key, "V_AWP SNIPER"))
  8093. copy(model_vawp_sniper, charsmax(model_vawp_sniper), value)
  8094. else if (equal(key, "V_KNIFE ASSASSIN"))
  8095. copy(model_vknife_assassin, charsmax(model_vknife_assassin), value)
  8096. }
  8097. case SECTION_GRENADE_SPRITES:
  8098. {
  8099. if (equal(key, "TRAIL"))
  8100. copy(sprite_grenade_trail, charsmax(sprite_grenade_trail), value)
  8101. else if (equal(key, "RING"))
  8102. copy(sprite_grenade_ring, charsmax(sprite_grenade_ring), value)
  8103. else if (equal(key, "FIRE"))
  8104. copy(sprite_grenade_fire, charsmax(sprite_grenade_fire), value)
  8105. else if (equal(key, "SMOKE"))
  8106. copy(sprite_grenade_smoke, charsmax(sprite_grenade_smoke), value)
  8107. else if (equal(key, "GLASS"))
  8108. copy(sprite_grenade_glass, charsmax(sprite_grenade_glass), value)
  8109. }
  8110. case SECTION_SOUNDS:
  8111. {
  8112. if (equal(key, "WIN ZOMBIES"))
  8113. {
  8114. // Parse sounds
  8115. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8116. {
  8117. // Trim spaces
  8118. trim(key)
  8119. trim(value)
  8120.  
  8121. // Add to sounds array
  8122. ArrayPushString(sound_win_zombies, key)
  8123. }
  8124. }
  8125. else if (equal(key, "WIN HUMANS"))
  8126. {
  8127. // Parse sounds
  8128. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8129. {
  8130. // Trim spaces
  8131. trim(key)
  8132. trim(value)
  8133.  
  8134. // Add to sounds array
  8135. ArrayPushString(sound_win_humans, key)
  8136. }
  8137. }
  8138. else if (equal(key, "WIN NO ONE"))
  8139. {
  8140. // Parse sounds
  8141. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8142. {
  8143. // Trim spaces
  8144. trim(key)
  8145. trim(value)
  8146.  
  8147. // Add to sounds array
  8148. ArrayPushString(sound_win_no_one, key)
  8149. }
  8150. }
  8151. else if (equal(key, "ZOMBIE INFECT"))
  8152. {
  8153. // Parse sounds
  8154. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8155. {
  8156. // Trim spaces
  8157. trim(key)
  8158. trim(value)
  8159.  
  8160. // Add to sounds array
  8161. ArrayPushString(zombie_infect, key)
  8162. }
  8163. }
  8164. else if (equal(key, "ZOMBIE PAIN"))
  8165. {
  8166. // Parse sounds
  8167. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8168. {
  8169. // Trim spaces
  8170. trim(key)
  8171. trim(value)
  8172.  
  8173. // Add to sounds array
  8174. ArrayPushString(zombie_pain, key)
  8175. }
  8176. }
  8177. else if (equal(key, "NEMESIS PAIN"))
  8178. {
  8179. // Parse sounds
  8180. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8181. {
  8182. // Trim spaces
  8183. trim(key)
  8184. trim(value)
  8185.  
  8186. // Add to sounds array
  8187. ArrayPushString(nemesis_pain, key)
  8188. }
  8189. }
  8190. else if (equal(key, "ASSASSIN PAIN"))
  8191. {
  8192. // Parse sounds
  8193. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8194. {
  8195. // Trim spaces
  8196. trim(key)
  8197. trim(value)
  8198.  
  8199. // Add to sounds array
  8200. ArrayPushString(assassin_pain, key)
  8201. }
  8202. }
  8203. else if (equal(key, "ZOMBIE DIE"))
  8204. {
  8205. // Parse sounds
  8206. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8207. {
  8208. // Trim spaces
  8209. trim(key)
  8210. trim(value)
  8211.  
  8212. // Add to sounds array
  8213. ArrayPushString(zombie_die, key)
  8214. }
  8215. }
  8216. else if (equal(key, "ZOMBIE FALL"))
  8217. {
  8218. // Parse sounds
  8219. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8220. {
  8221. // Trim spaces
  8222. trim(key)
  8223. trim(value)
  8224.  
  8225. // Add to sounds array
  8226. ArrayPushString(zombie_fall, key)
  8227. }
  8228. }
  8229. else if (equal(key, "ZOMBIE MISS SLASH"))
  8230. {
  8231. // Parse sounds
  8232. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8233. {
  8234. // Trim spaces
  8235. trim(key)
  8236. trim(value)
  8237.  
  8238. // Add to sounds array
  8239. ArrayPushString(zombie_miss_slash, key)
  8240. }
  8241. }
  8242. else if (equal(key, "ZOMBIE MISS WALL"))
  8243. {
  8244. // Parse sounds
  8245. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8246. {
  8247. // Trim spaces
  8248. trim(key)
  8249. trim(value)
  8250.  
  8251. // Add to sounds array
  8252. ArrayPushString(zombie_miss_wall, key)
  8253. }
  8254. }
  8255. else if (equal(key, "ZOMBIE HIT NORMAL"))
  8256. {
  8257. // Parse sounds
  8258. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8259. {
  8260. // Trim spaces
  8261. trim(key)
  8262. trim(value)
  8263.  
  8264. // Add to sounds array
  8265. ArrayPushString(zombie_hit_normal, key)
  8266. }
  8267. }
  8268. else if (equal(key, "ZOMBIE HIT STAB"))
  8269. {
  8270. // Parse sounds
  8271. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8272. {
  8273. // Trim spaces
  8274. trim(key)
  8275. trim(value)
  8276.  
  8277. // Add to sounds array
  8278. ArrayPushString(zombie_hit_stab, key)
  8279. }
  8280. }
  8281. else if (equal(key, "ZOMBIE IDLE"))
  8282. {
  8283. // Parse sounds
  8284. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8285. {
  8286. // Trim spaces
  8287. trim(key)
  8288. trim(value)
  8289.  
  8290. // Add to sounds array
  8291. ArrayPushString(zombie_idle, key)
  8292. }
  8293. }
  8294. else if (equal(key, "ZOMBIE IDLE LAST"))
  8295. {
  8296. // Parse sounds
  8297. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8298. {
  8299. // Trim spaces
  8300. trim(key)
  8301. trim(value)
  8302.  
  8303. // Add to sounds array
  8304. ArrayPushString(zombie_idle_last, key)
  8305. }
  8306. }
  8307. else if (equal(key, "ZOMBIE MADNESS"))
  8308. {
  8309. // Parse sounds
  8310. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8311. {
  8312. // Trim spaces
  8313. trim(key)
  8314. trim(value)
  8315.  
  8316. // Add to sounds array
  8317. ArrayPushString(zombie_madness, key)
  8318. }
  8319. }
  8320. else if (equal(key, "ROUND NEMESIS"))
  8321. {
  8322. // Parse sounds
  8323. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8324. {
  8325. // Trim spaces
  8326. trim(key)
  8327. trim(value)
  8328.  
  8329. // Add to sounds array
  8330. ArrayPushString(sound_nemesis, key)
  8331. }
  8332. }
  8333. else if (equal(key, "ROUND SURVIVOR"))
  8334. {
  8335. // Parse sounds
  8336. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8337. {
  8338. // Trim spaces
  8339. trim(key)
  8340. trim(value)
  8341.  
  8342. // Add to sounds array
  8343. ArrayPushString(sound_survivor, key)
  8344. }
  8345. }
  8346. else if (equal(key, "ROUND SWARM"))
  8347. {
  8348. // Parse sounds
  8349. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8350. {
  8351. // Trim spaces
  8352. trim(key)
  8353. trim(value)
  8354.  
  8355. // Add to sounds array
  8356. ArrayPushString(sound_swarm, key)
  8357. }
  8358. }
  8359. else if (equal(key, "ROUND MULTI"))
  8360. {
  8361. // Parse sounds
  8362. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8363. {
  8364. // Trim spaces
  8365. trim(key)
  8366. trim(value)
  8367.  
  8368. // Add to sounds array
  8369. ArrayPushString(sound_multi, key)
  8370. }
  8371. }
  8372. else if (equal(key, "ROUND PLAGUE"))
  8373. {
  8374. // Parse sounds
  8375. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8376. {
  8377. // Trim spaces
  8378. trim(key)
  8379. trim(value)
  8380.  
  8381. // Add to sounds array
  8382. ArrayPushString(sound_plague, key)
  8383. }
  8384. }
  8385. else if (equal(key, "GRENADE INFECT EXPLODE"))
  8386. {
  8387. // Parse sounds
  8388. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8389. {
  8390. // Trim spaces
  8391. trim(key)
  8392. trim(value)
  8393.  
  8394. // Add to sounds array
  8395. ArrayPushString(grenade_infect, key)
  8396. }
  8397. }
  8398. else if (equal(key, "GRENADE INFECT PLAYER"))
  8399. {
  8400. // Parse sounds
  8401. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8402. {
  8403. // Trim spaces
  8404. trim(key)
  8405. trim(value)
  8406.  
  8407. // Add to sounds array
  8408. ArrayPushString(grenade_infect_player, key)
  8409. }
  8410. }
  8411. else if (equal(key, "GRENADE FIRE EXPLODE"))
  8412. {
  8413. // Parse sounds
  8414. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8415. {
  8416. // Trim spaces
  8417. trim(key)
  8418. trim(value)
  8419.  
  8420. // Add to sounds array
  8421. ArrayPushString(grenade_fire, key)
  8422. }
  8423. }
  8424. else if (equal(key, "GRENADE FIRE PLAYER"))
  8425. {
  8426. // Parse sounds
  8427. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8428. {
  8429. // Trim spaces
  8430. trim(key)
  8431. trim(value)
  8432.  
  8433. // Add to sounds array
  8434. ArrayPushString(grenade_fire_player, key)
  8435. }
  8436. }
  8437. else if (equal(key, "GRENADE FROST EXPLODE"))
  8438. {
  8439. // Parse sounds
  8440. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8441. {
  8442. // Trim spaces
  8443. trim(key)
  8444. trim(value)
  8445.  
  8446. // Add to sounds array
  8447. ArrayPushString(grenade_frost, key)
  8448. }
  8449. }
  8450. else if (equal(key, "GRENADE FROST PLAYER"))
  8451. {
  8452. // Parse sounds
  8453. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8454. {
  8455. // Trim spaces
  8456. trim(key)
  8457. trim(value)
  8458.  
  8459. // Add to sounds array
  8460. ArrayPushString(grenade_frost_player, key)
  8461. }
  8462. }
  8463. else if (equal(key, "GRENADE FROST BREAK"))
  8464. {
  8465. // Parse sounds
  8466. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8467. {
  8468. // Trim spaces
  8469. trim(key)
  8470. trim(value)
  8471.  
  8472. // Add to sounds array
  8473. ArrayPushString(grenade_frost_break, key)
  8474. }
  8475. }
  8476. else if (equal(key, "GRENADE FLARE"))
  8477. {
  8478. // Parse sounds
  8479. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8480. {
  8481. // Trim spaces
  8482. trim(key)
  8483. trim(value)
  8484.  
  8485. // Add to sounds array
  8486. ArrayPushString(grenade_flare, key)
  8487. }
  8488. }
  8489. else if (equal(key, "ANTIDOTE"))
  8490. {
  8491. // Parse sounds
  8492. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8493. {
  8494. // Trim spaces
  8495. trim(key)
  8496. trim(value)
  8497.  
  8498. // Add to sounds array
  8499. ArrayPushString(sound_antidote, key)
  8500. }
  8501. }
  8502. else if (equal(key, "THUNDER"))
  8503. {
  8504. // Parse sounds
  8505. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8506. {
  8507. // Trim spaces
  8508. trim(key)
  8509. trim(value)
  8510.  
  8511. // Add to sounds array
  8512. ArrayPushString(sound_thunder, key)
  8513. }
  8514. }
  8515. else if (equal(key, "ROUND SNIPER"))
  8516. {
  8517. // Parse sounds
  8518. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8519. {
  8520. // Trim spaces
  8521. trim(key)
  8522. trim(value)
  8523.  
  8524. // Add to sounds array
  8525. ArrayPushString(sound_sniper, key)
  8526. }
  8527. }
  8528. else if (equal(key, "ROUND ASSASSIN"))
  8529. {
  8530. // Parse sounds
  8531. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8532. {
  8533. // Trim spaces
  8534. trim(key)
  8535. trim(value)
  8536.  
  8537. // Add to sounds array
  8538. ArrayPushString(sound_assassin, key)
  8539. }
  8540. }
  8541. else if (equal(key, "ROUND LNJ"))
  8542. {
  8543. // Parse sounds
  8544. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8545. {
  8546. // Trim spaces
  8547. trim(key)
  8548. trim(value)
  8549.  
  8550. // Add to sounds array
  8551. ArrayPushString(sound_lnj, key)
  8552. }
  8553. }
  8554. }
  8555. case SECTION_AMBIENCE_SOUNDS:
  8556. {
  8557. if (equal(key, "INFECTION ENABLE"))
  8558. g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] = str_to_num(value)
  8559. else if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && equal(key, "INFECTION SOUNDS"))
  8560. {
  8561. // Parse sounds
  8562. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8563. {
  8564. // Trim spaces
  8565. trim(key)
  8566. trim(value)
  8567.  
  8568. // Add to sounds array
  8569. ArrayPushString(sound_ambience1, key)
  8570. ArrayPushCell(sound_ambience1_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8571. }
  8572. }
  8573. else if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && equal(key, "INFECTION DURATIONS"))
  8574. {
  8575. // Parse sounds
  8576. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8577. {
  8578. // Trim spaces
  8579. trim(key)
  8580. trim(value)
  8581.  
  8582. // Add to sounds array
  8583. ArrayPushCell(sound_ambience1_duration, str_to_num(key))
  8584. }
  8585. }
  8586. else if (equal(key, "NEMESIS ENABLE"))
  8587. g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] = str_to_num(value)
  8588. else if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && equal(key, "NEMESIS SOUNDS"))
  8589. {
  8590. // Parse sounds
  8591. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8592. {
  8593. // Trim spaces
  8594. trim(key)
  8595. trim(value)
  8596.  
  8597. // Add to sounds array
  8598. ArrayPushString(sound_ambience2, key)
  8599. ArrayPushCell(sound_ambience2_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8600. }
  8601. }
  8602. else if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && equal(key, "NEMESIS DURATIONS"))
  8603. {
  8604. // Parse sounds
  8605. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8606. {
  8607. // Trim spaces
  8608. trim(key)
  8609. trim(value)
  8610.  
  8611. // Add to sounds array
  8612. ArrayPushCell(sound_ambience2_duration, str_to_num(key))
  8613. }
  8614. }
  8615. else if (equal(key, "SURVIVOR ENABLE"))
  8616. g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] = str_to_num(value)
  8617. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && equal(key, "SURVIVOR SOUNDS"))
  8618. {
  8619. // Parse sounds
  8620. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8621. {
  8622. // Trim spaces
  8623. trim(key)
  8624. trim(value)
  8625.  
  8626. // Add to sounds array
  8627. ArrayPushString(sound_ambience3, key)
  8628. ArrayPushCell(sound_ambience3_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8629. }
  8630. }
  8631. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && equal(key, "SURVIVOR DURATIONS"))
  8632. {
  8633. // Parse sounds
  8634. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8635. {
  8636. // Trim spaces
  8637. trim(key)
  8638. trim(value)
  8639.  
  8640. // Add to sounds array
  8641. ArrayPushCell(sound_ambience3_duration, str_to_num(key))
  8642. }
  8643. }
  8644. else if (equal(key, "SWARM ENABLE"))
  8645. g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] = str_to_num(value)
  8646. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && equal(key, "SWARM SOUNDS"))
  8647. {
  8648. // Parse sounds
  8649. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8650. {
  8651. // Trim spaces
  8652. trim(key)
  8653. trim(value)
  8654.  
  8655. // Add to sounds array
  8656. ArrayPushString(sound_ambience4, key)
  8657. ArrayPushCell(sound_ambience4_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8658. }
  8659. }
  8660. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && equal(key, "SWARM DURATIONS"))
  8661. {
  8662. // Parse sounds
  8663. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8664. {
  8665. // Trim spaces
  8666. trim(key)
  8667. trim(value)
  8668.  
  8669. // Add to sounds array
  8670. ArrayPushCell(sound_ambience4_duration, str_to_num(key))
  8671. }
  8672. }
  8673. else if (equal(key, "PLAGUE ENABLE"))
  8674. g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] = str_to_num(value)
  8675. else if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && equal(key, "PLAGUE SOUNDS"))
  8676. {
  8677. // Parse sounds
  8678. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8679. {
  8680. // Trim spaces
  8681. trim(key)
  8682. trim(value)
  8683.  
  8684. // Add to sounds array
  8685. ArrayPushString(sound_ambience5, key)
  8686. ArrayPushCell(sound_ambience5_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8687. }
  8688. }
  8689. else if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && equal(key, "PLAGUE DURATIONS"))
  8690. {
  8691. // Parse sounds
  8692. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8693. {
  8694. // Trim spaces
  8695. trim(key)
  8696. trim(value)
  8697.  
  8698. // Add to sounds array
  8699. ArrayPushCell(sound_ambience5_duration, str_to_num(key))
  8700. }
  8701. }
  8702. else if (equal(key, "SNIPER ENABLE"))
  8703. g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] = str_to_num(value)
  8704. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && equal(key, "SNIPER SOUNDS"))
  8705. {
  8706. // Parse sounds
  8707. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8708. {
  8709. // Trim spaces
  8710. trim(key)
  8711. trim(value)
  8712.  
  8713. // Add to sounds array
  8714. ArrayPushString(sound_ambience6, key)
  8715. ArrayPushCell(sound_ambience6_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8716. }
  8717. }
  8718. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && equal(key, "SNIPER DURATIONS"))
  8719. {
  8720. // Parse sounds
  8721. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8722. {
  8723. // Trim spaces
  8724. trim(key)
  8725. trim(value)
  8726.  
  8727. // Add to sounds array
  8728. ArrayPushCell(sound_ambience6_duration, str_to_num(key))
  8729. }
  8730. }
  8731. else if (equal(key, "ASSASSIN ENABLE"))
  8732. g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] = str_to_num(value)
  8733. else if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && equal(key, "ASSASSIN SOUNDS"))
  8734. {
  8735. // Parse sounds
  8736. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8737. {
  8738. // Trim spaces
  8739. trim(key)
  8740. trim(value)
  8741.  
  8742. // Add to sounds array
  8743. ArrayPushString(sound_ambience7, key)
  8744. ArrayPushCell(sound_ambience7_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8745. }
  8746. }
  8747. else if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && equal(key, "ASSASSIN DURATIONS"))
  8748. {
  8749. // Parse sounds
  8750. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8751. {
  8752. // Trim spaces
  8753. trim(key)
  8754. trim(value)
  8755.  
  8756. // Add to sounds array
  8757. ArrayPushCell(sound_ambience7_duration, str_to_num(key))
  8758. }
  8759. }
  8760. else if (equal(key, "LNJ ENABLE"))
  8761. g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] = str_to_num(value)
  8762. else if (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] && equal(key, "LNJ SOUNDS"))
  8763. {
  8764. // Parse sounds
  8765. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8766. {
  8767. // Trim spaces
  8768. trim(key)
  8769. trim(value)
  8770.  
  8771. // Add to sounds array
  8772. ArrayPushString(sound_ambience8, key)
  8773. ArrayPushCell(sound_ambience8_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  8774. }
  8775. }
  8776. else if (g_ambience_sounds[AMBIENCE_SOUNDS_LNJ] && equal(key, "LNJ DURATIONS"))
  8777. {
  8778. // Parse sounds
  8779. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8780. {
  8781. // Trim spaces
  8782. trim(key)
  8783. trim(value)
  8784.  
  8785. // Add to sounds array
  8786. ArrayPushCell(sound_ambience8_duration, str_to_num(key))
  8787. }
  8788. }
  8789. }
  8790. case SECTION_BUY_MENU_WEAPONS:
  8791. {
  8792. if (equal(key, "PRIMARY"))
  8793. {
  8794. // Parse weapons
  8795. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8796. {
  8797. // Trim spaces
  8798. trim(key)
  8799. trim(value)
  8800.  
  8801. // Add to weapons array
  8802. ArrayPushString(g_primary_items, key)
  8803. ArrayPushCell(g_primary_weaponids, cs_weapon_name_to_id(key))
  8804. }
  8805. }
  8806. else if (equal(key, "SECONDARY"))
  8807. {
  8808. // Parse weapons
  8809. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8810. {
  8811. // Trim spaces
  8812. trim(key)
  8813. trim(value)
  8814.  
  8815. // Add to weapons array
  8816. ArrayPushString(g_secondary_items, key)
  8817. ArrayPushCell(g_secondary_weaponids, cs_weapon_name_to_id(key))
  8818. }
  8819. }
  8820. else if (equal(key, "ADDITIONAL ITEMS"))
  8821. {
  8822. // Parse weapons
  8823. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8824. {
  8825. // Trim spaces
  8826. trim(key)
  8827. trim(value)
  8828.  
  8829. // Add to weapons array
  8830. ArrayPushString(g_additional_items, key)
  8831. }
  8832. }
  8833. }
  8834. case SECTION_EXTRA_ITEMS_WEAPONS:
  8835. {
  8836. if (equal(key, "NAMES"))
  8837. {
  8838. // Parse weapon items
  8839. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8840. {
  8841. // Trim spaces
  8842. trim(key)
  8843. trim(value)
  8844.  
  8845. // Add to weapons array
  8846. ArrayPushString(g_extraweapon_names, key)
  8847. }
  8848. }
  8849. else if (equal(key, "ITEMS"))
  8850. {
  8851. // Parse weapon items
  8852. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8853. {
  8854. // Trim spaces
  8855. trim(key)
  8856. trim(value)
  8857.  
  8858. // Add to weapons array
  8859. ArrayPushString(g_extraweapon_items, key)
  8860. }
  8861. }
  8862. else if (equal(key, "COSTS"))
  8863. {
  8864. // Parse weapon items
  8865. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8866. {
  8867. // Trim spaces
  8868. trim(key)
  8869. trim(value)
  8870.  
  8871. // Add to weapons array
  8872. ArrayPushCell(g_extraweapon_costs, str_to_num(key))
  8873. }
  8874. }
  8875. }
  8876. case SECTION_HARD_CODED_ITEMS_COSTS:
  8877. {
  8878. if (equal(key, "NIGHT VISION"))
  8879. g_extra_costs2[EXTRA_NVISION] = str_to_num(value)
  8880. else if (equal(key, "ANTIDOTE"))
  8881. g_extra_costs2[EXTRA_ANTIDOTE] = str_to_num(value)
  8882. else if (equal(key, "ZOMBIE MADNESS"))
  8883. g_extra_costs2[EXTRA_MADNESS] = str_to_num(value)
  8884. else if (equal(key, "INFECTION BOMB"))
  8885. g_extra_costs2[EXTRA_INFBOMB] = str_to_num(value)
  8886. }
  8887. case SECTION_WEATHER_EFFECTS:
  8888. {
  8889. if (equal(key, "RAIN"))
  8890. g_ambience_rain = str_to_num(value)
  8891. else if (equal(key, "SNOW"))
  8892. g_ambience_snow = str_to_num(value)
  8893. else if (equal(key, "FOG"))
  8894. g_ambience_fog = str_to_num(value)
  8895. else if (equal(key, "FOG DENSITY"))
  8896. copy(g_fog_density, charsmax(g_fog_density), value)
  8897. else if (equal(key, "FOG COLOR"))
  8898. copy(g_fog_color, charsmax(g_fog_color), value)
  8899. }
  8900. case SECTION_SKY:
  8901. {
  8902. if (equal(key, "ENABLE"))
  8903. g_sky_enable = str_to_num(value)
  8904. else if (equal(key, "SKY NAMES"))
  8905. {
  8906. // Parse sky names
  8907. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8908. {
  8909. // Trim spaces
  8910. trim(key)
  8911. trim(value)
  8912.  
  8913. // Add to skies array
  8914. ArrayPushString(g_sky_names, key)
  8915.  
  8916. // Preache custom sky files
  8917. formatex(linedata, charsmax(linedata), "gfx/env/%sbk.tga", key)
  8918. engfunc(EngFunc_PrecacheGeneric, linedata)
  8919. formatex(linedata, charsmax(linedata), "gfx/env/%sdn.tga", key)
  8920. engfunc(EngFunc_PrecacheGeneric, linedata)
  8921. formatex(linedata, charsmax(linedata), "gfx/env/%sft.tga", key)
  8922. engfunc(EngFunc_PrecacheGeneric, linedata)
  8923. formatex(linedata, charsmax(linedata), "gfx/env/%slf.tga", key)
  8924. engfunc(EngFunc_PrecacheGeneric, linedata)
  8925. formatex(linedata, charsmax(linedata), "gfx/env/%srt.tga", key)
  8926. engfunc(EngFunc_PrecacheGeneric, linedata)
  8927. formatex(linedata, charsmax(linedata), "gfx/env/%sup.tga", key)
  8928. engfunc(EngFunc_PrecacheGeneric, linedata)
  8929. }
  8930. }
  8931. }
  8932. case SECTION_LIGHTNING:
  8933. {
  8934. if (equal(key, "LIGHTS"))
  8935. {
  8936. // Parse lights
  8937. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8938. {
  8939. // Trim spaces
  8940. trim(key)
  8941. trim(value)
  8942.  
  8943. // Add to lightning array
  8944. ArrayPushString(lights_thunder, key)
  8945. }
  8946. }
  8947. }
  8948. case SECTION_ZOMBIE_DECALS:
  8949. {
  8950. if (equal(key, "DECALS"))
  8951. {
  8952. // Parse decals
  8953. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8954. {
  8955. // Trim spaces
  8956. trim(key)
  8957. trim(value)
  8958.  
  8959. // Add to zombie decals array
  8960. ArrayPushCell(zombie_decals, str_to_num(key))
  8961. }
  8962. }
  8963. }
  8964. case SECTION_KNOCKBACK:
  8965. {
  8966. // Format weapon entity name
  8967. strtolower(key)
  8968. format(key, charsmax(key), "weapon_%s", key)
  8969.  
  8970. // Add value to knockback power array
  8971. kb_weapon_power[cs_weapon_name_to_id(key)] = str_to_float(value)
  8972. }
  8973. case SECTION_OBJECTIVE_ENTS:
  8974. {
  8975. if (equal(key, "CLASSNAMES"))
  8976. {
  8977. // Parse classnames
  8978. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  8979. {
  8980. // Trim spaces
  8981. trim(key)
  8982. trim(value)
  8983.  
  8984. // Add to objective ents array
  8985. ArrayPushString(g_objective_ents, key)
  8986. }
  8987. }
  8988. }
  8989. case SECTION_SVC_BAD:
  8990. {
  8991. if (equal(key, "MODELCHANGE DELAY"))
  8992. g_modelchange_delay = str_to_float(value)
  8993. else if (equal(key, "HANDLE MODELS ON SEPARATE ENT"))
  8994. g_handle_models_on_separate_ent = str_to_num(value)
  8995. else if (equal(key, "SET MODELINDEX OFFSET"))
  8996. g_set_modelindex_offset = str_to_num(value)
  8997. }
  8998. }
  8999. }
  9000. if (file) fclose(file)
  9001.  
  9002. // Build zombie classes file path
  9003. get_configsdir(path, charsmax(path))
  9004. format(path, charsmax(path), "%s/%s", path, ZP_ZOMBIECLASSES_FILE)
  9005.  
  9006. // Parse if present
  9007. if (file_exists(path))
  9008. {
  9009. // Open zombie classes file for reading
  9010. file = fopen(path, "rt")
  9011.  
  9012. while (file && !feof(file))
  9013. {
  9014. // Read one line at a time
  9015. fgets(file, linedata, charsmax(linedata))
  9016.  
  9017. // Replace newlines with a null character to prevent headaches
  9018. replace(linedata, charsmax(linedata), "^n", "")
  9019.  
  9020. // Blank line or comment
  9021. if (!linedata[0] || linedata[0] == ';') continue;
  9022.  
  9023. // New class starting
  9024. if (linedata[0] == '[')
  9025. {
  9026. // Remove first and last characters (braces)
  9027. linedata[strlen(linedata) - 1] = 0
  9028. copy(linedata, charsmax(linedata), linedata[1])
  9029.  
  9030. // Store its real name for future reference
  9031. ArrayPushString(g_zclass2_realname, linedata)
  9032. continue;
  9033. }
  9034.  
  9035. // Get key and value(s)
  9036. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  9037.  
  9038. // Trim spaces
  9039. trim(key)
  9040. trim(value)
  9041.  
  9042. if (equal(key, "NAME"))
  9043. ArrayPushString(g_zclass2_name, value)
  9044. else if (equal(key, "INFO"))
  9045. ArrayPushString(g_zclass2_info, value)
  9046. else if (equal(key, "MODELS"))
  9047. {
  9048. // Set models start index
  9049. ArrayPushCell(g_zclass2_modelsstart, ArraySize(g_zclass2_playermodel))
  9050.  
  9051. // Parse class models
  9052. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9053. {
  9054. // Trim spaces
  9055. trim(key)
  9056. trim(value)
  9057.  
  9058. // Add to class models array
  9059. ArrayPushString(g_zclass2_playermodel, key)
  9060. ArrayPushCell(g_zclass2_modelindex, -1)
  9061. }
  9062.  
  9063. // Set models end index
  9064. ArrayPushCell(g_zclass2_modelsend, ArraySize(g_zclass2_playermodel))
  9065. }
  9066. else if (equal(key, "CLAWMODEL"))
  9067. ArrayPushString(g_zclass2_clawmodel, value)
  9068. else if (equal(key, "HEALTH"))
  9069. ArrayPushCell(g_zclass2_hp, str_to_num(value))
  9070. else if (equal(key, "SPEED"))
  9071. ArrayPushCell(g_zclass2_spd, str_to_num(value))
  9072. else if (equal(key, "GRAVITY"))
  9073. ArrayPushCell(g_zclass2_grav, str_to_float(value))
  9074. else if (equal(key, "KNOCKBACK"))
  9075. ArrayPushCell(g_zclass2_kb, str_to_float(value))
  9076. }
  9077. if (file) fclose(file)
  9078. }
  9079.  
  9080. // Build extra items file path
  9081. get_configsdir(path, charsmax(path))
  9082. format(path, charsmax(path), "%s/%s", path, ZP_EXTRAITEMS_FILE)
  9083.  
  9084. // Parse if present
  9085. if (file_exists(path))
  9086. {
  9087. // Open extra items file for reading
  9088. file = fopen(path, "rt")
  9089.  
  9090. while (file && !feof(file))
  9091. {
  9092. // Read one line at a time
  9093. fgets(file, linedata, charsmax(linedata))
  9094.  
  9095. // Replace newlines with a null character to prevent headaches
  9096. replace(linedata, charsmax(linedata), "^n", "")
  9097.  
  9098. // Blank line or comment
  9099. if (!linedata[0] || linedata[0] == ';') continue;
  9100.  
  9101. // New item starting
  9102. if (linedata[0] == '[')
  9103. {
  9104. // Remove first and last characters (braces)
  9105. linedata[strlen(linedata) - 1] = 0
  9106. copy(linedata, charsmax(linedata), linedata[1])
  9107.  
  9108. // Store its real name for future reference
  9109. ArrayPushString(g_extraitem2_realname, linedata)
  9110. continue;
  9111. }
  9112.  
  9113. // Get key and value(s)
  9114. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  9115.  
  9116. // Trim spaces
  9117. trim(key)
  9118. trim(value)
  9119.  
  9120. if (equal(key, "NAME"))
  9121. ArrayPushString(g_extraitem2_name, value)
  9122. else if (equal(key, "COST"))
  9123. ArrayPushCell(g_extraitem2_cost, str_to_num(value))
  9124. else if (equal(key, "TEAMS"))
  9125. {
  9126. // Clear teams bitsum
  9127. teams = 0
  9128.  
  9129. // Parse teams
  9130. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9131. {
  9132. // Trim spaces
  9133. trim(key)
  9134. trim(value)
  9135.  
  9136. if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_ZOMBIE]))
  9137. teams |= ZP_TEAM_ZOMBIE
  9138. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_HUMAN]))
  9139. teams |= ZP_TEAM_HUMAN
  9140. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_NEMESIS]))
  9141. teams |= ZP_TEAM_NEMESIS
  9142. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_SURVIVOR]))
  9143. teams |= ZP_TEAM_SURVIVOR
  9144. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_SNIPER]))
  9145. teams |= ZP_TEAM_SNIPER
  9146. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_ASSASSIN]))
  9147. teams |= ZP_TEAM_ASSASSIN
  9148. }
  9149.  
  9150. // Add to teams array
  9151. ArrayPushCell(g_extraitem2_team, teams)
  9152. }
  9153. }
  9154. if (file) fclose(file)
  9155. }
  9156. }
  9157.  
  9158. save_customization()
  9159. {
  9160. new i, k, buffer[512]
  9161.  
  9162. // Build zombie classes file path
  9163. new path[64]
  9164. get_configsdir(path, charsmax(path))
  9165. format(path, charsmax(path), "%s/%s", path, ZP_ZOMBIECLASSES_FILE)
  9166.  
  9167. // Open zombie classes file for appending data
  9168. new file = fopen(path, "at"), size = ArraySize(g_zclass_name)
  9169.  
  9170. // Add any new zombie classes data at the end if needed
  9171. for (i = 0; i < size; i++)
  9172. {
  9173. if (ArrayGetCell(g_zclass_new, i))
  9174. {
  9175. // Add real name
  9176. ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))
  9177. format(buffer, charsmax(buffer), "^n[%s]", buffer)
  9178. fputs(file, buffer)
  9179.  
  9180. // Add caption
  9181. ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))
  9182. format(buffer, charsmax(buffer), "^nNAME = %s", buffer)
  9183. fputs(file, buffer)
  9184.  
  9185. // Add info
  9186. ArrayGetString(g_zclass_info, i, buffer, charsmax(buffer))
  9187. format(buffer, charsmax(buffer), "^nINFO = %s", buffer)
  9188. fputs(file, buffer)
  9189.  
  9190. // Add models
  9191. for (k = ArrayGetCell(g_zclass_modelsstart, i); k < ArrayGetCell(g_zclass_modelsend, i); k++)
  9192. {
  9193. if (k == ArrayGetCell(g_zclass_modelsstart, i))
  9194. {
  9195. // First model, overwrite buffer
  9196. ArrayGetString(g_zclass_playermodel, k, buffer, charsmax(buffer))
  9197. }
  9198. else
  9199. {
  9200. // Successive models, append to buffer
  9201. ArrayGetString(g_zclass_playermodel, k, path, charsmax(path))
  9202. format(buffer, charsmax(buffer), "%s , %s", buffer, path)
  9203. }
  9204. }
  9205. format(buffer, charsmax(buffer), "^nMODELS = %s", buffer)
  9206. fputs(file, buffer)
  9207.  
  9208. // Add clawmodel
  9209. ArrayGetString(g_zclass_clawmodel, i, buffer, charsmax(buffer))
  9210. format(buffer, charsmax(buffer), "^nCLAWMODEL = %s", buffer)
  9211. fputs(file, buffer)
  9212.  
  9213. // Add health
  9214. formatex(buffer, charsmax(buffer), "^nHEALTH = %d", ArrayGetCell(g_zclass_hp, i))
  9215. fputs(file, buffer)
  9216.  
  9217. // Add speed
  9218. formatex(buffer, charsmax(buffer), "^nSPEED = %d", ArrayGetCell(g_zclass_spd, i))
  9219. fputs(file, buffer)
  9220.  
  9221. // Add gravity
  9222. formatex(buffer, charsmax(buffer), "^nGRAVITY = %.2f", Float:ArrayGetCell(g_zclass_grav, i))
  9223. fputs(file, buffer)
  9224.  
  9225. // Add knockback
  9226. formatex(buffer, charsmax(buffer), "^nKNOCKBACK = %.2f^n", Float:ArrayGetCell(g_zclass_kb, i))
  9227. fputs(file, buffer)
  9228. }
  9229. }
  9230. fclose(file)
  9231.  
  9232. // Build extra items file path
  9233. get_configsdir(path, charsmax(path))
  9234. format(path, charsmax(path), "%s/%s", path, ZP_EXTRAITEMS_FILE)
  9235.  
  9236. // Open extra items file for appending data
  9237. file = fopen(path, "at")
  9238. size = ArraySize(g_extraitem_name)
  9239.  
  9240. // Add any new extra items data at the end if needed
  9241. for (i = EXTRAS_CUSTOM_STARTID; i < size; i++)
  9242. {
  9243. if (ArrayGetCell(g_extraitem_new, i))
  9244. {
  9245. // Add real name
  9246. ArrayGetString(g_extraitem_name, i, buffer, charsmax(buffer))
  9247. format(buffer, charsmax(buffer), "^n[%s]", buffer)
  9248. fputs(file, buffer)
  9249.  
  9250. // Add caption
  9251. ArrayGetString(g_extraitem_name, i, buffer, charsmax(buffer))
  9252. format(buffer, charsmax(buffer), "^nNAME = %s", buffer)
  9253. fputs(file, buffer)
  9254.  
  9255. // Add cost
  9256. formatex(buffer, charsmax(buffer), "^nCOST = %d", ArrayGetCell(g_extraitem_cost, i))
  9257. fputs(file, buffer)
  9258.  
  9259. // Add team
  9260. formatex(buffer, charsmax(buffer), "^nTEAMS = %s^n", ZP_TEAM_NAMES[ArrayGetCell(g_extraitem_team, i)])
  9261. fputs(file, buffer)
  9262. }
  9263. }
  9264. fclose(file)
  9265.  
  9266. // Free arrays containing class/item overrides
  9267. ArrayDestroy(g_zclass2_realname)
  9268. ArrayDestroy(g_zclass2_name)
  9269. ArrayDestroy(g_zclass2_info)
  9270. ArrayDestroy(g_zclass2_modelsstart)
  9271. ArrayDestroy(g_zclass2_modelsend)
  9272. ArrayDestroy(g_zclass2_playermodel)
  9273. ArrayDestroy(g_zclass2_modelindex)
  9274. ArrayDestroy(g_zclass2_clawmodel)
  9275. ArrayDestroy(g_zclass2_hp)
  9276. ArrayDestroy(g_zclass2_spd)
  9277. ArrayDestroy(g_zclass2_grav)
  9278. ArrayDestroy(g_zclass2_kb)
  9279. ArrayDestroy(g_zclass_new)
  9280. ArrayDestroy(g_extraitem2_realname)
  9281. ArrayDestroy(g_extraitem2_name)
  9282. ArrayDestroy(g_extraitem2_cost)
  9283. ArrayDestroy(g_extraitem2_team)
  9284. ArrayDestroy(g_extraitem_new)
  9285. }
  9286.  
  9287. // Register Ham Forwards for CZ bots
  9288. public register_ham_czbots(id)
  9289. {
  9290. // Make sure it's a CZ bot and it's still connected
  9291. if (g_hamczbots || !g_isconnected[id] || !get_pcvar_num(cvar_botquota))
  9292. return;
  9293.  
  9294. RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
  9295. RegisterHamFromEntity(Ham_Killed, id, "fw_PlayerKilled")
  9296. RegisterHamFromEntity(Ham_Killed, id, "fw_PlayerKilled_Post", 1)
  9297. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  9298. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage_Post", 1)
  9299. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  9300.  
  9301. // Ham forwards for CZ bots succesfully registered
  9302. g_hamczbots = true
  9303.  
  9304. // If the bot has already spawned, call the forward manually for him
  9305. if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
  9306. }
  9307.  
  9308. // Disable minmodels task
  9309. public disable_minmodels(id)
  9310. {
  9311. if (!g_isconnected[id]) return;
  9312. client_cmd(id, "cl_minmodels 0")
  9313. }
  9314.  
  9315. // Bots automatically buy extra items
  9316. public bot_buy_extras(taskid)
  9317. {
  9318. // Nemesis, Survivor or Sniper bots have nothing to buy by default
  9319. if (!g_isalive[ID_SPAWN] || g_survivor[ID_SPAWN] || g_nemesis[ID_SPAWN] || g_sniper[ID_SPAWN])
  9320. return;
  9321.  
  9322. if (!g_zombie[ID_SPAWN]) // human bots
  9323. {
  9324. // Attempt to buy Night Vision
  9325. buy_extra_item(ID_SPAWN, EXTRA_NVISION)
  9326.  
  9327. // Attempt to buy a weapon
  9328. buy_extra_item(ID_SPAWN, random_num(EXTRA_WEAPONS_STARTID, EXTRAS_CUSTOM_STARTID-1))
  9329. }
  9330. else // zombie bots
  9331. {
  9332. // Attempt to buy an Antidote
  9333. buy_extra_item(ID_SPAWN, EXTRA_ANTIDOTE)
  9334. }
  9335. }
  9336.  
  9337. // Refill BP Ammo Task
  9338. public refill_bpammo(const args[], id)
  9339. {
  9340. // Player died or turned into a zombie
  9341. if (!g_isalive[id] || g_zombie[id])
  9342. return;
  9343.  
  9344. set_msg_block(g_msgAmmoPickup, BLOCK_ONCE)
  9345. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[REFILL_WEAPONID], AMMOTYPE[REFILL_WEAPONID], MAXBPAMMO[REFILL_WEAPONID])
  9346. }
  9347.  
  9348. // Balance Teams Task
  9349. balance_teams()
  9350. {
  9351. // Get amount of users playing
  9352. static iPlayersnum
  9353. iPlayersnum = fnGetPlaying()
  9354.  
  9355. // No players, don't bother
  9356. if (iPlayersnum < 1) return;
  9357.  
  9358. // Split players evenly
  9359. static iTerrors, iMaxTerrors, id, team[33]
  9360. iMaxTerrors = iPlayersnum/2
  9361. iTerrors = 0
  9362.  
  9363. // First, set everyone to CT
  9364. for (id = 1; id <= g_maxplayers; id++)
  9365. {
  9366. // Skip if not connected
  9367. if (!g_isconnected[id])
  9368. continue;
  9369.  
  9370. team[id] = fm_cs_get_user_team(id)
  9371.  
  9372. // Skip if not playing
  9373. if (team[id] == FM_CS_TEAM_SPECTATOR || team[id] == FM_CS_TEAM_UNASSIGNED)
  9374. continue;
  9375.  
  9376. // Set team
  9377. remove_task(id+TASK_TEAM)
  9378. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  9379. team[id] = FM_CS_TEAM_CT
  9380. }
  9381.  
  9382. // Then randomly set half of the players to Terrorists
  9383. while (iTerrors < iMaxTerrors)
  9384. {
  9385. // Keep looping through all players
  9386. if (++id > g_maxplayers) id = 1
  9387.  
  9388. // Skip if not connected
  9389. if (!g_isconnected[id])
  9390. continue;
  9391.  
  9392. // Skip if not playing or already a Terrorist
  9393. if (team[id] != FM_CS_TEAM_CT)
  9394. continue;
  9395.  
  9396. // Random chance
  9397. if (random_num(0, 1))
  9398. {
  9399. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  9400. team[id] = FM_CS_TEAM_T
  9401. iTerrors++
  9402. }
  9403. }
  9404. }
  9405.  
  9406. // Welcome Message Task
  9407. public welcome_msg()
  9408. {
  9409. // Show mod info
  9410. zp_colored_print(0, "^x01**** ^x04%s^x01 ****", g_modname)
  9411. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO1")
  9412. if (!get_pcvar_num(cvar_infammo)) zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO2")
  9413.  
  9414. // Show T-virus HUD notice
  9415. set_hudmessage(0, 125, 200, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 3.0, 2.0, 1.0, -1)
  9416. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_VIRUS_FREE")
  9417. }
  9418.  
  9419. // Respawn Player Task
  9420. public respawn_player_task(taskid)
  9421. {
  9422. // Get player's team
  9423. static team
  9424. team = fm_cs_get_user_team(ID_SPAWN)
  9425.  
  9426. // Respawn player automatically if allowed on current round
  9427. if ((!g_endround && team != FM_CS_TEAM_SPECTATOR && team != FM_CS_TEAM_UNASSIGNED && !g_isalive[ID_SPAWN] && (!g_survround || get_pcvar_num(cvar_allowrespawnsurv)) && (!g_swarmround || get_pcvar_num(cvar_allowrespawnswarm))
  9428. && (!g_nemround || get_pcvar_num(cvar_allowrespawnnem))&& (!g_plagueround || get_pcvar_num(cvar_allowrespawnplague)) && (!g_sniperround || get_pcvar_num(cvar_allowrespawnsniper)) && (!g_assassinround || get_pcvar_num(cvar_allowrespawnassassin))
  9429. && (!g_lnjround || get_pcvar_num(cvar_allowrespawnlnj))) && (!(g_currentmode > MODE_LNJ) || (g_deathmatchmode > 0)))
  9430. {
  9431. // Infection rounds = none of the above
  9432. if (!get_pcvar_num(cvar_allowrespawninfection) && (g_currentmode == MODE_INFECTION || g_currentmode == MODE_MULTI))
  9433. return;
  9434.  
  9435. // Override respawn as zombie setting on nemesis, assassin, survivor and sniper rounds
  9436. if (g_survround || g_sniperround) g_respawn_as_zombie[ID_SPAWN] = true
  9437. else if (g_nemround || g_assassinround) g_respawn_as_zombie[ID_SPAWN] = false
  9438.  
  9439. respawn_player_manually(ID_SPAWN)
  9440. }
  9441. }
  9442.  
  9443. // Respawn Player Manually (called after respawn checks are done)
  9444. respawn_player_manually(id)
  9445. {
  9446. // Set proper team before respawning, so that the TeamInfo message that's sent doesn't confuse PODBots
  9447. if (g_respawn_as_zombie[id])
  9448. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  9449. else
  9450. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  9451.  
  9452. // Respawning a player has never been so easy
  9453. ExecuteHamB(Ham_CS_RoundRespawn, id)
  9454. }
  9455.  
  9456. // Check Round Task -check that we still have both zombies and humans on a round-
  9457. check_round(leaving_player)
  9458. {
  9459. // Round ended or make_a_zombie task still active
  9460. if (g_endround || task_exists(TASK_MAKEZOMBIE))
  9461. return;
  9462.  
  9463. // Get alive players count
  9464. static iPlayersnum, id
  9465. iPlayersnum = fnGetAlive()
  9466.  
  9467. // Last alive player, don't bother
  9468. if (iPlayersnum < 2)
  9469. return;
  9470.  
  9471. // Last zombie disconnecting
  9472. if (g_zombie[leaving_player] && fnGetZombies() == 1)
  9473. {
  9474. // Only one CT left, don't bother
  9475. if (fnGetHumans() == 1 && fnGetCTs() == 1)
  9476. return;
  9477.  
  9478. // Pick a random one to take his place
  9479. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) { /* keep looping */ }
  9480.  
  9481. // Show last zombie left notice
  9482. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_ZOMBIE_LEFT", g_playername[id])
  9483.  
  9484. // Set player leaving flag
  9485. g_lastplayerleaving = true
  9486.  
  9487. // Turn into a Nemesis, Assassin or just a zombie?
  9488. if (g_nemesis[leaving_player])
  9489. zombieme(id, 0, 1, 0, 0, 0)
  9490. else if (g_assassin[leaving_player])
  9491. zombieme(id, 0, 0, 0, 0, 1)
  9492. else
  9493. zombieme(id, 0, 0, 0, 0, 0)
  9494.  
  9495. // Remove player leaving flag
  9496. g_lastplayerleaving = false
  9497.  
  9498. // If Nemesis, set chosen player's health to that of the one who's leaving
  9499. if (get_pcvar_num(cvar_keephealthondisconnect) && g_nemesis[leaving_player])
  9500. fm_set_user_health(id, pev(leaving_player, pev_health))
  9501.  
  9502. // If Assassin, set chosen player's health to that of the one who's leaving
  9503. if (get_pcvar_num(cvar_keephealthondisconnect) && g_assassin[leaving_player])
  9504. fm_set_user_health(id, pev(leaving_player, pev_health))
  9505. }
  9506.  
  9507. // Last human disconnecting
  9508. else if (!g_zombie[leaving_player] && fnGetHumans() == 1)
  9509. {
  9510. // Only one T left, don't bother
  9511. if (fnGetZombies() == 1 && fnGetTs() == 1)
  9512. return;
  9513.  
  9514. // Pick a random one to take his place
  9515. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) { /* keep looping */ }
  9516.  
  9517. // Show last human left notice
  9518. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_HUMAN_LEFT", g_playername[id])
  9519.  
  9520. // Set player leaving flag
  9521. g_lastplayerleaving = true
  9522.  
  9523. // Turn into a Survivor, Sniper or just a human?
  9524. if (g_survivor[leaving_player])
  9525. humanme(id, 1, 0, 0)
  9526. else if (g_sniper[leaving_player])
  9527. humanme(id, 0, 0, 1)
  9528. else
  9529. humanme(id, 0, 0, 0)
  9530.  
  9531. // Remove player leaving flag
  9532. g_lastplayerleaving = false
  9533.  
  9534. // If Survivor, set chosen player's health to that of the one who's leaving
  9535. if (get_pcvar_num(cvar_keephealthondisconnect) && g_survivor[leaving_player])
  9536. fm_set_user_health(id, pev(leaving_player, pev_health))
  9537.  
  9538. // If Sniper, set chosen player's health to that of the one who's leaving
  9539. if (get_pcvar_num(cvar_keephealthondisconnect) && g_sniper[leaving_player])
  9540. fm_set_user_health(id, pev(leaving_player, pev_health))
  9541. }
  9542. }
  9543.  
  9544. // Lighting Effects Task
  9545. public lighting_effects()
  9546. {
  9547. // Cache some CVAR values at every 5 secs
  9548. cache_cvars()
  9549.  
  9550. // Get lighting style
  9551. static lighting[2]
  9552. get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
  9553. strtolower(lighting)
  9554.  
  9555. // Lighting disabled? ["0"]
  9556. if (lighting[0] == '0')
  9557. return;
  9558.  
  9559. // Darkest light settings?
  9560. if (lighting[0] >= 'a' && lighting[0] <= 'd')
  9561. {
  9562. static thunderclap_in_progress, Float:thunder
  9563. thunderclap_in_progress = task_exists(TASK_THUNDER)
  9564. thunder = get_pcvar_float(cvar_thunder)
  9565.  
  9566. // Set thunderclap tasks if not existant
  9567. if (thunder > 0.0 && !task_exists(TASK_THUNDER_PRE) && !thunderclap_in_progress)
  9568. {
  9569. g_lights_i = 0
  9570. ArrayGetString(lights_thunder, random_num(0, ArraySize(lights_thunder) - 1), g_lights_cycle, charsmax(g_lights_cycle))
  9571. g_lights_cycle_len = strlen(g_lights_cycle)
  9572. set_task(thunder, "thunderclap", TASK_THUNDER_PRE)
  9573. }
  9574.  
  9575. // Set lighting only when no thunderclaps are going on
  9576. if (!thunderclap_in_progress) engfunc(EngFunc_LightStyle, 0, g_assassinround ? "a" : lighting) // no lighting in assassin round
  9577. }
  9578. else
  9579. {
  9580. // Remove thunderclap tasks
  9581. remove_task(TASK_THUNDER_PRE)
  9582. remove_task(TASK_THUNDER)
  9583.  
  9584. // Set lighting
  9585. engfunc(EngFunc_LightStyle, 0, g_assassinround ? "a" : lighting) // no lighting in assassin round
  9586. }
  9587. }
  9588.  
  9589. // Thunderclap task
  9590. public thunderclap()
  9591. {
  9592. // Play thunder sound
  9593. if (g_lights_i == 0)
  9594. {
  9595. static sound[64]
  9596. ArrayGetString(sound_thunder, random_num(0, ArraySize(sound_thunder) - 1), sound, charsmax(sound))
  9597. PlaySound(sound)
  9598. }
  9599.  
  9600. // Set lighting
  9601. static light[2]
  9602. light[0] = g_lights_cycle[g_lights_i]
  9603. engfunc(EngFunc_LightStyle, 0, light)
  9604.  
  9605. g_lights_i++
  9606.  
  9607. // Lighting cycle end?
  9608. if (g_lights_i >= g_lights_cycle_len)
  9609. {
  9610. remove_task(TASK_THUNDER)
  9611. lighting_effects()
  9612. }
  9613. // Lighting cycle start?
  9614. else if (!task_exists(TASK_THUNDER))
  9615. set_task(0.1, "thunderclap", TASK_THUNDER, _, _, "b")
  9616. }
  9617.  
  9618. // Ambience Sound Effects Task
  9619. public ambience_sound_effects(taskid)
  9620. {
  9621. // Play a random sound depending on the round
  9622. static sound[64], iRand, duration, ismp3
  9623.  
  9624. // Check for current game mode
  9625. switch (g_currentmode)
  9626. {
  9627. case MODE_INFECTION:
  9628. {
  9629. iRand = random_num(0, ArraySize(sound_ambience1) - 1)
  9630. ArrayGetString(sound_ambience1, iRand, sound, charsmax(sound))
  9631. duration = ArrayGetCell(sound_ambience1_duration, iRand)
  9632. ismp3 = ArrayGetCell(sound_ambience1_ismp3, iRand)
  9633. }
  9634. case MODE_NEMESIS:
  9635. {
  9636. iRand = random_num(0, ArraySize(sound_ambience2) - 1)
  9637. ArrayGetString(sound_ambience2, iRand, sound, charsmax(sound))
  9638. duration = ArrayGetCell(sound_ambience2_duration, iRand)
  9639. ismp3 = ArrayGetCell(sound_ambience2_ismp3, iRand)
  9640. }
  9641. case MODE_ASSASSIN:
  9642. {
  9643. iRand = random_num(0, ArraySize(sound_ambience7) - 1)
  9644. ArrayGetString(sound_ambience7, iRand, sound, charsmax(sound))
  9645. duration = ArrayGetCell(sound_ambience7_duration, iRand)
  9646. ismp3 = ArrayGetCell(sound_ambience7_ismp3, iRand)
  9647. }
  9648. case MODE_SURVIVOR:
  9649. {
  9650. iRand = random_num(0, ArraySize(sound_ambience3) - 1)
  9651. ArrayGetString(sound_ambience3, iRand, sound, charsmax(sound))
  9652. duration = ArrayGetCell(sound_ambience3_duration, iRand)
  9653. ismp3 = ArrayGetCell(sound_ambience3_ismp3, iRand)
  9654. }
  9655. case MODE_SNIPER:
  9656. {
  9657. iRand = random_num(0, ArraySize(sound_ambience6) - 1)
  9658. ArrayGetString(sound_ambience6, iRand, sound, charsmax(sound))
  9659. duration = ArrayGetCell(sound_ambience6_duration, iRand)
  9660. ismp3 = ArrayGetCell(sound_ambience6_ismp3, iRand)
  9661. }
  9662. case MODE_SWARM:
  9663. {
  9664. iRand = random_num(0, ArraySize(sound_ambience4) - 1)
  9665. ArrayGetString(sound_ambience4, iRand, sound, charsmax(sound))
  9666. duration = ArrayGetCell(sound_ambience4_duration, iRand)
  9667. ismp3 = ArrayGetCell(sound_ambience4_ismp3, iRand)
  9668. }
  9669. case MODE_MULTI:
  9670. {
  9671. iRand = random_num(0, ArraySize(sound_ambience1) - 1)
  9672. ArrayGetString(sound_ambience1, iRand, sound, charsmax(sound))
  9673. duration = ArrayGetCell(sound_ambience1_duration, iRand)
  9674. ismp3 = ArrayGetCell(sound_ambience1_ismp3, iRand)
  9675. }
  9676. case MODE_PLAGUE:
  9677. {
  9678. iRand = random_num(0, ArraySize(sound_ambience5) - 1)
  9679. ArrayGetString(sound_ambience5, iRand, sound, charsmax(sound))
  9680. duration = ArrayGetCell(sound_ambience5_duration, iRand)
  9681. ismp3 = ArrayGetCell(sound_ambience5_ismp3, iRand)
  9682. }
  9683. case MODE_LNJ:
  9684. {
  9685. iRand = random_num(0, ArraySize(sound_ambience8) - 1)
  9686. ArrayGetString(sound_ambience8, iRand, sound, charsmax(sound))
  9687. duration = ArrayGetCell(sound_ambience8_duration, iRand)
  9688. ismp3 = ArrayGetCell(sound_ambience8_ismp3, iRand)
  9689. }
  9690. }
  9691.  
  9692. // Play it on clients
  9693. if (ismp3)
  9694. client_cmd(0, "mp3 play ^"sound/%s^"", sound)
  9695. else
  9696. PlaySound(sound)
  9697.  
  9698. // Set the task for when the sound is done playing
  9699. set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  9700. }
  9701.  
  9702. // Ambience Sounds Stop Task
  9703. ambience_sound_stop()
  9704. {
  9705. client_cmd(0, "mp3 stop; stopsound")
  9706. }
  9707.  
  9708. // Flashlight Charge Task
  9709. public flashlight_charge(taskid)
  9710. {
  9711. // Drain or charge?
  9712. if (g_flashlight[ID_CHARGE])
  9713. g_flashbattery[ID_CHARGE] -= get_pcvar_num(cvar_flashdrain)
  9714. else
  9715. g_flashbattery[ID_CHARGE] += get_pcvar_num(cvar_flashcharge)
  9716.  
  9717. // Battery fully charged
  9718. if (g_flashbattery[ID_CHARGE] >= 100)
  9719. {
  9720. // Don't exceed 100%
  9721. g_flashbattery[ID_CHARGE] = 100
  9722.  
  9723. // Update flashlight battery on HUD
  9724. message_begin(MSG_ONE, g_msgFlashBat, _, ID_CHARGE)
  9725. write_byte(100) // battery
  9726. message_end()
  9727.  
  9728. // Task not needed anymore
  9729. remove_task(taskid);
  9730. return;
  9731. }
  9732.  
  9733. // Battery depleted
  9734. if (g_flashbattery[ID_CHARGE] <= 0)
  9735. {
  9736. // Turn it off
  9737. g_flashlight[ID_CHARGE] = false
  9738. g_flashbattery[ID_CHARGE] = 0
  9739.  
  9740. // Play flashlight toggle sound
  9741. emit_sound(ID_CHARGE, CHAN_ITEM, sound_flashlight, 1.0, ATTN_NORM, 0, PITCH_NORM)
  9742.  
  9743. // Update flashlight status on HUD
  9744. message_begin(MSG_ONE, g_msgFlashlight, _, ID_CHARGE)
  9745. write_byte(0) // toggle
  9746. write_byte(0) // battery
  9747. message_end()
  9748.  
  9749. // Remove flashlight task for this player
  9750. remove_task(ID_CHARGE+TASK_FLASH)
  9751. }
  9752. else
  9753. {
  9754. // Update flashlight battery on HUD
  9755. message_begin(MSG_ONE_UNRELIABLE, g_msgFlashBat, _, ID_CHARGE)
  9756. write_byte(g_flashbattery[ID_CHARGE]) // battery
  9757. message_end()
  9758. }
  9759. }
  9760.  
  9761. // Remove Spawn Protection Task
  9762. public remove_spawn_protection(taskid)
  9763. {
  9764. // Not alive
  9765. if (!g_isalive[ID_SPAWN])
  9766. return;
  9767.  
  9768. // Remove spawn protection
  9769. g_nodamage[ID_SPAWN] = false
  9770. set_pev(ID_SPAWN, pev_effects, pev(ID_SPAWN, pev_effects) & ~EF_NODRAW)
  9771. }
  9772.  
  9773. // Hide Player's Money Task
  9774. public task_hide_money(taskid)
  9775. {
  9776. // Not alive
  9777. if (!g_isalive[ID_SPAWN])
  9778. return;
  9779.  
  9780. // Hide money
  9781. message_begin(MSG_ONE, g_msgHideWeapon, _, ID_SPAWN)
  9782. write_byte(HIDE_MONEY) // what to hide bitsum
  9783. message_end()
  9784.  
  9785. // Hide the HL crosshair that's drawn
  9786. message_begin(MSG_ONE, g_msgCrosshair, _, ID_SPAWN)
  9787. write_byte(0) // toggle
  9788. message_end()
  9789. }
  9790.  
  9791. // Turn Off Flashlight and Restore Batteries
  9792. turn_off_flashlight(id)
  9793. {
  9794. // Restore batteries for the next use
  9795. fm_cs_set_user_batteries(id, 100)
  9796.  
  9797. // Check if flashlight is on
  9798. if (pev(id, pev_effects) & EF_DIMLIGHT)
  9799. {
  9800. // Turn it off
  9801. set_pev(id, pev_impulse, IMPULSE_FLASHLIGHT)
  9802. }
  9803. else
  9804. {
  9805. // Clear any stored flashlight impulse (bugfix)
  9806. set_pev(id, pev_impulse, 0)
  9807. }
  9808.  
  9809. // Turn off custom flashlight
  9810. if (g_cached_customflash)
  9811. {
  9812. // Turn it off
  9813. g_flashlight[id] = false
  9814. g_flashbattery[id] = 100
  9815.  
  9816. // Update flashlight HUD
  9817. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  9818. write_byte(0) // toggle
  9819. write_byte(100) // battery
  9820. message_end()
  9821.  
  9822. // Remove previous tasks
  9823. remove_task(id+TASK_CHARGE)
  9824. remove_task(id+TASK_FLASH)
  9825. }
  9826. }
  9827.  
  9828. // Some one aimed at someone
  9829. public event_show_status(id)
  9830. {
  9831. // Not a bot and is still connected
  9832. if (!g_isbot[id] && g_isconnected[id] && get_pcvar_num(cvar_aiminfo))
  9833. {
  9834. // Retrieve the aimed player's id
  9835. static aimid
  9836. aimid = read_data(2)
  9837.  
  9838. // Only show friends status ?
  9839. if (g_zombie[id] == g_zombie[aimid])
  9840. {
  9841. static class[32], red, blue
  9842.  
  9843. // Format the class name according to the player's team
  9844. if (g_zombie[id])
  9845. {
  9846. red = 255
  9847. blue = 0
  9848.  
  9849. if (g_nemesis[aimid])
  9850. formatex(class, charsmax(class), "%L %L", id, "CLASS_CLASS", id, "CLASS_NEMESIS")
  9851. else if (g_assassin[aimid])
  9852. formatex(class, charsmax(class), "%L %L", id, "CLASS_CLASS", id, "CLASS_ASSASSIN")
  9853. else
  9854. formatex(class, charsmax(class), "%L %s", id, "CLASS_CLASS", g_zombie_classname[aimid])
  9855. }
  9856. else
  9857. {
  9858. red = 0
  9859. blue = 255
  9860.  
  9861. if (g_survivor[aimid])
  9862. formatex(class, charsmax(class), "%L %L", id, "CLASS_CLASS", id, "CLASS_SURVIVOR")
  9863. else if (g_sniper[aimid])
  9864. formatex(class, charsmax(class), "%L %L", id, "CLASS_CLASS", id, "CLASS_SNIPER")
  9865. else
  9866. formatex(class, charsmax(class), "%L %L", id, "CLASS_CLASS", id, "CLASS_HUMAN")
  9867. }
  9868.  
  9869. // Show the notice
  9870. set_hudmessage(red, 50, blue, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
  9871. ShowSyncHudMsg(id, g_MsgSync3,"%L", id, "AIM_INFO", g_playername[aimid], class, pev(aimid, pev_health), pev(aimid, pev_armorvalue), g_ammopacks[aimid])
  9872. }
  9873. }
  9874. }
  9875.  
  9876. // Remove the aim-info message
  9877. public event_hide_status(id)
  9878. {
  9879. ClearSyncHud(id, g_MsgSync3)
  9880. }
  9881.  
  9882. // ZPA Shut Down
  9883. public shut_the_mode()
  9884. {
  9885. // Time to switch off ZPA ?
  9886. if (g_time <= 0)
  9887. {
  9888. server_cmd("zp_toggle 0")
  9889. return;
  9890. }
  9891.  
  9892. // Send the notice to all players
  9893. set_hudmessage(250, 10, 10, -1.0, -1.0, 1, 0.0, 5.0, 1.0, 1.0, -1)
  9894. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SHUT_DOWN", g_time)
  9895.  
  9896. // Decrease counter
  9897. g_time--
  9898.  
  9899. // Repeat
  9900. set_task(1.0, "shut_the_mode")
  9901. }
  9902.  
  9903. // Infection Bomb Explosion
  9904. infection_explode(ent)
  9905. {
  9906. // Round ended (bugfix)
  9907. if (g_endround) return;
  9908.  
  9909. // Get origin
  9910. static Float:originF[3]
  9911. pev(ent, pev_origin, originF)
  9912.  
  9913. // Make the explosion
  9914. create_blast(originF)
  9915.  
  9916. // Infection nade explode sound
  9917. static sound[64]
  9918. ArrayGetString(grenade_infect, random_num(0, ArraySize(grenade_infect) - 1), sound, charsmax(sound))
  9919. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  9920.  
  9921. // Get attacker
  9922. static attacker
  9923. attacker = pev(ent, pev_owner)
  9924.  
  9925. // Collisions
  9926. static victim
  9927. victim = -1
  9928.  
  9929. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  9930. {
  9931. // Only effect alive non-spawnprotected humans
  9932. if (!is_user_valid_alive(victim) || g_zombie[victim] || g_nodamage[victim])
  9933. continue;
  9934.  
  9935. // Last human is killed
  9936. if (fnGetHumans() == 1)
  9937. {
  9938. ExecuteHamB(Ham_Killed, victim, attacker, 0)
  9939. continue;
  9940. }
  9941.  
  9942. // Infected victim's sound
  9943. ArrayGetString(grenade_infect_player, random_num(0, ArraySize(grenade_infect_player) - 1), sound, charsmax(sound))
  9944. emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  9945.  
  9946. // Turn into zombie
  9947. zombieme(victim, attacker, 0, 1, 1, 0)
  9948. }
  9949.  
  9950. // Get rid of the grenade
  9951. engfunc(EngFunc_RemoveEntity, ent)
  9952. }
  9953.  
  9954. // Fire Grenade Explosion
  9955. fire_explode(ent)
  9956. {
  9957. // Get origin
  9958. static Float:originF[3]
  9959. pev(ent, pev_origin, originF)
  9960.  
  9961. // Make the explosion
  9962. create_blast2(originF)
  9963.  
  9964. // Fire nade explode sound
  9965. static sound[64]
  9966. ArrayGetString(grenade_fire, random_num(0, ArraySize(grenade_fire) - 1), sound, charsmax(sound))
  9967. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  9968.  
  9969. // Collisions
  9970. static victim
  9971. victim = -1
  9972.  
  9973. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  9974. {
  9975. // Only effect alive zombies
  9976. if (!is_user_valid_alive(victim) || !g_zombie[victim] || g_nodamage[victim])
  9977. continue;
  9978.  
  9979. // Heat icon?
  9980. if (get_pcvar_num(cvar_hudicons))
  9981. {
  9982. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  9983. write_byte(0) // damage save
  9984. write_byte(0) // damage take
  9985. write_long(DMG_BURN) // damage type
  9986. write_coord(0) // x
  9987. write_coord(0) // y
  9988. write_coord(0) // z
  9989. message_end()
  9990. }
  9991.  
  9992. if (g_nemesis[victim] || g_assassin[victim]) // fire duration (nemesis/assassin is fire resistant)
  9993. g_burning_duration[victim] += get_pcvar_num(cvar_fireduration)
  9994. else
  9995. g_burning_duration[victim] += get_pcvar_num(cvar_fireduration) * 5
  9996.  
  9997. // Set burning task on victim if not present
  9998. if (!task_exists(victim+TASK_BURN))
  9999. set_task(0.2, "burning_flame", victim+TASK_BURN, _, _, "b")
  10000. }
  10001.  
  10002. // Get rid of the grenade
  10003. engfunc(EngFunc_RemoveEntity, ent)
  10004. }
  10005.  
  10006. // Frost Grenade Explosion
  10007. frost_explode(ent)
  10008. {
  10009. // Get origin
  10010. static Float:originF[3]
  10011. pev(ent, pev_origin, originF)
  10012.  
  10013. // Make the explosion
  10014. create_blast3(originF)
  10015.  
  10016. // Frost nade explode sound
  10017. static sound[64]
  10018. ArrayGetString(grenade_frost, random_num(0, ArraySize(grenade_frost) - 1), sound, charsmax(sound))
  10019. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10020.  
  10021. // Collisions
  10022. static victim
  10023. victim = -1
  10024.  
  10025. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  10026. {
  10027. // Only effect alive unfrozen zombies
  10028. if (!is_user_valid_alive(victim) || !g_zombie[victim] || g_frozen[victim] || g_nodamage[victim])
  10029. continue;
  10030.  
  10031. // Nemesis and Assassin shouldn't be frozen
  10032. if (g_nemesis[victim] || g_assassin[victim])
  10033. {
  10034. // Get player's origin
  10035. static origin2[3]
  10036. get_user_origin(victim, origin2)
  10037.  
  10038. // Broken glass sound
  10039. ArrayGetString(grenade_frost_break, random_num(0, ArraySize(grenade_frost_break) - 1), sound, charsmax(sound))
  10040. emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10041.  
  10042. // Glass shatter
  10043. message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
  10044. write_byte(TE_BREAKMODEL) // TE id
  10045. write_coord(origin2[0]) // x
  10046. write_coord(origin2[1]) // y
  10047. write_coord(origin2[2]+24) // z
  10048. write_coord(16) // size x
  10049. write_coord(16) // size y
  10050. write_coord(16) // size z
  10051. write_coord(random_num(-50, 50)) // velocity x
  10052. write_coord(random_num(-50, 50)) // velocity y
  10053. write_coord(25) // velocity z
  10054. write_byte(10) // random velocity
  10055. write_short(g_glassSpr) // model
  10056. write_byte(10) // count
  10057. write_byte(25) // life
  10058. write_byte(BREAK_GLASS) // flags
  10059. message_end()
  10060.  
  10061. continue;
  10062. }
  10063.  
  10064. // Freeze icon?
  10065. if (get_pcvar_num(cvar_hudicons))
  10066. {
  10067. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  10068. write_byte(0) // damage save
  10069. write_byte(0) // damage take
  10070. write_long(DMG_DROWN) // damage type - DMG_FREEZE
  10071. write_coord(0) // x
  10072. write_coord(0) // y
  10073. write_coord(0) // z
  10074. message_end()
  10075. }
  10076.  
  10077. // Light blue glow while frozen
  10078. if (g_handle_models_on_separate_ent)
  10079. fm_set_rendering(g_ent_playermodel[victim], kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  10080. else
  10081. fm_set_rendering(victim, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  10082.  
  10083. // Freeze sound
  10084. ArrayGetString(grenade_frost_player, random_num(0, ArraySize(grenade_frost_player) - 1), sound, charsmax(sound))
  10085. emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10086.  
  10087. // Add a blue tint to their screen
  10088. message_begin(MSG_ONE, g_msgScreenFade, _, victim)
  10089. write_short(0) // duration
  10090. write_short(0) // hold time
  10091. write_short(FFADE_STAYOUT) // fade type
  10092. write_byte(0) // red
  10093. write_byte(50) // green
  10094. write_byte(200) // blue
  10095. write_byte(100) // alpha
  10096. message_end()
  10097.  
  10098. // Prevent from jumping
  10099. if (pev(victim, pev_flags) & FL_ONGROUND)
  10100. set_pev(victim, pev_gravity, 999999.9) // set really high
  10101. else
  10102. set_pev(victim, pev_gravity, 0.000001) // no gravity
  10103.  
  10104. // Set a task to remove the freeze
  10105. g_frozen[victim] = true;
  10106. set_task(get_pcvar_float(cvar_freezeduration), "remove_freeze", victim)
  10107. }
  10108.  
  10109. // Get rid of the grenade
  10110. engfunc(EngFunc_RemoveEntity, ent)
  10111. }
  10112.  
  10113. // Remove freeze task
  10114. public remove_freeze(id)
  10115. {
  10116. // Not alive or not frozen anymore
  10117. if (!g_isalive[id] || !g_frozen[id])
  10118. return;
  10119.  
  10120. // Unfreeze
  10121. g_frozen[id] = false;
  10122.  
  10123. // Restore gravity
  10124. if (g_zombie[id])
  10125. {
  10126. if (g_nemesis[id])
  10127. set_pev(id, pev_gravity, get_pcvar_float(cvar_nemgravity))
  10128. else if (g_assassin[id])
  10129. set_pev(id, pev_gravity, get_pcvar_float(cvar_assassingravity))
  10130. else
  10131. set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  10132. }
  10133. else
  10134. {
  10135. if (g_survivor[id])
  10136. set_pev(id, pev_gravity, get_pcvar_float(cvar_survgravity))
  10137. else if (g_sniper[id])
  10138. set_pev(id, pev_gravity, get_pcvar_float(cvar_snipergravity))
  10139. else
  10140. set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity))
  10141. }
  10142.  
  10143. // Restore rendering
  10144. if (g_handle_models_on_separate_ent)
  10145. {
  10146. // Nemesis, Assassin, Survivor or Sniper glow / remove glow on player model entity
  10147. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  10148. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  10149. else if (g_nemesis[id] && !(get_pcvar_num(cvar_nemglow)))
  10150. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10151.  
  10152. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  10153. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  10154. else if (g_assassin[id] && !(get_pcvar_num(cvar_assassinglow)))
  10155. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10156.  
  10157. else if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  10158. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 250, 250, kRenderNormal, 25)
  10159. else if (g_survivor[id] && !(get_pcvar_num(cvar_survglow)))
  10160. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10161.  
  10162. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  10163. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, get_pcvar_num(cvar_snipercolor[0]), get_pcvar_num(cvar_snipercolor[1]), get_pcvar_num(cvar_snipercolor[2]), kRenderNormal, 25)
  10164. else if (g_sniper[id] && !(get_pcvar_num(cvar_sniperglow)))
  10165. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10166.  
  10167. else
  10168. fm_set_rendering(g_ent_playermodel[id])
  10169. }
  10170. else
  10171. {
  10172. // Nemesis, Assassin, Survivor or Sniper glow / remove glow
  10173. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  10174. fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  10175. else if (g_nemesis[id] && !(get_pcvar_num(cvar_nemglow)))
  10176. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10177.  
  10178. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  10179. fm_set_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 25)
  10180. else if (g_assassin[id] && !(get_pcvar_num(cvar_assassinglow)))
  10181. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10182.  
  10183. else if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  10184. fm_set_rendering(id, kRenderFxGlowShell, 0, 250, 250, kRenderNormal, 25)
  10185. else if (g_survivor[id] && !(get_pcvar_num(cvar_survglow)))
  10186. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10187.  
  10188. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  10189. fm_set_rendering(id, kRenderFxGlowShell, get_pcvar_num(cvar_snipercolor[0]), get_pcvar_num(cvar_snipercolor[1]), get_pcvar_num(cvar_snipercolor[2]), kRenderNormal, 25)
  10190. else if (g_sniper[id] && !(get_pcvar_num(cvar_sniperglow)))
  10191. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 25)
  10192.  
  10193. else
  10194. fm_set_rendering(id)
  10195. }
  10196.  
  10197. // Gradually remove screen's blue tint
  10198. message_begin(MSG_ONE, g_msgScreenFade, _, id)
  10199. write_short(UNIT_SECOND) // duration
  10200. write_short(0) // hold time
  10201. write_short(FFADE_IN) // fade type
  10202. write_byte(0) // red
  10203. write_byte(50) // green
  10204. write_byte(200) // blue
  10205. write_byte(100) // alpha
  10206. message_end()
  10207.  
  10208. // Broken glass sound
  10209. static sound[64]
  10210. ArrayGetString(grenade_frost_break, random_num(0, ArraySize(grenade_frost_break) - 1), sound, charsmax(sound))
  10211. emit_sound(id, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10212.  
  10213. // Get player's origin
  10214. static origin2[3]
  10215. get_user_origin(id, origin2)
  10216.  
  10217. // Glass shatter
  10218. message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
  10219. write_byte(TE_BREAKMODEL) // TE id
  10220. write_coord(origin2[0]) // x
  10221. write_coord(origin2[1]) // y
  10222. write_coord(origin2[2]+24) // z
  10223. write_coord(16) // size x
  10224. write_coord(16) // size y
  10225. write_coord(16) // size z
  10226. write_coord(random_num(-50, 50)) // velocity x
  10227. write_coord(random_num(-50, 50)) // velocity y
  10228. write_coord(25) // velocity z
  10229. write_byte(10) // random velocity
  10230. write_short(g_glassSpr) // model
  10231. write_byte(10) // count
  10232. write_byte(25) // life
  10233. write_byte(BREAK_GLASS) // flags
  10234. message_end()
  10235.  
  10236. ExecuteForward(g_fwUserUnfrozen, g_fwDummyResult, id);
  10237. }
  10238.  
  10239. // Remove Stuff Task
  10240. public remove_stuff()
  10241. {
  10242. static ent
  10243.  
  10244. // Remove rotating doors
  10245. if (get_pcvar_num(cvar_removedoors) > 0)
  10246. {
  10247. ent = -1;
  10248. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door_rotating")) != 0)
  10249. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  10250. }
  10251.  
  10252. // Remove all doors
  10253. if (get_pcvar_num(cvar_removedoors) > 1)
  10254. {
  10255. ent = -1;
  10256. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door")) != 0)
  10257. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  10258. }
  10259.  
  10260. // Triggered lights
  10261. if (!get_pcvar_num(cvar_triggered))
  10262. {
  10263. ent = -1
  10264. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "light")) != 0)
  10265. {
  10266. dllfunc(DLLFunc_Use, ent, 0); // turn off the light
  10267. set_pev(ent, pev_targetname, 0) // prevent it from being triggered
  10268. }
  10269. }
  10270. }
  10271.  
  10272. // Set Custom Weapon Models
  10273. replace_weapon_models(id, weaponid)
  10274. {
  10275. switch (weaponid)
  10276. {
  10277. case CSW_KNIFE: // Custom knife models
  10278. {
  10279. if (g_zombie[id])
  10280. {
  10281. if (g_nemesis[id]) // Nemesis
  10282. {
  10283. set_pev(id, pev_viewmodel2, model_vknife_nemesis)
  10284. set_pev(id, pev_weaponmodel2, "")
  10285. }
  10286. else if (g_assassin[id]) // Assassin
  10287. {
  10288. set_pev(id, pev_viewmodel2, model_vknife_assassin)
  10289. set_pev(id, pev_weaponmodel2, "")
  10290. }
  10291. else // Zombies
  10292. {
  10293. // Admin knife models?
  10294. if (get_pcvar_num(cvar_adminknifemodelszombie) && get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS])
  10295. {
  10296. set_pev(id, pev_viewmodel2, model_vknife_admin_zombie)
  10297. set_pev(id, pev_weaponmodel2, "")
  10298. }
  10299. else
  10300. {
  10301. static clawmodel[100]
  10302. ArrayGetString(g_zclass_clawmodel, g_zombieclass[id], clawmodel, charsmax(clawmodel))
  10303. format(clawmodel, charsmax(clawmodel), "models/zombie_plague/%s", clawmodel)
  10304. set_pev(id, pev_viewmodel2, clawmodel)
  10305. set_pev(id, pev_weaponmodel2, "")
  10306. }
  10307. }
  10308. }
  10309. else // Humans
  10310. {
  10311. // Admin knife models?
  10312. if (get_pcvar_num(cvar_adminknifemodelshuman) && get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS])
  10313. {
  10314. set_pev(id, pev_viewmodel2, model_vknife_admin_human)
  10315. }
  10316. else
  10317. {
  10318. set_pev(id, pev_viewmodel2, model_vknife_human)
  10319. set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
  10320. }
  10321. }
  10322. }
  10323. case CSW_M249: // Survivor's M249
  10324. {
  10325. if (g_survivor[id])
  10326. set_pev(id, pev_viewmodel2, model_vm249_survivor)
  10327. }
  10328. case CSW_HEGRENADE: // Infection bomb or fire grenade
  10329. {
  10330. if (g_zombie[id])
  10331. set_pev(id, pev_viewmodel2, model_grenade_infect)
  10332. else
  10333. set_pev(id, pev_viewmodel2, model_grenade_fire)
  10334. }
  10335. case CSW_FLASHBANG: // Frost grenade
  10336. {
  10337. set_pev(id, pev_viewmodel2, model_grenade_frost)
  10338. }
  10339. case CSW_SMOKEGRENADE: // Flare grenade
  10340. {
  10341. set_pev(id, pev_viewmodel2, model_grenade_flare)
  10342. }
  10343. case CSW_AWP: // Sniper's AWP
  10344. {
  10345. if (g_sniper[id])
  10346. set_pev(id, pev_viewmodel2, model_vawp_sniper)
  10347. }
  10348. }
  10349.  
  10350. // Update model on weaponmodel ent
  10351. if (g_handle_models_on_separate_ent) fm_set_weaponmodel_ent(id)
  10352. }
  10353.  
  10354. // Reset Player Vars
  10355. reset_vars(id, resetall)
  10356. {
  10357. g_zombie[id] = false
  10358. g_nemesis[id] = false
  10359. g_survivor[id] = false
  10360. g_firstzombie[id] = false
  10361. g_lastzombie[id] = false
  10362. g_lasthuman[id] = false
  10363. g_sniper[id] = false
  10364. g_assassin[id] = false
  10365. g_frozen[id] = false
  10366. g_nodamage[id] = false
  10367. g_respawn_as_zombie[id] = false
  10368. g_nvision[id] = false
  10369. g_nvisionenabled[id] = false
  10370. g_flashlight[id] = false
  10371. g_flashbattery[id] = 100
  10372. g_canbuy[id] = true
  10373. g_burning_duration[id] = 0
  10374.  
  10375. if (resetall)
  10376. {
  10377. g_ammopacks[id] = get_pcvar_num(cvar_startammopacks)
  10378. g_zombieclass[id] = ZCLASS_NONE
  10379. g_zombieclassnext[id] = ZCLASS_NONE
  10380. g_damagedealt[id] = 0
  10381. WPN_AUTO_ON = 0
  10382. }
  10383. }
  10384.  
  10385. // Set spectators nightvision
  10386. public spec_nvision(id)
  10387. {
  10388. // Not connected, alive, or bot
  10389. if (!g_isconnected[id] || g_isalive[id] || g_isbot[id])
  10390. return;
  10391.  
  10392. // Give Night Vision?
  10393. if (get_pcvar_num(cvar_nvggive))
  10394. {
  10395. g_nvision[id] = true
  10396.  
  10397. // Turn on Night Vision automatically?
  10398. if (get_pcvar_num(cvar_nvggive) == 1)
  10399. {
  10400. g_nvisionenabled[id] = true
  10401.  
  10402. // Custom nvg?
  10403. if (get_pcvar_num(cvar_customnvg))
  10404. {
  10405. remove_task(id+TASK_NVISION)
  10406. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  10407. }
  10408. else
  10409. set_user_gnvision(id, 1)
  10410. }
  10411. }
  10412. }
  10413.  
  10414. // Show HUD Task
  10415. public ShowHUD(taskid)
  10416. {
  10417. static id
  10418. id = ID_SHOWHUD;
  10419.  
  10420. // Player died?
  10421. if (!g_isalive[id])
  10422. {
  10423. // Get spectating target
  10424. id = pev(id, PEV_SPEC_TARGET)
  10425.  
  10426. // Target not alive
  10427. if (!g_isalive[id]) return;
  10428. }
  10429.  
  10430. // Format classname
  10431. static class[32], red, green, blue
  10432.  
  10433. if (g_zombie[id]) // zombies
  10434. {
  10435. red = 250
  10436. green = 250
  10437. blue = 10
  10438.  
  10439. if (g_nemesis[id])
  10440. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
  10441. else if (g_assassin[id])
  10442. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_ASSASSIN")
  10443. else
  10444. copy(class, charsmax(class), g_zombie_classname[id])
  10445. }
  10446. else // humans
  10447. {
  10448. red = 0
  10449. green = 180
  10450. blue = 255
  10451.  
  10452. if (g_survivor[id])
  10453. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
  10454. else if (g_sniper[id])
  10455. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SNIPER")
  10456. else
  10457. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_HUMAN")
  10458. }
  10459.  
  10460. // Spectating someone else?
  10461. if (id != ID_SHOWHUD)
  10462. {
  10463. // Show name, health, class, and ammo packs and armor
  10464. set_hudmessage(255, 10, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
  10465. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L %s^nHP: %d - %L %s - %L %d - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id],
  10466. pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
  10467. }
  10468. else
  10469. {
  10470. // Show health, class and ammo packs and armor
  10471. set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  10472. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d - %L %s - %L %d - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS",
  10473. class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(ID_SHOWHUD, pev_armorvalue))
  10474. }
  10475. }
  10476.  
  10477. // Play idle zombie sounds
  10478. public zombie_play_idle(taskid)
  10479. {
  10480. // Round ended/new one starting
  10481. if (g_endround || g_newround)
  10482. return;
  10483.  
  10484. static sound[64]
  10485.  
  10486. // Last zombie?
  10487. if (g_lastzombie[ID_BLOOD])
  10488. {
  10489. ArrayGetString(zombie_idle_last, random_num(0, ArraySize(zombie_idle_last) - 1), sound, charsmax(sound))
  10490. emit_sound(ID_BLOOD, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10491. }
  10492. else
  10493. {
  10494. ArrayGetString(zombie_idle, random_num(0, ArraySize(zombie_idle) - 1), sound, charsmax(sound))
  10495. emit_sound(ID_BLOOD, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  10496. }
  10497. }
  10498.  
  10499. // Madness Over Task
  10500. public madness_over(taskid)
  10501. {
  10502. g_nodamage[ID_BLOOD] = false
  10503. }
  10504.  
  10505. // Place user at a random spawn
  10506. do_random_spawn(id, regularspawns = 0)
  10507. {
  10508. static hull, sp_index, i
  10509.  
  10510. // Get whether the player is crouching
  10511. hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  10512.  
  10513. // Use regular spawns?
  10514. if (!regularspawns)
  10515. {
  10516. // No spawns?
  10517. if (!g_spawnCount)
  10518. return;
  10519.  
  10520. // Choose random spawn to start looping at
  10521. sp_index = random_num(0, g_spawnCount - 1)
  10522.  
  10523. // Try to find a clear spawn
  10524. for (i = sp_index + 1; /*no condition*/; i++)
  10525. {
  10526. // Start over when we reach the end
  10527. if (i >= g_spawnCount) i = 0
  10528.  
  10529. // Free spawn space?
  10530. if (is_hull_vacant(g_spawns[i], hull))
  10531. {
  10532. // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  10533. engfunc(EngFunc_SetOrigin, id, g_spawns[i])
  10534. break;
  10535. }
  10536.  
  10537. // Loop completed, no free space found
  10538. if (i == sp_index) break;
  10539. }
  10540. }
  10541. else
  10542. {
  10543. // No spawns?
  10544. if (!g_spawnCount2)
  10545. return;
  10546.  
  10547. // Choose random spawn to start looping at
  10548. sp_index = random_num(0, g_spawnCount2 - 1)
  10549.  
  10550. // Try to find a clear spawn
  10551. for (i = sp_index + 1; /*no condition*/; i++)
  10552. {
  10553. // Start over when we reach the end
  10554. if (i >= g_spawnCount2) i = 0
  10555.  
  10556. // Free spawn space?
  10557. if (is_hull_vacant(g_spawns2[i], hull))
  10558. {
  10559. // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  10560. engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
  10561. break;
  10562. }
  10563.  
  10564. // Loop completed, no free space found
  10565. if (i == sp_index) break;
  10566. }
  10567. }
  10568. }
  10569.  
  10570. // Get Zombies -returns alive zombies number-
  10571. fnGetZombies()
  10572. {
  10573. static iZombies, id
  10574. iZombies = 0
  10575.  
  10576. for (id = 1; id <= g_maxplayers; id++)
  10577. {
  10578. if (g_isalive[id] && g_zombie[id])
  10579. iZombies++
  10580. }
  10581.  
  10582. return iZombies;
  10583. }
  10584.  
  10585. // Get Humans -returns alive humans number-
  10586. fnGetHumans()
  10587. {
  10588. static iHumans, id
  10589. iHumans = 0
  10590.  
  10591. for (id = 1; id <= g_maxplayers; id++)
  10592. {
  10593. if (g_isalive[id] && !g_zombie[id])
  10594. iHumans++
  10595. }
  10596.  
  10597. return iHumans;
  10598. }
  10599.  
  10600. // Get Nemesis -returns alive nemesis number-
  10601. fnGetNemesis()
  10602. {
  10603. static iNemesis, id
  10604. iNemesis = 0
  10605.  
  10606. for (id = 1; id <= g_maxplayers; id++)
  10607. {
  10608. if (g_isalive[id] && g_nemesis[id])
  10609. iNemesis++
  10610. }
  10611.  
  10612. return iNemesis;
  10613. }
  10614.  
  10615. // Get Survivors -returns alive survivors number-
  10616. fnGetSurvivors()
  10617. {
  10618. static iSurvivors, id
  10619. iSurvivors = 0
  10620.  
  10621. for (id = 1; id <= g_maxplayers; id++)
  10622. {
  10623. if (g_isalive[id] && g_survivor[id])
  10624. iSurvivors++
  10625. }
  10626.  
  10627. return iSurvivors;
  10628. }
  10629.  
  10630. // Get Snipers -returns alive snipers number-
  10631. fnGetSnipers()
  10632. {
  10633. static iSnipers, id
  10634. iSnipers = 0
  10635.  
  10636. for (id = 1; id <= g_maxplayers; id++)
  10637. {
  10638. if (g_isalive[id] && g_sniper[id])
  10639. iSnipers++
  10640. }
  10641.  
  10642. return iSnipers;
  10643. }
  10644. // Get Assassins -returns alive assassin numbers-
  10645. fnGetAssassin()
  10646. {
  10647. static iAssassin, id
  10648. iAssassin = 0
  10649.  
  10650. for (id = 1; id <= g_maxplayers; id++)
  10651. {
  10652. if (g_isalive[id] && g_assassin[id])
  10653. iAssassin++
  10654. }
  10655.  
  10656. return iAssassin;
  10657. }
  10658.  
  10659. // Get Alive -returns alive players number-
  10660. fnGetAlive()
  10661. {
  10662. static iAlive, id
  10663. iAlive = 0
  10664.  
  10665. for (id = 1; id <= g_maxplayers; id++)
  10666. {
  10667. if (g_isalive[id])
  10668. iAlive++
  10669. }
  10670.  
  10671. return iAlive;
  10672. }
  10673.  
  10674. // Get Random Alive -returns index of alive player number n -
  10675. fnGetRandomAlive(n)
  10676. {
  10677. static iAlive, id
  10678. iAlive = 0
  10679.  
  10680. for (id = 1; id <= g_maxplayers; id++)
  10681. {
  10682. if (g_isalive[id])
  10683. iAlive++
  10684.  
  10685. if (iAlive == n)
  10686. return id;
  10687. }
  10688.  
  10689. return -1;
  10690. }
  10691.  
  10692. // Get Playing -returns number of users playing-
  10693. fnGetPlaying()
  10694. {
  10695. static iPlaying, id, team
  10696. iPlaying = 0
  10697.  
  10698. for (id = 1; id <= g_maxplayers; id++)
  10699. {
  10700. if (g_isconnected[id])
  10701. {
  10702. team = fm_cs_get_user_team(id)
  10703.  
  10704. if (team != FM_CS_TEAM_SPECTATOR && team != FM_CS_TEAM_UNASSIGNED)
  10705. iPlaying++
  10706. }
  10707. }
  10708.  
  10709. return iPlaying;
  10710. }
  10711.  
  10712. // Get CTs -returns number of CTs connected-
  10713. fnGetCTs()
  10714. {
  10715. static iCTs, id
  10716. iCTs = 0
  10717.  
  10718. for (id = 1; id <= g_maxplayers; id++)
  10719. {
  10720. if (g_isconnected[id])
  10721. {
  10722. if (fm_cs_get_user_team(id) == FM_CS_TEAM_CT)
  10723. iCTs++
  10724. }
  10725. }
  10726.  
  10727. return iCTs;
  10728. }
  10729.  
  10730. // Get Ts -returns number of Ts connected-
  10731. fnGetTs()
  10732. {
  10733. static iTs, id
  10734. iTs = 0
  10735.  
  10736. for (id = 1; id <= g_maxplayers; id++)
  10737. {
  10738. if (g_isconnected[id])
  10739. {
  10740. if (fm_cs_get_user_team(id) == FM_CS_TEAM_T)
  10741. iTs++
  10742. }
  10743. }
  10744.  
  10745. return iTs;
  10746. }
  10747.  
  10748. // Get Alive CTs -returns number of CTs alive-
  10749. fnGetAliveCTs()
  10750. {
  10751. static iCTs, id
  10752. iCTs = 0
  10753.  
  10754. for (id = 1; id <= g_maxplayers; id++)
  10755. {
  10756. if (g_isalive[id])
  10757. {
  10758. if (fm_cs_get_user_team(id) == FM_CS_TEAM_CT)
  10759. iCTs++
  10760. }
  10761. }
  10762.  
  10763. return iCTs;
  10764. }
  10765.  
  10766. // Get Alive Ts -returns number of Ts alive-
  10767. fnGetAliveTs()
  10768. {
  10769. static iTs, id
  10770. iTs = 0
  10771.  
  10772. for (id = 1; id <= g_maxplayers; id++)
  10773. {
  10774. if (g_isalive[id])
  10775. {
  10776. if (fm_cs_get_user_team(id) == FM_CS_TEAM_T)
  10777. iTs++
  10778. }
  10779. }
  10780.  
  10781. return iTs;
  10782. }
  10783.  
  10784. // Last Zombie Check -check for last zombie and set its flag-
  10785. fnCheckLastZombie()
  10786. {
  10787. static id
  10788. for (id = 1; id <= g_maxplayers; id++)
  10789. {
  10790. // Last zombie
  10791. if (g_isalive[id] && g_zombie[id] && !g_nemesis[id] && !g_assassin[id] && fnGetZombies() == 1)
  10792. {
  10793. if (!g_lastzombie[id])
  10794. {
  10795. // Last zombie forward
  10796. ExecuteForward(g_fwUserLastZombie, g_fwDummyResult, id);
  10797. }
  10798. g_lastzombie[id] = true
  10799. }
  10800. else
  10801. g_lastzombie[id] = false
  10802.  
  10803. // Last human
  10804. if (g_isalive[id] && !g_zombie[id] && !g_survivor[id] && !g_sniper[id] && fnGetHumans() == 1)
  10805. {
  10806. if (!g_lasthuman[id])
  10807. {
  10808. // Last human forward
  10809. ExecuteForward(g_fwUserLastHuman, g_fwDummyResult, id);
  10810.  
  10811. // Reward extra hp
  10812. fm_set_user_health(id, pev(id, pev_health) + get_pcvar_num(cvar_humanlasthp))
  10813. }
  10814. g_lasthuman[id] = true
  10815. }
  10816. else
  10817. g_lasthuman[id] = false
  10818. }
  10819. }
  10820.  
  10821. // Save player's stats to database
  10822. save_stats(id)
  10823. {
  10824. // Check whether there is another record already in that slot
  10825. if (db_name[id][0] && !equal(g_playername[id], db_name[id]))
  10826. {
  10827. // If DB size is exceeded, write over old records
  10828. if (db_slot_i >= sizeof db_name)
  10829. db_slot_i = g_maxplayers+1
  10830.  
  10831. // Move previous record onto an additional save slot
  10832. copy(db_name[db_slot_i], charsmax(db_name[]), db_name[id])
  10833. db_ammopacks[db_slot_i] = db_ammopacks[id]
  10834. db_zombieclass[db_slot_i] = db_zombieclass[id]
  10835. db_slot_i++
  10836. }
  10837.  
  10838. // Now save the current player stats
  10839. copy(db_name[id], charsmax(db_name[]), g_playername[id]) // name
  10840. db_ammopacks[id] = g_ammopacks[id] // ammo packs
  10841. db_zombieclass[id] = g_zombieclassnext[id] // zombie class
  10842. }
  10843.  
  10844. // Load player's stats from database (if a record is found)
  10845. load_stats(id)
  10846. {
  10847. // Look for a matching record
  10848. static i
  10849. for (i = 0; i < sizeof db_name; i++)
  10850. {
  10851. if (equal(g_playername[id], db_name[i]))
  10852. {
  10853. // Bingo!
  10854. g_ammopacks[id] = db_ammopacks[i]
  10855. g_zombieclass[id] = db_zombieclass[i]
  10856. g_zombieclassnext[id] = db_zombieclass[i]
  10857. return;
  10858. }
  10859. }
  10860. }
  10861.  
  10862. // Checks if a player is allowed to be zombie
  10863. allowed_zombie(id)
  10864. {
  10865. if ((g_zombie[id] && !g_nemesis[id] && !g_assassin[id]) || g_endround || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  10866. return false;
  10867.  
  10868. return true;
  10869. }
  10870.  
  10871. // Checks if a player is allowed to be human
  10872. allowed_human(id)
  10873. {
  10874. if ((!g_zombie[id] && !g_survivor[id] && !g_sniper[id]) || g_endround || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  10875. return false;
  10876.  
  10877. return true;
  10878. }
  10879.  
  10880. // Checks if a player is allowed to be survivor
  10881. allowed_survivor(id)
  10882. {
  10883. if (g_endround || g_survivor[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  10884. return false;
  10885.  
  10886. return true;
  10887. }
  10888.  
  10889. // Checks if a player is allowed to be nemesis
  10890. allowed_nemesis(id)
  10891. {
  10892. if (g_endround || g_nemesis[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  10893. return false;
  10894.  
  10895. return true;
  10896. }
  10897.  
  10898. // Checks if a player is allowed to respawn
  10899. allowed_respawn(id)
  10900. {
  10901. static team
  10902. team = fm_cs_get_user_team(id)
  10903.  
  10904. if (g_endround || team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED || g_isalive[id])
  10905. return false;
  10906.  
  10907. return true;
  10908. }
  10909.  
  10910. // Checks if swarm mode is allowed
  10911. allowed_swarm()
  10912. {
  10913. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG))
  10914. return false;
  10915.  
  10916. return true;
  10917. }
  10918.  
  10919. // Checks if multi infection mode is allowed
  10920. allowed_multi()
  10921. {
  10922. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG) || floatround(fnGetAlive()*get_pcvar_float(cvar_multiratio), floatround_ceil) < 2 || floatround(fnGetAlive()*get_pcvar_float(cvar_multiratio), floatround_ceil) >= fnGetAlive())
  10923. return false;
  10924.  
  10925. return true;
  10926. }
  10927.  
  10928. // Checks if plague mode is allowed
  10929. allowed_plague()
  10930. {
  10931. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG) || floatround((fnGetAlive()-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) < 1
  10932. || fnGetAlive()-(get_pcvar_num(cvar_plaguesurvnum)+get_pcvar_num(cvar_plaguenemnum)+floatround((fnGetAlive()-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)) < 1)
  10933. return false;
  10934.  
  10935. return true;
  10936. }
  10937.  
  10938. // Checks if a player is allowed to be sniper
  10939. allowed_sniper(id)
  10940. {
  10941. if (g_endround || g_sniper[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  10942. return false;
  10943.  
  10944. return true;
  10945. }
  10946. // Checks if a player ia sllowed to be assassin
  10947. allowed_assassin(id)
  10948. {
  10949. if (g_endround || g_assassin[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  10950. return false;
  10951.  
  10952. return true;
  10953. }
  10954.  
  10955. // Checks if armageddon mode is allowed
  10956. allowed_lnj()
  10957. {
  10958. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG) || fnGetAlive() < 2)
  10959. return false;
  10960.  
  10961. return true;
  10962. }
  10963.  
  10964. // Checks if a custom game mode is allowed
  10965. allowed_custom_game()
  10966. {
  10967. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG) || fnGetAlive() < 2)
  10968. return false;
  10969.  
  10970. return true;
  10971. }
  10972.  
  10973. // Admin Command. zp_zombie
  10974. command_zombie(id, player)
  10975. {
  10976. // Show activity?
  10977. switch (get_pcvar_num(cvar_showactivity))
  10978. {
  10979. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_INFECT")
  10980. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_INFECT")
  10981. }
  10982.  
  10983. // Log to Zombie Plague Advance log file?
  10984. if (get_pcvar_num(cvar_logcommands))
  10985. {
  10986. static logdata[100], authid[32], ip[16]
  10987. get_user_authid(id, authid, charsmax(authid))
  10988. get_user_ip(id, ip, charsmax(ip), 1)
  10989. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER, "CMD_INFECT", fnGetPlaying(), g_maxplayers)
  10990. log_to_file("zombie_plague_advance.log", logdata)
  10991. }
  10992.  
  10993. // New round?
  10994. if (g_newround)
  10995. {
  10996. // Set as first zombie
  10997. remove_task(TASK_MAKEZOMBIE)
  10998. start_infection_mode(player, MODE_SET)
  10999. }
  11000. else
  11001. {
  11002. // Just infect
  11003. zombieme(player, 0, 0, 0, 0, 0)
  11004. }
  11005. }
  11006.  
  11007. // Admin Command. zp_human
  11008. command_human(id, player)
  11009. {
  11010. // Show activity?
  11011. switch (get_pcvar_num(cvar_showactivity))
  11012. {
  11013. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
  11014. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
  11015. }
  11016.  
  11017. // Log to Zombie Plague log file?
  11018. if (get_pcvar_num(cvar_logcommands))
  11019. {
  11020. static logdata[100], authid[32], ip[16]
  11021. get_user_authid(id, authid, charsmax(authid))
  11022. get_user_ip(id, ip, charsmax(ip), 1)
  11023. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_DISINFECT", fnGetPlaying(), g_maxplayers)
  11024. log_to_file("zombie_plague_advance.log", logdata)
  11025. }
  11026.  
  11027. // Turn to human
  11028. humanme(player, 0, 0, 0)
  11029. }
  11030.  
  11031. // Admin Command. zp_survivor
  11032. command_survivor(id, player)
  11033. {
  11034. // Show activity?
  11035. switch (get_pcvar_num(cvar_showactivity))
  11036. {
  11037. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_SURVIVAL")
  11038. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_SURVIVAL")
  11039. }
  11040.  
  11041. // Log to Zombie Plague log file?
  11042. if (get_pcvar_num(cvar_logcommands))
  11043. {
  11044. static logdata[100], authid[32], ip[16]
  11045. get_user_authid(id, authid, charsmax(authid))
  11046. get_user_ip(id, ip, charsmax(ip), 1)
  11047. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_SURVIVAL", fnGetPlaying(), g_maxplayers)
  11048. log_to_file("zombie_plague_advance.log", logdata)
  11049. }
  11050.  
  11051. // New round?
  11052. if (g_newround)
  11053. {
  11054. // Set as first survivor
  11055. remove_task(TASK_MAKEZOMBIE)
  11056. start_survivor_mode(player, MODE_SET)
  11057. }
  11058. else
  11059. {
  11060. // Turn player into a Survivor
  11061. humanme(player, 1, 0, 0)
  11062. }
  11063. }
  11064.  
  11065. // Admin Command. zp_nemesis
  11066. command_nemesis(id, player)
  11067. {
  11068. // Show activity?
  11069. switch (get_pcvar_num(cvar_showactivity))
  11070. {
  11071. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_NEMESIS")
  11072. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_NEMESIS")
  11073. }
  11074.  
  11075. // Log to Zombie Plague log file?
  11076. if (get_pcvar_num(cvar_logcommands))
  11077. {
  11078. static logdata[100], authid[32], ip[16]
  11079. get_user_authid(id, authid, charsmax(authid))
  11080. get_user_ip(id, ip, charsmax(ip), 1)
  11081. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_NEMESIS", fnGetPlaying(), g_maxplayers)
  11082. log_to_file("zombie_plague_advance.log", logdata)
  11083. }
  11084.  
  11085. // New round?
  11086. if (g_newround)
  11087. {
  11088. // Set as first nemesis
  11089. remove_task(TASK_MAKEZOMBIE)
  11090. start_nemesis_mode(player, MODE_SET)
  11091. }
  11092. else
  11093. {
  11094. // Turn player into a Nemesis
  11095. zombieme(player, 0, 1, 0, 0, 0)
  11096. }
  11097. }
  11098.  
  11099. // Admin Command. zp_respawn
  11100. command_respawn(id, player)
  11101. {
  11102. // Show activity?
  11103. switch (get_pcvar_num(cvar_showactivity))
  11104. {
  11105. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_RESPAWN")
  11106. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_RESPAWN")
  11107. }
  11108.  
  11109. // Log to Zombie Plague log file?
  11110. if (get_pcvar_num(cvar_logcommands))
  11111. {
  11112. static logdata[100], authid[32], ip[16]
  11113. get_user_authid(id, authid, charsmax(authid))
  11114. get_user_ip(id, ip, charsmax(ip), 1)
  11115. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER, "CMD_RESPAWN", fnGetPlaying(), g_maxplayers)
  11116. log_to_file("zombie_plague_advance.log", logdata)
  11117. }
  11118.  
  11119. // Respawn as zombie?
  11120. if (g_currentmode > MODE_LNJ) // Custom round ?
  11121. {
  11122. if(g_deathmatchmode == 2 || (g_deathmatchmode == 3 && random_num(0, 1)) || (g_deathmatchmode == 4 && (fnGetZombies() < (fnGetAlive()/2))))
  11123. g_respawn_as_zombie[player] = true
  11124. }
  11125. else // Normal round
  11126. {
  11127. if (get_pcvar_num(cvar_deathmatch) == 2 || (get_pcvar_num(cvar_deathmatch) == 3 && random_num(0, 1)) || (get_pcvar_num(cvar_deathmatch) == 4 && (fnGetZombies() < (fnGetAlive()/2))))
  11128. g_respawn_as_zombie[player] = true
  11129. }
  11130.  
  11131. // Override respawn as zombie setting on nemesis, assassin, survivor and sniper rounds
  11132. if (g_survround || g_sniperround) g_respawn_as_zombie[player] = true
  11133. else if (g_nemround || g_assassinround) g_respawn_as_zombie[player] = false
  11134.  
  11135. respawn_player_manually(player);
  11136. }
  11137.  
  11138. // Admin Command. zp_swarm
  11139. command_swarm(id)
  11140. {
  11141. // Show activity?
  11142. switch (get_pcvar_num(cvar_showactivity))
  11143. {
  11144. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_SWARM")
  11145. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_SWARM")
  11146. }
  11147.  
  11148. // Log to Zombie Plague log file?
  11149. if (get_pcvar_num(cvar_logcommands))
  11150. {
  11151. static logdata[100], authid[32], ip[16]
  11152. get_user_authid(id, authid, charsmax(authid))
  11153. get_user_ip(id, ip, charsmax(ip), 1)
  11154. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER, "CMD_SWARM", fnGetPlaying(), g_maxplayers)
  11155. log_to_file("zombie_plague_advance.log", logdata)
  11156. }
  11157.  
  11158. // Call Swarm Mode
  11159. remove_task(TASK_MAKEZOMBIE)
  11160. start_swarm_mode(0, MODE_SET)
  11161. }
  11162.  
  11163. // Admin Command. zp_multi
  11164. command_multi(id)
  11165. {
  11166. // Show activity?
  11167. switch (get_pcvar_num(cvar_showactivity))
  11168. {
  11169. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_MULTI")
  11170. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_MULTI")
  11171. }
  11172.  
  11173. // Log to Zombie Plague log file?
  11174. if (get_pcvar_num(cvar_logcommands))
  11175. {
  11176. static logdata[100], authid[32], ip[16]
  11177. get_user_authid(id, authid, charsmax(authid))
  11178. get_user_ip(id, ip, charsmax(ip), 1)
  11179. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER,"CMD_MULTI", fnGetPlaying(), g_maxplayers)
  11180. log_to_file("zombie_plague_advance.log", logdata)
  11181. }
  11182.  
  11183. // Call Multi Infection
  11184. remove_task(TASK_MAKEZOMBIE)
  11185. start_multi_mode(0, MODE_SET)
  11186. }
  11187.  
  11188. // Admin Command. zp_plague
  11189. command_plague(id)
  11190. {
  11191. // Show activity?
  11192. switch (get_pcvar_num(cvar_showactivity))
  11193. {
  11194. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_PLAGUE")
  11195. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_PLAGUE")
  11196. }
  11197.  
  11198. // Log to Zombie Plague log file?
  11199. if (get_pcvar_num(cvar_logcommands))
  11200. {
  11201. static logdata[100], authid[32], ip[16]
  11202. get_user_authid(id, authid, charsmax(authid))
  11203. get_user_ip(id, ip, charsmax(ip), 1)
  11204. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER,"CMD_PLAGUE", fnGetPlaying(), g_maxplayers)
  11205. log_to_file("zombie_plague_advance.log", logdata)
  11206. }
  11207.  
  11208. // Call Plague Mode
  11209. remove_task(TASK_MAKEZOMBIE)
  11210. start_plague_mode(0, MODE_SET)
  11211. }
  11212.  
  11213. // Admin Command. zp_sniper
  11214. command_sniper(id, player)
  11215. {
  11216. // Show activity?
  11217. switch (get_pcvar_num(cvar_showactivity))
  11218. {
  11219. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_SNIPER")
  11220. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_SNIPER")
  11221. }
  11222.  
  11223. // Log to Zombie Plague log file?
  11224. if (get_pcvar_num(cvar_logcommands))
  11225. {
  11226. static logdata[100], authid[32], ip[16]
  11227. get_user_authid(id, authid, charsmax(authid))
  11228. get_user_ip(id, ip, charsmax(ip), 1)
  11229. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_SNIPER", fnGetPlaying(), g_maxplayers)
  11230. log_to_file("zombie_plague_advance.log", logdata)
  11231. }
  11232.  
  11233. // New round?
  11234. if (g_newround)
  11235. {
  11236. // Set as first sniper
  11237. remove_task(TASK_MAKEZOMBIE)
  11238. start_sniper_mode(player, MODE_SET)
  11239. }
  11240. else
  11241. {
  11242. // Turn player into a Sniper
  11243. humanme(player, 0, 0, 1)
  11244. }
  11245. }
  11246. // Admin command: Assassin
  11247. command_assassin(id, player)
  11248. {
  11249. // Show activity?
  11250. switch (get_pcvar_num(cvar_showactivity))
  11251. {
  11252. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_ASSASSIN")
  11253. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_ASSASSIN")
  11254. }
  11255.  
  11256. // Log to Zombie Plague log file?
  11257. if (get_pcvar_num(cvar_logcommands))
  11258. {
  11259. static logdata[100], authid[32], ip[16]
  11260. get_user_authid(id, authid, charsmax(authid))
  11261. get_user_ip(id, ip, charsmax(ip), 1)
  11262. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_ASSASSIN", fnGetPlaying(), g_maxplayers)
  11263. log_to_file("zombie_plague_advance.log", logdata)
  11264. }
  11265.  
  11266. // New round?
  11267. if (g_newround)
  11268. {
  11269. // Set as first assassin
  11270. remove_task(TASK_MAKEZOMBIE)
  11271. start_assassin_mode(player, MODE_SET)
  11272. }
  11273. else
  11274. {
  11275. // Turn player into a Assassin
  11276. zombieme(player, 0, 0, 0, 0, 1)
  11277. }
  11278. }
  11279.  
  11280. // Admin Command. zp_lnj
  11281. command_lnj(id)
  11282. {
  11283. // Show activity?
  11284. switch (get_pcvar_num(cvar_showactivity))
  11285. {
  11286. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_LNJ")
  11287. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_LNJ")
  11288. }
  11289.  
  11290. // Log to Zombie Plague log file?
  11291. if (get_pcvar_num(cvar_logcommands))
  11292. {
  11293. static logdata[100], authid[32], ip[16]
  11294. get_user_authid(id, authid, charsmax(authid))
  11295. get_user_ip(id, ip, charsmax(ip), 1)
  11296. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER, "CMD_LNJ", fnGetPlaying(), g_maxplayers)
  11297. log_to_file("zombie_plague_advance.log", logdata)
  11298. }
  11299.  
  11300. // Call Armageddon Mode
  11301. remove_task(TASK_MAKEZOMBIE)
  11302. start_lnj_mode(0, MODE_SET)
  11303. }
  11304.  
  11305. // Admin command for a custom game mode
  11306. command_custom_game(gameid, id)
  11307. {
  11308. // Retrieve the game mode name as it will be used
  11309. static buffer[32]
  11310. ArrayGetString(g_gamemode_name, (gameid - MAX_GAME_MODES), buffer, charsmax(buffer))
  11311.  
  11312. // Show activity?
  11313. switch (get_pcvar_num(cvar_showactivity))
  11314. {
  11315. case 1: client_print(0, print_chat, "ADMIN - %L %s", LANG_PLAYER, "MENU_ADMIN2_CUSTOM", buffer)
  11316. case 2: client_print(0, print_chat, "ADMIN %s - %L %s", g_playername[id], LANG_PLAYER, "MENU_ADMIN2_CUSTOM", buffer)
  11317. }
  11318.  
  11319. // Log to Zombie Plague Advance log file?
  11320. if (get_pcvar_num(cvar_logcommands))
  11321. {
  11322. static logdata[100], authid[32], ip[16]
  11323. get_user_authid(id, authid, charsmax(authid))
  11324. get_user_ip(id, ip, charsmax(ip), 1)
  11325. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L %s (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER, "MENU_ADMIN2_CUSTOM", buffer, fnGetPlaying(), g_maxplayers)
  11326. log_to_file("zombie_plague_advance.log", logdata)
  11327. }
  11328.  
  11329. // Remove make a zombie task
  11330. remove_task(TASK_MAKEZOMBIE)
  11331.  
  11332. // No more a new round
  11333. g_newround = false
  11334.  
  11335. // Current game mode and last game mode are equal to the game mode id
  11336. g_currentmode = gameid
  11337. g_lastmode = gameid
  11338.  
  11339. // Check whether or not to allow infection during this game mode
  11340. g_allowinfection = (ArrayGetCell(g_gamemode_allow, (gameid - MAX_GAME_MODES)) == 1) ? true : false
  11341.  
  11342. // Check the death match mode required by the game mode
  11343. g_deathmatchmode = ArrayGetCell(g_gamemode_dm, (gameid - MAX_GAME_MODES))
  11344.  
  11345. // Our custom game mode has fully started
  11346. g_modestarted = true
  11347.  
  11348. // Execute our round start forward with the game mode id [BUGFIX]
  11349. ExecuteForward(g_fwRoundStart, g_fwDummyResult, gameid, 0)
  11350.  
  11351. // Execute our game mode selected forward
  11352. ExecuteForward(g_fwGameModeSelected, g_fwDummyResult, gameid, id)
  11353. }
  11354.  
  11355. /*================================================================================
  11356.  [Custom Natives]
  11357. =================================================================================*/
  11358.  
  11359. // Native: zp_get_user_zombie
  11360. public native_get_user_zombie(id)
  11361. {
  11362. return g_zombie[id];
  11363. }
  11364.  
  11365. // Native: zp_get_user_nemesis
  11366. public native_get_user_nemesis(id)
  11367. {
  11368. return g_nemesis[id];
  11369. }
  11370.  
  11371. // Native: zp_get_user_survivor
  11372. public native_get_user_survivor(id)
  11373. {
  11374. return g_survivor[id];
  11375. }
  11376.  
  11377. public native_get_user_first_zombie(id)
  11378. {
  11379. return g_firstzombie[id];
  11380. }
  11381.  
  11382. // Native: zp_get_user_last_zombie
  11383. public native_get_user_last_zombie(id)
  11384. {
  11385. return g_lastzombie[id];
  11386. }
  11387.  
  11388. // Native: zp_get_user_last_human
  11389. public native_get_user_last_human(id)
  11390. {
  11391. return g_lasthuman[id];
  11392. }
  11393.  
  11394. // Native: zp_get_user_zombie_class
  11395. public native_get_user_zombie_class(id)
  11396. {
  11397. return g_zombieclass[id];
  11398. }
  11399.  
  11400. // Native: zp_get_user_next_class
  11401. public native_get_user_next_class(id)
  11402. {
  11403. return g_zombieclassnext[id];
  11404. }
  11405.  
  11406. // Native: zp_set_user_zombie_class
  11407. public native_set_user_zombie_class(id, classid)
  11408. {
  11409. if (classid < 0 || classid >= g_zclass_i)
  11410. return 0;
  11411.  
  11412. g_zombieclassnext[id] = classid
  11413. return 1;
  11414. }
  11415.  
  11416. // Native: zp_get_user_ammo_packs
  11417. public native_get_user_ammo_packs(id)
  11418. {
  11419. return g_ammopacks[id];
  11420. }
  11421.  
  11422. // Native: zp_set_user_ammo_packs
  11423. public native_set_user_ammo_packs(id, amount)
  11424. {
  11425. g_ammopacks[id] = amount;
  11426. }
  11427.  
  11428. // Native: zp_get_zombie_maxhealth
  11429. public native_get_zombie_maxhealth(id)
  11430. {
  11431. // ZPA disabled
  11432. if (!g_pluginenabled)
  11433. return -1;
  11434.  
  11435. if (g_zombie[id] && !g_nemesis[id] && !g_assassin[id])
  11436. {
  11437. if (g_firstzombie[id])
  11438. return floatround(float(ArrayGetCell(g_zclass_hp, g_zombieclass[id])) * get_pcvar_float(cvar_zombiefirsthp))
  11439. else
  11440. return ArrayGetCell(g_zclass_hp, g_zombieclass[id])
  11441. }
  11442. return -1;
  11443. }
  11444.  
  11445. // Native: zp_get_user_batteries
  11446. public native_get_user_batteries(id)
  11447. {
  11448. return g_flashbattery[id];
  11449. }
  11450.  
  11451. // Native: zp_set_user_batteries
  11452. public native_set_user_batteries(id, value)
  11453. {
  11454. // ZPA disabled
  11455. if (!g_pluginenabled)
  11456. return;
  11457.  
  11458. g_flashbattery[id] = clamp(value, 0, 100);
  11459.  
  11460. if (g_cached_customflash)
  11461. {
  11462. // Set the flashlight charge task to update battery status
  11463. remove_task(id+TASK_CHARGE)
  11464. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  11465. }
  11466. }
  11467.  
  11468. // Native: zp_get_user_nightvision
  11469. public native_get_user_nightvision(id)
  11470. {
  11471. return g_nvision[id];
  11472. }
  11473.  
  11474. // Native: zp_set_user_nightvision
  11475. public native_set_user_nightvision(id, set)
  11476. {
  11477. // ZPA disabled
  11478. if (!g_pluginenabled)
  11479. return;
  11480.  
  11481. if (set)
  11482. {
  11483. g_nvision[id] = true
  11484.  
  11485. if (!g_isbot[id])
  11486. {
  11487. g_nvisionenabled[id] = true
  11488.  
  11489. // Custom nvg?
  11490. if (get_pcvar_num(cvar_customnvg))
  11491. {
  11492. remove_task(id+TASK_NVISION)
  11493. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  11494. }
  11495. else
  11496. set_user_gnvision(id, 1)
  11497. }
  11498. else
  11499. cs_set_user_nvg(id, 1)
  11500. }
  11501. else
  11502. {
  11503. // Turn off NVG for bots
  11504. if (g_isbot[id]) cs_set_user_nvg(id, 0);
  11505. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  11506. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  11507. g_nvision[id] = false
  11508. g_nvisionenabled[id] = false
  11509. }
  11510. }
  11511.  
  11512. // Native: zp_infect_user
  11513. public native_infect_user(id, infector, silent, rewards)
  11514. {
  11515. // ZPA disabled
  11516. if (!g_pluginenabled)
  11517. return -1;
  11518.  
  11519. // Not allowed to be zombie
  11520. if (!allowed_zombie(id))
  11521. return 0;
  11522.  
  11523. // New round?
  11524. if (g_newround)
  11525. {
  11526. // Set as first zombie
  11527. remove_task(TASK_MAKEZOMBIE)
  11528. start_infection_mode(id, MODE_SET)
  11529. }
  11530. else
  11531. {
  11532. // Just infect (plus some checks)
  11533. zombieme(id, is_user_valid_alive(infector) ? infector : 0, 0, (silent == 1) ? 1 : 0, (rewards == 1) ? 1 : 0, 0)
  11534. }
  11535.  
  11536. return 1;
  11537. }
  11538.  
  11539. // Native: zp_disinfect_user
  11540. public native_disinfect_user(id, silent)
  11541. {
  11542. // ZPA disabled
  11543. if (!g_pluginenabled)
  11544. return -1;
  11545.  
  11546. // Not allowed to be human
  11547. if (!allowed_human(id))
  11548. return 0;
  11549.  
  11550. // Turn to human
  11551. humanme(id, 0, (silent == 1) ? 1 : 0, 0)
  11552. return 1;
  11553. }
  11554.  
  11555. // Native: zp_make_user_nemesis
  11556. public native_make_user_nemesis(id)
  11557. {
  11558. // ZPA disabled
  11559. if (!g_pluginenabled)
  11560. return -1;
  11561.  
  11562. // Not allowed to be nemesis
  11563. if (!allowed_nemesis(id))
  11564. return 0;
  11565.  
  11566. // New round?
  11567. if (g_newround)
  11568. {
  11569. // Set as first nemesis
  11570. remove_task(TASK_MAKEZOMBIE)
  11571. start_nemesis_mode(id, MODE_SET)
  11572. }
  11573. else
  11574. {
  11575. // Turn player into a Nemesis
  11576. zombieme(id, 0, 1, 0, 0, 0)
  11577. }
  11578.  
  11579. return 1;
  11580. }
  11581.  
  11582. // Native: zp_make_user_survivor
  11583. public native_make_user_survivor(id)
  11584. {
  11585. // ZPA disabled
  11586. if (!g_pluginenabled)
  11587. return -1;
  11588.  
  11589. // Not allowed to be survivor
  11590. if (!allowed_survivor(id))
  11591. return 0;
  11592.  
  11593. // New round?
  11594. if (g_newround)
  11595. {
  11596. // Set as first survivor
  11597. remove_task(TASK_MAKEZOMBIE)
  11598. start_survivor_mode(id, MODE_SET)
  11599. }
  11600. else
  11601. {
  11602. // Turn player into a Survivor
  11603. humanme(id, 1, 0, 0)
  11604. }
  11605.  
  11606. return 1;
  11607. }
  11608.  
  11609. // Native: zp_respawn_user
  11610. public native_respawn_user(id, team)
  11611. {
  11612. // ZPA disabled
  11613. if (!g_pluginenabled)
  11614. return -1;
  11615.  
  11616. // Invalid player
  11617. if (!is_user_valid_connected(id))
  11618. return 0;
  11619.  
  11620. // Respawn not allowed
  11621. if (!allowed_respawn(id))
  11622. return 0;
  11623.  
  11624. // Respawn as zombie?
  11625. g_respawn_as_zombie[id] = (team == ZP_TEAM_ZOMBIE) ? true : false
  11626.  
  11627. // Respawnish!
  11628. respawn_player_manually(id)
  11629. return 1;
  11630. }
  11631.  
  11632. // Native: zp_force_buy_extra_item
  11633. public native_force_buy_extra_item(id, itemid, ignorecost)
  11634. {
  11635. // ZPA disabled
  11636. if (!g_pluginenabled)
  11637. return -1;
  11638.  
  11639. if (itemid < 0 || itemid >= g_extraitem_i)
  11640. return 0;
  11641.  
  11642. buy_extra_item(id, itemid, ignorecost)
  11643. return 1;
  11644. }
  11645.  
  11646. // Native: zp_get_user_sniper
  11647. public native_get_user_sniper(id)
  11648. {
  11649. return g_sniper[id];
  11650. }
  11651.  
  11652. // Native: zp_make_user_sniper
  11653. public native_make_user_sniper(id)
  11654. {
  11655. // ZPA disabled
  11656. if (!g_pluginenabled)
  11657. return -1;
  11658.  
  11659. // Not allowed to be sniper
  11660. if (!allowed_sniper(id))
  11661. return 0;
  11662.  
  11663. // New round?
  11664. if (g_newround)
  11665. {
  11666. // Set as first sniper
  11667. remove_task(TASK_MAKEZOMBIE)
  11668. start_sniper_mode(id, MODE_SET)
  11669. }
  11670. else
  11671. {
  11672. // Turn player into a Sniper
  11673. humanme(id, 0, 0, 1)
  11674. }
  11675.  
  11676. return 1;
  11677. }
  11678.  
  11679. // Native: zp_get_user_assassin
  11680. public native_get_user_assassin(id)
  11681. {
  11682. return g_assassin[id];
  11683. }
  11684.  
  11685. // Native: zp_make_user_assassin
  11686. public native_make_user_assassin(id)
  11687. {
  11688. // ZPA disabled
  11689. if (!g_pluginenabled)
  11690. return -1;
  11691.  
  11692. // Not allowed to be assassin
  11693. if (!allowed_assassin(id))
  11694. return 0;
  11695.  
  11696. // New round?
  11697. if (g_newround)
  11698. {
  11699. // Set as first assassin
  11700. remove_task(TASK_MAKEZOMBIE)
  11701. start_assassin_mode(id, MODE_SET)
  11702. }
  11703. else
  11704. {
  11705. // Turn player into a Assassin
  11706. zombieme(id, 0, 0, 0, 0, 1)
  11707. }
  11708.  
  11709. return 1;
  11710. }
  11711.  
  11712. // Native: zp_get_user_model
  11713. public native_get_user_model(plugin_id, param_nums)
  11714. {
  11715. // ZPA disabled
  11716. if (!g_pluginenabled)
  11717. return -1;
  11718.  
  11719. // Insufficient number of arguments
  11720. if (param_nums != 3)
  11721. return -1;
  11722.  
  11723. // Retrieve the player's index
  11724. static id; id = get_param(1)
  11725.  
  11726. // Not an alive player or invalid player
  11727. if (!is_user_valid_alive(id))
  11728. return 0;
  11729.  
  11730. // Retrieve the player's current model
  11731. static current_model[32]
  11732. fm_cs_get_user_model(id, current_model, charsmax(current_model))
  11733.  
  11734. // Copy the model name into the array passed
  11735. set_string(2, current_model, get_param(3))
  11736.  
  11737. return 1;
  11738. }
  11739. // Native: zp_set_user_model
  11740. public native_set_user_model(id, const model[])
  11741. {
  11742. // ZPA disabled
  11743. if (!g_pluginenabled)
  11744. return -1;
  11745.  
  11746. // Not an alive player or invalid player
  11747. if (!is_user_valid_alive(id))
  11748. return -1;
  11749.  
  11750. // Strings passed byref
  11751. param_convert(2)
  11752.  
  11753. // Retrieve the player's current model
  11754. static current_model[32]
  11755. fm_cs_get_user_model(id, current_model, charsmax(current_model))
  11756.  
  11757. // Check whether we already have the model set on the player
  11758. if (equal(current_model, model))
  11759. return 0;
  11760.  
  11761. // Update player's model
  11762. copy(g_playermodel[id], charsmax(g_playermodel[]), model)
  11763.  
  11764. // Set the right model for the player
  11765. if (g_handle_models_on_separate_ent) fm_set_playermodel_ent(id)
  11766. else fm_user_model_update(id+TASK_MODEL)
  11767.  
  11768. return 1;
  11769. }
  11770.  
  11771. // Native: zp_get_current_mode
  11772. public native_get_current_mode()
  11773. {
  11774. return g_currentmode
  11775. }
  11776.  
  11777. // Native: zp_has_round_started
  11778. public native_has_round_started()
  11779. {
  11780. if (g_newround) return 0; // not started
  11781. if (g_modestarted) return 1; // started
  11782. return 2; // starting
  11783. }
  11784.  
  11785. // Native: zp_is_nemesis_round
  11786. public native_is_nemesis_round()
  11787. {
  11788. return g_nemround;
  11789. }
  11790.  
  11791. // Native: zp_is_survivor_round
  11792. public native_is_survivor_round()
  11793. {
  11794. return g_survround;
  11795. }
  11796.  
  11797. // Native: zp_is_swarm_round
  11798. public native_is_swarm_round()
  11799. {
  11800. return g_swarmround;
  11801. }
  11802.  
  11803. // Native: zp_is_plague_round
  11804. public native_is_plague_round()
  11805. {
  11806. return g_plagueround;
  11807. }
  11808.  
  11809. // Native: zp_get_zombie_count
  11810. public native_get_zombie_count()
  11811. {
  11812. return fnGetZombies();
  11813. }
  11814.  
  11815. // Native: zp_get_human_count
  11816. public native_get_human_count()
  11817. {
  11818. return fnGetHumans();
  11819. }
  11820.  
  11821. // Native: zp_get_nemesis_count
  11822. public native_get_nemesis_count()
  11823. {
  11824. return fnGetNemesis();
  11825. }
  11826.  
  11827. // Native: zp_get_survivor_count
  11828. public native_get_survivor_count()
  11829. {
  11830. return fnGetSurvivors();
  11831. }
  11832.  
  11833. // Native: zp_is_sniper_round
  11834. public native_is_sniper_round()
  11835. {
  11836. return g_sniperround;
  11837. }
  11838.  
  11839. // Native: zp_get_sniper_count
  11840. public native_get_sniper_count()
  11841. {
  11842. return fnGetSnipers();
  11843. }
  11844.  
  11845. // Native: zp_is_assassin_round
  11846. public native_is_assassin_round()
  11847. {
  11848. return g_assassinround;
  11849. }
  11850.  
  11851. // Native: zp_get_assassin_count
  11852. public native_get_assassin_count()
  11853. {
  11854. return fnGetAssassin();
  11855. }
  11856.  
  11857. // Native: zp_is_lnj_round
  11858. public native_is_lnj_round()
  11859. {
  11860. return g_lnjround;
  11861. }
  11862.  
  11863. // Native: zp_register_game_mode
  11864. public native_register_game_mode( const name[], flags, chance, allow, dm_mode)
  11865. {
  11866. // ZPA disabled
  11867. if (!g_pluginenabled)
  11868. return -1;
  11869.  
  11870. // Arrays not yet initialized
  11871. if (!g_arrays_created)
  11872. return -1;
  11873.  
  11874. // Strings passed byref
  11875. param_convert(1)
  11876.  
  11877. // Add the game mode
  11878. ArrayPushString(g_gamemode_name, name)
  11879. ArrayPushCell(g_gamemode_flag, flags)
  11880. ArrayPushCell(g_gamemode_chance, chance)
  11881. ArrayPushCell(g_gamemode_allow, allow)
  11882. ArrayPushCell(g_gamemode_dm, dm_mode)
  11883.  
  11884. // Increase registered game modes counter
  11885. g_gamemodes_i++
  11886.  
  11887. // Return id under which we registered the game mode
  11888. return (g_gamemodes_i-1);
  11889. }
  11890.  
  11891. // Native: zp_register_extra_item
  11892. public native_register_extra_item(const name[], cost, team)
  11893. {
  11894. // ZPA disabled
  11895. if (!g_pluginenabled)
  11896. return -1;
  11897.  
  11898. // Arrays not yet initialized
  11899. if (!g_arrays_created)
  11900. return -1;
  11901.  
  11902. // For backwards compatibility
  11903. if (team == ZP_TEAM_ANY)
  11904. team = ZP_TEAM_ZOMBIE|ZP_TEAM_HUMAN
  11905.  
  11906. // Strings passed byref
  11907. param_convert(1)
  11908.  
  11909. // Add the item
  11910. ArrayPushString(g_extraitem_name, name)
  11911. ArrayPushCell(g_extraitem_cost, cost)
  11912. ArrayPushCell(g_extraitem_team, team)
  11913.  
  11914. // Set temporary new item flag
  11915. ArrayPushCell(g_extraitem_new, 1)
  11916.  
  11917. // Override extra items data with our customizations
  11918. new i, buffer[32], size = ArraySize(g_extraitem2_realname)
  11919. for (i = 0; i < size; i++)
  11920. {
  11921. ArrayGetString(g_extraitem2_realname, i, buffer, charsmax(buffer))
  11922.  
  11923. // Check if this is the intended item to override
  11924. if (!equal(name, buffer))
  11925. continue;
  11926.  
  11927. // Remove new item flag
  11928. ArraySetCell(g_extraitem_new, g_extraitem_i, 0)
  11929.  
  11930. // Replace caption
  11931. ArrayGetString(g_extraitem2_name, i, buffer, charsmax(buffer))
  11932. ArraySetString(g_extraitem_name, g_extraitem_i, buffer)
  11933.  
  11934. // Replace cost
  11935. buffer[0] = ArrayGetCell(g_extraitem2_cost, i)
  11936. ArraySetCell(g_extraitem_cost, g_extraitem_i, buffer[0])
  11937.  
  11938. // Replace team
  11939. buffer[0] = ArrayGetCell(g_extraitem2_team, i)
  11940. ArraySetCell(g_extraitem_team, g_extraitem_i, buffer[0])
  11941. }
  11942.  
  11943. // Increase registered items counter
  11944. g_extraitem_i++
  11945.  
  11946. // Return id under which we registered the item
  11947. return (g_extraitem_i-1);
  11948. }
  11949.  
  11950. // Function: zp_register_extra_item (to be used within this plugin only)
  11951. native_register_extra_item2(const name[], cost, team)
  11952. {
  11953. // Add the item
  11954. ArrayPushString(g_extraitem_name, name)
  11955. ArrayPushCell(g_extraitem_cost, cost)
  11956. ArrayPushCell(g_extraitem_team, team)
  11957.  
  11958. // Set temporary new item flag
  11959. ArrayPushCell(g_extraitem_new, 1)
  11960.  
  11961. // Increase registered items counter
  11962. g_extraitem_i++
  11963. }
  11964.  
  11965. // Native: zp_register_zombie_class
  11966. public native_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback)
  11967. {
  11968. // ZPA disabled
  11969. if (!g_pluginenabled)
  11970. return -1;
  11971.  
  11972. // Arrays not yet initialized
  11973. if (!g_arrays_created)
  11974. return -1;
  11975.  
  11976. // Strings passed byref
  11977. param_convert(1)
  11978. param_convert(2)
  11979. param_convert(3)
  11980. param_convert(4)
  11981.  
  11982. // Add the class
  11983. ArrayPushString(g_zclass_name, name)
  11984. ArrayPushString(g_zclass_info, info)
  11985.  
  11986. // Using same zombie models for all classes?
  11987. if (g_same_models_for_all)
  11988. {
  11989. ArrayPushCell(g_zclass_modelsstart, 0)
  11990. ArrayPushCell(g_zclass_modelsend, ArraySize(g_zclass_playermodel))
  11991. }
  11992. else
  11993. {
  11994. ArrayPushCell(g_zclass_modelsstart, ArraySize(g_zclass_playermodel))
  11995. ArrayPushString(g_zclass_playermodel, model)
  11996. ArrayPushCell(g_zclass_modelsend, ArraySize(g_zclass_playermodel))
  11997. ArrayPushCell(g_zclass_modelindex, -1)
  11998. }
  11999.  
  12000. ArrayPushString(g_zclass_clawmodel, clawmodel)
  12001. ArrayPushCell(g_zclass_hp, hp)
  12002. ArrayPushCell(g_zclass_spd, speed)
  12003. ArrayPushCell(g_zclass_grav, gravity)
  12004. ArrayPushCell(g_zclass_kb, knockback)
  12005.  
  12006. // Set temporary new class flag
  12007. ArrayPushCell(g_zclass_new, 1)
  12008.  
  12009. // Override zombie classes data with our customizations
  12010. new i, k, buffer[32], Float:buffer2, nummodels_custom, nummodels_default, prec_mdl[100], size = ArraySize(g_zclass2_realname)
  12011. for (i = 0; i < size; i++)
  12012. {
  12013. ArrayGetString(g_zclass2_realname, i, buffer, charsmax(buffer))
  12014.  
  12015. // Check if this is the intended class to override
  12016. if (!equal(name, buffer))
  12017. continue;
  12018.  
  12019. // Remove new class flag
  12020. ArraySetCell(g_zclass_new, g_zclass_i, 0)
  12021.  
  12022. // Replace caption
  12023. ArrayGetString(g_zclass2_name, i, buffer, charsmax(buffer))
  12024. ArraySetString(g_zclass_name, g_zclass_i, buffer)
  12025.  
  12026. // Replace info
  12027. ArrayGetString(g_zclass2_info, i, buffer, charsmax(buffer))
  12028. ArraySetString(g_zclass_info, g_zclass_i, buffer)
  12029.  
  12030. // Replace models, unless using same models for all classes
  12031. if (!g_same_models_for_all)
  12032. {
  12033. nummodels_custom = ArrayGetCell(g_zclass2_modelsend, i) - ArrayGetCell(g_zclass2_modelsstart, i)
  12034. nummodels_default = ArrayGetCell(g_zclass_modelsend, g_zclass_i) - ArrayGetCell(g_zclass_modelsstart, g_zclass_i)
  12035.  
  12036. // Replace each player model and model index
  12037. for (k = 0; k < min(nummodels_custom, nummodels_default); k++)
  12038. {
  12039. ArrayGetString(g_zclass2_playermodel, ArrayGetCell(g_zclass2_modelsstart, i) + k, buffer, charsmax(buffer))
  12040. ArraySetString(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k, buffer)
  12041.  
  12042. // Precache player model and replace its modelindex with the real one
  12043. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", buffer, buffer)
  12044. ArraySetCell(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k, engfunc(EngFunc_PrecacheModel, prec_mdl))
  12045. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  12046. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  12047. }
  12048.  
  12049. // We have more custom models than what we can accommodate,
  12050. // Let's make some space...
  12051. if (nummodels_custom > nummodels_default)
  12052. {
  12053. for (k = nummodels_default; k < nummodels_custom; k++)
  12054. {
  12055. ArrayGetString(g_zclass2_playermodel, ArrayGetCell(g_zclass2_modelsstart, i) + k, buffer, charsmax(buffer))
  12056. ArrayInsertStringAfter(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k - 1, buffer)
  12057.  
  12058. // Precache player model and retrieve its modelindex
  12059. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", buffer, buffer)
  12060. ArrayInsertCellAfter(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k - 1, engfunc(EngFunc_PrecacheModel, prec_mdl))
  12061. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  12062. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  12063. }
  12064.  
  12065. // Fix models end index for this class
  12066. ArraySetCell(g_zclass_modelsend, g_zclass_i, ArrayGetCell(g_zclass_modelsend, g_zclass_i) + (nummodels_custom - nummodels_default))
  12067. }
  12068.  
  12069. /* --- Not needed since classes can't have more than 1 default model for now ---
  12070. // We have less custom models than what this class has by default,
  12071. // Get rid of those extra entries...
  12072. if (nummodels_custom < nummodels_default)
  12073. {
  12074. for (k = nummodels_custom; k < nummodels_default; k++)
  12075. {
  12076. ArrayDeleteItem(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + nummodels_custom)
  12077. }
  12078.  
  12079. // Fix models end index for this class
  12080. ArraySetCell(g_zclass_modelsend, g_zclass_i, ArrayGetCell(g_zclass_modelsend, g_zclass_i) - (nummodels_default - nummodels_custom))
  12081. }
  12082. */
  12083. }
  12084.  
  12085. // Replace clawmodel
  12086. ArrayGetString(g_zclass2_clawmodel, i, buffer, charsmax(buffer))
  12087. ArraySetString(g_zclass_clawmodel, g_zclass_i, buffer)
  12088.  
  12089. // Precache clawmodel
  12090. formatex(prec_mdl, charsmax(prec_mdl), "models/zombie_plague/%s", buffer)
  12091. engfunc(EngFunc_PrecacheModel, prec_mdl)
  12092.  
  12093. // Replace health
  12094. buffer[0] = ArrayGetCell(g_zclass2_hp, i)
  12095. ArraySetCell(g_zclass_hp, g_zclass_i, buffer[0])
  12096.  
  12097. // Replace speed
  12098. buffer[0] = ArrayGetCell(g_zclass2_spd, i)
  12099. ArraySetCell(g_zclass_spd, g_zclass_i, buffer[0])
  12100.  
  12101. // Replace gravity
  12102. buffer2 = Float:ArrayGetCell(g_zclass2_grav, i)
  12103. ArraySetCell(g_zclass_grav, g_zclass_i, buffer2)
  12104.  
  12105. // Replace knockback
  12106. buffer2 = Float:ArrayGetCell(g_zclass2_kb, i)
  12107. ArraySetCell(g_zclass_kb, g_zclass_i, buffer2)
  12108. }
  12109.  
  12110. // If class was not overriden with customization data
  12111. if (ArrayGetCell(g_zclass_new, g_zclass_i))
  12112. {
  12113. // If not using same models for all classes
  12114. if (!g_same_models_for_all)
  12115. {
  12116. // Precache default class model and replace modelindex with the real one
  12117. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", model, model)
  12118. ArraySetCell(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i), engfunc(EngFunc_PrecacheModel, prec_mdl))
  12119. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  12120. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  12121. }
  12122.  
  12123. // Precache default clawmodel
  12124. formatex(prec_mdl, charsmax(prec_mdl), "models/zombie_plague/%s", clawmodel)
  12125. engfunc(EngFunc_PrecacheModel, prec_mdl)
  12126. }
  12127.  
  12128. // Increase registered classes counter
  12129. g_zclass_i++
  12130.  
  12131. // Return id under which we registered the class
  12132. return (g_zclass_i-1);
  12133. }
  12134.  
  12135. // Native: zp_get_extra_item_id
  12136. public native_get_extra_item_id(const name[])
  12137. {
  12138. // ZPA disabled
  12139. if (!g_pluginenabled)
  12140. return -1;
  12141.  
  12142. // Strings passed byref
  12143. param_convert(1)
  12144.  
  12145. // Loop through every item
  12146. static i, item_name[32]
  12147. for (i = 0; i < g_extraitem_i; i++)
  12148. {
  12149. ArrayGetString(g_extraitem_name, i, item_name, charsmax(item_name))
  12150.  
  12151. // Check if this is the item to retrieve
  12152. if (equali(name, item_name))
  12153. return i;
  12154. }
  12155.  
  12156. return -1;
  12157. }
  12158.  
  12159. // Native: zp_get_zombie_class_id
  12160. public native_get_zombie_class_id(const name[])
  12161. {
  12162. // ZPA disabled
  12163. if (!g_pluginenabled)
  12164. return -1;
  12165.  
  12166. // Strings passed byref
  12167. param_convert(1)
  12168.  
  12169. // Loop through every class
  12170. static i, class_name[32]
  12171. for (i = 0; i < g_zclass_i; i++)
  12172. {
  12173. ArrayGetString(g_zclass_name, i, class_name, charsmax(class_name))
  12174.  
  12175. // Check if this is the class to retrieve
  12176. if (equali(name, class_name))
  12177. return i;
  12178. }
  12179.  
  12180. return -1;
  12181. }
  12182.  
  12183. /*================================================================================
  12184.  [Custom Messages]
  12185. =================================================================================*/
  12186.  
  12187. // Custom Night Vision
  12188. public set_user_nvision(taskid)
  12189. {
  12190. // Get player's origin
  12191. static origin[3]
  12192. get_user_origin(ID_NVISION, origin)
  12193.  
  12194. // Nightvision message
  12195. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_NVISION)
  12196. write_byte(TE_DLIGHT) // TE id
  12197. write_coord(origin[0]) // x
  12198. write_coord(origin[1]) // y
  12199. write_coord(origin[2]) // z
  12200. write_byte(get_pcvar_num(cvar_nvgsize)) // radius
  12201.  
  12202. // Nemesis / Madness / Spectator in nemesis round
  12203. if (g_nemesis[ID_NVISION] || (g_zombie[ID_NVISION] && g_nodamage[ID_NVISION]) || (!g_isalive[ID_NVISION] && g_nemround))
  12204. {
  12205. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  12206. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  12207. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  12208. }
  12209. // Assassin / Spectator in assassin round
  12210. else if (g_assassin[ID_NVISION] || (!g_isalive[ID_NVISION] && g_assassinround))
  12211. {
  12212. write_byte(get_pcvar_num(cvar_assassinnvgcolor[0])) // r
  12213. write_byte(get_pcvar_num(cvar_assassinnvgcolor[1])) // g
  12214. write_byte(get_pcvar_num(cvar_assassinnvgcolor[2])) // b
  12215. }
  12216. // Human / Spectator in normal round
  12217. else if (!g_zombie[ID_NVISION] || !g_isalive[ID_NVISION])
  12218. {
  12219. write_byte(get_pcvar_num(cvar_humnvgcolor[0])) // r
  12220. write_byte(get_pcvar_num(cvar_humnvgcolor[1])) // g
  12221. write_byte(get_pcvar_num(cvar_humnvgcolor[2])) // b
  12222. }
  12223. // Zombie
  12224. else
  12225. {
  12226. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  12227. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  12228. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  12229. }
  12230.  
  12231. write_byte(2) // life
  12232. write_byte(0) // decay rate
  12233. message_end()
  12234. }
  12235.  
  12236. // Game Nightvision
  12237. set_user_gnvision(id, toggle)
  12238. {
  12239. // Toggle NVG message
  12240. message_begin(MSG_ONE, g_msgNVGToggle, _, id)
  12241. write_byte(toggle) // toggle
  12242. message_end()
  12243. }
  12244.  
  12245. // Custom Flashlight
  12246. public set_user_flashlight(taskid)
  12247. {
  12248. // Get player and aiming origins
  12249. static Float:originF[3], Float:destoriginF[3]
  12250. pev(ID_FLASH, pev_origin, originF)
  12251. fm_get_aim_origin(ID_FLASH, destoriginF)
  12252.  
  12253. // Max distance check
  12254. if (get_distance_f(originF, destoriginF) > get_pcvar_float(cvar_flashdist))
  12255. return;
  12256.  
  12257. // Send to all players?
  12258. if (get_pcvar_num(cvar_flashshowall))
  12259. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, destoriginF, 0)
  12260. else
  12261. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_FLASH)
  12262.  
  12263. // Flashlight
  12264. write_byte(TE_DLIGHT) // TE id
  12265. engfunc(EngFunc_WriteCoord, destoriginF[0]) // x
  12266. engfunc(EngFunc_WriteCoord, destoriginF[1]) // y
  12267. engfunc(EngFunc_WriteCoord, destoriginF[2]) // z
  12268.  
  12269. // Different flashlight in assassin round ?
  12270. if (g_assassinround)
  12271. {
  12272. write_byte(get_pcvar_num(cvar_flashsize2)) // radius
  12273. write_byte(get_pcvar_num(cvar_flashcolor2[0])) // r
  12274. write_byte(get_pcvar_num(cvar_flashcolor2[1])) // g
  12275. write_byte(get_pcvar_num(cvar_flashcolor2[2])) // b
  12276. }
  12277. else
  12278. {
  12279. write_byte(get_pcvar_num(cvar_flashsize)) // radius
  12280. write_byte(get_pcvar_num(cvar_flashcolor[0])) // r
  12281. write_byte(get_pcvar_num(cvar_flashcolor[1])) // g
  12282. write_byte(get_pcvar_num(cvar_flashcolor[2])) // b
  12283. }
  12284.  
  12285. write_byte(3) // life
  12286. write_byte(0) // decay rate
  12287. message_end()
  12288. }
  12289.  
  12290. // Infection special effects
  12291. infection_effects(id)
  12292. {
  12293. // Screen fade? (unless frozen)
  12294. if (!g_frozen[id] && get_pcvar_num(cvar_infectionscreenfade))
  12295. {
  12296. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
  12297. write_short(UNIT_SECOND) // duration
  12298. write_short(0) // hold time
  12299. write_short(FFADE_IN) // fade type
  12300. if (g_nemesis[id])
  12301. {
  12302. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  12303. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  12304. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  12305. }
  12306. else if (g_assassin[id])
  12307. {
  12308. write_byte(get_pcvar_num(cvar_assassinnvgcolor[0])) // r
  12309. write_byte(get_pcvar_num(cvar_assassinnvgcolor[1])) // g
  12310. write_byte(get_pcvar_num(cvar_assassinnvgcolor[2])) // b
  12311. }
  12312. else
  12313. {
  12314. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  12315. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  12316. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  12317. }
  12318. write_byte (255) // alpha
  12319. message_end()
  12320. }
  12321.  
  12322. // Screen shake?
  12323. if (get_pcvar_num(cvar_infectionscreenshake))
  12324. {
  12325. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
  12326. write_short(UNIT_SECOND*75) // amplitude
  12327. write_short(UNIT_SECOND*5) // duration
  12328. write_short(UNIT_SECOND*75) // frequency
  12329. message_end()
  12330. }
  12331.  
  12332. // Infection icon?
  12333. if (get_pcvar_num(cvar_hudicons))
  12334. {
  12335. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
  12336. write_byte(0) // damage save
  12337. write_byte(0) // damage take
  12338. write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
  12339. write_coord(0) // x
  12340. write_coord(0) // y
  12341. write_coord(0) // z
  12342. message_end()
  12343. }
  12344.  
  12345. // Get player's origin
  12346. static origin[3]
  12347. get_user_origin(id, origin)
  12348.  
  12349. // Tracers?
  12350. if (get_pcvar_num(cvar_infectiontracers))
  12351. {
  12352. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12353. write_byte(TE_IMPLOSION) // TE id
  12354. write_coord(origin[0]) // x
  12355. write_coord(origin[1]) // y
  12356. write_coord(origin[2]) // z
  12357. write_byte(128) // radius
  12358. write_byte(20) // count
  12359. write_byte(3) // duration
  12360. message_end()
  12361. }
  12362.  
  12363. // Particle burst?
  12364. if (get_pcvar_num(cvar_infectionparticles))
  12365. {
  12366. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12367. write_byte(TE_PARTICLEBURST) // TE id
  12368. write_coord(origin[0]) // x
  12369. write_coord(origin[1]) // y
  12370. write_coord(origin[2]) // z
  12371. write_short(50) // radius
  12372. write_byte(70) // color
  12373. write_byte(3) // duration (will be randomized a bit)
  12374. message_end()
  12375. }
  12376.  
  12377. // Light sparkle?
  12378. if (get_pcvar_num(cvar_infectionsparkle))
  12379. {
  12380. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12381. write_byte(TE_DLIGHT) // TE id
  12382. write_coord(origin[0]) // x
  12383. write_coord(origin[1]) // y
  12384. write_coord(origin[2]) // z
  12385. write_byte(20) // radius
  12386. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  12387. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  12388. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  12389. write_byte(2) // life
  12390. write_byte(0) // decay rate
  12391. message_end()
  12392. }
  12393. }
  12394.  
  12395. // Nemesis/madness aura task
  12396. public zombie_aura(taskid)
  12397. {
  12398. // Not nemesis, not in zombie madness
  12399. if (!g_nemesis[ID_AURA] && !g_nodamage[ID_AURA] && !g_assassin[ID_AURA])
  12400. {
  12401. // Task not needed anymore
  12402. remove_task(taskid);
  12403. return;
  12404. }
  12405.  
  12406. // Get player's origin
  12407. static origin[3]
  12408. get_user_origin(ID_AURA, origin)
  12409.  
  12410. // Colored Aura
  12411. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12412. write_byte(TE_DLIGHT) // TE id
  12413. write_coord(origin[0]) // x
  12414. write_coord(origin[1]) // y
  12415. write_coord(origin[2]) // z
  12416. write_byte(get_pcvar_num(cvar_nemauraradius)) // radius
  12417.  
  12418. // Different aura color for assassin
  12419. if (g_assassin[ID_AURA])
  12420. {
  12421. write_byte(get_pcvar_num(cvar_assassinnvgcolor[0])) // r
  12422. write_byte(get_pcvar_num(cvar_assassinnvgcolor[1])) // g
  12423. write_byte(get_pcvar_num(cvar_assassinnvgcolor[2])) // b
  12424. }
  12425. else // Aura color for nemesis
  12426. {
  12427. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  12428. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  12429. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  12430. }
  12431.  
  12432. write_byte(2) // life
  12433. write_byte(0) // decay rate
  12434. message_end()
  12435. }
  12436.  
  12437. // Survivor/Sniper aura task
  12438. public human_aura(taskid)
  12439. {
  12440. // Not survivor or sniper
  12441. if (!g_survivor[ID_AURA] && !g_sniper[ID_AURA])
  12442. {
  12443. // Task not needed anymore
  12444. remove_task(taskid);
  12445. return;
  12446. }
  12447.  
  12448. // Get player's origin
  12449. static origin[3]
  12450. get_user_origin(ID_AURA, origin)
  12451.  
  12452. // Colored Aura
  12453. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12454. write_byte(TE_DLIGHT) // TE id
  12455. write_coord(origin[0]) // x
  12456. write_coord(origin[1]) // y
  12457. write_coord(origin[2]) // z
  12458.  
  12459. // Set aura for sniper
  12460. if (g_sniper[ID_AURA])
  12461. {
  12462. write_byte(get_pcvar_num(cvar_sniperauraradius)) // radius
  12463. write_byte(get_pcvar_num(cvar_snipercolor[0])) // r
  12464. write_byte(get_pcvar_num(cvar_snipercolor[1])) // g
  12465. write_byte(get_pcvar_num(cvar_snipercolor[2])) // b
  12466. }
  12467. else // Set it for survivor
  12468. {
  12469. write_byte(get_pcvar_num(cvar_surv_aura_radius)) // radius
  12470. write_byte(get_pcvar_num(cvar_surv_aura[0])) // r
  12471. write_byte(get_pcvar_num(cvar_surv_aura[1])) // g
  12472. write_byte(get_pcvar_num(cvar_surv_aura[2])) // b
  12473. }
  12474.  
  12475. write_byte(2) // life
  12476. write_byte(0) // decay rate
  12477. message_end()
  12478. }
  12479.  
  12480. // Make zombies leave footsteps and bloodstains on the floor
  12481. public make_blood(taskid)
  12482. {
  12483. // Only bleed when moving on ground
  12484. if (!(pev(ID_BLOOD, pev_flags) & FL_ONGROUND) || fm_get_speed(ID_BLOOD) < 80)
  12485. return;
  12486.  
  12487. // Get user origin
  12488. static Float:originF[3]
  12489. pev(ID_BLOOD, pev_origin, originF)
  12490.  
  12491. // If ducking set a little lower
  12492. if (pev(ID_BLOOD, pev_bInDuck))
  12493. originF[2] -= 18.0
  12494. else
  12495. originF[2] -= 36.0
  12496.  
  12497. // Send the decal message
  12498. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  12499. write_byte(TE_WORLDDECAL) // TE id
  12500. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12501. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12502. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12503. write_byte(ArrayGetCell(zombie_decals, random_num(0, ArraySize(zombie_decals) - 1)) + (g_czero * 12)) // random decal number (offsets +12 for CZ)
  12504. message_end()
  12505. }
  12506.  
  12507. // Flare Lighting Effects
  12508. flare_lighting(entity, duration)
  12509. {
  12510. // Get origin and color
  12511. static Float:originF[3], color[3]
  12512. pev(entity, pev_origin, originF)
  12513. pev(entity, PEV_FLARE_COLOR, color)
  12514.  
  12515. if (g_assassinround)
  12516. {
  12517. // Lighting in assassin round is different
  12518. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  12519. write_byte(TE_DLIGHT) // TE id
  12520. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12521. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12522. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12523. write_byte(get_pcvar_num(cvar_flaresize2)) // radius
  12524. write_byte(color[0]) // r
  12525. write_byte(color[1]) // g
  12526. write_byte(color[2]) // b
  12527. write_byte(51) //life
  12528. write_byte((duration < 2) ? 3 : 0) //decay rate
  12529. message_end()
  12530. }
  12531. else
  12532. {
  12533. // Lighting
  12534. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  12535. write_byte(TE_DLIGHT) // TE id
  12536. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12537. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12538. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12539. write_byte(get_pcvar_num(cvar_flaresize)) // radius
  12540. write_byte(color[0]) // r
  12541. write_byte(color[1]) // g
  12542. write_byte(color[2]) // b
  12543. write_byte(51) //life
  12544. write_byte((duration < 2) ? 3 : 0) //decay rate
  12545. message_end()
  12546. }
  12547.  
  12548. // Sparks
  12549. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12550. write_byte(TE_SPARKS) // TE id
  12551. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12552. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12553. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12554. message_end()
  12555. }
  12556.  
  12557. // Burning Flames
  12558. public burning_flame(taskid)
  12559. {
  12560. // Get player origin and flags
  12561. static origin[3], flags
  12562. get_user_origin(ID_BURN, origin)
  12563. flags = pev(ID_BURN, pev_flags)
  12564.  
  12565. // Madness mode - in water - burning stopped
  12566. if (g_nodamage[ID_BURN] || (flags & FL_INWATER) || g_burning_duration[ID_BURN] < 1)
  12567. {
  12568. // Smoke sprite
  12569. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12570. write_byte(TE_SMOKE) // TE id
  12571. write_coord(origin[0]) // x
  12572. write_coord(origin[1]) // y
  12573. write_coord(origin[2]-50) // z
  12574. write_short(g_smokeSpr) // sprite
  12575. write_byte(random_num(15, 20)) // scale
  12576. write_byte(random_num(10, 20)) // framerate
  12577. message_end()
  12578.  
  12579. // Task not needed anymore
  12580. remove_task(taskid);
  12581. return;
  12582. }
  12583.  
  12584. // Randomly play burning zombie scream sounds (not for nemesis or assassin)
  12585. if (!g_nemesis[ID_BURN] && !g_assassin[ID_BURN] && !random_num(0, 20))
  12586. {
  12587. static sound[64]
  12588. ArrayGetString(grenade_fire_player, random_num(0, ArraySize(grenade_fire_player) - 1), sound, charsmax(sound))
  12589. emit_sound(ID_BURN, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  12590. }
  12591.  
  12592. // Fire slow down, unless nemesis
  12593. if (!g_nemesis[ID_BURN] && !g_assassin[ID_BURN] && (flags & FL_ONGROUND) && get_pcvar_float(cvar_fireslowdown) > 0.0)
  12594. {
  12595. static Float:velocity[3]
  12596. pev(ID_BURN, pev_velocity, velocity)
  12597. xs_vec_mul_scalar(velocity, get_pcvar_float(cvar_fireslowdown), velocity)
  12598. set_pev(ID_BURN, pev_velocity, velocity)
  12599. }
  12600.  
  12601. // Get player's health
  12602. static health
  12603. health = pev(ID_BURN, pev_health)
  12604.  
  12605. // Take damage from the fire
  12606. if (health - floatround(get_pcvar_float(cvar_firedamage), floatround_ceil) > 0)
  12607. fm_set_user_health(ID_BURN, health - floatround(get_pcvar_float(cvar_firedamage), floatround_ceil))
  12608.  
  12609. // Flame sprite
  12610. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  12611. write_byte(TE_SPRITE) // TE id
  12612. write_coord(origin[0]+random_num(-5, 5)) // x
  12613. write_coord(origin[1]+random_num(-5, 5)) // y
  12614. write_coord(origin[2]+random_num(-10, 10)) // z
  12615. write_short(g_flameSpr) // sprite
  12616. write_byte(random_num(5, 10)) // scale
  12617. write_byte(200) // brightness
  12618. message_end()
  12619.  
  12620. // Decrease burning duration counter
  12621. g_burning_duration[ID_BURN]--
  12622. }
  12623.  
  12624. // Infection Bomb: Blast
  12625. create_blast(const Float:originF[3])
  12626. {
  12627. // Smallest ring
  12628. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12629. write_byte(TE_BEAMCYLINDER) // TE id
  12630. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12631. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12632. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12633. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12634. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12635. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  12636. write_short(g_exploSpr) // sprite
  12637. write_byte(0) // startframe
  12638. write_byte(0) // framerate
  12639. write_byte(4) // life
  12640. write_byte(60) // width
  12641. write_byte(0) // noise
  12642. write_byte(0) // red
  12643. write_byte(250) // green
  12644. write_byte(0) // blue
  12645. write_byte(200) // brightness
  12646. write_byte(0) // speed
  12647. message_end()
  12648.  
  12649. // Medium ring
  12650. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12651. write_byte(TE_BEAMCYLINDER) // TE id
  12652. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12653. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12654. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12655. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12656. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12657. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  12658. write_short(g_exploSpr) // sprite
  12659. write_byte(0) // startframe
  12660. write_byte(0) // framerate
  12661. write_byte(4) // life
  12662. write_byte(60) // width
  12663. write_byte(0) // noise
  12664. write_byte(0) // red
  12665. write_byte(250) // green
  12666. write_byte(0) // blue
  12667. write_byte(200) // brightness
  12668. write_byte(0) // speed
  12669. message_end()
  12670.  
  12671. // Largest ring
  12672. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12673. write_byte(TE_BEAMCYLINDER) // TE id
  12674. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12675. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12676. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12677. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12678. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12679. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  12680. write_short(g_exploSpr) // sprite
  12681. write_byte(0) // startframe
  12682. write_byte(0) // framerate
  12683. write_byte(4) // life
  12684. write_byte(60) // width
  12685. write_byte(0) // noise
  12686. write_byte(0) // red
  12687. write_byte(250) // green
  12688. write_byte(0) // blue
  12689. write_byte(200) // brightness
  12690. write_byte(0) // speed
  12691. message_end()
  12692. }
  12693.  
  12694. // Fire Grenade: Fire Blast
  12695. create_blast2(const Float:originF[3])
  12696. {
  12697. // Smallest ring
  12698. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12699. write_byte(TE_BEAMCYLINDER) // TE id
  12700. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12701. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12702. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12703. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12704. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12705. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  12706. write_short(g_exploSpr) // sprite
  12707. write_byte(0) // startframe
  12708. write_byte(0) // framerate
  12709. write_byte(4) // life
  12710. write_byte(60) // width
  12711. write_byte(0) // noise
  12712. write_byte(200) // red
  12713. write_byte(100) // green
  12714. write_byte(0) // blue
  12715. write_byte(200) // brightness
  12716. write_byte(0) // speed
  12717. message_end()
  12718.  
  12719. // Medium ring
  12720. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12721. write_byte(TE_BEAMCYLINDER) // TE id
  12722. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12723. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12724. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12725. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12726. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12727. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  12728. write_short(g_exploSpr) // sprite
  12729. write_byte(0) // startframe
  12730. write_byte(0) // framerate
  12731. write_byte(4) // life
  12732. write_byte(60) // width
  12733. write_byte(0) // noise
  12734. write_byte(200) // red
  12735. write_byte(50) // green
  12736. write_byte(0) // blue
  12737. write_byte(200) // brightness
  12738. write_byte(0) // speed
  12739. message_end()
  12740.  
  12741. // Largest ring
  12742. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12743. write_byte(TE_BEAMCYLINDER) // TE id
  12744. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12745. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12746. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12747. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12748. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12749. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  12750. write_short(g_exploSpr) // sprite
  12751. write_byte(0) // startframe
  12752. write_byte(0) // framerate
  12753. write_byte(4) // life
  12754. write_byte(60) // width
  12755. write_byte(0) // noise
  12756. write_byte(200) // red
  12757. write_byte(0) // green
  12758. write_byte(0) // blue
  12759. write_byte(200) // brightness
  12760. write_byte(0) // speed
  12761. message_end()
  12762. }
  12763.  
  12764. // Frost Grenade: Freeze Blast
  12765. create_blast3(const Float:originF[3])
  12766. {
  12767. // Smallest ring
  12768. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12769. write_byte(TE_BEAMCYLINDER) // TE id
  12770. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12771. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12772. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12773. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12774. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12775. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  12776. write_short(g_exploSpr) // sprite
  12777. write_byte(0) // startframe
  12778. write_byte(0) // framerate
  12779. write_byte(4) // life
  12780. write_byte(60) // width
  12781. write_byte(0) // noise
  12782. write_byte(0) // red
  12783. write_byte(100) // green
  12784. write_byte(200) // blue
  12785. write_byte(200) // brightness
  12786. write_byte(0) // speed
  12787. message_end()
  12788.  
  12789. // Medium ring
  12790. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12791. write_byte(TE_BEAMCYLINDER) // TE id
  12792. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12793. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12794. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12795. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12796. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12797. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  12798. write_short(g_exploSpr) // sprite
  12799. write_byte(0) // startframe
  12800. write_byte(0) // framerate
  12801. write_byte(4) // life
  12802. write_byte(60) // width
  12803. write_byte(0) // noise
  12804. write_byte(0) // red
  12805. write_byte(100) // green
  12806. write_byte(200) // blue
  12807. write_byte(200) // brightness
  12808. write_byte(0) // speed
  12809. message_end()
  12810.  
  12811. // Largest ring
  12812. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  12813. write_byte(TE_BEAMCYLINDER) // TE id
  12814. engfunc(EngFunc_WriteCoord, originF[0]) // x
  12815. engfunc(EngFunc_WriteCoord, originF[1]) // y
  12816. engfunc(EngFunc_WriteCoord, originF[2]) // z
  12817. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  12818. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  12819. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  12820. write_short(g_exploSpr) // sprite
  12821. write_byte(0) // startframe
  12822. write_byte(0) // framerate
  12823. write_byte(4) // life
  12824. write_byte(60) // width
  12825. write_byte(0) // noise
  12826. write_byte(0) // red
  12827. write_byte(100) // green
  12828. write_byte(200) // blue
  12829. write_byte(200) // brightness
  12830. write_byte(0) // speed
  12831. message_end()
  12832. }
  12833.  
  12834. // Fix Dead Attrib on scoreboard
  12835. FixDeadAttrib(id)
  12836. {
  12837. message_begin(MSG_BROADCAST, g_msgScoreAttrib)
  12838. write_byte(id) // id
  12839. write_byte(0) // attrib
  12840. message_end()
  12841. }
  12842.  
  12843. // Send Death Message for infections
  12844. SendDeathMsg(attacker, victim)
  12845. {
  12846. message_begin(MSG_BROADCAST, g_msgDeathMsg)
  12847. write_byte(attacker) // killer
  12848. write_byte(victim) // victim
  12849. write_byte(1) // headshot flag
  12850. write_string("infection") // killer's weapon
  12851. message_end()
  12852. }
  12853.  
  12854. // Update Player Frags and Deaths
  12855. UpdateFrags(attacker, victim, frags, deaths, scoreboard)
  12856. {
  12857. // Set attacker frags
  12858. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  12859.  
  12860. // Set victim deaths
  12861. fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) + deaths)
  12862.  
  12863. // Update scoreboard with attacker and victim info
  12864. if (scoreboard)
  12865. {
  12866. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  12867. write_byte(attacker) // id
  12868. write_short(pev(attacker, pev_frags)) // frags
  12869. write_short(cs_get_user_deaths(attacker)) // deaths
  12870. write_short(0) // class?
  12871. write_short(fm_cs_get_user_team(attacker)) // team
  12872. message_end()
  12873.  
  12874. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  12875. write_byte(victim) // id
  12876. write_short(pev(victim, pev_frags)) // frags
  12877. write_short(cs_get_user_deaths(victim)) // deaths
  12878. write_short(0) // class?
  12879. write_short(fm_cs_get_user_team(victim)) // team
  12880. message_end()
  12881. }
  12882. }
  12883.  
  12884. // Remove Player Frags (when Nemesis/Survivor/Sniper ignore_frags cvar is enabled)
  12885. RemoveFrags(attacker, victim)
  12886. {
  12887. // Remove attacker frags
  12888. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) - 1))
  12889.  
  12890. // Remove victim deaths
  12891. fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) - 1)
  12892. }
  12893.  
  12894. // Plays a sound on clients
  12895. PlaySound(const sound[])
  12896. {
  12897. client_cmd(0, "spk ^"%s^"", sound)
  12898. }
  12899.  
  12900. // Prints a colored message to target (use 0 for everyone), supports ML formatting.
  12901. // Note: I still need to make something like gungame's LANG_PLAYER_C to avoid unintended
  12902. // argument replacement when a function passes -1 (it will be considered a LANG_PLAYER)
  12903. zp_colored_print(target, const message[], any:...)
  12904. {
  12905. static buffer[512], i, argscount
  12906. argscount = numargs()
  12907.  
  12908. // Send to everyone
  12909. if (!target)
  12910. {
  12911. static player
  12912. for (player = 1; player <= g_maxplayers; player++)
  12913. {
  12914. // Not connected
  12915. if (!g_isconnected[player])
  12916. continue;
  12917.  
  12918. // Remember changed arguments
  12919. static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
  12920. changedcount = 0
  12921.  
  12922. // Replace LANG_PLAYER with player id
  12923. for (i = 2; i < argscount; i++)
  12924. {
  12925. if (getarg(i) == LANG_PLAYER)
  12926. {
  12927. setarg(i, 0, player)
  12928. changed[changedcount] = i
  12929. changedcount++
  12930. }
  12931. }
  12932.  
  12933. // Format message for player
  12934. vformat(buffer, charsmax(buffer), message, 3)
  12935.  
  12936. // Send it
  12937. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
  12938. write_byte(player)
  12939. write_string(buffer)
  12940. message_end()
  12941.  
  12942. // Replace back player id's with LANG_PLAYER
  12943. for (i = 0; i < changedcount; i++)
  12944. setarg(changed[i], 0, LANG_PLAYER)
  12945. }
  12946. }
  12947. // Send to specific target
  12948. else
  12949. {
  12950. // Format message for player
  12951. vformat(buffer, charsmax(buffer), message, 3)
  12952.  
  12953. // Send it
  12954. message_begin(MSG_ONE, g_msgSayText, _, target)
  12955. write_byte(target)
  12956. write_string(buffer)
  12957. message_end()
  12958. }
  12959. }
  12960.  
  12961. /*================================================================================
  12962.  [Stocks]
  12963. =================================================================================*/
  12964.  
  12965. // Set an entity's key value (from fakemeta_util)
  12966. stock fm_set_kvd(entity, const key[], const value[], const classname[])
  12967. {
  12968. set_kvd(0, KV_ClassName, classname)
  12969. set_kvd(0, KV_KeyName, key)
  12970. set_kvd(0, KV_Value, value)
  12971. set_kvd(0, KV_fHandled, 0)
  12972.  
  12973. dllfunc(DLLFunc_KeyValue, entity, 0)
  12974. }
  12975.  
  12976. // Set entity's rendering type (from fakemeta_util)
  12977. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  12978. {
  12979. static Float:color[3]
  12980. color[0] = float(r)
  12981. color[1] = float(g)
  12982. color[2] = float(b)
  12983.  
  12984. set_pev(entity, pev_renderfx, fx)
  12985. set_pev(entity, pev_rendercolor, color)
  12986. set_pev(entity, pev_rendermode, render)
  12987. set_pev(entity, pev_renderamt, float(amount))
  12988. }
  12989.  
  12990. // Get entity's speed (from fakemeta_util)
  12991. stock fm_get_speed(entity)
  12992. {
  12993. static Float:velocity[3]
  12994. pev(entity, pev_velocity, velocity)
  12995.  
  12996. return floatround(vector_length(velocity));
  12997. }
  12998.  
  12999. // Get entity's aim origins (from fakemeta_util)
  13000. stock fm_get_aim_origin(id, Float:origin[3])
  13001. {
  13002. static Float:origin1F[3], Float:origin2F[3]
  13003. pev(id, pev_origin, origin1F)
  13004. pev(id, pev_view_ofs, origin2F)
  13005. xs_vec_add(origin1F, origin2F, origin1F)
  13006.  
  13007. pev(id, pev_v_angle, origin2F);
  13008. engfunc(EngFunc_MakeVectors, origin2F)
  13009. global_get(glb_v_forward, origin2F)
  13010. xs_vec_mul_scalar(origin2F, 9999.0, origin2F)
  13011. xs_vec_add(origin1F, origin2F, origin2F)
  13012.  
  13013. engfunc(EngFunc_TraceLine, origin1F, origin2F, 0, id, 0)
  13014. get_tr2(0, TR_vecEndPos, origin)
  13015. }
  13016.  
  13017. // Find entity by its owner (from fakemeta_util)
  13018. stock fm_find_ent_by_owner(entity, const classname[], owner)
  13019. {
  13020. while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  13021. return entity;
  13022. }
  13023.  
  13024. // Set player's health (from fakemeta_util)
  13025. stock fm_set_user_health(id, health)
  13026. {
  13027. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  13028. }
  13029.  
  13030. // Give an item to a player (from fakemeta_util)
  13031. stock fm_give_item(id, const item[])
  13032. {
  13033. static ent
  13034. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  13035. if (!pev_valid(ent)) return;
  13036.  
  13037. static Float:originF[3]
  13038. pev(id, pev_origin, originF)
  13039. set_pev(ent, pev_origin, originF)
  13040. set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  13041. dllfunc(DLLFunc_Spawn, ent)
  13042.  
  13043. static save
  13044. save = pev(ent, pev_solid)
  13045. dllfunc(DLLFunc_Touch, ent, id)
  13046. if (pev(ent, pev_solid) != save)
  13047. return;
  13048.  
  13049. engfunc(EngFunc_RemoveEntity, ent)
  13050. }
  13051.  
  13052. // Strip user weapons (from fakemeta_util)
  13053. stock fm_strip_user_weapons(id)
  13054. {
  13055. static ent
  13056. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  13057. if (!pev_valid(ent)) return;
  13058.  
  13059. dllfunc(DLLFunc_Spawn, ent)
  13060. dllfunc(DLLFunc_Use, ent, id)
  13061. engfunc(EngFunc_RemoveEntity, ent)
  13062. }
  13063.  
  13064. // Collect random spawn points
  13065. stock load_spawns()
  13066. {
  13067. // Check for CSDM spawns of the current map
  13068. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  13069. get_configsdir(cfgdir, charsmax(cfgdir))
  13070. get_mapname(mapname, charsmax(mapname))
  13071. formatex(filepath, charsmax(filepath), "%s/csdm/%s.spawns.cfg", cfgdir, mapname)
  13072.  
  13073. // Load CSDM spawns if present
  13074. if (file_exists(filepath))
  13075. {
  13076. new csdmdata[10][6], file = fopen(filepath,"rt")
  13077.  
  13078. while (file && !feof(file))
  13079. {
  13080. fgets(file, linedata, charsmax(linedata))
  13081.  
  13082. // invalid spawn
  13083. if (!linedata[0] || str_count(linedata,' ') < 2) continue;
  13084.  
  13085. // get spawn point data
  13086. parse(linedata,csdmdata[0],5,csdmdata[1],5,csdmdata[2],5,csdmdata[3],5,csdmdata[4],5,csdmdata[5],5,csdmdata[6],5,csdmdata[7],5,csdmdata[8],5,csdmdata[9],5)
  13087.  
  13088. // origin
  13089. g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
  13090. g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
  13091. g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
  13092.  
  13093. // increase spawn count
  13094. g_spawnCount++
  13095. if (g_spawnCount >= sizeof g_spawns) break;
  13096. }
  13097. if (file) fclose(file)
  13098. }
  13099. else
  13100. {
  13101. // Collect regular spawns
  13102. collect_spawns_ent("info_player_start")
  13103. collect_spawns_ent("info_player_deathmatch")
  13104. }
  13105.  
  13106. // Collect regular spawns for non-random spawning unstuck
  13107. collect_spawns_ent2("info_player_start")
  13108. collect_spawns_ent2("info_player_deathmatch")
  13109. }
  13110.  
  13111. // Collect spawn points from entity origins
  13112. stock collect_spawns_ent(const classname[])
  13113. {
  13114. new ent = -1
  13115. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) != 0)
  13116. {
  13117. // get origin
  13118. new Float:originF[3]
  13119. pev(ent, pev_origin, originF)
  13120. g_spawns[g_spawnCount][0] = originF[0]
  13121. g_spawns[g_spawnCount][1] = originF[1]
  13122. g_spawns[g_spawnCount][2] = originF[2]
  13123.  
  13124. // increase spawn count
  13125. g_spawnCount++
  13126. if (g_spawnCount >= sizeof g_spawns) break;
  13127. }
  13128. }
  13129.  
  13130. // Collect spawn points from entity origins
  13131. stock collect_spawns_ent2(const classname[])
  13132. {
  13133. new ent = -1
  13134. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) != 0)
  13135. {
  13136. // get origin
  13137. new Float:originF[3]
  13138. pev(ent, pev_origin, originF)
  13139. g_spawns2[g_spawnCount2][0] = originF[0]
  13140. g_spawns2[g_spawnCount2][1] = originF[1]
  13141. g_spawns2[g_spawnCount2][2] = originF[2]
  13142.  
  13143. // increase spawn count
  13144. g_spawnCount2++
  13145. if (g_spawnCount2 >= sizeof g_spawns2) break;
  13146. }
  13147. }
  13148.  
  13149. // Drop primary/secondary weapons
  13150. stock drop_weapons(id, dropwhat)
  13151. {
  13152. // Get user weapons
  13153. static weapons[32], num, i, weaponid
  13154. num = 0 // reset passed weapons count (bugfix)
  13155. get_user_weapons(id, weapons, num)
  13156.  
  13157. // Loop through them and drop primaries or secondaries
  13158. for (i = 0; i < num; i++)
  13159. {
  13160. // Prevent re-indexing the array
  13161. weaponid = weapons[i]
  13162.  
  13163. if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  13164. {
  13165. // Get weapon entity
  13166. static wname[32], weapon_ent
  13167. get_weaponname(weaponid, wname, charsmax(wname))
  13168. weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  13169.  
  13170. // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  13171. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
  13172.  
  13173. // Player drops the weapon and looses his bpammo
  13174. engclient_cmd(id, "drop", wname)
  13175. cs_set_user_bpammo(id, weaponid, 0)
  13176. }
  13177. }
  13178. }
  13179.  
  13180. // Stock by (probably) Twilight Suzuka -counts number of chars in a string
  13181. stock str_count(const str[], searchchar)
  13182. {
  13183. new count, i, len = strlen(str)
  13184.  
  13185. for (i = 0; i <= len; i++)
  13186. {
  13187. if (str[i] == searchchar)
  13188. count++
  13189. }
  13190.  
  13191. return count;
  13192. }
  13193.  
  13194. // Checks if a space is vacant (credits to VEN)
  13195. stock is_hull_vacant(Float:origin[3], hull)
  13196. {
  13197. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
  13198.  
  13199. if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
  13200. return true;
  13201.  
  13202. return false;
  13203. }
  13204.  
  13205. // Check if a player is stuck (credits to VEN)
  13206. stock is_player_stuck(id)
  13207. {
  13208. static Float:originF[3]
  13209. pev(id, pev_origin, originF)
  13210.  
  13211. engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  13212.  
  13213. if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  13214. return true;
  13215.  
  13216. return false;
  13217. }
  13218.  
  13219. // Simplified get_weaponid (CS only)
  13220. stock cs_weapon_name_to_id(const weapon[])
  13221. {
  13222. static i
  13223. for (i = 0; i < sizeof WEAPONENTNAMES; i++)
  13224. {
  13225. if (equal(weapon, WEAPONENTNAMES[i]))
  13226. return i;
  13227. }
  13228.  
  13229. return 0;
  13230. }
  13231.  
  13232. // Get User Current Weapon Entity
  13233. stock fm_cs_get_current_weapon_ent(id)
  13234. {
  13235. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
  13236. }
  13237.  
  13238. // Get Weapon Entity's Owner
  13239. stock fm_cs_get_weapon_ent_owner(ent)
  13240. {
  13241. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  13242. }
  13243.  
  13244. // Set User Deaths
  13245. stock fm_cs_set_user_deaths(id, value)
  13246. {
  13247. set_pdata_int(id, OFFSET_CSDEATHS, value, OFFSET_LINUX)
  13248. }
  13249.  
  13250. // Get User Team
  13251. stock fm_cs_get_user_team(id)
  13252. {
  13253. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  13254. }
  13255.  
  13256. // Set a Player's Team
  13257. stock fm_cs_set_user_team(id, team)
  13258. {
  13259. set_pdata_int(id, OFFSET_CSTEAMS, team, OFFSET_LINUX)
  13260. }
  13261.  
  13262. // Set User Money
  13263. stock fm_cs_set_user_money(id, value)
  13264. {
  13265. set_pdata_int(id, OFFSET_CSMONEY, value, OFFSET_LINUX)
  13266. }
  13267.  
  13268. // Set User Flashlight Batteries
  13269. stock fm_cs_set_user_batteries(id, value)
  13270. {
  13271. set_pdata_int(id, OFFSET_FLASHLIGHT_BATTERY, value, OFFSET_LINUX)
  13272. }
  13273.  
  13274. // Update Player's Team on all clients (adding needed delays)
  13275. stock fm_user_team_update(id)
  13276. {
  13277. static Float:current_time
  13278. current_time = get_gametime()
  13279.  
  13280. if (current_time - g_teams_targettime >= 0.1)
  13281. {
  13282. set_task(0.1, "fm_cs_set_user_team_msg", id+TASK_TEAM)
  13283. g_teams_targettime = current_time + 0.1
  13284. }
  13285. else
  13286. {
  13287. set_task((g_teams_targettime + 0.1) - current_time, "fm_cs_set_user_team_msg", id+TASK_TEAM)
  13288. g_teams_targettime = g_teams_targettime + 0.1
  13289. }
  13290. }
  13291.  
  13292. // Send User Team Message
  13293. public fm_cs_set_user_team_msg(taskid)
  13294. {
  13295. // Note to self: this next message can now be received by other plugins
  13296.  
  13297. // Set the switching team flag
  13298. g_switchingteam = true
  13299.  
  13300. // Tell everyone my new team
  13301. emessage_begin(MSG_ALL, g_msgTeamInfo)
  13302. ewrite_byte(ID_TEAM) // player
  13303. ewrite_string(CS_TEAM_NAMES[fm_cs_get_user_team(ID_TEAM)]) // team
  13304. emessage_end()
  13305.  
  13306. // Done switching team
  13307. g_switchingteam = false
  13308. }
  13309.  
  13310. // Set the precached model index (updates hitboxes server side)
  13311. stock fm_cs_set_user_model_index(id, value)
  13312. {
  13313. set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
  13314. }
  13315.  
  13316. // Set Player Model on Entity
  13317. stock fm_set_playermodel_ent(id)
  13318. {
  13319. // Make original player entity invisible without hiding shadows or firing effects
  13320. fm_set_rendering(id, kRenderFxNone, 255, 255, 255, kRenderTransTexture, 1)
  13321.  
  13322. // Format model string
  13323. static model[100]
  13324. formatex(model, charsmax(model), "models/player/%s/%s.mdl", g_playermodel[id], g_playermodel[id])
  13325.  
  13326. // Set model on entity or make a new one if unexistant
  13327. if (!pev_valid(g_ent_playermodel[id]))
  13328. {
  13329. g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  13330. if (!pev_valid(g_ent_playermodel[id])) return;
  13331.  
  13332. set_pev(g_ent_playermodel[id], pev_classname, MODEL_ENT_CLASSNAME)
  13333. set_pev(g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW)
  13334. set_pev(g_ent_playermodel[id], pev_aiment, id)
  13335. set_pev(g_ent_playermodel[id], pev_owner, id)
  13336. }
  13337.  
  13338. engfunc(EngFunc_SetModel, g_ent_playermodel[id], model)
  13339. }
  13340.  
  13341. // Set Weapon Model on Entity
  13342. stock fm_set_weaponmodel_ent(id)
  13343. {
  13344. // Get player's p_ weapon model
  13345. static model[100]
  13346. pev(id, pev_weaponmodel2, model, charsmax(model))
  13347.  
  13348. // Set model on entity or make a new one if unexistant
  13349. if (!pev_valid(g_ent_weaponmodel[id]))
  13350. {
  13351. g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  13352. if (!pev_valid(g_ent_weaponmodel[id])) return;
  13353.  
  13354. set_pev(g_ent_weaponmodel[id], pev_classname, WEAPON_ENT_CLASSNAME)
  13355. set_pev(g_ent_weaponmodel[id], pev_movetype, MOVETYPE_FOLLOW)
  13356. set_pev(g_ent_weaponmodel[id], pev_aiment, id)
  13357. set_pev(g_ent_weaponmodel[id], pev_owner, id)
  13358. }
  13359.  
  13360. engfunc(EngFunc_SetModel, g_ent_weaponmodel[id], model)
  13361. }
  13362.  
  13363. // Remove Custom Model Entities
  13364. stock fm_remove_model_ents(id)
  13365. {
  13366. // Remove "playermodel" ent if present
  13367. if (pev_valid(g_ent_playermodel[id]))
  13368. {
  13369. engfunc(EngFunc_RemoveEntity, g_ent_playermodel[id])
  13370. g_ent_playermodel[id] = 0
  13371. }
  13372. // Remove "weaponmodel" ent if present
  13373. if (pev_valid(g_ent_weaponmodel[id]))
  13374. {
  13375. engfunc(EngFunc_RemoveEntity, g_ent_weaponmodel[id])
  13376. g_ent_weaponmodel[id] = 0
  13377. }
  13378. }
  13379.  
  13380. // Set User Model
  13381. public fm_cs_set_user_model(taskid)
  13382. {
  13383. set_user_info(ID_MODEL, "model", g_playermodel[ID_MODEL])
  13384. }
  13385.  
  13386. // Get User Model -model passed byref-
  13387. stock fm_cs_get_user_model(player, model[], len)
  13388. {
  13389. get_user_info(player, "model", model, len)
  13390. }
  13391.  
  13392. // Update Player's Model on all clients (adding needed delays)
  13393. public fm_user_model_update(taskid)
  13394. {
  13395. static Float:current_time
  13396. current_time = get_gametime()
  13397.  
  13398. if (current_time - g_models_targettime >= g_modelchange_delay)
  13399. {
  13400. fm_cs_set_user_model(taskid)
  13401. g_models_targettime = current_time
  13402. }
  13403. else
  13404. {
  13405. set_task((g_models_targettime + g_modelchange_delay) - current_time, "fm_cs_set_user_model", taskid)
  13406. g_models_targettime = g_models_targettime + g_modelchange_delay
  13407. }
  13408. }
  13409.