Guest User

Untitled

a guest
Nov 5th, 2017
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 484.36 KB | None | 0 0
  1. /*================================================================================
  2.  
  3. *****************************************************
  4. ************** [Zombie Plague Mod 4.3] **************
  5. *****************************************************
  6.  
  7. ----------------------
  8. -*- Licensing Info -*-
  9. ----------------------
  10.  
  11. Zombie Plague Mod
  12. Copyright (C) 2008-2009 by MeRcyLeZZ
  13.  
  14. This program is free software: you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation, either version 3 of the License, or
  17. (at your option) any later version.
  18.  
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23.  
  24. You should have received a copy of the GNU General Public License
  25. along with this program. If not, see <http://www.gnu.org/licenses/>.
  26.  
  27. In addition, as a special exception, the author gives permission to
  28. link the code of this program with the Half-Life Game Engine ("HL
  29. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  30. L.L.C ("Valve"). You must obey the GNU General Public License in all
  31. respects for all of the code used other than the HL Engine and MODs
  32. from Valve. If you modify this file, you may extend this exception
  33. to your version of the file, but you are not obligated to do so. If
  34. you do not wish to do so, delete this exception statement from your
  35. version.
  36.  
  37. -------------------
  38. -*- Description -*-
  39. -------------------
  40.  
  41. Zombie Plague is a Counter-Strike server side modification, developed as
  42. an AMX Mod X plugin, which completely revamps the gameplay, turning the
  43. game into an intense "Humans vs Zombies" survival experience.
  44.  
  45. Even though it's strongly based on the classic zombie infection mods, it
  46. takes the concept to a new level by introducing:
  47.  
  48. * New Gameplay Modes: Nemesis, Survivor, Multi Infection, Swarm, Plague
  49. * Zombie Classes System: allows addding unlimited custom zombie classes
  50. * Ammo Packs: awarded to skilled players, can be exchanged for goods
  51. * Extra Items System: allows adding unlimited custom items to buy
  52. * Custom Grenades: Napalms, Frost Nades, Flares, and Infection Bombs
  53. * Deathmatch Mode: where zombies or humans can continually respawn
  54. * Admin Menus: to easily perform the included console commands
  55. * Special Effects: from the HL Engine, such as dynamic lighting and fog
  56.  
  57. There is plenty of customization as well, which enables you to create
  58. several different styles of gameplay. You can:
  59.  
  60. * Set zombies and humans' health, speed, models, rewards, and more
  61. * Toggle unlimited ammo and adjustable knockback for weapons
  62. * Separately enable and customize the new gameplay modes to your liking
  63. * Change overall map lighting (lightnings available for the dark settings)
  64. * Set different colors and sizes for flashlight and nightvision
  65. * Toggle leap (long jumping) and pain shock free (no damage slowdowns)
  66. * Toggle various infection effects, such as sparks and screen shakes
  67. * Enable random spawning (CSDM-spawn friendly)
  68. * Replace sounds or add some background themes
  69. * And many more...
  70.  
  71. -------------
  72. -*- Media -*-
  73. -------------
  74.  
  75. * Gameplay Video 1: http://www.youtube.com/watch?v=HFUyF7-_uzw
  76. * Gameplay Video 2: http://www.youtube.com/watch?v=XByif6Mti-w
  77.  
  78. --------------------
  79. -*- Requirements -*-
  80. --------------------
  81.  
  82. * Mods: Counter-Strike 1.6 or Condition-Zero
  83. * AMXX: Version 1.8.0 or later
  84.  
  85. --------------------
  86. -*- Installation -*-
  87. --------------------
  88.  
  89. Extract the contents from the .zip file to your server's mod directory
  90. ("cstrike" or "czero"). Make sure to keep folder structure.
  91.  
  92. -----------------------
  93. -*- Official Forums -*-
  94. -----------------------
  95.  
  96. For the official Zombie Plague forums visit:
  97. http://forums.alliedmods.net/forumdisplay.php?f=126
  98.  
  99. There you can:
  100.  
  101. * Get the latest releases and early betas
  102. * Discuss new features and suggestions
  103. * Share sub-plugins (expansions) for the mod
  104. * Find the support and help you need
  105. * Report any bugs you might find
  106. * And all that sort of stuff...
  107.  
  108. -------------------------------
  109. -*- CVARS and Customization -*-
  110. -------------------------------
  111.  
  112. For a complete and in-depth cvar list, look at the zombieplague.cfg file
  113. located in the amxmodx\configs directory.
  114.  
  115. Additionally, you can change player models, sounds, weather effects,
  116. and some other stuff from the configuration file zombieplague.ini.
  117.  
  118. As for editing attributes of zombie classes or custom extra items, you'll
  119. find a zp_zombieclasses.ini and zp_extraitems.ini. These files will be
  120. automatically updated as you install new custom classes or items with
  121. new entries for you to edit conveniently.
  122.  
  123. ---------------
  124. -*- History -*-
  125. ---------------
  126.  
  127. This project started back on late 2007, when the free infection mods
  128. around were quite buggy and I wanted to make one on my own. With little
  129. to no experience at AMXX scripting, I had to start from the very scratch.
  130.  
  131. Not after spending over a week looking at many plugins (mainly Zombie
  132. Swarm) and scarce tutorials, I somehow managed to have all the basic
  133. stuff working quite well (even though the code was a real mess). The
  134. following months were spent polishing things up and trying to fulfill
  135. new original ideas, most of them quite worth the hard work.
  136.  
  137. In the meantime, I got the chance to try the plugin out on a 32 man
  138. server. This meant a huge progress on development, and after lots of
  139. testing and bug fixing, the mod turned out to be more than the simple
  140. infection plugin I had originally planned it to be.
  141.  
  142. The project has come a long way since, and I'm glad to say I'm finally
  143. making it freely available. All I'm asking in return is to keep my
  144. name in the plugin.
  145.  
  146. -Enjoy!
  147.  
  148. ----------------------
  149. -*- Infection Mode -*-
  150. ----------------------
  151.  
  152. On every round players start out as humans, equip themselves with a few
  153. weapons and grenades, and head to the closest cover they find, knowing
  154. that one of them is infected with the T-Virus, and will suddenly turn
  155. into a vicious brain eating creature.
  156.  
  157. Only little time after, the battle for survival begins. The first zombie
  158. has to infect as many humans as possible to cluster a numerous zombie
  159. horde and take over the world.
  160.  
  161. Maps are set in the dark by default. Humans must use flashlights to light
  162. their way and spot any enemies. Zombies, on the other hand, have night
  163. vision but can only attack melee.
  164.  
  165. --------------------------
  166. -*- New Gameplay Modes -*-
  167. --------------------------
  168.  
  169. * Nemesis:
  170. The first zombie may turn into a Nemesis, a powerful fast-moving
  171. beast. His goal is to kill every human while sustaining the gunfire.
  172.  
  173. * Survivor:
  174. Everyone became a zombie except him. The survivor gets a machinegun
  175. with unlimited ammo and has to stop the never-ending army of undead.
  176.  
  177. * Multiple Infection:
  178. The round starts with many humans infected, so the remaining players
  179. will have to act quickly in order to control the situation.
  180.  
  181. * Swarm Mode:
  182. Half of the players turn into zombies, the rest become immune and
  183. cannot be infected. It's a battle to death.
  184.  
  185. * Plague Mode: [bonus]
  186. A full armed Survivor and his soldiers are to face Nemesis and
  187. his zombie minions. The future of the world is in their hands.
  188.  
  189. --------------------
  190. -*- In-Game Menu -*-
  191. --------------------
  192.  
  193. Players can access the mod menu by typing "zpmenu" on chat, or by
  194. pressing the M ("chooseteam") key. The menu allows players to choose
  195. their zombie class, buy extra items, get unstuck, or see the ingame
  196. help. Admins will find an additional option to easily perform all
  197. console commands.
  198.  
  199. ----------------------
  200. -*- Admin Commands -*-
  201. ----------------------
  202.  
  203. The following console commands are available:
  204.  
  205. * zp_zombie <target> - Turn someone into a Zombie
  206. * zp_human <target> - Turn someone back to Human
  207. * zp_nemesis <target> - Turn someone into a Nemesis
  208. * zp_survivor <target> - Turn someone into a Survivor
  209. * zp_respawn <target> - Respawn someone
  210. * zp_swarm - Start Swarm Mode (*)
  211. * zp_multi - Start Multi Infection (*)
  212. * zp_plague - Start Plague Mode (*)
  213.  
  214. (*) - These commands can only be used at round start, that is, when the
  215. T-Virus notice is shown on screen.
  216.  
  217. ------------------
  218. -*- Plugin API -*-
  219. ------------------
  220.  
  221. From version 3.6, some natives and forwards have been added to ease the
  222. development of sub-plugins, though you may also find them useful to work
  223. out compatibility issues with existing plugins.
  224.  
  225. Look for the zombieplague.inc file in your amxmodx\scripting\include
  226. folder for the full documented list.
  227.  
  228. ----------------------
  229. -*- Zombie Classes -*-
  230. ----------------------
  231.  
  232. From version 4.0 it is possible to create and add an unlimited number of
  233. zombie classes to the main mod. They can be made as separate plugins,
  234. by using the provided zombie class API, and easily distributed.
  235.  
  236. By default, five zombie classes are included:
  237.  
  238. * Classic Zombie: well balanced zombie for beginners.
  239. * Raptor Zombie: fast moving zombie, but also the weakest.
  240. * Poison Zombie: light weighed zombie, jumps higher.
  241. * Big Zombie: slow but strong zombie, with lots of hit points.
  242. * Leech Zombie: regains additional health when infecting.
  243.  
  244. -------------------
  245. -*- Extra Items -*-
  246. -------------------
  247.  
  248. From version 4.0 it is possible to add an unlimited number of items
  249. which can be purchased through the Extra Items menu. All you need
  250. to do is use the provided item registration natives on your custom
  251. plugins. You can set the name, the cost in ammo packs, and the team
  252. the extra item should be available for.
  253.  
  254. By default there is a number of items already included, listed here:
  255.  
  256. * Night Vision: makes you able to see in the dark for a single round [Human]
  257. * T-Virus Antidote: makes you turn back to your human form [Zombie]
  258. * Zombie Madness: you develop a powerful shield for a short time [Zombie]
  259. * Infection Bomb: infects anyone within its explosion radius [Zombie]
  260.  
  261. You are also able to choose some weapons to act as extra items, and change
  262. ammo packs costs in the customization file (zombieplague.ini).
  263.  
  264. ---------------
  265. -*- Credits -*-
  266. ---------------
  267.  
  268. * AMXX Dev Team: for all the hard work which made this possible
  269. * Imperio LNJ Community: for providing the first server where I
  270. could really test the plugin and for everyone's support
  271. * Mini_Midget: for his Zombie Swarm plugin which I used for reference
  272. on earliest stages of development
  273. * Avalanche: for the random spawning code I got from GunGame and the
  274. original Frostnades concept that I ported in here
  275. * cheap_suit: for some modelchange and knockback codes that I got from
  276. Biohazard
  277. * Simon Logic/ConnorMcLeod: for the Pain Shock Free feature
  278. * KRoT@L: for some code from Follow the Wounded, used to make the zombie
  279. bleeding feature
  280. * VEN: for Fakemeta Utilities and some useful stocks
  281. * RaaPuar and Goltark: for the custom grenade models
  282. * Orangutanz: for finding the precached modelindex offset
  283. * ML Translations: DKs/nunoabc/DarkMarcos (bp), JahMan/KWo (pl), DA (de),
  284. Zombie Lurker (ls), DoPe^ (da), k1nny (fr), NeWbiE' (cz), skymoon (tc),
  285. SUPER MATRIX/Shidla/zDemon/4eRT (ru), zsy314 (cine), lOlIl/Seehank (sk),
  286. Bridgestone (sv), crazyeffect.net/Mave/Wesley (nl), hleV/aaarnas (lt),
  287. darkbad945 (bg), decongamco (vn), beckham9224 (mine), TehGeorge (gr),
  288. shadoww_ro/tuty/georgik57/EastSider (ro)
  289. * Beta testers: for all the feedback, bug reports, and suggestions which
  290. constantly help improve this mod further
  291. * And to all zombie-mod supporters out there!
  292.  
  293. -----------------
  294. -*- Changelog -*-
  295. -----------------
  296.  
  297. * v1.0: (Dec 2007)
  298. - First Release: most of the basic stuff done.
  299. - Added: random spawning, HP display on hud, lighting setting,
  300. simple buy menu, custom nightvision, admin commands, Nemesis
  301. and Survivor modes, glow and leap settings for them.
  302.  
  303. * v2.2: (Jan 2008)
  304. - Added: zombie classes, ammo packs system, buying ammo for weapons,
  305. custom flashlight, admin skins setting, zombieplague.cfg file
  306. - Upgraded: weapons menu improved, flashlight and nightvision colors
  307. now customizable, HamSandwich module used to handle damage.
  308. - Fixed various bugs.
  309.  
  310. * v3.0: (Mar 2008)
  311. - Added: door removal setting, unstuck feature, human cvars, armor
  312. cvar for zombies, weapon knockback, zombie bleeding, flares,
  313. extra items (weapons, antidote, infection bomb), pain shock
  314. free setting, Multiple Infection and Swarm modes.
  315. - Upgraded: dumped Engine, Fun and Cstrike modules, code optimized,
  316. new model change method, new gfx effects for zombie infections.
  317. - Fixed a bunch of gameplay bugs.
  318.  
  319. * v3.5: (May 2008)
  320. - Added: deathmatch setting with spawn protection, unlimited ammo
  321. setting, fire and frost grenades, additional customization cvars,
  322. new extra items, help menu.
  323. - Upgraded: better objectives removal method, dropped weapons now
  324. keep their bpammo, code optimized a lot.
  325. - Fixed: no more game commencing bug when last zombie/human leaves,
  326. no more hegrenade infection bug, reduced svc_bad errors, and
  327. many more.
  328.  
  329. * v3.6: (Jun 2008)
  330. - Added: a few natives and forwards for sub-plugins support,
  331. zombie classes can now have their own models, additional
  332. knockback customization, bot support, various CVARs.
  333. - Upgraded: extra items now supporting grenades and pistols, changed
  334. bomb removal method, players can join on survivor/swarm rounds,
  335. extended lightnings support to other dark settings.
  336. - Fixed: a bunch of minor bugs, and a server crash with CZ bots.
  337.  
  338. * v4.0: (Aug 2008)
  339. - Added: new gameplay mode (Plague Mode), option to remember weapon
  340. selection, command to enable/disable the plugin, more CVARs.
  341. - Upgraded: redid all the menus, extra items and zombie classes now
  342. support external additions, survivor can now have its own model,
  343. upgraded model changing method.
  344. - Fixed: some bugs with bots, win sounds not being precached.
  345.  
  346. * v4.1: (Oct 2008)
  347. - Added: more CVARs, more customization, more natives, custom
  348. leap system, admin zombie models support, and more.
  349. - Upgraded: custom grenades compatible with Nade Modes, ambience
  350. sounds specific game mode support, optimized bandwidth usage
  351. for temp ents, admin commands logged with IP and SteamID.
  352. - Fixed: lots of bugs (some minor, some not)
  353.  
  354. * v4.2: (Feb 2009)
  355. - Added various CVARs for customization, improved prevention of
  356. svc_bad in some cases, optimized ammo handling code.
  357. - Fixed server crash with 'msg 35 has not been sent yet' error,
  358. fixed client overflow issues with ambience sounds, resolved
  359. many gameplay bugs.
  360.  
  361. * v4.3: (Apr 2009)
  362. - Customization settings can now be edited through external files,
  363. added support for global and multiple random zombie models,
  364. added even more CVARs for tweaking stuff, extended admin commands'
  365. functionality, greatly extended API capabilities, implemented a
  366. more efficient Pain Shock Free code, reworked some menus.
  367. - Fixed pretty much all reported bugs to the date.
  368.  
  369. =================================================================================*/
  370.  
  371. new cvar_armageddonchance;
  372. new cvar_armageddon;
  373. new cvar_armageddonminplayers;
  374. new cvar_allowrespawnarmageddon;
  375.  
  376. new cvar_avschance;
  377. new cvar_avs;
  378. new cvar_avsminplayers;
  379. new cvar_allowrespawnavs;
  380.  
  381. /*================================================================================
  382. [Plugin Customization]
  383. =================================================================================*/
  384.  
  385. // All customization settings have been moved
  386. // to external files to allow easier editing
  387. new const ZP_CUSTOMIZATION_FILE[] = "zombieplague.ini"
  388. new const ZP_EXTRAITEMS_FILE[] = "zp_extraitems.ini"
  389. new const ZP_ZOMBIECLASSES_FILE[] = "zp_zombieclasses.ini"
  390.  
  391. // Limiters for stuff not worth making dynamic arrays out of (increase if needed)
  392. // Hattrick
  393. //
  394. //const MAX_CSDM_SPAWNS = 128
  395. //const MAX_STATS_SAVED = 64
  396. const MAX_CSDM_SPAWNS = 256
  397. const MAX_STATS_SAVED = 512
  398.  
  399. /*================================================================================
  400. Customization ends here! Yes, that's it. Editing anything beyond
  401. here is not officially supported. Proceed at your own risk...
  402. =================================================================================*/
  403.  
  404. #include <amxmodx>
  405. #include <amxmisc>
  406. #include <cstrike>
  407. #include <fakemeta>
  408. #include <hamsandwich>
  409.  
  410. // Hattrick
  411. //
  412. //#include license
  413. #include <nvault>
  414. #include <geoip>
  415. #include <fun>
  416. #include <engine>
  417.  
  418. #include hatt_ei
  419.  
  420. #include <xs>
  421.  
  422. #if AMXX_VERSION_NUM <= 182
  423. #include <dhudmessage>
  424. #endif
  425.  
  426. /*================================================================================
  427. [Constants, Offsets, Macros]
  428. =================================================================================*/
  429.  
  430. // Plugin Version
  431. // Hattrick
  432. //
  433. // new const PLUGIN_VERSION[] = "4.3 Fix5a"
  434. new const PLUGIN_VERSION[] = "6.3"
  435.  
  436. // Customization file sections
  437. enum
  438. {
  439. SECTION_NONE = 0,
  440. SECTION_ACCESS_FLAGS,
  441. SECTION_PLAYER_MODELS,
  442. SECTION_WEAPON_MODELS,
  443. SECTION_GRENADE_SPRITES,
  444. SECTION_SOUNDS,
  445. SECTION_AMBIENCE_SOUNDS,
  446. SECTION_BUY_MENU_WEAPONS,
  447. SECTION_EXTRA_ITEMS_WEAPONS,
  448. SECTION_HARD_CODED_ITEMS_COSTS,
  449. SECTION_WEATHER_EFFECTS,
  450. SECTION_SKY,
  451. SECTION_LIGHTNING,
  452. SECTION_ZOMBIE_DECALS,
  453. SECTION_KNOCKBACK,
  454. SECTION_OBJECTIVE_ENTS,
  455. SECTION_SVC_BAD
  456. }
  457.  
  458. // Access flags
  459. enum
  460. {
  461. ACCESS_ENABLE_MOD = 0,
  462. ACCESS_ADMIN_MENU,
  463. ACCESS_MODE_INFECTION,
  464. ACCESS_MODE_NEMESIS,
  465. // Hattrick
  466. //
  467. ACCESS_MODE_ASSASSIN,
  468. ACCESS_MODE_SURVIVOR,
  469.  
  470. // Hattrick
  471. //
  472. ACCESS_GIVE_POINTS,
  473. ACCESS_GIVE_AMMO,
  474. ACCESS_MODE_AVS,
  475. ACCESS_MODE_ARMAGEDDON,
  476.  
  477. // Hattrick
  478. //
  479. ACCESS_MODE_SNIPER,
  480. ACCESS_MODE_SWARM,
  481. ACCESS_MODE_MULTI,
  482. ACCESS_MODE_PLAGUE,
  483. ACCESS_MAKE_ZOMBIE,
  484. ACCESS_MAKE_HUMAN,
  485. ACCESS_MAKE_NEMESIS,
  486. // Hattrick
  487. //
  488. ACCESS_MAKE_ASSASSIN,
  489. ACCESS_MAKE_SURVIVOR,
  490. // Hattrick
  491. //
  492. ACCESS_MAKE_SNIPER,
  493. ACCESS_RESPAWN_PLAYERS,
  494. ACCESS_ADMIN_MODELS,
  495. MAX_ACCESS_FLAGS
  496. }
  497.  
  498. // Task offsets
  499. enum (+= 100)
  500. {
  501. TASK_MODEL = 2000,
  502. TASK_TEAM,
  503. TASK_SPAWN,
  504. TASK_BLOOD,
  505. TASK_AURA,
  506. TASK_BURN,
  507. TASK_NVISION,
  508. TASK_FLASH,
  509. TASK_CHARGE,
  510. TASK_SHOWHUD,
  511. TASK_MAKEZOMBIE,
  512. TASK_WELCOMEMSG,
  513. TASK_THUNDER_PRE,
  514. TASK_THUNDER,
  515. TASK_AMBIENCESOUNDS
  516. }
  517.  
  518. // IDs inside tasks
  519. #define ID_MODEL (taskid - TASK_MODEL)
  520. #define ID_TEAM (taskid - TASK_TEAM)
  521. #define ID_SPAWN (taskid - TASK_SPAWN)
  522. #define ID_BLOOD (taskid - TASK_BLOOD)
  523. #define ID_AURA (taskid - TASK_AURA)
  524. #define ID_BURN (taskid - TASK_BURN)
  525. #define ID_NVISION (taskid - TASK_NVISION)
  526. #define ID_FLASH (taskid - TASK_FLASH)
  527. #define ID_CHARGE (taskid - TASK_CHARGE)
  528. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  529.  
  530. // BP Ammo Refill task
  531. #define REFILL_WEAPONID args[0]
  532.  
  533. // For weapon buy menu handlers
  534. #define WPN_STARTID g_menu_data[id][1]
  535. #define WPN_MAXIDS ArraySize(g_primary_items)
  536. #define WPN_SELECTION (g_menu_data[id][1]+key)
  537. #define WPN_AUTO_ON g_menu_data[id][2]
  538. #define WPN_AUTO_PRI g_menu_data[id][3]
  539. #define WPN_AUTO_SEC g_menu_data[id][4]
  540.  
  541. // For player list menu handlers
  542. #define PL_ACTION g_menu_data[id][0]
  543.  
  544. // For remembering menu pages
  545. #define MENU_PAGE_ZCLASS g_menu_data[id][5]
  546. #define MENU_PAGE_EXTRAS g_menu_data[id][6]
  547. #define MENU_PAGE_PLAYERS g_menu_data[id][7]
  548.  
  549. // For extra items menu handlers
  550. #define EXTRAS_CUSTOM_STARTID (EXTRA_WEAPONS_STARTID + ArraySize(g_extraweapon_names))
  551.  
  552. // Menu selections
  553. const MENU_KEY_AUTOSELECT = 7
  554. const MENU_KEY_BACK = 7
  555. const MENU_KEY_NEXT = 8
  556. const MENU_KEY_EXIT = 9
  557.  
  558. // Hard coded extra items
  559. enum
  560. {
  561. EXTRA_NVISION = 0,
  562. EXTRA_ANTIDOTE,
  563. EXTRA_MADNESS,
  564. EXTRA_INFBOMB,
  565. EXTRA_WEAPONS_STARTID
  566. }
  567.  
  568. // Game modes
  569. enum
  570. {
  571. MODE_NONE = 0,
  572. MODE_INFECTION,
  573. MODE_NEMESIS,
  574. MODE_SURVIVOR,
  575. MODE_SWARM,
  576. MODE_MULTI,
  577. MODE_PLAGUE,
  578. // Hattrick
  579. //
  580. MODE_SNIPER,
  581. MODE_ASSASSIN,
  582. MODE_AVS,
  583. MODE_ARMAGEDDON
  584. }
  585.  
  586. // ZP Teams
  587. const ZP_TEAM_NO_ONE = 0
  588. const ZP_TEAM_ANY = 0
  589. const ZP_TEAM_ZOMBIE = (1<<0)
  590. const ZP_TEAM_HUMAN = (1<<1)
  591. const ZP_TEAM_NEMESIS = (1<<2)
  592. const ZP_TEAM_SURVIVOR = (1<<3)
  593. // Hattrick
  594. //
  595. const ZP_TEAM_SNIPER = (1<<4)
  596. const ZP_TEAM_ASSASSIN = (1<<5)
  597.  
  598. // Hattrick
  599. //
  600. //new const ZP_TEAM_NAMES[][] = { "ZOMBIE , HUMAN", "ZOMBIE", "HUMAN", "ZOMBIE , HUMAN", "NEMESIS",
  601. // "ZOMBIE , NEMESIS", "HUMAN , NEMESIS", "ZOMBIE , HUMAN , NEMESIS",
  602. // "SURVIVOR", "ZOMBIE , SURVIVOR", "HUMAN , SURVIVOR", "ZOMBIE , HUMAN , SURVIVOR",
  603. //"NEMESIS , SURVIVOR", "ZOMBIE , NEMESIS , SURVIVOR", "HUMAN, NEMESIS, SURVIVOR",
  604. //"ZOMBIE , HUMAN , NEMESIS , SURVIVOR" }
  605.  
  606. new const ZP_TEAM_NAMES[][] =
  607. {
  608. "ZOMBIE , HUMAN",
  609. "ZOMBIE",
  610. "HUMAN",
  611. "ZOMBIE , HUMAN",
  612. "NEMESIS",
  613. "ZOMBIE , NEMESIS",
  614. "HUMAN , NEMESIS",
  615. "ZOMBIE , HUMAN , NEMESIS",
  616. "SURVIVOR",
  617. "ZOMBIE , SURVIVOR",
  618. "HUMAN , SURVIVOR",
  619. "ZOMBIE, HUMAN, SURVIVOR",
  620. "NEMESIS , SURVIVOR",
  621. "ZOMBIE , NEMESIS , SURVIVOR",
  622. "HUMAN, NEMESIS, SURVIVOR",
  623. "ZOMBIE , HUMAN , NEMESIS , SURVIVOR",
  624. "SNIPER",
  625. "ZOMBIE, SNIPER",
  626. "HUMAN, SNIPER",
  627. "ZOMBIE, HUMAN, SNIPER",
  628. "NEMESIS , SNIPER",
  629. "ZOMBIE , NEMESIS , SNIPER",
  630. "HUMAN , NEMESIS , SNIPER",
  631. "ZOMBIE , HUMAN , NEMESIS , SNIPER",
  632. "SURVIVOR, SNIPER",
  633. "ZOMBIE, SURVIVOR, SNIPER",
  634. "HUMAN, SURVIVOR, SNIPER",
  635. "ZOMBIE, HUMAN, SURVIVOR, SNIPER",
  636. "NEMESIS, SURVIVOR, SNIPER",
  637. "ZOMBIE, NEMESIS, SURVIVOR, SNIPER",
  638. "HUMAN, NEMESIS, SURVIVOR, SNIPER",
  639. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, SNIPER",
  640. "ASSASSIN",
  641. "ZOMBIE, ASSASSIN",
  642. "HUMAN, ASSASSIN",
  643. "ZOMBIE, HUMAN, ASSASSIN",
  644. "NEMESIS, ASSASSIN",
  645. "ZOMBIE, NEMESIS, ASSASSIN",
  646. "HUMAN, NEMESIS, ASSASSIN",
  647. "ZOMBIE, HUMAN, NEMESIS, ASSASSIN",
  648. "SURVIVOR, ASSASSIN",
  649. "ZOMBIE, SURVIVOR, ASSASSIN",
  650. "HUMAN, SURVIVOR, ASSASSIN",
  651. "ZOMBIE, HUMAN, SURVIVOR, ASSASSIN",
  652. "NEMESIS, SURVIVOR, ASSASSIN",
  653. "ZOMBIE, NEMESIS, SURVIVOR, ASSASSIN",
  654. "HUMAN, NEMESIS, SURVIVOR, ASSASSIN",
  655. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, ASSASSIN",
  656. "SNIPER, ASSASSIN",
  657. "ZOMBIE, SNIPER, ASSASSIN",
  658. "HUMAN, SNIPER, ASSASSIN",
  659. "ZOMBIE, HUMAN, SNIPER, ASSASSIN",
  660. "NEMESIS, SNIPER, ASSASSIN",
  661. "ZOMBIE, NEMESIS, SNIPER, ASSASSIN",
  662. "HUMAN, NEMESIS, SNIPER, ASSASSIN",
  663. "ZOMBIE, HUMAN, NEMESIS, SNIPER, ASSASSIN",
  664. "SURVIVOR, SNIPER, ASSASSIN",
  665. "ZOMBIE, SURVIVOR, SNIPER, ASSASSIN",
  666. "HUMAN, SURVIVOR, SNIPER, ASSASSIN",
  667. "ZOMBIE, HUMAN, SURVIVOR, SNIPER, ASSASSIN",
  668. "NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  669. "ZOMBIE, NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  670. "HUMAN, NEMESIS, SURVIVOR, SNIPER, ASSASSIN",
  671. "ZOMBIE, HUMAN, NEMESIS, SURVIVOR, SNIPER, ASSASSIN"
  672. }
  673.  
  674. // Zombie classes
  675. const ZCLASS_NONE = -1
  676.  
  677. // HUD messages
  678. const Float:HUD_EVENT_X = -1.0
  679. const Float:HUD_EVENT_Y = 0.17
  680. const Float:HUD_INFECT_X = 0.05
  681. const Float:HUD_INFECT_Y = 0.45
  682. // Hattrick
  683. //
  684. //const Float:HUD_SPECT_X = 0.6
  685. //const Float:HUD_SPECT_Y = 0.8
  686.  
  687. const Float:HUD_SPECT_X = 0.6 // -1.0
  688. const Float:HUD_SPECT_Y = 0.8
  689.  
  690. const Float:HUD_STATS_X = 0.02
  691. const Float:HUD_STATS_Y = 0.9
  692.  
  693. // Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
  694. new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
  695.  
  696. // CS Player PData Offsets (win32)
  697. const PDATA_SAFE = 2
  698. const OFFSET_PAINSHOCK = 108 // ConnorMcLeod
  699. const OFFSET_CSTEAMS = 114
  700. const OFFSET_CSMONEY = 115
  701. const OFFSET_CSMENUCODE = 205
  702. const OFFSET_FLASHLIGHT_BATTERY = 244
  703. const OFFSET_CSDEATHS = 444
  704. const OFFSET_MODELINDEX = 491 // Orangutanz
  705.  
  706. // CS Player CBase Offsets (win32)
  707. const OFFSET_ACTIVE_ITEM = 373
  708.  
  709. // CS Weapon CBase Offsets (win32)
  710. const OFFSET_WEAPONOWNER = 41
  711.  
  712. // Linux diff's
  713. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  714. const OFFSET_LINUX_WEAPONS = 4 // weapon offsets are only 4 steps higher on Linux
  715.  
  716. // CS Teams
  717. enum
  718. {
  719. FM_CS_TEAM_UNASSIGNED = 0,
  720. FM_CS_TEAM_T,
  721. FM_CS_TEAM_CT,
  722. FM_CS_TEAM_SPECTATOR
  723. }
  724. new const CS_TEAM_NAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
  725.  
  726. // Some constants
  727. const HIDE_MONEY = (1<<5)
  728. const UNIT_SECOND = (1<<12)
  729. const DMG_HEGRENADE = (1<<24)
  730. const IMPULSE_FLASHLIGHT = 100
  731. const USE_USING = 2
  732. const USE_STOPPED = 0
  733. const STEPTIME_SILENT = 999
  734. const BREAK_GLASS = 0x01
  735. const FFADE_IN = 0x0000
  736. const FFADE_STAYOUT = 0x0004
  737. const PEV_SPEC_TARGET = pev_iuser2
  738.  
  739. // Max BP ammo for weapons
  740. new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
  741. 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }
  742.  
  743. // Max Clip for weapons
  744. new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
  745. 10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 }
  746.  
  747. // Amount of ammo to give when buying additional clips for weapons
  748. new const BUYAMMO[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
  749. 10, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }
  750.  
  751. // Ammo IDs for weapons
  752. new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
  753. 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }
  754.  
  755. // Ammo Type Names for weapons
  756. new const AMMOTYPE[][] = { "", "357sig", "", "762nato", "", "buckshot", "", "45acp", "556nato", "", "9mm", "57mm", "45acp",
  757. "556nato", "556nato", "556nato", "45acp", "9mm", "338magnum", "9mm", "556natobox", "buckshot",
  758. "556nato", "9mm", "762nato", "", "50ae", "556nato", "762nato", "", "57mm" }
  759.  
  760. // Weapon IDs for ammo types
  761. new const AMMOWEAPON[] = { 0, CSW_AWP, CSW_SCOUT, CSW_M249, CSW_AUG, CSW_XM1014, CSW_MAC10, CSW_FIVESEVEN, CSW_DEAGLE,
  762. CSW_P228, CSW_ELITE, CSW_FLASHBANG, CSW_HEGRENADE, CSW_SMOKEGRENADE, CSW_C4 }
  763.  
  764. // Primary and Secondary Weapon Names
  765. new const WEAPONNAMES[][] = { "", "P228 Compact", "", "Schmidt Scout", "", "XM1014 M4", "", "Ingram MAC-10", "Steyr AUG A1",
  766. "", "Dual Elite Berettas", "FiveseveN", "UMP 45", "SG-550 Auto-Sniper", "IMI Galil", "Famas",
  767. "USP .45 ACP Tactical", "Glock 18C", "AWP Magnum Sniper", "MP5 Navy", "M249 Para Machinegun",
  768. "M3 Super 90", "M4A1 Carbine", "Schmidt TMP", "G3SG1 Auto-Sniper", "", "Desert Eagle .50 AE",
  769. "SG-552 Commando", "AK-47 Kalashnikov", "", "ES P90" }
  770.  
  771. // Weapon entity names
  772. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  773. "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  774. "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  775. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  776. "weapon_ak47", "weapon_knife", "weapon_p90" }
  777.  
  778. // CS sounds
  779. new const sound_flashlight[] = "items/flashlight1.wav"
  780. new const sound_buyammo[] = "items/9mmclip1.wav"
  781. new const sound_armorhit[] = "player/bhit_helmet-1.wav"
  782.  
  783. // Explosion radius for custom grenades
  784. const Float:NADE_EXPLOSION_RADIUS = 240.0
  785.  
  786. // HACK: pev_ field used to store additional ammo on weapons
  787. const PEV_ADDITIONAL_AMMO = pev_iuser1
  788.  
  789. // HACK: pev_ field used to store custom nade types and their values
  790. const PEV_NADE_TYPE = pev_flTimeStepSound
  791. const NADE_TYPE_INFECTION = 1111
  792. const NADE_TYPE_NAPALM = 2222
  793. const NADE_TYPE_FROST = 3333
  794. const NADE_TYPE_FLARE = 4444
  795. // Hattrick
  796. //
  797. //const PEV_FLARE_COLOR = pev_punchangle
  798. //const PEV_FLARE_DURATION = pev_flSwimTime
  799.  
  800. // Weapon bitsums
  801. 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)
  802. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  803.  
  804. // Allowed weapons for zombies (added grenades/bomb for sub-plugin support, since they shouldn't be getting them anyway)
  805. const ZOMBIE_ALLOWED_WEAPONS_BITSUM = (1<<CSW_KNIFE)|(1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_C4)
  806.  
  807. // Classnames for separate model entities
  808. new const MODEL_ENT_CLASSNAME[] = "player_model"
  809. new const WEAPON_ENT_CLASSNAME[] = "weapon_model"
  810.  
  811. // Menu keys
  812. 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
  813.  
  814. // Ambience Sounds
  815. enum
  816. {
  817. AMBIENCE_SOUNDS_INFECTION = 0,
  818. AMBIENCE_SOUNDS_NEMESIS,
  819. AMBIENCE_SOUNDS_SURVIVOR,
  820. // Hattrick
  821. //
  822. AMBIENCE_SOUNDS_SNIPER,
  823. AMBIENCE_SOUNDS_ASSASSIN,
  824.  
  825. AMBIENCE_SOUNDS_SWARM,
  826. AMBIENCE_SOUNDS_PLAGUE,
  827. MAX_AMBIENCE_SOUNDS
  828. }
  829.  
  830. // Admin menu actions
  831. enum
  832. {
  833. ACTION_ZOMBIEFY_HUMANIZE = 0,
  834. ACTION_MAKE_NEMESIS,
  835. ACTION_MAKE_SURVIVOR,
  836. ACTION_RESPAWN_PLAYER,
  837. ACTION_MODE_SWARM,
  838. ACTION_MODE_MULTI,
  839.  
  840. // Hattrick
  841. //
  842. //ACTION_MODE_PLAGUE
  843.  
  844. ACTION_MODE_PLAGUE,
  845.  
  846. ACTION_MAKE_ASSASSIN,
  847. ACTION_MAKE_SNIPER
  848. }
  849.  
  850. // Custom forward return values
  851. const ZP_PLUGIN_HANDLED = 97
  852.  
  853. /*================================================================================
  854. [Global Variables]
  855. =================================================================================*/
  856.  
  857. // Player vars
  858. new g_zombie[33] // is zombie
  859. new g_nemesis[33] // is nemesis
  860. new g_survivor[33] // is survivor
  861.  
  862. // Hattrick
  863. //
  864. new g_sniper[33]
  865. new g_assassin[33]
  866.  
  867. new g_firstzombie[33] // is first zombie
  868. new g_lastzombie[33] // is last zombie
  869. new g_lasthuman[33] // is last human
  870. new g_frozen[33] // is frozen (can't move)
  871. new Float:g_frozen_gravity[33] // store previous gravity when frozen
  872. new g_nodamage[33] // has spawn protection/zombie madness
  873. new g_respawn_as_zombie[33] // should respawn as zombie
  874. new g_nvision[33] // has night vision
  875. new g_nvisionenabled[33] // has night vision turned on
  876. new g_zombieclass[33] // zombie class
  877. new g_zombieclassnext[33] // zombie class for next infection
  878. new g_flashlight[33] // has custom flashlight turned on
  879. new g_flashbattery[33] = { 100, ... } // custom flashlight battery
  880. new g_canbuy[33] // is allowed to buy a new weapon through the menu
  881. new g_ammopacks[33] // ammo pack count
  882. new g_damagedealt_human[33] // damage dealt as human (used to calculate ammo packs reward)
  883. new g_damagedealt_zombie[33] // damage dealt as zombie (used to calculate ammo packs reward)
  884. new Float:g_lastleaptime[33] // time leap was last used
  885. new Float:g_lastflashtime[33] // time flashlight was last toggled
  886. new g_playermodel[33][32] // current model's short name [player][model]
  887. new g_menu_data[33][8] // data for some menu handlers
  888. new g_ent_playermodel[33] // player model entity
  889. new g_ent_weaponmodel[33] // weapon model entity
  890. new g_burning_duration[33] // burning task duration
  891. new Float:g_buytime[33] // used to calculate custom buytime
  892.  
  893. // Hattrick
  894. //
  895. new g_country[33][64]
  896. new g_doubledamage[33]
  897. new g_city[33][64]
  898. new g_points[33]
  899. new g_ip[33][64]
  900. new g_steam[33][64]
  901.  
  902. // Game vars
  903. new g_pluginenabled // ZP enabled
  904. new g_newround // new round starting
  905. new g_endround // round ended
  906. new g_nemround // nemesis round
  907.  
  908. // Hattrick
  909. //
  910. new g_sniperround
  911. new g_assassinround
  912.  
  913. new Array:g_vname, Array:g_vflags, Array:g_vpwd;
  914. new bool:g_vip[33], g_vip_flags[33][32]
  915.  
  916. new g_armageddonround
  917. new g_avsround
  918. new g_survround // survivor round
  919. new g_swarmround // swarm round
  920. new g_plagueround // plague round
  921. new g_modestarted // mode fully started
  922. new g_lastmode // last played mode
  923. new g_scorezombies, g_scorehumans, g_gamecommencing // team scores
  924. new g_spawnCount, g_spawnCount2 // available spawn points counter
  925. new Float:g_spawns[MAX_CSDM_SPAWNS][3], Float:g_spawns2[MAX_CSDM_SPAWNS][3] // spawn points data
  926. new g_lights_i // lightning current lights counter
  927. new g_lights_cycle[32] // current lightning cycle
  928. new g_lights_cycle_len // lightning cycle length
  929. new Float:g_models_targettime // for adding delays between Model Change messages
  930. new Float:g_teams_targettime // for adding delays between Team Change messages
  931. new g_MsgSync, g_MsgSync2, g_MsgSync3 // message sync objects
  932. new g_trailSpr, g_exploSpr, g_flameSpr, g_smokeSpr, g_glassSpr // grenade sprites
  933. new g_modname[32] // for formatting the mod name
  934. new g_freezetime // whether CS's freeze time is on
  935. new g_maxplayers // max players counter
  936. new g_czero // whether we are running on a CZ server
  937. new g_hamczbots // whether ham forwards are registered for CZ bots
  938. new g_fwSpawn, g_fwPrecacheSound // spawn and precache sound forward handles
  939. new g_infbombcounter, g_antidotecounter, g_madnesscounter // to limit buying some items
  940. new g_arrays_created // to prevent stuff from being registered before initializing arrays
  941. new g_lastplayerleaving // flag for whenever a player leaves and another takes his place
  942. new g_switchingteam // flag for whenever a player's team change emessage is sent
  943. new g_buyzone_ent // custom buyzone entity
  944.  
  945. // Hattrick
  946. //
  947. new g_vault=INVALID_HANDLE;
  948.  
  949. // Message IDs vars
  950. new g_msgScoreInfo, g_msgNVGToggle, g_msgScoreAttrib, g_msgAmmoPickup, g_msgScreenFade,
  951. g_msgDeathMsg, g_msgSetFOV, g_msgFlashlight, g_msgFlashBat, g_msgTeamInfo, g_msgDamage,
  952. g_msgHideWeapon, g_msgCrosshair, g_msgSayText, g_msgScreenShake, g_msgCurWeapon
  953.  
  954. // Some forward handlers
  955. new g_fwRoundStart, g_fwRoundEnd, g_fwUserInfected_pre, g_fwUserInfected_post,
  956. g_fwUserHumanized_pre, g_fwUserHumanized_post, g_fwUserInfect_attempt,
  957. g_fwUserHumanize_attempt, g_fwExtraItemSelected, g_fwUserUnfrozen,
  958. g_fwUserLastZombie, g_fwUserLastHuman, g_fwDummyResult
  959.  
  960. // Temporary Database vars (used to restore players stats in case they get disconnected)
  961. new db_name[MAX_STATS_SAVED][32] // player name
  962. new db_ammopacks[MAX_STATS_SAVED] // ammo pack count
  963. new db_zombieclass[MAX_STATS_SAVED] // zombie class
  964. new db_slot_i // additional saved slots counter (should start on maxplayers+1)
  965.  
  966. // Extra Items vars
  967. new Array:g_extraitem_name // caption
  968. new Array:g_extraitem_cost // cost
  969. new Array:g_extraitem_team // team
  970. new g_extraitem_i // loaded extra items counter
  971.  
  972. // For extra items file parsing
  973. new Array:g_extraitem2_realname, Array:g_extraitem2_name, Array:g_extraitem2_cost,
  974. Array:g_extraitem2_team, Array:g_extraitem_new
  975.  
  976. // Zombie Classes vars
  977. new Array:g_zclass_name // caption
  978. new Array:g_zclass_info // description
  979. new Array:g_zclass_modelsstart // start position in models array
  980. new Array:g_zclass_modelsend // end position in models array
  981. new Array:g_zclass_playermodel // player models array
  982. new Array:g_zclass_modelindex // model indices array
  983. new Array:g_zclass_clawmodel // claw model
  984. new Array:g_zclass_hp // health
  985. new Array:g_zclass_spd // speed
  986. new Array:g_zclass_grav // gravity
  987. new Array:g_zclass_kb // knockback
  988. new g_zclass_i // loaded zombie classes counter
  989.  
  990. // For zombie classes file parsing
  991. new Array:g_zclass2_realname, Array:g_zclass2_name, Array:g_zclass2_info,
  992. Array:g_zclass2_modelsstart, Array:g_zclass2_modelsend, Array:g_zclass2_playermodel,
  993. Array:g_zclass2_modelindex, Array:g_zclass2_clawmodel, Array:g_zclass2_hp,
  994. Array:g_zclass2_spd, Array:g_zclass2_grav, Array:g_zclass2_kb, Array:g_zclass_new, g_iLaser
  995.  
  996. // Customization vars
  997. new g_access_flag[MAX_ACCESS_FLAGS], Array:model_nemesis, Array:model_survivor, Array:model_human, /* HATTRICK */ Array:model_assassin, Array:model_sniper,
  998. Array:model_admin_zombie, Array:model_admin_human, Array:model_vip, Array:g_modelindex_human, /* HATTRICK */ Array:g_modelindex_sniper, Array:g_modelindex_assassin,
  999. Array:g_modelindex_nemesis, Array:g_modelindex_survivor, g_same_models_for_all, Array:g_modelindex_vip,
  1000. Array:g_modelindex_admin_zombie, Array:g_modelindex_admin_human, model_vknife_human[64],
  1001. model_vknife_nemesis[64], /*HATTRICK model_vweapon_survivor[64], */ model_grenade_infect[64], /* HATTRICK */ model_vknife_assassin[64], model_pawp_sniper[64], model_vawp_sniper[64],
  1002. model_grenade_fire[64], model_grenade_frost[64], model_grenade_flare[64],
  1003. model_vknife_admin_human[64], model_vknife_admin_zombie[64],
  1004. sprite_grenade_trail[64], sprite_grenade_ring[64], sprite_grenade_fire[64],
  1005. sprite_grenade_smoke[64], sprite_grenade_glass[64], Array:sound_win_zombies,
  1006. Array:sound_win_humans, Array:sound_win_no_one, Array:sound_win_zombies_ismp3,
  1007. Array:sound_win_humans_ismp3, Array:sound_win_no_one_ismp3, Array:zombie_infect,
  1008. Array:zombie_idle, Array:zombie_pain, Array:nemesis_pain, Array:zombie_die, Array:zombie_fall, /* HATTRICK */ Array:assassin_pain,
  1009. Array:zombie_miss_wall, Array:zombie_hit_normal, Array:zombie_hit_stab, g_ambience_rain,
  1010. Array:zombie_idle_last, Array:zombie_madness, Array:sound_nemesis, Array:sound_survivor, /* Hattrick */ Array:sound_sniper, Array:sound_assassin,
  1011. Array:sound_swarm, Array:sound_multi, Array:sound_plague, Array:grenade_infect,
  1012. Array:grenade_infect_player, Array:grenade_fire, Array:grenade_fire_player,
  1013. Array:grenade_frost, Array:grenade_frost_player, Array:grenade_frost_break,
  1014. /*HATTRICK Array:grenade_flare,*/ Array:sound_antidote, Array:sound_thunder, g_ambience_sounds[MAX_AMBIENCE_SOUNDS],
  1015. Array:sound_ambience1, Array:sound_ambience2, Array:sound_ambience3, Array:sound_ambience4,
  1016. Array:sound_ambience5, Array:sound_ambience1_duration, Array:sound_ambience2_duration,
  1017. Array:sound_ambience3_duration, Array:sound_ambience4_duration,
  1018. Array:sound_ambience5_duration, Array:sound_ambience1_ismp3, Array:sound_ambience2_ismp3,
  1019.  
  1020. // Hattrick
  1021. //
  1022. g_infector[33],
  1023. g_iEntityID[33],
  1024.  
  1025. Array:sound_ambience6, Array:sound_ambience7,
  1026. Array:sound_ambience6_duration, Array:sound_ambience7_duration,
  1027. Array:sound_ambience6_ismp3, Array:sound_ambience7_ismp3,
  1028.  
  1029. Array:sound_ambience3_ismp3, Array:sound_ambience4_ismp3, Array:sound_ambience5_ismp3,
  1030. Array:g_primary_items, Array:g_secondary_items, Array:g_additional_items,
  1031. Array:g_primary_weaponids, Array:g_secondary_weaponids, Array:g_extraweapon_names,
  1032. Array:g_extraweapon_items, Array:g_extraweapon_costs, g_extra_costs2[EXTRA_WEAPONS_STARTID],
  1033. g_ambience_snow, g_ambience_fog, g_fog_density[10], g_fog_color[12], g_sky_enable,
  1034. Array:g_sky_names, Array:lights_thunder, Array:zombie_decals, Array:g_objective_ents,
  1035. Float:g_modelchange_delay, g_set_modelindex_offset, g_handle_models_on_separate_ent,
  1036. Float:kb_weapon_power[31] = { -1.0, ... }, Array:zombie_miss_slash, g_force_consistency
  1037.  
  1038. // CVAR pointers
  1039. new cvar_lighting, cvar_zombiefov, cvar_plague, cvar_plaguechance, cvar_zombiefirsthp,
  1040. cvar_removemoney, cvar_thunder, cvar_zombiebonushp, cvar_nemhp, cvar_nem, cvar_surv,
  1041. cvar_nemchance, cvar_deathmatch, cvar_nemglow, cvar_customnvg, cvar_hitzones, cvar_humanhp,
  1042. cvar_nemgravity, cvar_flashsize, cvar_ammodamage_human, cvar_ammodamage_zombie,
  1043. cvar_zombiearmor, cvar_survpainfree, cvar_nempainfree, cvar_nemspd, cvar_survchance,
  1044. cvar_survhp, cvar_survspd, cvar_humanspd, cvar_swarmchance, cvar_flashdrain,
  1045. cvar_zombiebleeding, cvar_removedoors, cvar_customflash, cvar_randspawn, cvar_multi,
  1046. cvar_multichance, cvar_infammo, cvar_swarm, cvar_ammoinfect, cvar_toggle,
  1047. cvar_knockbackpower, cvar_freezeduration, cvar_triggered, cvar_flashcharge,
  1048. cvar_firegrenades, cvar_frostgrenades, cvar_survgravity, cvar_logcommands, cvar_survglow,
  1049. cvar_humangravity, cvar_spawnprotection, cvar_nvgsize, /* HATTRICK cvar_flareduration, */ cvar_zclasses,
  1050. cvar_extraitems, cvar_showactivity, cvar_humanlasthp, cvar_nemignorefrags, cvar_warmup,
  1051. cvar_flashdist, /* HATTRICK cvar_flarecolor, */ cvar_survignorefrags, cvar_fireduration, cvar_firedamage,
  1052. cvar_flaregrenades, cvar_knockbackducking, cvar_knockbackdamage, cvar_knockbackzvel,
  1053. cvar_multiratio, /* HATTRICK cvar_flaresize, */ cvar_spawndelay, cvar_extraantidote, cvar_extramadness,
  1054. cvar_extraweapons, cvar_extranvision, cvar_nvggive, cvar_preventconsecutive, cvar_botquota,
  1055. cvar_buycustom, cvar_zombiepainfree, cvar_fireslowdown, cvar_survbasehp, cvar_survaura,
  1056. cvar_nemignoreammo, cvar_survignoreammo, cvar_nemaura, cvar_extrainfbomb, cvar_knockback,
  1057. cvar_fragsinfect, cvar_fragskill, cvar_humanarmor, cvar_zombiesilent, cvar_removedropped,
  1058. cvar_plagueratio, cvar_blocksuicide, cvar_knockbackdist, cvar_nemdamage, cvar_leapzombies,
  1059. cvar_leapzombiesforce, cvar_leapzombiesheight, cvar_leapzombiescooldown, cvar_leapnemesis,
  1060. cvar_leapnemesisforce, cvar_leapnemesisheight, cvar_leapnemesiscooldown, cvar_leapsurvivor,
  1061. cvar_leapsurvivorforce, cvar_leapsurvivorheight, cvar_nemminplayers, cvar_survminplayers,
  1062. cvar_respawnonsuicide, cvar_respawnafterlast, cvar_leapsurvivorcooldown, cvar_statssave,
  1063. cvar_swarmminplayers, cvar_multiminplayers, cvar_plagueminplayers, cvar_adminmodelshuman,
  1064. cvar_adminmodelszombie, cvar_nembasehp, cvar_blockpushables, cvar_respawnworldspawnkill,
  1065. cvar_madnessduration, cvar_plaguenemnum, cvar_plaguenemhpmulti, cvar_plaguesurvhpmulti,
  1066. /*HATTRICK cvar_survweapon,*/ cvar_plaguesurvnum, cvar_infectionscreenfade, cvar_infectionscreenshake,
  1067. cvar_infectionsparkle, cvar_infectiontracers, cvar_infectionparticles, cvar_infbomblimit,
  1068. cvar_allowrespawnsurv, cvar_flashshowall, cvar_allowrespawninfection, cvar_allowrespawnnem,
  1069. cvar_allowrespawnswarm, cvar_allowrespawnplague, cvar_survinfammo, cvar_nemknockback,
  1070. cvar_nvgcolor[3], cvar_nemnvgcolor[3], cvar_humnvgcolor[3], cvar_flashcolor[3],
  1071. cvar_hudicons, cvar_respawnzomb, cvar_respawnhum, cvar_respawnnem, cvar_respawnsurv,
  1072. cvar_startammopacks, cvar_randweapons, cvar_antidotelimit, cvar_madnesslimit,
  1073. cvar_adminknifemodelshuman, cvar_adminknifemodelszombie, cvar_keephealthondisconnect,
  1074. cvar_buyzonetime, cvar_huddisplay , g_srvname , g_maxammo, cvar_menucustomcommand1
  1075.  
  1076. // Hattrick
  1077. //
  1078. new cvar_sniperinfammo,
  1079. cvar_assassinignorefrags,
  1080. cvar_assassinignoreammo,
  1081. cvar_respawnassassin,
  1082. cvar_damagewhilefrost,
  1083. cvar_sniperignoreammo,
  1084. cvar_sniperdamage,
  1085. cvar_assassindamage,
  1086. cvar_assassinpainfree,
  1087. cvar_sniperpainfree,
  1088. cvar_assassinknockback,
  1089.  
  1090. cvar_sniperignorefrags,
  1091. cvar_respawnsniper,
  1092.  
  1093. cvar_assassinnvgcolor[3],
  1094. cvar_assassinglow,
  1095. cvar_assassinaura,
  1096. cvar_assassinbasehp,
  1097. cvar_assassinhp, cvar_assassinspd, cvar_assassinminplayers,
  1098. cvar_assassingravity, cvar_assassinchance,
  1099.  
  1100. cvar_sniperaura,
  1101. cvar_sniperglow,
  1102. cvar_sniperhp,
  1103. cvar_sniperbasehp,
  1104. cvar_sniperchance,
  1105. cvar_sniperspd,
  1106. cvar_snipergravity,
  1107. cvar_sniperminplayers,
  1108.  
  1109. cvar_assassin,
  1110. cvar_sniper,
  1111.  
  1112. cvar_allowrespawnassassin,
  1113. cvar_allowrespawnsniper
  1114.  
  1115. // Hattrick
  1116. //
  1117. new g_zexplo;
  1118.  
  1119. // Cached stuff for players
  1120. new g_isconnected[33] // whether player is connected
  1121. new g_isalive[33] // whether player is alive
  1122. new g_isbot[33] // whether player is a bot
  1123. new g_currentweapon[33] // player's current weapon id
  1124. new g_playername[33][32] // player's name
  1125. new Float:g_zombie_spd[33] // zombie class speed
  1126. new Float:g_zombie_knockback[33] // zombie class knockback
  1127. new g_zombie_classname[33][32] // zombie class name
  1128. #define is_user_valid_connected(%1) (1 <= %1 <= g_maxplayers && g_isconnected[%1])
  1129. #define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && g_isalive[%1])
  1130. #define is_user_valid(%1) (1 <= %1 <= g_maxplayers)
  1131.  
  1132. // Cached CVARs
  1133. new g_cached_customflash, g_cached_zombiesilent, g_cached_leapzombies, g_cached_leapnemesis,
  1134. g_cached_leapsurvivor, Float:g_cached_leapzombiescooldown, Float:g_cached_leapnemesiscooldown,
  1135. Float:g_cached_leapsurvivorcooldown, Float:g_cached_buytime,
  1136.  
  1137. // Hattrick
  1138. //
  1139. g_cached_leapassassin, Float: g_cached_leapassassincooldown,
  1140. g_cached_leapsniper, Float: g_cached_leapsnipercooldown,
  1141.  
  1142. jumpnum[33] = 0,
  1143. bool:dojump[33] = false,
  1144.  
  1145. cvar_leapsniperforce, cvar_leapsniperheight, cvar_leapsniper,
  1146. cvar_leapassassinforce, cvar_leapassassincooldown, cvar_leapsnipercooldown, cvar_leapassassin,
  1147. cvar_leapassassinheight
  1148.  
  1149. /*================================================================================
  1150. [Natives, Precache and Init]
  1151. =================================================================================*/
  1152.  
  1153. public plugin_natives()
  1154. {
  1155. register_native("zp_frozen", "zp_frozen", 1)
  1156. // Player specific natives
  1157. register_native("zp_is_user_infector", "native_is_user_infector", 1)
  1158. register_native("zp_get_user_zombie", "native_get_user_zombie", 1)
  1159. register_native("zp_get_user_nemesis", "native_get_user_nemesis", 1)
  1160. register_native("zp_get_user_survivor", "native_get_user_survivor", 1)
  1161.  
  1162. // Hattrick
  1163. //
  1164. register_native("zp_get_user_sniper", "native_get_user_sniper", 1)
  1165. register_native("zp_get_user_assassin", "native_get_user_assassin", 1)
  1166.  
  1167. register_native("zp_get_user_first_zombie", "native_get_user_first_zombie", 1)
  1168. register_native("zp_get_user_last_zombie", "native_get_user_last_zombie", 1)
  1169. register_native("zp_get_user_last_human", "native_get_user_last_human", 1)
  1170. register_native("zp_get_user_zombie_class", "native_get_user_zombie_class", 1)
  1171. register_native("zp_get_user_next_class", "native_get_user_next_class", 1)
  1172. register_native("zp_set_user_zombie_class", "native_set_user_zombie_class", 1)
  1173. register_native("zp_get_user_ammo_packs", "native_get_user_ammo_packs", 1)
  1174. register_native("zp_set_user_ammo_packs", "native_set_user_ammo_packs", 1)
  1175.  
  1176. // Hattrick
  1177. //
  1178. register_native("zp_get_user_zp_points", "native_get_user_zp_points", 1)
  1179. register_native("zp_set_user_zp_points", "native_set_user_zp_points", 1)
  1180.  
  1181. register_native("zp_get_zombie_maxhealth", "native_get_zombie_maxhealth", 1)
  1182. register_native("zp_get_user_batteries", "native_get_user_batteries", 1)
  1183. register_native("zp_set_user_batteries", "native_set_user_batteries", 1)
  1184. register_native("zp_get_user_nightvision", "native_get_user_nightvision", 1)
  1185. register_native("zp_set_user_nightvision", "native_set_user_nightvision", 1)
  1186. register_native("zp_infect_user", "native_infect_user", 1)
  1187. register_native("zp_disinfect_user", "native_disinfect_user", 1)
  1188. register_native("zp_make_user_nemesis", "native_make_user_nemesis", 1)
  1189. register_native("zp_make_user_survivor", "native_make_user_survivor", 1)
  1190.  
  1191. // Hattrick
  1192. //
  1193. register_native("zp_make_user_sniper", "native_make_user_sniper", 1)
  1194. register_native("zp_make_user_assassin", "native_make_user_assassin", 1)
  1195.  
  1196. register_native("zp_respawn_user", "native_respawn_user", 1)
  1197. register_native("zp_force_buy_extra_item", "native_force_buy_extra_item", 1)
  1198. register_native("zp_override_user_model", "native_override_user_model", 1)
  1199.  
  1200. // Hattrick
  1201. //
  1202. register_native("zp_get_user_no_damage", "native_get_user_no_damage", 1)
  1203.  
  1204. // Round natives
  1205. register_native("zp_has_round_started", "native_has_round_started", 1)
  1206. register_native("zp_is_nemesis_round", "native_is_nemesis_round", 1)
  1207. register_native("zp_is_survivor_round", "native_is_survivor_round", 1)
  1208.  
  1209. // Hattrick
  1210. //
  1211. register_native("zp_is_sniper_round", "native_is_sniper_round", 1)
  1212. register_native("zp_is_assassin_round", "native_is_assassin_round", 1)
  1213.  
  1214. register_native("zp_is_swarm_round", "native_is_swarm_round", 1)
  1215. register_native("zp_is_plague_round", "native_is_plague_round", 1)
  1216. register_native("zp_get_zombie_count", "native_get_zombie_count", 1)
  1217. register_native("zp_get_human_count", "native_get_human_count", 1)
  1218. register_native("zp_get_nemesis_count", "native_get_nemesis_count", 1)
  1219. register_native("zp_get_survivor_count", "native_get_survivor_count", 1)
  1220.  
  1221. // Hattrick
  1222. //
  1223. register_native("zp_get_assassin_count", "native_get_assassin_count", 1)
  1224. register_native("zp_get_sniper_count", "native_get_sniper_count", 1)
  1225.  
  1226. // External additions natives
  1227. register_native("zp_register_extra_item", "native_register_extra_item", 1)
  1228. register_native("zp_register_zombie_class", "native_register_zombie_class", 1)
  1229. register_native("zp_get_extra_item_id", "native_get_extra_item_id", 1)
  1230. register_native("zp_get_zombie_class_id", "native_get_zombie_class_id", 1)
  1231. register_native("zp_get_zombie_class_info", "native_get_zombie_class_info", 1)
  1232. }
  1233.  
  1234. public plugin_precache()
  1235. {
  1236. // Hattrick
  1237. //
  1238.  
  1239. // Register earlier to show up in plugins list properly after plugin disable/error at loading
  1240. // register_plugin("Zombie Plague", PLUGIN_VERSION, "MeRcyLeZZ")
  1241. register_plugin("Zombie Plague", PLUGIN_VERSION, "Hattrick")
  1242.  
  1243. // To switch plugin on/off
  1244. register_concmd("zp_toggle", "cmd_toggle", _, "<1/0> - Enable/Disable Zombie Plague (will restart the current map)", 0)
  1245. cvar_toggle = register_cvar("zp_on", "1")
  1246.  
  1247. // Plugin disabled?
  1248. if (!get_pcvar_num(cvar_toggle)) return;
  1249. g_pluginenabled = true
  1250.  
  1251. // Initialize a few dynamically sized arrays (alright, maybe more than just a few...)
  1252. model_human = ArrayCreate(32, 1)
  1253. model_nemesis = ArrayCreate(32, 1)
  1254.  
  1255. // Hattrick
  1256. //
  1257. model_assassin = ArrayCreate(32, 1)
  1258. model_sniper = ArrayCreate(32, 1)
  1259.  
  1260. model_survivor = ArrayCreate(32, 1)
  1261. model_admin_human = ArrayCreate(32, 1)
  1262. model_vip = ArrayCreate(32, 1)
  1263. model_admin_zombie = ArrayCreate(32, 1)
  1264. g_modelindex_human = ArrayCreate(1, 1)
  1265. g_modelindex_nemesis = ArrayCreate(1, 1)
  1266. g_modelindex_survivor = ArrayCreate(1, 1)
  1267. g_modelindex_admin_human = ArrayCreate(1, 1)
  1268. g_modelindex_vip = ArrayCreate(1,1)
  1269.  
  1270. g_vflags = ArrayCreate(64, 1)
  1271. g_vname = ArrayCreate(64, 1)
  1272. g_vpwd = ArrayCreate(64, 1)
  1273.  
  1274. // Hattrick
  1275. //
  1276. g_modelindex_sniper = ArrayCreate(1, 1)
  1277. g_modelindex_assassin = ArrayCreate(1, 1)
  1278.  
  1279. g_modelindex_admin_zombie = ArrayCreate(1, 1)
  1280. sound_win_zombies = ArrayCreate(64, 1)
  1281. sound_win_zombies_ismp3 = ArrayCreate(1, 1)
  1282. sound_win_humans = ArrayCreate(64, 1)
  1283. sound_win_humans_ismp3 = ArrayCreate(1, 1)
  1284. sound_win_no_one = ArrayCreate(64, 1)
  1285. sound_win_no_one_ismp3 = ArrayCreate(1, 1)
  1286. zombie_infect = ArrayCreate(64, 1)
  1287. zombie_pain = ArrayCreate(64, 1)
  1288. nemesis_pain = ArrayCreate(64, 1)
  1289. // Hattrick
  1290. //
  1291. assassin_pain = ArrayCreate(64, 1)
  1292. zombie_die = ArrayCreate(64, 1)
  1293. zombie_fall = ArrayCreate(64, 1)
  1294. zombie_miss_slash = ArrayCreate(64, 1)
  1295. zombie_miss_wall = ArrayCreate(64, 1)
  1296. zombie_hit_normal = ArrayCreate(64, 1)
  1297. zombie_hit_stab = ArrayCreate(64, 1)
  1298. zombie_idle = ArrayCreate(64, 1)
  1299. zombie_idle_last = ArrayCreate(64, 1)
  1300. zombie_madness = ArrayCreate(64, 1)
  1301. sound_nemesis = ArrayCreate(64, 1)
  1302. sound_survivor = ArrayCreate(64, 1)
  1303.  
  1304. // Hattrick
  1305. //
  1306. sound_sniper = ArrayCreate(64, 1)
  1307. sound_assassin = ArrayCreate(64, 1)
  1308.  
  1309. sound_swarm = ArrayCreate(64, 1)
  1310. sound_multi = ArrayCreate(64, 1)
  1311. sound_plague = ArrayCreate(64, 1)
  1312. grenade_infect = ArrayCreate(64, 1)
  1313. grenade_infect_player = ArrayCreate(64, 1)
  1314. grenade_fire = ArrayCreate(64, 1)
  1315. grenade_fire_player = ArrayCreate(64, 1)
  1316. grenade_frost = ArrayCreate(64, 1)
  1317. grenade_frost_player = ArrayCreate(64, 1)
  1318. grenade_frost_break = ArrayCreate(64, 1)
  1319. // Hattrick
  1320. //
  1321. //grenade_flare = ArrayCreate(64, 1)
  1322. sound_antidote = ArrayCreate(64, 1)
  1323. sound_thunder = ArrayCreate(64, 1)
  1324. sound_ambience1 = ArrayCreate(64, 1)
  1325. sound_ambience2 = ArrayCreate(64, 1)
  1326. sound_ambience3 = ArrayCreate(64, 1)
  1327. sound_ambience4 = ArrayCreate(64, 1)
  1328. sound_ambience5 = ArrayCreate(64, 1)
  1329.  
  1330. // Hattrick
  1331. //
  1332. sound_ambience6 = ArrayCreate(64, 1)
  1333. sound_ambience7 = ArrayCreate(64, 1)
  1334.  
  1335. sound_ambience1_duration = ArrayCreate(1, 1)
  1336. sound_ambience2_duration = ArrayCreate(1, 1)
  1337. sound_ambience3_duration = ArrayCreate(1, 1)
  1338. sound_ambience4_duration = ArrayCreate(1, 1)
  1339. sound_ambience5_duration = ArrayCreate(1, 1)
  1340.  
  1341. // Hattrick
  1342. //
  1343. sound_ambience6_duration = ArrayCreate(1, 1)
  1344. sound_ambience7_duration = ArrayCreate(1, 1)
  1345.  
  1346. sound_ambience1_ismp3 = ArrayCreate(1, 1)
  1347. sound_ambience2_ismp3 = ArrayCreate(1, 1)
  1348. sound_ambience3_ismp3 = ArrayCreate(1, 1)
  1349. sound_ambience4_ismp3 = ArrayCreate(1, 1)
  1350. sound_ambience5_ismp3 = ArrayCreate(1, 1)
  1351.  
  1352. // Hattrick
  1353. //
  1354. sound_ambience6_ismp3 = ArrayCreate(1, 1)
  1355. sound_ambience7_ismp3 = ArrayCreate(1, 1)
  1356.  
  1357. g_primary_items = ArrayCreate(32, 1)
  1358. g_secondary_items = ArrayCreate(32, 1)
  1359. g_additional_items = ArrayCreate(32, 1)
  1360. g_primary_weaponids = ArrayCreate(1, 1)
  1361. g_secondary_weaponids = ArrayCreate(1, 1)
  1362. g_extraweapon_names = ArrayCreate(32, 1)
  1363. g_extraweapon_items = ArrayCreate(32, 1)
  1364. g_extraweapon_costs = ArrayCreate(1, 1)
  1365. g_sky_names = ArrayCreate(32, 1)
  1366. lights_thunder = ArrayCreate(32, 1)
  1367. zombie_decals = ArrayCreate(1, 1)
  1368. g_objective_ents = ArrayCreate(32, 1)
  1369. g_extraitem_name = ArrayCreate(32, 1)
  1370. g_extraitem_cost = ArrayCreate(1, 1)
  1371. g_extraitem_team = ArrayCreate(1, 1)
  1372. g_extraitem2_realname = ArrayCreate(32, 1)
  1373. g_extraitem2_name = ArrayCreate(32, 1)
  1374. g_extraitem2_cost = ArrayCreate(1, 1)
  1375. g_extraitem2_team = ArrayCreate(1, 1)
  1376. g_extraitem_new = ArrayCreate(1, 1)
  1377. g_zclass_name = ArrayCreate(32, 1)
  1378. g_zclass_info = ArrayCreate(32, 1)
  1379. g_zclass_modelsstart = ArrayCreate(1, 1)
  1380. g_zclass_modelsend = ArrayCreate(1, 1)
  1381. g_zclass_playermodel = ArrayCreate(32, 1)
  1382. g_zclass_modelindex = ArrayCreate(1, 1)
  1383. g_zclass_clawmodel = ArrayCreate(32, 1)
  1384. g_zclass_hp = ArrayCreate(1, 1)
  1385. g_zclass_spd = ArrayCreate(1, 1)
  1386. g_zclass_grav = ArrayCreate(1, 1)
  1387. g_zclass_kb = ArrayCreate(1, 1)
  1388. g_zclass2_realname = ArrayCreate(32, 1)
  1389. g_zclass2_name = ArrayCreate(32, 1)
  1390. g_zclass2_info = ArrayCreate(32, 1)
  1391. g_zclass2_modelsstart = ArrayCreate(1, 1)
  1392. g_zclass2_modelsend = ArrayCreate(1, 1)
  1393. g_zclass2_playermodel = ArrayCreate(32, 1)
  1394. g_zclass2_modelindex = ArrayCreate(1, 1)
  1395. g_zclass2_clawmodel = ArrayCreate(32, 1)
  1396. g_zclass2_hp = ArrayCreate(1, 1)
  1397. g_zclass2_spd = ArrayCreate(1, 1)
  1398. g_zclass2_grav = ArrayCreate(1, 1)
  1399. g_zclass2_kb = ArrayCreate(1, 1)
  1400. g_zclass_new = ArrayCreate(1, 1)
  1401.  
  1402. // Allow registering stuff now
  1403. g_arrays_created = true
  1404.  
  1405. // Load customization data
  1406. load_customization_from_files()
  1407.  
  1408. new i, buffer[100]
  1409.  
  1410. // Hattrick
  1411. //
  1412. g_zexplo = precache_model("sprites/zerogxplode.spr");
  1413.  
  1414. precache_model("models/ZombieOutstanding/p_golden_ak47.mdl");
  1415. precache_model("models/ZombieOutstanding/v_golden_ak47.mdl");
  1416.  
  1417. precache_model("sprites/674628.spr");
  1418.  
  1419. precache_model("models/ZombieOutstanding/p_golden_deagle.mdl");
  1420. precache_model("models/ZombieOutstanding/v_golden_deagle.mdl");
  1421.  
  1422. // Load up the hard coded extra items
  1423. native_register_extra_item2("NightVision", g_extra_costs2[EXTRA_NVISION], ZP_TEAM_HUMAN)
  1424. native_register_extra_item2("T-Virus Antidote", g_extra_costs2[EXTRA_ANTIDOTE], ZP_TEAM_ZOMBIE)
  1425. native_register_extra_item2("Zombie Madness", g_extra_costs2[EXTRA_MADNESS], ZP_TEAM_ZOMBIE)
  1426. native_register_extra_item2("Infection Bomb", g_extra_costs2[EXTRA_INFBOMB], ZP_TEAM_ZOMBIE)
  1427.  
  1428. // Extra weapons
  1429. for (i = 0; i < ArraySize(g_extraweapon_names); i++)
  1430. {
  1431. ArrayGetString(g_extraweapon_names, i, buffer, charsmax(buffer))
  1432. native_register_extra_item2(buffer, ArrayGetCell(g_extraweapon_costs, i), ZP_TEAM_HUMAN)
  1433. }
  1434.  
  1435. // Custom player models
  1436. for (i = 0; i < ArraySize(model_human); i++)
  1437. {
  1438. ArrayGetString(model_human, i, buffer, charsmax(buffer))
  1439. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1440. ArrayPushCell(g_modelindex_human, engfunc(EngFunc_PrecacheModel, buffer))
  1441. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1442. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1443. // Precache modelT.mdl files too
  1444. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1445. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1446. }
  1447. for (i = 0; i < ArraySize(model_nemesis); i++)
  1448. {
  1449. ArrayGetString(model_nemesis, i, buffer, charsmax(buffer))
  1450. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1451. ArrayPushCell(g_modelindex_nemesis, engfunc(EngFunc_PrecacheModel, buffer))
  1452. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1453. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1454. // Precache modelT.mdl files too
  1455. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1456. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1457. }
  1458.  
  1459. // Hattrick
  1460. //
  1461. for (i = 0; i < ArraySize(model_assassin); i++)
  1462. {
  1463. ArrayGetString(model_assassin, i, buffer, charsmax(buffer))
  1464. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1465. ArrayPushCell(g_modelindex_assassin, engfunc(EngFunc_PrecacheModel, buffer))
  1466. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1467. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1468. // Precache modelT.mdl files too
  1469. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1470. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1471. }
  1472. for (i = 0; i < ArraySize(model_sniper); i++)
  1473. {
  1474. ArrayGetString(model_sniper, i, buffer, charsmax(buffer))
  1475. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1476. ArrayPushCell(g_modelindex_sniper, engfunc(EngFunc_PrecacheModel, buffer))
  1477. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1478. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1479. // Precache modelT.mdl files too
  1480. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1481. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1482. }
  1483.  
  1484. for (i = 0; i < ArraySize(model_survivor); i++)
  1485. {
  1486. ArrayGetString(model_survivor, i, buffer, charsmax(buffer))
  1487. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1488. ArrayPushCell(g_modelindex_survivor, engfunc(EngFunc_PrecacheModel, buffer))
  1489. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1490. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1491. // Precache modelT.mdl files too
  1492. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1493. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1494. }
  1495. for (i = 0; i < ArraySize(model_admin_zombie); i++)
  1496. {
  1497. ArrayGetString(model_admin_zombie, i, buffer, charsmax(buffer))
  1498. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1499. ArrayPushCell(g_modelindex_admin_zombie, engfunc(EngFunc_PrecacheModel, buffer))
  1500. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1501. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1502. // Precache modelT.mdl files too
  1503. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1504. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1505. }
  1506. for (i = 0; i < ArraySize(model_admin_human); i++)
  1507. {
  1508. ArrayGetString(model_admin_human, i, buffer, charsmax(buffer))
  1509. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1510. ArrayPushCell(g_modelindex_admin_human, engfunc(EngFunc_PrecacheModel, buffer))
  1511. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1512. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1513. // Precache modelT.mdl files too
  1514. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1515. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1516. }
  1517. for (i = 0; i < ArraySize(model_vip); i++)
  1518. {
  1519. ArrayGetString(model_vip, i, buffer, charsmax(buffer))
  1520. format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
  1521. ArrayPushCell(g_modelindex_vip, engfunc(EngFunc_PrecacheModel, buffer))
  1522. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
  1523. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
  1524. // Precache modelT.mdl files too
  1525. copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
  1526. if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
  1527. }
  1528.  
  1529. // Custom weapon models
  1530. engfunc(EngFunc_PrecacheModel, model_vknife_human)
  1531. engfunc(EngFunc_PrecacheModel, model_vknife_nemesis)
  1532. // Hattrick
  1533. //
  1534. // engfunc(EngFunc_PrecacheModel, model_vweapon_survivor)
  1535. engfunc(EngFunc_PrecacheModel, model_grenade_infect)
  1536. engfunc(EngFunc_PrecacheModel, model_grenade_fire)
  1537. engfunc(EngFunc_PrecacheModel, model_grenade_frost)
  1538. engfunc(EngFunc_PrecacheModel, model_grenade_flare)
  1539. engfunc(EngFunc_PrecacheModel, model_vknife_admin_human)
  1540. engfunc(EngFunc_PrecacheModel, model_vknife_admin_zombie)
  1541. engfunc(EngFunc_PrecacheModel, model_vawp_sniper)
  1542. engfunc(EngFunc_PrecacheModel, model_pawp_sniper)
  1543. engfunc(EngFunc_PrecacheModel, model_vknife_assassin)
  1544.  
  1545. // Custom sprites for grenades
  1546. g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
  1547. g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
  1548. g_flameSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_fire)
  1549. g_smokeSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_smoke)
  1550. g_glassSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_glass)
  1551. g_iLaser=precache_model("sprites/laserbeam.spr");
  1552.  
  1553. // Custom sounds
  1554. for (i = 0; i < ArraySize(sound_win_zombies); i++)
  1555. {
  1556. ArrayGetString(sound_win_zombies, i, buffer, charsmax(buffer))
  1557. if (ArrayGetCell(sound_win_zombies_ismp3, i))
  1558. {
  1559. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1560. engfunc(EngFunc_PrecacheGeneric, buffer)
  1561. }
  1562. else
  1563. {
  1564. engfunc(EngFunc_PrecacheSound, buffer)
  1565. }
  1566. }
  1567. for (i = 0; i < ArraySize(sound_win_humans); i++)
  1568. {
  1569. ArrayGetString(sound_win_humans, i, buffer, charsmax(buffer))
  1570. if (ArrayGetCell(sound_win_humans_ismp3, i))
  1571. {
  1572. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1573. engfunc(EngFunc_PrecacheGeneric, buffer)
  1574. }
  1575. else
  1576. {
  1577. engfunc(EngFunc_PrecacheSound, buffer)
  1578. }
  1579. }
  1580. for (i = 0; i < ArraySize(sound_win_no_one); i++)
  1581. {
  1582. ArrayGetString(sound_win_no_one, i, buffer, charsmax(buffer))
  1583. if (ArrayGetCell(sound_win_no_one_ismp3, i))
  1584. {
  1585. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1586. engfunc(EngFunc_PrecacheGeneric, buffer)
  1587. }
  1588. else
  1589. {
  1590. engfunc(EngFunc_PrecacheSound, buffer)
  1591. }
  1592. }
  1593. for (i = 0; i < ArraySize(zombie_infect); i++)
  1594. {
  1595. ArrayGetString(zombie_infect, i, buffer, charsmax(buffer))
  1596. engfunc(EngFunc_PrecacheSound, buffer)
  1597. }
  1598. for (i = 0; i < ArraySize(zombie_pain); i++)
  1599. {
  1600. ArrayGetString(zombie_pain, i, buffer, charsmax(buffer))
  1601. engfunc(EngFunc_PrecacheSound, buffer)
  1602. }
  1603. for (i = 0; i < ArraySize(nemesis_pain); i++)
  1604. {
  1605. ArrayGetString(nemesis_pain, i, buffer, charsmax(buffer))
  1606. engfunc(EngFunc_PrecacheSound, buffer)
  1607. }
  1608. // Hattrick
  1609. //
  1610. for (i = 0; i < ArraySize(assassin_pain); i++)
  1611. {
  1612. ArrayGetString(assassin_pain, i, buffer, charsmax(buffer))
  1613. engfunc(EngFunc_PrecacheSound, buffer)
  1614. }
  1615.  
  1616. for (i = 0; i < ArraySize(zombie_die); i++)
  1617. {
  1618. ArrayGetString(zombie_die, i, buffer, charsmax(buffer))
  1619. engfunc(EngFunc_PrecacheSound, buffer)
  1620. }
  1621. for (i = 0; i < ArraySize(zombie_fall); i++)
  1622. {
  1623. ArrayGetString(zombie_fall, i, buffer, charsmax(buffer))
  1624. engfunc(EngFunc_PrecacheSound, buffer)
  1625. }
  1626. for (i = 0; i < ArraySize(zombie_miss_slash); i++)
  1627. {
  1628. ArrayGetString(zombie_miss_slash, i, buffer, charsmax(buffer))
  1629. engfunc(EngFunc_PrecacheSound, buffer)
  1630. }
  1631. for (i = 0; i < ArraySize(zombie_miss_wall); i++)
  1632. {
  1633. ArrayGetString(zombie_miss_wall, i, buffer, charsmax(buffer))
  1634. engfunc(EngFunc_PrecacheSound, buffer)
  1635. }
  1636. for (i = 0; i < ArraySize(zombie_hit_normal); i++)
  1637. {
  1638. ArrayGetString(zombie_hit_normal, i, buffer, charsmax(buffer))
  1639. engfunc(EngFunc_PrecacheSound, buffer)
  1640. }
  1641. for (i = 0; i < ArraySize(zombie_hit_stab); i++)
  1642. {
  1643. ArrayGetString(zombie_hit_stab, i, buffer, charsmax(buffer))
  1644. engfunc(EngFunc_PrecacheSound, buffer)
  1645. }
  1646. for (i = 0; i < ArraySize(zombie_idle); i++)
  1647. {
  1648. ArrayGetString(zombie_idle, i, buffer, charsmax(buffer))
  1649. engfunc(EngFunc_PrecacheSound, buffer)
  1650. }
  1651. for (i = 0; i < ArraySize(zombie_idle_last); i++)
  1652. {
  1653. ArrayGetString(zombie_idle_last, i, buffer, charsmax(buffer))
  1654. engfunc(EngFunc_PrecacheSound, buffer)
  1655. }
  1656. for (i = 0; i < ArraySize(zombie_madness); i++)
  1657. {
  1658. ArrayGetString(zombie_madness, i, buffer, charsmax(buffer))
  1659. engfunc(EngFunc_PrecacheSound, buffer)
  1660. }
  1661. for (i = 0; i < ArraySize(sound_nemesis); i++)
  1662. {
  1663. ArrayGetString(sound_nemesis, i, buffer, charsmax(buffer))
  1664. engfunc(EngFunc_PrecacheSound, buffer)
  1665. }
  1666. for (i = 0; i < ArraySize(sound_survivor); i++)
  1667. {
  1668. ArrayGetString(sound_survivor, i, buffer, charsmax(buffer))
  1669. engfunc(EngFunc_PrecacheSound, buffer)
  1670. }
  1671.  
  1672. // Hattrick
  1673. //
  1674. for (i = 0; i < ArraySize(sound_sniper); i++)
  1675. {
  1676. ArrayGetString(sound_sniper, i, buffer, charsmax(buffer))
  1677. engfunc(EngFunc_PrecacheSound, buffer)
  1678. }
  1679. for (i = 0; i < ArraySize(sound_assassin); i++)
  1680. {
  1681. ArrayGetString(sound_assassin, i, buffer, charsmax(buffer))
  1682. engfunc(EngFunc_PrecacheSound, buffer)
  1683. }
  1684.  
  1685.  
  1686.  
  1687. for (i = 0; i < ArraySize(sound_swarm); i++)
  1688. {
  1689. ArrayGetString(sound_swarm, i, buffer, charsmax(buffer))
  1690. engfunc(EngFunc_PrecacheSound, buffer)
  1691. }
  1692. for (i = 0; i < ArraySize(sound_multi); i++)
  1693. {
  1694. ArrayGetString(sound_multi, i, buffer, charsmax(buffer))
  1695. engfunc(EngFunc_PrecacheSound, buffer)
  1696. }
  1697. for (i = 0; i < ArraySize(sound_plague); i++)
  1698. {
  1699. ArrayGetString(sound_plague, i, buffer, charsmax(buffer))
  1700. engfunc(EngFunc_PrecacheSound, buffer)
  1701. }
  1702. for (i = 0; i < ArraySize(grenade_infect); i++)
  1703. {
  1704. ArrayGetString(grenade_infect, i, buffer, charsmax(buffer))
  1705. engfunc(EngFunc_PrecacheSound, buffer)
  1706. }
  1707. for (i = 0; i < ArraySize(grenade_infect_player); i++)
  1708. {
  1709. ArrayGetString(grenade_infect_player, i, buffer, charsmax(buffer))
  1710. engfunc(EngFunc_PrecacheSound, buffer)
  1711. }
  1712. for (i = 0; i < ArraySize(grenade_fire); i++)
  1713. {
  1714. ArrayGetString(grenade_fire, i, buffer, charsmax(buffer))
  1715. engfunc(EngFunc_PrecacheSound, buffer)
  1716. }
  1717. for (i = 0; i < ArraySize(grenade_fire_player); i++)
  1718. {
  1719. ArrayGetString(grenade_fire_player, i, buffer, charsmax(buffer))
  1720. engfunc(EngFunc_PrecacheSound, buffer)
  1721. }
  1722. for (i = 0; i < ArraySize(grenade_frost); i++)
  1723. {
  1724. ArrayGetString(grenade_frost, i, buffer, charsmax(buffer))
  1725. engfunc(EngFunc_PrecacheSound, buffer)
  1726. }
  1727. for (i = 0; i < ArraySize(grenade_frost_player); i++)
  1728. {
  1729. ArrayGetString(grenade_frost_player, i, buffer, charsmax(buffer))
  1730. engfunc(EngFunc_PrecacheSound, buffer)
  1731. }
  1732. for (i = 0; i < ArraySize(grenade_frost_break); i++)
  1733. {
  1734. ArrayGetString(grenade_frost_break, i, buffer, charsmax(buffer))
  1735. engfunc(EngFunc_PrecacheSound, buffer)
  1736. }
  1737. // Hattrick
  1738. //
  1739. /*
  1740. for (i = 0; i < ArraySize(grenade_flare); i++)
  1741. {
  1742. ArrayGetString(grenade_flare, i, buffer, charsmax(buffer))
  1743. engfunc(EngFunc_PrecacheSound, buffer)
  1744. }
  1745. */
  1746. for (i = 0; i < ArraySize(sound_antidote); i++)
  1747. {
  1748. ArrayGetString(sound_antidote, i, buffer, charsmax(buffer))
  1749. engfunc(EngFunc_PrecacheSound, buffer)
  1750. }
  1751. for (i = 0; i < ArraySize(sound_thunder); i++)
  1752. {
  1753. ArrayGetString(sound_thunder, i, buffer, charsmax(buffer))
  1754. engfunc(EngFunc_PrecacheSound, buffer)
  1755. }
  1756.  
  1757. // Ambience Sounds
  1758. if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION])
  1759. {
  1760. for (i = 0; i < ArraySize(sound_ambience1); i++)
  1761. {
  1762. ArrayGetString(sound_ambience1, i, buffer, charsmax(buffer))
  1763.  
  1764. if (ArrayGetCell(sound_ambience1_ismp3, i))
  1765. {
  1766. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1767. engfunc(EngFunc_PrecacheGeneric, buffer)
  1768. }
  1769. else
  1770. {
  1771. engfunc(EngFunc_PrecacheSound, buffer)
  1772. }
  1773. }
  1774. }
  1775. if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS])
  1776. {
  1777. for (i = 0; i < ArraySize(sound_ambience2); i++)
  1778. {
  1779. ArrayGetString(sound_ambience2, i, buffer, charsmax(buffer))
  1780.  
  1781. if (ArrayGetCell(sound_ambience2_ismp3, i))
  1782. {
  1783. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1784. engfunc(EngFunc_PrecacheGeneric, buffer)
  1785. }
  1786. else
  1787. {
  1788. engfunc(EngFunc_PrecacheSound, buffer)
  1789. }
  1790. }
  1791. }
  1792. // Hattrick
  1793. //
  1794. if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN])
  1795. {
  1796. for (i = 0; i < ArraySize(sound_ambience6); i++)
  1797. {
  1798. ArrayGetString(sound_ambience6, i, buffer, charsmax(buffer))
  1799.  
  1800. if (ArrayGetCell(sound_ambience6_ismp3, i))
  1801. {
  1802. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1803. engfunc(EngFunc_PrecacheGeneric, buffer)
  1804. }
  1805. else
  1806. {
  1807. engfunc(EngFunc_PrecacheSound, buffer)
  1808. }
  1809. }
  1810. }
  1811. if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR])
  1812. {
  1813. for (i = 0; i < ArraySize(sound_ambience3); i++)
  1814. {
  1815. ArrayGetString(sound_ambience3, i, buffer, charsmax(buffer))
  1816.  
  1817. if (ArrayGetCell(sound_ambience3_ismp3, i))
  1818. {
  1819. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1820. engfunc(EngFunc_PrecacheGeneric, buffer)
  1821. }
  1822. else
  1823. {
  1824. engfunc(EngFunc_PrecacheSound, buffer)
  1825. }
  1826. }
  1827. }
  1828. // Hattrick
  1829. //
  1830. if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER])
  1831. {
  1832. for (i = 0; i < ArraySize(sound_ambience7); i++)
  1833. {
  1834. ArrayGetString(sound_ambience7, i, buffer, charsmax(buffer))
  1835.  
  1836. if (ArrayGetCell(sound_ambience7_ismp3, i))
  1837. {
  1838. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1839. engfunc(EngFunc_PrecacheGeneric, buffer)
  1840. }
  1841. else
  1842. {
  1843. engfunc(EngFunc_PrecacheSound, buffer)
  1844. }
  1845. }
  1846. }
  1847. if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM])
  1848. {
  1849. for (i = 0; i < ArraySize(sound_ambience4); i++)
  1850. {
  1851. ArrayGetString(sound_ambience4, i, buffer, charsmax(buffer))
  1852.  
  1853. if (ArrayGetCell(sound_ambience4_ismp3, i))
  1854. {
  1855. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1856. engfunc(EngFunc_PrecacheGeneric, buffer)
  1857. }
  1858. else
  1859. {
  1860. engfunc(EngFunc_PrecacheSound, buffer)
  1861. }
  1862. }
  1863. }
  1864. if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE])
  1865. {
  1866. for (i = 0; i < ArraySize(sound_ambience5); i++)
  1867. {
  1868. ArrayGetString(sound_ambience5, i, buffer, charsmax(buffer))
  1869.  
  1870. if (ArrayGetCell(sound_ambience5_ismp3, i))
  1871. {
  1872. format(buffer, charsmax(buffer), "sound/%s", buffer)
  1873. engfunc(EngFunc_PrecacheGeneric, buffer)
  1874. }
  1875. else
  1876. {
  1877. engfunc(EngFunc_PrecacheSound, buffer)
  1878. }
  1879. }
  1880. }
  1881.  
  1882. // CS sounds (just in case)
  1883. engfunc(EngFunc_PrecacheSound, sound_flashlight)
  1884. engfunc(EngFunc_PrecacheSound, sound_buyammo)
  1885. engfunc(EngFunc_PrecacheSound, sound_armorhit)
  1886.  
  1887. new ent
  1888.  
  1889. // Fake Hostage (to force round ending)
  1890. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"))
  1891. if (pev_valid(ent))
  1892. {
  1893. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0,8192.0,8192.0})
  1894. dllfunc(DLLFunc_Spawn, ent)
  1895. }
  1896.  
  1897. // Weather/ambience effects
  1898. if (g_ambience_fog)
  1899. {
  1900. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  1901. if (pev_valid(ent))
  1902. {
  1903. fm_set_kvd(ent, "density", g_fog_density, "env_fog")
  1904. fm_set_kvd(ent, "rendercolor", g_fog_color, "env_fog")
  1905. }
  1906. }
  1907. if (g_ambience_rain) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain"))
  1908. if (g_ambience_snow) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_snow"))
  1909.  
  1910. // Custom buyzone for all players
  1911. g_buyzone_ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_buyzone"))
  1912. if (pev_valid(g_buyzone_ent))
  1913. {
  1914. dllfunc(DLLFunc_Spawn, g_buyzone_ent)
  1915. set_pev(g_buyzone_ent, pev_solid, SOLID_NOT)
  1916. }
  1917.  
  1918. // Prevent some entities from spawning
  1919. g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  1920.  
  1921. // Prevent hostage sounds from being precached
  1922. g_fwPrecacheSound = register_forward(FM_PrecacheSound, "fw_PrecacheSound")
  1923. }
  1924.  
  1925. // Hattrick
  1926. //
  1927. loadPoints(id)
  1928. {
  1929. g_vault = nvault_open("points");
  1930.  
  1931. if (g_vault != INVALID_HANDLE)
  1932. {
  1933. g_points[id] = nvault_get(g_vault, g_playername[id]);
  1934. nvault_close(g_vault);
  1935. g_vault = INVALID_HANDLE;
  1936. }
  1937. }
  1938.  
  1939. savePoints(id)
  1940. {
  1941. g_vault = nvault_open("points");
  1942.  
  1943. if (g_vault != INVALID_HANDLE)
  1944. {
  1945. new str[16];
  1946. num_to_str(g_points[id], str, charsmax(str));
  1947.  
  1948. nvault_set(g_vault, g_playername[id], str);
  1949. nvault_close(g_vault);
  1950. g_vault = INVALID_HANDLE;
  1951. }
  1952. }
  1953.  
  1954. public client_authorized(id)
  1955. {
  1956. static pwd[32], field[32], reqname[64], reqpwd[64], reqflags[64], i;
  1957.  
  1958. get_cvar_string("amx_password_field", field, 31);
  1959.  
  1960. get_user_ip(id, g_ip[id], charsmax(g_ip[]), 1);
  1961. get_user_name(id, g_playername[id], charsmax(g_playername[]));
  1962. get_user_authid(id, g_steam[id], charsmax(g_steam[]));
  1963. get_user_info(id, field, pwd, 31);
  1964.  
  1965. g_doubledamage[id] = false;
  1966. g_vip[id] = false;
  1967. g_infector[id] = false;
  1968.  
  1969. for (i = 0; i < ArraySize(g_vname); i++)
  1970. {
  1971. ArrayGetString(g_vname, i, reqname, 63);
  1972. ArrayGetString(g_vpwd, i, reqpwd, 63);
  1973. ArrayGetString(g_vflags, i, reqflags, 63);
  1974.  
  1975. if (equali(g_playername[id], reqname))
  1976. {
  1977. if (equali(pwd, reqpwd) && strlen(pwd) > 0)
  1978. {
  1979. g_vip[id] = true;
  1980. formatex(g_vip_flags[id], charsmax(g_vip_flags[]), "%s", reqflags);
  1981. break;
  1982. }
  1983.  
  1984. else
  1985. {
  1986. server_cmd("kick #%d INVALiD ViP PASSWORD.", get_user_userid(id));
  1987. break;
  1988. }
  1989. }
  1990.  
  1991. if (equali(g_ip[id], reqname) || equali(g_steam[id], reqname))
  1992. {
  1993. g_vip[id] = true;
  1994. formatex(g_vip_flags[id], charsmax(g_vip_flags[]), "%s", reqflags);
  1995. break;
  1996. }
  1997. }
  1998.  
  1999. loadPoints(id);
  2000. }
  2001.  
  2002. public client_infochanged(id)
  2003. {
  2004. if (!is_user_connected(id))return
  2005. static newn[64], oldn[64]
  2006. get_user_name(id,oldn,63)
  2007. get_user_info(id,"name",newn,63)
  2008. if(!equali(oldn,newn)&&strlen(newn)>0)
  2009. {
  2010. new vlt=nvault_open("points")
  2011. if (vlt != INVALID_HANDLE)
  2012. {
  2013. g_points[id]=nvault_get(vlt,newn)
  2014. nvault_close(vlt)
  2015. vlt=INVALID_HANDLE
  2016. }
  2017. }
  2018. }
  2019.  
  2020. // Hattrick
  2021. //
  2022. public plugin_end()
  2023. {
  2024. if (g_vault != INVALID_HANDLE)
  2025. {
  2026. nvault_close(g_vault);
  2027. g_vault = INVALID_HANDLE;
  2028. }
  2029.  
  2030. new vault = nvault_open("ammo");
  2031. if (vault != INVALID_HANDLE)
  2032. {
  2033. nvault_prune(vault, 0, get_systime())
  2034.  
  2035. nvault_close(vault)
  2036. vault=INVALID_HANDLE
  2037. }
  2038. }
  2039.  
  2040. public plugin_init()
  2041. {
  2042. // Plugin disabled?
  2043. if (!g_pluginenabled) return;
  2044.  
  2045. // No zombie classes?
  2046. if (!g_zclass_i) set_fail_state("No zombie classes loaded!")
  2047.  
  2048. // Language files
  2049. register_dictionary("zombie_plague.txt")
  2050. new vault = nvault_open("ammo");
  2051.  
  2052. if (vault != INVALID_HANDLE)
  2053. {
  2054. nvault_prune(vault, 0, get_systime())
  2055.  
  2056. nvault_close(vault)
  2057. vault=INVALID_HANDLE
  2058. }
  2059.  
  2060. vault = nvault_open("points")
  2061. if (vault != INVALID_HANDLE)
  2062. {
  2063. nvault_prune(vault, 0, get_systime() - 2629743);
  2064. nvault_close(vault)
  2065. vault=INVALID_HANDLE
  2066. }
  2067.  
  2068. // Hattrick
  2069. //
  2070. new cfgs[128];
  2071. get_configsdir(cfgs, 127)
  2072. add(cfgs, 127, "/vips.ini")
  2073.  
  2074. new file = fopen(cfgs, "r")
  2075. if (file)
  2076. {
  2077. new line[512], name[64], pwd[64], flags[64]
  2078.  
  2079. while (!feof(file))
  2080. {
  2081. fgets(file, line ,511)
  2082. trim(line)
  2083. if (!line[0] || line[0] == '/' || line[0] == ';' || line[0] == '#')
  2084. continue;
  2085. new r=parse(line, name,63,pwd,63,flags,63)
  2086. if (r < 3) continue;
  2087. ArrayPushString(g_vname, name)
  2088. ArrayPushString(g_vpwd, pwd)
  2089. ArrayPushString(g_vflags, flags)
  2090. }
  2091.  
  2092. fclose(file)
  2093. }
  2094.  
  2095. // Events
  2096. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  2097. register_logevent("logevent_round_start",2, "1=Round_Start")
  2098. register_logevent("logevent_round_end", 2, "1=Round_End")
  2099. register_event("AmmoX", "event_ammo_x", "be")
  2100. 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] || g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE])
  2101. register_event("30", "event_intermission", "a")
  2102.  
  2103. register_event("StatusValue", "event_show_status", "be", "1=2", "2!0")
  2104. register_event("StatusValue", "event_hide_status", "be", "1=1", "2=0")
  2105. register_event("ResetHUD", "resethud", "be");
  2106.  
  2107. // HAM Forwards
  2108. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  2109. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  2110. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
  2111. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  2112. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Post", 1)
  2113. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  2114. RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1)
  2115. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary")
  2116. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary")
  2117. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary")
  2118. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary")
  2119. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
  2120. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
  2121. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
  2122. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
  2123. RegisterHam(Ham_Use, "func_pushable", "fw_UsePushable")
  2124. RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  2125. RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  2126. RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  2127. RegisterHam(Ham_AddPlayerItem, "player", "fw_AddPlayerItem")
  2128. for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  2129. if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  2130.  
  2131. // FM Forwards
  2132. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  2133. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect_Post", 1)
  2134. register_forward(FM_ClientKill, "fw_ClientKill")
  2135. register_forward(FM_EmitSound, "fw_EmitSound")
  2136. if (!g_handle_models_on_separate_ent) register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
  2137. register_forward(FM_ClientUserInfoChanged, "fw_ClientUserInfoChanged")
  2138. register_forward(FM_GetGameDescription, "fw_GetGameDescription")
  2139. register_forward(FM_SetModel, "fw_SetModel")
  2140. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  2141. register_forward(FM_CmdStart, "fw_CmdStart")
  2142. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  2143. unregister_forward(FM_Spawn, g_fwSpawn)
  2144. unregister_forward(FM_PrecacheSound, g_fwPrecacheSound)
  2145.  
  2146. // Client commands
  2147. register_clcmd("say zpmenu", "clcmd_saymenu")
  2148. register_clcmd("say /zpmenu", "clcmd_saymenu")
  2149. register_clcmd("say unstuck", "clcmd_sayunstuck")
  2150. register_clcmd("say /unstuck", "clcmd_sayunstuck")
  2151. register_clcmd("nightvision", "clcmd_nightvision")
  2152. register_clcmd("drop", "clcmd_drop")
  2153. register_clcmd("buyammo1", "clcmd_buyammo")
  2154. register_clcmd("buyammo2", "clcmd_buyammo")
  2155. register_clcmd("chooseteam", "clcmd_changeteam")
  2156. register_clcmd("jointeam", "clcmd_changeteam")
  2157.  
  2158. // Menus
  2159. register_menu("Game Menu", KEYSMENU, "menu_game")
  2160. register_menu("Buy Menu 1", KEYSMENU, "menu_buy1")
  2161. register_menu("Buy Menu 2", KEYSMENU, "menu_buy2")
  2162. // register_menu("Mod Info", KEYSMENU, "menu_info")
  2163. register_menu("Admin Menu", KEYSMENU, "menu_admin")
  2164.  
  2165. set_task(10.0, "Rays", .flags="b");
  2166.  
  2167. // Hattrick
  2168. //
  2169. register_menu("Buy Features with Points", KEYSMENU, "menu_points");
  2170.  
  2171. // CS Buy Menus (to prevent zombies/survivor from buying)
  2172. register_menucmd(register_menuid("#Buy", 1), 511, "menu_cs_buy")
  2173. register_menucmd(register_menuid("BuyPistol", 1), 511, "menu_cs_buy")
  2174. register_menucmd(register_menuid("BuyShotgun", 1), 511, "menu_cs_buy")
  2175. register_menucmd(register_menuid("BuySub", 1), 511, "menu_cs_buy")
  2176. register_menucmd(register_menuid("BuyRifle", 1), 511, "menu_cs_buy")
  2177. register_menucmd(register_menuid("BuyMachine", 1), 511, "menu_cs_buy")
  2178. register_menucmd(register_menuid("BuyItem", 1), 511, "menu_cs_buy")
  2179. register_menucmd(-28, 511, "menu_cs_buy")
  2180. register_menucmd(-29, 511, "menu_cs_buy")
  2181. register_menucmd(-30, 511, "menu_cs_buy")
  2182. register_menucmd(-32, 511, "menu_cs_buy")
  2183. register_menucmd(-31, 511, "menu_cs_buy")
  2184. register_menucmd(-33, 511, "menu_cs_buy")
  2185. register_menucmd(-34, 511, "menu_cs_buy")
  2186.  
  2187. // Admin commands
  2188. register_concmd("zp_zombie", "cmd_zombie", _, "<target> - Turn someone into a Zombie", 0)
  2189. register_concmd("zp_human", "cmd_human", _, "<target> - Turn someone back to Human", 0)
  2190. register_concmd("zp_nemesis", "cmd_nemesis", _, "<target> - Turn someone into a Nemesis", 0)
  2191.  
  2192. // Hattrick
  2193. //
  2194. register_concmd("zp_sniper", "cmd_sniper", _, "<target> - Turn someone into a Sniper", 0)
  2195. register_concmd("zp_assassin", "cmd_assassin", _, "<target> - Turn someone into an Assassin", 0)
  2196.  
  2197. register_concmd("zp_ammo", "cmd_ammo", _, "<target> <amount> - Gives ammo", 0)
  2198. register_concmd("zp_points", "cmd_points", _, "<target> <amount> - Gives points", 0)
  2199.  
  2200. register_concmd("amx_ammo", "cmd_ammo", _, "<target> <amount> - Gives ammo", 0)
  2201. register_concmd("amx_points", "cmd_points", _, "<target> <amount> - Gives points", 0)
  2202.  
  2203. register_concmd("amx_reset_points", "cmd_reset_points", _, "- Resets all points", 0)
  2204. register_concmd("zp_reset_points", "cmd_reset_points", _, "- Resets all points", 0)
  2205.  
  2206. register_concmd("amx_subtract_points", "cmd_subtract_points", _, "<target> <amount> - Subtracts points", 0)
  2207. register_concmd("zp_subtract_points", "cmd_subtract_points", _, "<target> <amount> - Subtracts points", 0)
  2208.  
  2209. register_concmd("zp_survivor", "cmd_survivor", _, "<target> - Turn someone into a Survivor", 0)
  2210. register_concmd("zp_respawn", "cmd_respawn", _, "<target> - Respawn someone", 0)
  2211. register_concmd("zp_swarm", "cmd_swarm", _, " - Start Swarm Mode", 0)
  2212.  
  2213. register_concmd("zp_armageddon", "cmd_armageddon", _, " - Start Armageddon Mode", 0)
  2214. register_concmd("zp_avs", "cmd_avs", _, " - Start Assassins VS Snipers Mode", 0)
  2215.  
  2216. register_concmd("zp_multi", "cmd_multi", _, " - Start Multi Infection", 0)
  2217. register_concmd("zp_plague", "cmd_plague", _, " - Start Plague Mode", 0)
  2218.  
  2219. // Message IDs
  2220. g_msgScoreInfo = get_user_msgid("ScoreInfo")
  2221. g_msgTeamInfo = get_user_msgid("TeamInfo")
  2222. g_msgDeathMsg = get_user_msgid("DeathMsg")
  2223. g_msgScoreAttrib = get_user_msgid("ScoreAttrib")
  2224. g_msgSetFOV = get_user_msgid("SetFOV")
  2225. g_msgScreenFade = get_user_msgid("ScreenFade")
  2226. g_msgScreenShake = get_user_msgid("ScreenShake")
  2227. g_msgNVGToggle = get_user_msgid("NVGToggle")
  2228. g_msgFlashlight = get_user_msgid("Flashlight")
  2229. g_msgFlashBat = get_user_msgid("FlashBat")
  2230. g_msgAmmoPickup = get_user_msgid("AmmoPickup")
  2231. g_msgDamage = get_user_msgid("Damage")
  2232. g_msgHideWeapon = get_user_msgid("HideWeapon")
  2233. g_msgCrosshair = get_user_msgid("Crosshair")
  2234. g_msgSayText = get_user_msgid("SayText")
  2235. g_msgCurWeapon = get_user_msgid("CurWeapon")
  2236.  
  2237. // Message hooks
  2238. register_message(g_msgCurWeapon, "message_cur_weapon")
  2239. register_message(get_user_msgid("Money"), "message_money")
  2240. register_message(get_user_msgid("Health"), "message_health")
  2241. register_message(g_msgFlashBat, "message_flashbat")
  2242. register_message(g_msgScreenFade, "message_screenfade")
  2243. register_message(g_msgNVGToggle, "message_nvgtoggle")
  2244. if (g_handle_models_on_separate_ent) register_message(get_user_msgid("ClCorpse"), "message_clcorpse")
  2245. register_message(get_user_msgid("WeapPickup"), "message_weappickup")
  2246. register_message(g_msgAmmoPickup, "message_ammopickup")
  2247. register_message(get_user_msgid("Scenario"), "message_scenario")
  2248. register_message(get_user_msgid("HostagePos"), "message_hostagepos")
  2249. register_message(get_user_msgid("TextMsg"), "message_textmsg")
  2250. register_message(get_user_msgid("SendAudio"), "message_sendaudio")
  2251. register_message(get_user_msgid("TeamScore"), "message_teamscore")
  2252. register_message(g_msgTeamInfo, "message_teaminfo")
  2253.  
  2254. cvar_armageddonchance = register_cvar("zp_armageddon_chance", "28");
  2255. cvar_armageddon = register_cvar("zp_armageddon_enable", "1");
  2256. cvar_armageddonminplayers = register_cvar("zp_armageddon_min_plrs", "2");
  2257. cvar_allowrespawnarmageddon = register_cvar("zp_armageddon_allow_respawn", "0");
  2258.  
  2259. cvar_avschance = register_cvar("zp_avs_chance", "28");
  2260. cvar_avs = register_cvar("zp_avs_enable", "1");
  2261. cvar_avsminplayers = register_cvar("zp_avs_min_plrs", "2");
  2262. cvar_allowrespawnavs = register_cvar("zp_avs_allow_respawn", "0");
  2263.  
  2264. // Hattrick
  2265. //
  2266. register_cvar("zp_zombiefrost_enable_icecube", "1")
  2267. cvar_sniperinfammo = register_cvar("zp_sniper_unlimited_ammo", "1");
  2268. cvar_assassinignorefrags = register_cvar("zp_assassin_ignore_frags", "0");
  2269. cvar_assassinignoreammo = register_cvar("zp_assassin_ignore_ammo", "0");
  2270. cvar_respawnassassin = register_cvar("zp_respawn_assassin", "1");
  2271. cvar_damagewhilefrost = register_cvar("zp_damage_while_frost", "1");
  2272. cvar_sniperignoreammo = register_cvar("zp_sniper_ignore_ammo", "0");
  2273. cvar_sniperdamage = register_cvar("zp_sniper_damage", "5000");
  2274. cvar_assassindamage = register_cvar("zp_assassin_damage", "250");
  2275. cvar_assassinpainfree = register_cvar("zp_assassin_pain_free", "1");
  2276. cvar_sniperpainfree = register_cvar("zp_sniper_pain_free", "1");
  2277. cvar_assassinknockback = register_cvar("zp_assassin_knockback", "0.25");
  2278. cvar_sniperignorefrags = register_cvar("zp_sniper_ignore_frags", "0");
  2279. cvar_respawnsniper = register_cvar("zp_respawn_sniper", "1");
  2280. cvar_assassinaura = register_cvar("zp_assassin_aura", "0");
  2281. cvar_assassinbasehp = register_cvar("zp_assassin_base_hp", "0");
  2282. cvar_assassinchance = register_cvar("zp_assassin_chance", "25");
  2283. cvar_assassinglow = register_cvar("zp_assassin_glow", "0");
  2284. cvar_assassingravity = register_cvar("zp_assassin_gravity", "0.33")
  2285. g_maxammo=register_cvar("zp_max_admin_ammo","50")
  2286. cvar_assassinhp = register_cvar("zp_assassin_hp", "15000");
  2287. cvar_assassinminplayers = register_cvar("zp_assassin_min_players", "8")
  2288. cvar_assassinnvgcolor[0] = register_cvar("zp_assassin_nvg_r", "255");
  2289. cvar_assassinnvgcolor[1] = register_cvar("zp_assassin_nvg_g", "0");
  2290. cvar_assassinnvgcolor[2] = register_cvar("zp_assassin_nvg_b", "0");
  2291. cvar_assassinspd = register_cvar("zp_assassin_speed", "600");
  2292. cvar_sniperaura = register_cvar("zp_sniper_aura", "0");
  2293. cvar_sniperglow = register_cvar("zp_sniper_glow", "0");
  2294. cvar_sniperhp = register_cvar("zp_sniper_hp", "5000");
  2295. cvar_sniperbasehp = register_cvar("zp_sniper_base_hp", "0");
  2296. cvar_sniperchance = register_cvar("zp_sniper_chance", "28");
  2297. cvar_sniperspd = register_cvar("zp_sniper_speed", "250");
  2298. cvar_snipergravity = register_cvar("zp_sniper_gravity", "0.8");
  2299. cvar_sniperminplayers = register_cvar("zp_sniper_min_players", "8");
  2300. g_srvname = register_cvar("zp_hostname", "");
  2301.  
  2302. cvar_leapsniper = register_cvar("zp_leap_sniper", "0");
  2303. cvar_leapsnipercooldown = register_cvar("zp_leap_sniper_cooldown", "0");
  2304. cvar_leapsniperforce = register_cvar("zp_leap_sniper_force", "0");
  2305. cvar_leapsniperheight = register_cvar("zp_leap_sniper_height", "0");
  2306.  
  2307. cvar_leapassassin = register_cvar("zp_leap_assassin", "1");
  2308. cvar_leapassassinforce = register_cvar("zp_leap_assassin_force", "400");
  2309. cvar_leapassassincooldown = register_cvar("zp_leap_assassin_cooldown", "0.0");
  2310. cvar_leapassassinheight = register_cvar("zp_leap_assassin_height", "350");
  2311.  
  2312. cvar_assassin = register_cvar("zp_assassin_on", "1");
  2313. cvar_sniper = register_cvar("zp_sniper_on", "1");
  2314.  
  2315. cvar_allowrespawnassassin = register_cvar("zp_allow_respawn_assassin", "0");
  2316. cvar_allowrespawnsniper = register_cvar("zp_allow_respawn_sniper", "0");
  2317.  
  2318. // CVARS - General Purpose
  2319. cvar_warmup = register_cvar("zp_delay", "10")
  2320. cvar_lighting = register_cvar("zp_lighting", "a")
  2321. cvar_thunder = register_cvar("zp_thunderclap", "90")
  2322. cvar_triggered = register_cvar("zp_triggered_lights", "1")
  2323. cvar_removedoors = register_cvar("zp_remove_doors", "0")
  2324. cvar_blockpushables = register_cvar("zp_blockuse_pushables", "1")
  2325. cvar_blocksuicide = register_cvar("zp_block_suicide", "1")
  2326. cvar_randspawn = register_cvar("zp_random_spawn", "1")
  2327. cvar_respawnworldspawnkill = register_cvar("zp_respawn_on_worldspawn_kill", "1")
  2328. cvar_removedropped = register_cvar("zp_remove_dropped", "0")
  2329. cvar_removemoney = register_cvar("zp_remove_money", "1")
  2330. cvar_buycustom = register_cvar("zp_buy_custom", "1")
  2331. cvar_buyzonetime = register_cvar("zp_buyzone_time", "0.0")
  2332. cvar_randweapons = register_cvar("zp_random_weapons", "0")
  2333. cvar_adminmodelshuman = register_cvar("zp_admin_models_human", "1")
  2334. cvar_adminknifemodelshuman = register_cvar("zp_admin_knife_models_human", "0")
  2335. cvar_adminmodelszombie = register_cvar("zp_admin_models_zombie", "1")
  2336. cvar_adminknifemodelszombie = register_cvar("zp_admin_knife_models_zombie", "0")
  2337. cvar_zclasses = register_cvar("zp_zombie_classes", "1")
  2338. cvar_statssave = register_cvar("zp_stats_save", "1")
  2339. cvar_startammopacks = register_cvar("zp_starting_ammo_packs", "5")
  2340. cvar_preventconsecutive = register_cvar("zp_prevent_consecutive_modes", "1")
  2341. cvar_keephealthondisconnect = register_cvar("zp_keep_health_on_disconnect", "1")
  2342. cvar_huddisplay = register_cvar("zp_hud_display", "1")
  2343. cvar_menucustomcommand1 = register_cvar("zpnm_menu_custom_command1", "")
  2344.  
  2345. // CVARS - Deathmatch
  2346. cvar_deathmatch = register_cvar("zp_deathmatch", "0")
  2347. cvar_spawndelay = register_cvar("zp_spawn_delay", "5")
  2348. cvar_spawnprotection = register_cvar("zp_spawn_protection", "5")
  2349. cvar_respawnonsuicide = register_cvar("zp_respawn_on_suicide", "0")
  2350. cvar_respawnafterlast = register_cvar("zp_respawn_after_last_human", "1")
  2351. cvar_allowrespawninfection = register_cvar("zp_infection_allow_respawn", "1")
  2352. cvar_allowrespawnnem = register_cvar("zp_nem_allow_respawn", "0")
  2353. cvar_allowrespawnsurv = register_cvar("zp_surv_allow_respawn", "0")
  2354. cvar_allowrespawnswarm = register_cvar("zp_swarm_allow_respawn", "0")
  2355. cvar_allowrespawnplague = register_cvar("zp_plague_allow_respawn", "0")
  2356. cvar_respawnzomb = register_cvar("zp_respawn_zombies", "1")
  2357. cvar_respawnhum = register_cvar("zp_respawn_humans", "1")
  2358. cvar_respawnnem = register_cvar("zp_respawn_nemesis", "1")
  2359. cvar_respawnsurv = register_cvar("zp_respawn_survivors", "1")
  2360.  
  2361. // CVARS - Extra Items
  2362. cvar_extraitems = register_cvar("zp_extra_items", "1")
  2363. cvar_extraweapons = register_cvar("zp_extra_weapons", "1")
  2364. cvar_extranvision = register_cvar("zp_extra_nvision", "1")
  2365. cvar_extraantidote = register_cvar("zp_extra_antidote", "1")
  2366. cvar_antidotelimit = register_cvar("zp_extra_antidote_limit", "999")
  2367. cvar_extramadness = register_cvar("zp_extra_madness", "1")
  2368. cvar_madnesslimit = register_cvar("zp_extra_madness_limit", "999")
  2369. cvar_madnessduration = register_cvar("zp_extra_madness_duration", "5.0")
  2370. cvar_extrainfbomb = register_cvar("zp_extra_infbomb", "1")
  2371. cvar_infbomblimit = register_cvar("zp_extra_infbomb_limit", "999")
  2372.  
  2373. // CVARS - Flashlight and Nightvision
  2374. cvar_nvggive = register_cvar("zp_nvg_give", "1")
  2375. cvar_customnvg = register_cvar("zp_nvg_custom", "1")
  2376. cvar_nvgsize = register_cvar("zp_nvg_size", "80")
  2377. cvar_nvgcolor[0] = register_cvar("zp_nvg_color_R", "0")
  2378. cvar_nvgcolor[1] = register_cvar("zp_nvg_color_G", "150")
  2379. cvar_nvgcolor[2] = register_cvar("zp_nvg_color_B", "0")
  2380. cvar_humnvgcolor[0] = register_cvar("zp_nvg_hum_color_R", "0")
  2381. cvar_humnvgcolor[1] = register_cvar("zp_nvg_hum_color_G", "150")
  2382. cvar_humnvgcolor[2] = register_cvar("zp_nvg_hum_color_B", "0")
  2383. cvar_nemnvgcolor[0] = register_cvar("zp_nvg_nem_color_R", "150")
  2384. cvar_nemnvgcolor[1] = register_cvar("zp_nvg_nem_color_G", "0")
  2385. cvar_nemnvgcolor[2] = register_cvar("zp_nvg_nem_color_B", "0")
  2386. cvar_customflash = register_cvar("zp_flash_custom", "0")
  2387. cvar_flashsize = register_cvar("zp_flash_size", "10")
  2388. cvar_flashdrain = register_cvar("zp_flash_drain", "1")
  2389. cvar_flashcharge = register_cvar("zp_flash_charge", "5")
  2390. cvar_flashdist = register_cvar("zp_flash_distance", "1000")
  2391. cvar_flashcolor[0] = register_cvar("zp_flash_color_R", "100")
  2392. cvar_flashcolor[1] = register_cvar("zp_flash_color_G", "100")
  2393. cvar_flashcolor[2] = register_cvar("zp_flash_color_B", "100")
  2394. cvar_flashshowall = register_cvar("zp_flash_show_all", "1")
  2395.  
  2396. // CVARS - Knockback
  2397. cvar_knockback = register_cvar("zp_knockback", "0")
  2398. cvar_knockbackdamage = register_cvar("zp_knockback_damage", "1")
  2399. cvar_knockbackpower = register_cvar("zp_knockback_power", "1")
  2400. cvar_knockbackzvel = register_cvar("zp_knockback_zvel", "0")
  2401. cvar_knockbackducking = register_cvar("zp_knockback_ducking", "0.25")
  2402. cvar_knockbackdist = register_cvar("zp_knockback_distance", "500")
  2403. cvar_nemknockback = register_cvar("zp_knockback_nemesis", "0.25")
  2404.  
  2405. // CVARS - Leap
  2406. cvar_leapzombies = register_cvar("zp_leap_zombies", "0")
  2407. cvar_leapzombiesforce = register_cvar("zp_leap_zombies_force", "500")
  2408. cvar_leapzombiesheight = register_cvar("zp_leap_zombies_height", "300")
  2409. cvar_leapzombiescooldown = register_cvar("zp_leap_zombies_cooldown", "5.0")
  2410. cvar_leapnemesis = register_cvar("zp_leap_nemesis", "1")
  2411. cvar_leapnemesisforce = register_cvar("zp_leap_nemesis_force", "500")
  2412. cvar_leapnemesisheight = register_cvar("zp_leap_nemesis_height", "300")
  2413. cvar_leapnemesiscooldown = register_cvar("zp_leap_nemesis_cooldown", "5.0")
  2414. cvar_leapsurvivor = register_cvar("zp_leap_survivor", "0")
  2415. cvar_leapsurvivorforce = register_cvar("zp_leap_survivor_force", "500")
  2416. cvar_leapsurvivorheight = register_cvar("zp_leap_survivor_height", "300")
  2417. cvar_leapsurvivorcooldown = register_cvar("zp_leap_survivor_cooldown", "5.0")
  2418.  
  2419. // CVARS - Humans
  2420. cvar_humanhp = register_cvar("zp_human_health", "100")
  2421. cvar_humanlasthp = register_cvar("zp_human_last_extrahp", "0")
  2422. cvar_humanspd = register_cvar("zp_human_speed", "240")
  2423. cvar_humangravity = register_cvar("zp_human_gravity", "1.0")
  2424. cvar_humanarmor = register_cvar("zp_human_armor_protect", "1")
  2425. cvar_infammo = register_cvar("zp_human_unlimited_ammo", "0")
  2426. cvar_ammodamage_human = register_cvar("zp_human_damage_reward", "500")
  2427. cvar_fragskill = register_cvar("zp_human_frags_for_kill", "1")
  2428.  
  2429. // CVARS - Custom Grenades
  2430. cvar_firegrenades = register_cvar("zp_fire_grenades", "1")
  2431. cvar_fireduration = register_cvar("zp_fire_duration", "10")
  2432. cvar_firedamage = register_cvar("zp_fire_damage", "5")
  2433. cvar_fireslowdown = register_cvar("zp_fire_slowdown", "0.5")
  2434. cvar_frostgrenades = register_cvar("zp_frost_grenades", "1")
  2435. cvar_freezeduration = register_cvar("zp_frost_duration", "3")
  2436. cvar_flaregrenades = register_cvar("zp_flare_grenades","1")
  2437. // Hattrick
  2438. //
  2439. //cvar_flareduration = register_cvar("zp_flare_duration", "60")
  2440. //cvar_flaresize = register_cvar("zp_flare_size", "25")
  2441. //cvar_flarecolor = register_cvar("zp_flare_color", "0")
  2442.  
  2443. // CVARS - Zombies
  2444. cvar_zombiefirsthp = register_cvar("zp_zombie_first_hp", "2.0")
  2445. cvar_zombiearmor = register_cvar("zp_zombie_armor", "0.75")
  2446. cvar_hitzones = register_cvar("zp_zombie_hitzones", "0")
  2447. cvar_zombiebonushp = register_cvar("zp_zombie_infect_health", "100")
  2448. cvar_zombiefov = register_cvar("zp_zombie_fov", "110")
  2449. cvar_zombiesilent = register_cvar("zp_zombie_silent", "1")
  2450. cvar_zombiepainfree = register_cvar("zp_zombie_painfree", "2")
  2451. cvar_zombiebleeding = register_cvar("zp_zombie_bleeding", "1")
  2452. cvar_ammoinfect = register_cvar("zp_zombie_infect_reward", "1")
  2453. cvar_ammodamage_zombie = register_cvar("zp_zombie_damage_reward", "0")
  2454. cvar_fragsinfect = register_cvar("zp_zombie_frags_for_infect", "1")
  2455.  
  2456. // CVARS - Special Effects
  2457. cvar_infectionscreenfade = register_cvar("zp_infection_screenfade", "1")
  2458. cvar_infectionscreenshake = register_cvar("zp_infection_screenshake", "1")
  2459. cvar_infectionsparkle = register_cvar("zp_infection_sparkle", "1")
  2460. cvar_infectiontracers = register_cvar("zp_infection_tracers", "1")
  2461. cvar_infectionparticles = register_cvar("zp_infection_particles", "1")
  2462. cvar_hudicons = register_cvar("zp_hud_icons", "1")
  2463.  
  2464. // CVARS - Nemesis
  2465. cvar_nem = register_cvar("zp_nem_enabled", "1")
  2466. cvar_nemchance = register_cvar("zp_nem_chance", "20")
  2467. cvar_nemminplayers = register_cvar("zp_nem_min_players", "0")
  2468. cvar_nemhp = register_cvar("zp_nem_health", "0")
  2469. cvar_nembasehp = register_cvar("zp_nem_base_health", "0")
  2470. cvar_nemspd = register_cvar("zp_nem_speed", "250")
  2471. cvar_nemgravity = register_cvar("zp_nem_gravity", "0.5")
  2472. cvar_nemdamage = register_cvar("zp_nem_damage", "250")
  2473. cvar_nemglow = register_cvar("zp_nem_glow", "1")
  2474. cvar_nemaura = register_cvar("zp_nem_aura", "1")
  2475. cvar_nempainfree = register_cvar("zp_nem_painfree", "0")
  2476. cvar_nemignorefrags = register_cvar("zp_nem_ignore_frags", "1")
  2477. cvar_nemignoreammo = register_cvar("zp_nem_ignore_rewards", "1")
  2478.  
  2479. // CVARS - Survivor
  2480. cvar_surv = register_cvar("zp_surv_enabled", "1")
  2481. cvar_survchance = register_cvar("zp_surv_chance", "20")
  2482. cvar_survminplayers = register_cvar("zp_surv_min_players", "0")
  2483. cvar_survhp = register_cvar("zp_surv_health", "0")
  2484. cvar_survbasehp = register_cvar("zp_surv_base_health", "0")
  2485. cvar_survspd = register_cvar("zp_surv_speed", "230")
  2486. cvar_survgravity = register_cvar("zp_surv_gravity", "1.25")
  2487. cvar_survglow = register_cvar("zp_surv_glow", "1")
  2488. cvar_survaura = register_cvar("zp_surv_aura", "1")
  2489. cvar_survpainfree = register_cvar("zp_surv_painfree", "1")
  2490. cvar_survignorefrags = register_cvar("zp_surv_ignore_frags", "1")
  2491. cvar_survignoreammo = register_cvar("zp_surv_ignore_rewards", "1")
  2492. // Hattrick
  2493. //
  2494. //cvar_survweapon = register_cvar("zp_surv_weapon", "weapon_m249")
  2495. cvar_survinfammo = register_cvar("zp_surv_unlimited_ammo", "2")
  2496.  
  2497. // CVARS - Swarm Mode
  2498. cvar_swarm = register_cvar("zp_swarm_enabled", "1")
  2499. cvar_swarmchance = register_cvar("zp_swarm_chance", "20")
  2500. cvar_swarmminplayers = register_cvar("zp_swarm_min_players", "0")
  2501.  
  2502. // CVARS - Multi Infection
  2503. cvar_multi = register_cvar("zp_multi_enabled", "1")
  2504. cvar_multichance = register_cvar("zp_multi_chance", "20")
  2505. cvar_multiminplayers = register_cvar("zp_multi_min_players", "0")
  2506. cvar_multiratio = register_cvar("zp_multi_ratio", "0.15")
  2507.  
  2508. // CVARS - Plague Mode
  2509. cvar_plague = register_cvar("zp_plague_enabled", "1")
  2510. cvar_plaguechance = register_cvar("zp_plague_chance", "30")
  2511. cvar_plagueminplayers = register_cvar("zp_plague_min_players", "0")
  2512. cvar_plagueratio = register_cvar("zp_plague_ratio", "0.5")
  2513. cvar_plaguenemnum = register_cvar("zp_plague_nem_number", "1")
  2514. cvar_plaguenemhpmulti = register_cvar("zp_plague_nem_hp_multi", "0.5")
  2515. cvar_plaguesurvnum = register_cvar("zp_plague_surv_number", "1")
  2516. cvar_plaguesurvhpmulti = register_cvar("zp_plague_surv_hp_multi", "0.5")
  2517.  
  2518. // CVARS - Others
  2519. cvar_logcommands = register_cvar("zp_logcommands", "1")
  2520. cvar_showactivity = get_cvar_pointer("amx_show_activity")
  2521. cvar_botquota = get_cvar_pointer("bot_quota")
  2522. register_cvar("zp_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  2523. set_cvar_string("zp_version", PLUGIN_VERSION)
  2524.  
  2525. // Custom Forwards
  2526. g_fwRoundStart = CreateMultiForward("zp_round_started", ET_IGNORE, FP_CELL, FP_CELL)
  2527. g_fwRoundEnd = CreateMultiForward("zp_round_ended", ET_IGNORE, FP_CELL)
  2528. g_fwUserInfected_pre = CreateMultiForward("zp_user_infected_pre", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  2529. g_fwUserInfected_post = CreateMultiForward("zp_user_infected_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  2530. g_fwUserHumanized_pre = CreateMultiForward("zp_user_humanized_pre", ET_IGNORE, FP_CELL, FP_CELL)
  2531. g_fwUserHumanized_post = CreateMultiForward("zp_user_humanized_post", ET_IGNORE, FP_CELL, FP_CELL)
  2532. g_fwUserInfect_attempt = CreateMultiForward("zp_user_infect_attempt", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
  2533. g_fwUserHumanize_attempt = CreateMultiForward("zp_user_humanize_attempt", ET_CONTINUE, FP_CELL, FP_CELL)
  2534. g_fwExtraItemSelected = CreateMultiForward("zp_extra_item_selected", ET_CONTINUE, FP_CELL, FP_CELL)
  2535. g_fwUserUnfrozen = CreateMultiForward("zp_user_unfrozen", ET_IGNORE, FP_CELL)
  2536. g_fwUserLastZombie = CreateMultiForward("zp_user_last_zombie", ET_IGNORE, FP_CELL)
  2537. g_fwUserLastHuman = CreateMultiForward("zp_user_last_human", ET_IGNORE, FP_CELL)
  2538.  
  2539. // Collect random spawn points
  2540. load_spawns()
  2541.  
  2542. // Set a random skybox?
  2543. if (g_sky_enable)
  2544. {
  2545. new sky[32]
  2546. ArrayGetString(g_sky_names, random_num(0, ArraySize(g_sky_names) - 1), sky, charsmax(sky))
  2547. set_cvar_string("sv_skyname", sky)
  2548. }
  2549.  
  2550. // Disable sky lighting so it doesn't mess with our custom lighting
  2551. set_cvar_num("sv_skycolor_r", 0)
  2552. set_cvar_num("sv_skycolor_g", 0)
  2553. set_cvar_num("sv_skycolor_b", 0)
  2554.  
  2555. // Create the HUD Sync Objects
  2556. g_MsgSync = CreateHudSyncObj()
  2557. g_MsgSync2 = CreateHudSyncObj()
  2558. g_MsgSync3=CreateHudSyncObj()
  2559.  
  2560. // Format mod name
  2561. formatex(g_modname, charsmax(g_modname), "Zombie Plague %s", PLUGIN_VERSION)
  2562.  
  2563. // Get Max Players
  2564. g_maxplayers = get_maxplayers()
  2565.  
  2566. // Reserved saving slots starts on maxplayers+1
  2567. db_slot_i = g_maxplayers+1
  2568.  
  2569. // Check if it's a CZ server
  2570. new mymod[6]
  2571. get_modname(mymod, charsmax(mymod))
  2572. if (equal(mymod, "czero")) g_czero = 1
  2573. }
  2574.  
  2575. public plugin_cfg()
  2576. {
  2577. // Plugin disabled?
  2578. if (!g_pluginenabled) return;
  2579.  
  2580. // Get configs dir
  2581. new cfgdir[32]
  2582. get_configsdir(cfgdir, charsmax(cfgdir))
  2583.  
  2584. // Execute config file (zombieplague.cfg)
  2585. server_cmd("exec %s/zombieplague.cfg", cfgdir)
  2586.  
  2587. // Prevent any more stuff from registering
  2588. g_arrays_created = false
  2589.  
  2590. // Save customization data
  2591. save_customization()
  2592.  
  2593. // Lighting task
  2594. set_task(5.0, "lighting_effects", _, _, _, "b")
  2595.  
  2596. // Cache CVARs after configs are loaded / call roundstart manually
  2597. set_task(0.5, "cache_cvars")
  2598. set_task(0.5, "event_round_start")
  2599. set_task(0.5, "logevent_round_start")
  2600. }
  2601.  
  2602. public event_show_status(id)
  2603. {
  2604. //lcheck()
  2605.  
  2606. if (!g_isbot[id] && g_isconnected[id])
  2607. {
  2608. static aimid, class[32], red, blue, hp[32], armor[32] ,ammo[32],points[32]
  2609. aimid = read_data(2)
  2610.  
  2611. if (!g_isalive[aimid])
  2612. return;
  2613.  
  2614. if (g_zombie[id] == g_zombie[aimid])
  2615. {
  2616. if (g_zombie[id])
  2617. {
  2618. red = 255
  2619. blue = 0
  2620.  
  2621. if (g_nemesis[aimid])
  2622. formatex(class, charsmax(class), "%L", id, "CLASS_NEMESIS")
  2623. else if (g_assassin[aimid])
  2624. formatex(class, charsmax(class), "Assassin")
  2625. else
  2626. formatex(class, charsmax(class), "%s", g_zombie_classname[aimid])
  2627. }
  2628. else
  2629. {
  2630. red = 110
  2631. blue = 190
  2632.  
  2633. if (g_survivor[aimid])
  2634. formatex(class, charsmax(class), "%L", id, "CLASS_SURVIVOR")
  2635. else if (g_sniper[aimid])
  2636. formatex(class, charsmax(class), "Sniper")
  2637. else
  2638. formatex(class, charsmax(class), "%L", id, "CLASS_HUMAN")
  2639. }
  2640.  
  2641. // Show the notice
  2642. set_hudmessage(red, 20, blue, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
  2643. AddCommas(get_user_health(aimid), hp, 31)
  2644. AddCommas(get_user_armor(aimid), armor, 31)
  2645. AddCommas(g_ammopacks[aimid], ammo, 31)
  2646. AddCommas(g_points[aimid], points, 31)
  2647. ShowSyncHudMsg(id, g_MsgSync3,"%s [%s]^nHP: %s Armor: %s Ammo: %s Points: %s", g_playername[aimid], class, hp, armor, ammo, points)
  2648. }
  2649. else if (g_zombie[aimid] && !g_zombie[id])
  2650. {
  2651. red = 255
  2652. blue = 0
  2653.  
  2654. if (g_nemesis[aimid])
  2655. formatex(class, charsmax(class), "%L", id, "CLASS_NEMESIS")
  2656. else if (g_assassin[aimid])
  2657. formatex(class, charsmax(class), "Assassin")
  2658. else
  2659. formatex(class, charsmax(class), "%s", g_zombie_classname[aimid])
  2660.  
  2661. // Show the notice
  2662. set_hudmessage(red, 20, blue, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
  2663. AddCommas(get_user_health(aimid), hp, 31)
  2664. ShowSyncHudMsg(id, g_MsgSync3,"%s [%s]^n%s HP", g_playername[aimid], class, hp)
  2665. }
  2666. }
  2667. }
  2668.  
  2669. // Remove the aim-info message
  2670. public event_hide_status(id)
  2671. {
  2672. if (g_isalive[id])
  2673. ClearSyncHud(id, g_MsgSync3)
  2674. }
  2675.  
  2676. /*================================================================================
  2677. [Main Events]
  2678. =================================================================================*/
  2679.  
  2680. // Event Round Start
  2681. public event_round_start()
  2682. {
  2683. // Remove doors/lights?
  2684. set_task(0.1, "remove_stuff")
  2685.  
  2686. // New round starting
  2687. g_newround = true
  2688. g_endround = false
  2689. g_survround = false
  2690. g_nemround = false
  2691. g_swarmround = false
  2692. g_avsround = false
  2693. g_armageddonround = false
  2694. g_plagueround = false
  2695. g_modestarted = false
  2696. // Hattrick
  2697. //
  2698. g_assassinround = false
  2699. g_sniperround = false
  2700.  
  2701. // Reset bought infection bombs counter
  2702. g_infbombcounter = 0
  2703. g_antidotecounter = 0
  2704. g_madnesscounter = 0
  2705.  
  2706. // Freezetime begins
  2707. g_freezetime = true
  2708.  
  2709. // Show welcome message and T-Virus notice
  2710. remove_task(TASK_WELCOMEMSG)
  2711. set_task(2.0, "welcome_msg", TASK_WELCOMEMSG)
  2712.  
  2713. // Set a new "Make Zombie Task"
  2714. remove_task(TASK_MAKEZOMBIE)
  2715. set_task(2.0 + get_pcvar_float(cvar_warmup), "make_zombie_task", TASK_MAKEZOMBIE)
  2716. }
  2717.  
  2718. // Log Event Round Start
  2719. public logevent_round_start()
  2720. {
  2721. // Freezetime ends
  2722. g_freezetime = false
  2723. }
  2724.  
  2725. // Log Event Round End
  2726. public logevent_round_end()
  2727. {
  2728. // Prevent this from getting called twice when restarting (bugfix)
  2729. static Float:lastendtime, Float:current_time
  2730. current_time = get_gametime()
  2731. if (current_time - lastendtime < 0.5) return;
  2732. lastendtime = current_time
  2733.  
  2734. // Temporarily save player stats?
  2735. if (get_pcvar_num(cvar_statssave))
  2736. {
  2737. static id, team
  2738. for (id = 1; id <= g_maxplayers; id++)
  2739. {
  2740. // Not connected
  2741. if (!g_isconnected[id])
  2742. continue;
  2743.  
  2744. team = fm_cs_get_user_team(id)
  2745.  
  2746. // Not playing
  2747. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  2748. continue;
  2749.  
  2750. save_stats(id)
  2751. }
  2752. }
  2753.  
  2754. // Hattrick
  2755. //
  2756. for (new i = 1; i <= g_maxplayers; i++)
  2757. {
  2758. if (g_isconnected[i])
  2759. {
  2760. g_doubledamage[i] = false
  2761. if (get_user_godmode(i))
  2762. set_user_godmode(i, 0)
  2763. }
  2764. }
  2765.  
  2766. // Round ended
  2767. g_endround = true
  2768.  
  2769. // Stop old tasks (if any)
  2770. remove_task(TASK_WELCOMEMSG)
  2771. remove_task(TASK_MAKEZOMBIE)
  2772.  
  2773. // Hattrick
  2774. //
  2775. // Stop ambience sounds
  2776. //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) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround))
  2777. if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) ||
  2778. (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) ||
  2779. (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) ||
  2780. (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && g_sniperround) ||
  2781. (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && g_assassinround) ||
  2782. (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && (g_plagueround || g_avsround || g_armageddonround)) ||
  2783. (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_assassinround && !g_sniperround && !g_survround && !g_armageddonround && !g_avsround && !g_swarmround && !g_plagueround))
  2784. {
  2785. remove_task(TASK_AMBIENCESOUNDS)
  2786. ambience_sound_stop()
  2787. }
  2788.  
  2789. // Show HUD notice, play win sound, update team scores...
  2790. static sound[64]
  2791. if (!fnGetZombies())
  2792. {
  2793. // Human team wins
  2794. set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2795. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN")
  2796.  
  2797. // Play win sound and increase score, unless game commencing
  2798. ArrayGetString(sound_win_humans, random_num(0, ArraySize(sound_win_humans) - 1), sound, charsmax(sound))
  2799. PlaySound(sound)
  2800. if (!g_gamecommencing) g_scorehumans++
  2801.  
  2802. // Round end forward
  2803. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_HUMAN);
  2804. }
  2805. else if (!fnGetHumans())
  2806. {
  2807. // Zombie team wins
  2808. set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2809. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_ZOMBIE")
  2810.  
  2811. // Play win sound and increase score, unless game commencing
  2812. ArrayGetString(sound_win_zombies, random_num(0, ArraySize(sound_win_zombies) - 1), sound, charsmax(sound))
  2813. PlaySound(sound)
  2814. if (!g_gamecommencing) g_scorezombies++
  2815.  
  2816. // Round end forward
  2817. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_ZOMBIE);
  2818. }
  2819. else
  2820. {
  2821. // No one wins
  2822. set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2823. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_NO_ONE")
  2824.  
  2825. // Play win sound
  2826. ArrayGetString(sound_win_no_one, random_num(0, ArraySize(sound_win_no_one) - 1), sound, charsmax(sound))
  2827. PlaySound(sound)
  2828.  
  2829. // Round end forward
  2830. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, ZP_TEAM_NO_ONE);
  2831. }
  2832.  
  2833. // Game commencing triggers round end
  2834. g_gamecommencing = false
  2835.  
  2836. // Balance the teams
  2837. balance_teams()
  2838. }
  2839.  
  2840. // Event Map Ended
  2841. public event_intermission()
  2842. {
  2843. // Remove ambience sounds task
  2844. remove_task(TASK_AMBIENCESOUNDS)
  2845. }
  2846.  
  2847. // BP Ammo update
  2848. public event_ammo_x(id)
  2849. {
  2850. // Humans only
  2851. if (g_zombie[id])
  2852. return;
  2853.  
  2854. // Get ammo type
  2855. static type
  2856. type = read_data(1)
  2857.  
  2858. // Unknown ammo type
  2859. if (type >= sizeof AMMOWEAPON)
  2860. return;
  2861.  
  2862. // Get weapon's id
  2863. static weapon
  2864. weapon = AMMOWEAPON[type]
  2865.  
  2866. // Primary and secondary only
  2867. if (MAXBPAMMO[weapon] <= 2)
  2868. return;
  2869.  
  2870. // Get ammo amount
  2871. static amount
  2872. amount = read_data(2)
  2873.  
  2874. // Hattrick
  2875. //
  2876. // Unlimited BP Ammo?
  2877. //if (g_survivor[id] ? get_pcvar_num(cvar_survinfammo) : get_pcvar_num(cvar_infammo))
  2878. if (g_survivor[id] ? get_pcvar_num(cvar_survinfammo) : get_pcvar_num(cvar_infammo) || \
  2879. g_sniper[id] ? get_pcvar_num(cvar_sniperinfammo) : get_pcvar_num(cvar_infammo))
  2880. {
  2881. if (amount < MAXBPAMMO[weapon])
  2882. {
  2883. // The BP Ammo refill code causes the engine to send a message, but we
  2884. // can't have that in this forward or we risk getting some recursion bugs.
  2885. // For more info see: https://bugs.alliedmods.net/show_bug.cgi?id=3664
  2886. static args[1]
  2887. args[0] = weapon
  2888. set_task(0.1, "refill_bpammo", id, args, sizeof args)
  2889. }
  2890. }
  2891. // Bots automatically buy ammo when needed
  2892. else if (g_isbot[id] && amount <= BUYAMMO[weapon])
  2893. {
  2894. // Task needed for the same reason as above
  2895. set_task(0.1, "clcmd_buyammo", id)
  2896. }
  2897. }
  2898.  
  2899. /*================================================================================
  2900. [Main Forwards]
  2901. =================================================================================*/
  2902.  
  2903. // Entity Spawn Forward
  2904. public fw_Spawn(entity)
  2905. {
  2906. // Invalid entity
  2907. if (!pev_valid(entity)) return FMRES_IGNORED;
  2908.  
  2909. // Get classname
  2910. new classname[32], objective[32], size = ArraySize(g_objective_ents)
  2911. pev(entity, pev_classname, classname, charsmax(classname))
  2912.  
  2913. // Check whether it needs to be removed
  2914. for (new i = 0; i < size; i++)
  2915. {
  2916. ArrayGetString(g_objective_ents, i, objective, charsmax(objective))
  2917.  
  2918. if (equal(classname, objective))
  2919. {
  2920. engfunc(EngFunc_RemoveEntity, entity)
  2921. return FMRES_SUPERCEDE;
  2922. }
  2923. }
  2924.  
  2925. return FMRES_IGNORED;
  2926. }
  2927.  
  2928. // Sound Precache Forward
  2929. public fw_PrecacheSound(const sound[])
  2930. {
  2931. // Block all those unneeeded hostage sounds
  2932. if (equal(sound, "hostage", 7))
  2933. return FMRES_SUPERCEDE;
  2934.  
  2935. return FMRES_IGNORED;
  2936. }
  2937.  
  2938. public AddArmor(id)
  2939. {
  2940. static CsArmorType:at;
  2941. if (g_isalive[id])
  2942. {
  2943. if (containi(g_vip_flags[id], "A") != -1 && cs_get_user_armor(id, at) < 100)
  2944. cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM);
  2945.  
  2946. if (containi(g_vip_flags[id], "H") != -1 && get_user_health(id)<300)
  2947. set_user_health(id, 300);
  2948. }
  2949. }
  2950.  
  2951. // Ham Player Spawn Post Forward
  2952. public fw_PlayerSpawn_Post(id)
  2953. {
  2954. // Not alive or didn't join a team yet
  2955. if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  2956. return;
  2957.  
  2958. g_infector[id] = false
  2959. // Player spawned
  2960. g_isalive[id] = true
  2961. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  2962. {
  2963. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  2964. write_byte(id)
  2965. write_byte(4)
  2966. message_end()
  2967.  
  2968. set_task(0.175, "makevip", id, _, _, "a", 3)
  2969. }
  2970.  
  2971. if (g_vip[id])
  2972. set_task(1.0, "AddArmor", id);
  2973.  
  2974. // Remove previous tasks
  2975. remove_task(id+TASK_SPAWN)
  2976. remove_task(id+TASK_MODEL)
  2977. remove_task(id+TASK_BLOOD)
  2978. remove_task(id+TASK_AURA)
  2979. remove_task(id+TASK_BURN)
  2980. remove_task(id+TASK_CHARGE)
  2981. remove_task(id+TASK_FLASH)
  2982. remove_task(id+TASK_NVISION)
  2983.  
  2984. // Spawn at a random location?
  2985. if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
  2986.  
  2987. // Hide money?
  2988. if (get_pcvar_num(cvar_removemoney))
  2989. set_task(0.4, "task_hide_money", id+TASK_SPAWN)
  2990.  
  2991. // Respawn player if he dies because of a worldspawn kill?
  2992. if (get_pcvar_num(cvar_respawnworldspawnkill))
  2993. set_task(2.0, "respawn_player_check_task", id+TASK_SPAWN)
  2994.  
  2995. // Spawn as zombie?
  2996. if (g_respawn_as_zombie[id] && !g_newround)
  2997. {
  2998. reset_vars(id, 0) // reset player vars
  2999. zombieme(id, 0, 0, 0, 0) // make him zombie right away
  3000. return;
  3001. }
  3002.  
  3003. // Reset player vars
  3004. reset_vars(id, 0)
  3005. g_buytime[id] = get_gametime()
  3006.  
  3007. // Show custom buy menu?
  3008. if (get_pcvar_num(cvar_buycustom))
  3009. set_task(0.2, "show_menu_buy1", id+TASK_SPAWN)
  3010.  
  3011. // Set health and gravity
  3012. fm_set_user_health(id, get_pcvar_num(cvar_humanhp))
  3013. set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity))
  3014.  
  3015. // Set human maxspeed
  3016. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  3017.  
  3018. // Switch to CT if spawning mid-round
  3019. if (!g_newround && fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  3020. {
  3021. remove_task(id+TASK_TEAM)
  3022. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  3023. fm_user_team_update(id)
  3024. }
  3025.  
  3026. // Custom models stuff
  3027. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  3028. already_has_model = false
  3029.  
  3030. if (g_handle_models_on_separate_ent)
  3031. {
  3032. // Set the right model
  3033. if (g_vip[id] && containi(g_vip_flags[id], "M") != -1)
  3034. {
  3035. iRand = random_num(0, ArraySize(model_vip) - 1)
  3036. ArrayGetString(model_vip, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3037. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip, iRand))
  3038. }
  3039. else if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  3040. {
  3041. iRand = random_num(0, ArraySize(model_admin_human) - 1)
  3042. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3043. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  3044. }
  3045. else
  3046. {
  3047. iRand = random_num(0, ArraySize(model_human) - 1)
  3048. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3049. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  3050. }
  3051.  
  3052. // Set model on player model entity
  3053. fm_set_playermodel_ent(id)
  3054.  
  3055. // Remove glow on player model entity
  3056. fm_set_rendering(g_ent_playermodel[id])
  3057. }
  3058. else
  3059. {
  3060. // Get current model for comparing it with the current one
  3061. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  3062.  
  3063. // Set the right model, after checking that we don't already have it
  3064. if (g_vip[id] && containi(g_vip_flags[id], "M") != -1)
  3065. {
  3066. size = ArraySize(model_vip)
  3067. for (i = 0; i < size; i++)
  3068. {
  3069. ArrayGetString(model_vip, i, tempmodel, charsmax(tempmodel))
  3070. if (equal(currentmodel, tempmodel)) already_has_model = true
  3071. }
  3072.  
  3073. if (!already_has_model)
  3074. {
  3075. iRand = random_num(0, size - 1)
  3076. ArrayGetString(model_vip, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3077. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip, iRand))
  3078. }
  3079. }
  3080. else if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  3081. {
  3082. size = ArraySize(model_admin_human)
  3083. for (i = 0; i < size; i++)
  3084. {
  3085. ArrayGetString(model_admin_human, i, tempmodel, charsmax(tempmodel))
  3086. if (equal(currentmodel, tempmodel)) already_has_model = true
  3087. }
  3088.  
  3089. if (!already_has_model)
  3090. {
  3091. iRand = random_num(0, size - 1)
  3092. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3093. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  3094. }
  3095. }
  3096. else
  3097. {
  3098. size = ArraySize(model_human)
  3099. for (i = 0; i < size; i++)
  3100. {
  3101. ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
  3102. if (equal(currentmodel, tempmodel)) already_has_model = true
  3103. }
  3104.  
  3105. if (!already_has_model)
  3106. {
  3107. iRand = random_num(0, size - 1)
  3108. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  3109. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  3110. }
  3111. }
  3112.  
  3113. // Need to change the model?
  3114. if (!already_has_model)
  3115. {
  3116. // An additional delay is offset at round start
  3117. // since SVC_BAD is more likely to be triggered there
  3118. if (g_newround)
  3119. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  3120. else
  3121. fm_user_model_update(id+TASK_MODEL)
  3122. }
  3123.  
  3124. // Remove glow
  3125. fm_set_rendering(id)
  3126. }
  3127.  
  3128. // Bots stuff
  3129. if (g_isbot[id])
  3130. {
  3131. // Turn off NVG for bots
  3132. cs_set_user_nvg(id, 0)
  3133.  
  3134. // Automatically buy extra items/weapons after first zombie is chosen
  3135. if (get_pcvar_num(cvar_extraitems))
  3136. {
  3137. if (g_newround) set_task(10.0 + get_pcvar_float(cvar_warmup), "bot_buy_extras", id+TASK_SPAWN)
  3138. else set_task(10.0, "bot_buy_extras", id+TASK_SPAWN)
  3139. }
  3140. }
  3141.  
  3142. // Enable spawn protection for humans spawning mid-round
  3143. if (!g_newround && get_pcvar_float(cvar_spawnprotection) > 0.0)
  3144. {
  3145. // Do not take damage
  3146. g_nodamage[id] = true
  3147.  
  3148. // Make temporarily invisible
  3149. set_pev(id, pev_effects, pev(id, pev_effects) | EF_NODRAW)
  3150.  
  3151. // Set task to remove it
  3152. set_task(get_pcvar_float(cvar_spawnprotection), "remove_spawn_protection", id+TASK_SPAWN)
  3153. }
  3154.  
  3155. // Turn off his flashlight (prevents double flashlight bug/exploit)
  3156. turn_off_flashlight(id)
  3157.  
  3158. // Set the flashlight charge task to update battery status
  3159. if (g_cached_customflash)
  3160. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  3161.  
  3162. // Replace weapon models (bugfix)
  3163. static weapon_ent
  3164. weapon_ent = fm_cs_get_current_weapon_ent(id)
  3165. if (pev_valid(weapon_ent)) replace_weapon_models(id, cs_get_weapon_id(weapon_ent))
  3166.  
  3167. // Last Zombie Check
  3168. fnCheckLastZombie()
  3169. }
  3170.  
  3171. public client_PostThink(id)
  3172. {
  3173. if(!g_isalive[id] || !g_vip[id] || containi(g_vip_flags[id], "J") == -1)
  3174. return
  3175.  
  3176. if(dojump[id] == true)
  3177. {
  3178. new Float:velocity[3]
  3179. entity_get_vector(id,EV_VEC_velocity,velocity)
  3180. velocity[2] = random_float(265.0, 285.0)
  3181. entity_set_vector(id,EV_VEC_velocity,velocity)
  3182. dojump[id] = false
  3183. }
  3184. }
  3185.  
  3186. public resethud(id)
  3187. {
  3188. if(is_user_alive(id) && g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  3189. {
  3190. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  3191. write_byte(id)
  3192. write_byte(4)
  3193. message_end()
  3194.  
  3195. set_task(0.122, "makevip", id, _, _, "a", 3)
  3196. }
  3197. }
  3198.  
  3199. public makevip(id)
  3200. {
  3201. if(is_user_alive(id) && g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  3202. {
  3203. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  3204. write_byte(id)
  3205. write_byte(4)
  3206. message_end()
  3207. }
  3208. }
  3209.  
  3210. // Ham Player Killed Forward
  3211. public fw_PlayerKilled(victim, attacker, shouldgib)
  3212. {
  3213. // Player killed
  3214. g_isalive[victim] = false
  3215. // Disable nodamage mode after we die to prevent spectator nightvision using zombie madness colors bug
  3216. g_nodamage[victim] = false
  3217. g_infector[victim] = false
  3218.  
  3219. if (is_user_connected(attacker) && is_user_connected(victim) && attacker!=victim)
  3220. {
  3221. if (g_zombie[attacker])
  3222. {
  3223. g_points[attacker]++
  3224. savePoints(attacker)
  3225. }
  3226.  
  3227. else
  3228. {
  3229. if (g_sniper[attacker])
  3230. {
  3231. g_points[attacker]++
  3232. savePoints(attacker)
  3233. }
  3234.  
  3235. else
  3236. {
  3237. g_points[attacker]+=2
  3238. savePoints(attacker)
  3239. }
  3240. }
  3241. }
  3242.  
  3243. if (g_iEntityID[victim] > 0 && pev_valid(g_iEntityID[victim]))
  3244. {
  3245. remove_entity(g_iEntityID[victim]);
  3246. g_iEntityID[victim]=0;
  3247. }
  3248.  
  3249. // Hattrick
  3250. set_user_godmode(victim, 0);
  3251.  
  3252. // Hattrick
  3253. //
  3254. fm_set_rendering(victim);
  3255.  
  3256. new eff = pev(victim, pev_effects);
  3257. if (eff & EF_BRIGHTLIGHT)
  3258. {
  3259. eff &= ~EF_BRIGHTLIGHT;
  3260. set_pev(victim, pev_effects, eff);
  3261. }
  3262.  
  3263. // Enable dead players nightvision
  3264. set_task(0.1, "spec_nvision", victim)
  3265.  
  3266. // Disable nightvision when killed (bugfix)
  3267. if (get_pcvar_num(cvar_nvggive) == 0 && g_nvision[victim])
  3268. {
  3269. if (get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
  3270. else if (g_nvisionenabled[victim]) set_user_gnvision(victim, 0)
  3271. g_nvision[victim] = false
  3272. g_nvisionenabled[victim] = false
  3273. }
  3274.  
  3275. // Turn off nightvision when killed (bugfix)
  3276. if (get_pcvar_num(cvar_nvggive) == 2 && g_nvision[victim] && g_nvisionenabled[victim])
  3277. {
  3278. if (get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
  3279. else set_user_gnvision(victim, 0)
  3280. g_nvisionenabled[victim] = false
  3281. }
  3282.  
  3283. // Turn off custom flashlight when killed
  3284. if (g_cached_customflash)
  3285. {
  3286. // Turn it off
  3287. g_flashlight[victim] = false
  3288. g_flashbattery[victim] = 100
  3289.  
  3290. // Remove previous tasks
  3291. remove_task(victim+TASK_CHARGE)
  3292. remove_task(victim+TASK_FLASH)
  3293. }
  3294.  
  3295. // Stop bleeding/burning/aura when killed
  3296. if (g_zombie[victim])
  3297. {
  3298. remove_task(victim+TASK_BLOOD)
  3299. remove_task(victim+TASK_AURA)
  3300. remove_task(victim+TASK_BURN)
  3301. }
  3302.  
  3303. // Hattrick
  3304. //
  3305. // Nemesis explodes!
  3306. //if (g_nemesis[victim])
  3307. if (g_nemesis[victim] || g_assassin[victim])
  3308. SetHamParamInteger(3, 2)
  3309.  
  3310. // Determine whether the player killed himself
  3311. static selfkill
  3312. selfkill = (victim == attacker || !is_user_valid_connected(attacker)) ? true : false
  3313.  
  3314. // Killed by a non-player entity or self killed
  3315. if (selfkill) return;
  3316.  
  3317. // Hattrick
  3318. //
  3319. // Ignore Nemesis/Survivor Frags?
  3320. //if ((g_nemesis[attacker] && get_pcvar_num(cvar_nemignorefrags)) || (g_survivor[attacker] && get_pcvar_num(cvar_survignorefrags)))
  3321. if ((g_nemesis[attacker] && get_pcvar_num(cvar_nemignorefrags)) || (g_survivor[attacker] && get_pcvar_num(cvar_survignorefrags)) || \
  3322. (g_assassin[attacker] && get_pcvar_num(cvar_assassinignorefrags)) || (g_sniper[attacker] && get_pcvar_num(cvar_sniperignorefrags)))
  3323. RemoveFrags(attacker, victim)
  3324.  
  3325. // Hattrick
  3326. //
  3327. // Zombie/nemesis killed human, reward ammo packs
  3328. //if (g_zombie[attacker] && (!g_nemesis[attacker] || !get_pcvar_num(cvar_nemignoreammo)))
  3329. if (g_zombie[attacker] && (!g_nemesis[attacker] || !get_pcvar_num(cvar_nemignoreammo)) && (!g_assassin[attacker] || !get_pcvar_num(cvar_assassinignoreammo)))
  3330. g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect)
  3331.  
  3332. // Human killed zombie, add up the extra frags for kill
  3333. if (!g_zombie[attacker] && get_pcvar_num(cvar_fragskill) > 1)
  3334. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragskill) - 1, 0, 0)
  3335.  
  3336. // Zombie killed human, add up the extra frags for kill
  3337. if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)
  3338. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect) - 1, 0, 0)
  3339. }
  3340.  
  3341. public Rays()
  3342. {
  3343. static Float:origin[3];
  3344. for (new vip = 1; vip <= g_maxplayers; vip++)
  3345. {
  3346. if (is_user_alive(vip) && g_vip[vip] && containi(g_vip_flags[vip], "R") != -1)
  3347. {
  3348. if (!g_zombie[vip])
  3349. {
  3350. for (new z=1;z<=g_maxplayers;z++)
  3351. {
  3352. if (is_user_alive(z)&&g_zombie[z]&&!ExecuteHam(Ham_FVisible, vip, z))
  3353. {
  3354. pev(z,pev_origin,origin);
  3355. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, vip)
  3356. write_byte(TE_BEAMENTPOINT)
  3357. write_short(vip)
  3358. engfunc(EngFunc_WriteCoord, origin[0])
  3359. engfunc(EngFunc_WriteCoord, origin[1])
  3360. engfunc(EngFunc_WriteCoord, origin[2])
  3361. write_short(g_iLaser)
  3362. write_byte(10)
  3363. write_byte(10)
  3364. write_byte(10)
  3365. write_byte(10)
  3366. write_byte(10)
  3367. write_byte(255)
  3368. write_byte(0)
  3369. write_byte(0)
  3370. write_byte(200)
  3371. write_byte(10)
  3372. message_end()
  3373. }
  3374. }
  3375. }
  3376. else
  3377. {
  3378. for (new z=1;z<=g_maxplayers;z++)
  3379. {
  3380. if (is_user_alive(z)&&!g_zombie[z]&&!ExecuteHam(Ham_FVisible, vip, z))
  3381. {
  3382. pev(z,pev_origin,origin);
  3383. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, vip)
  3384. write_byte(TE_BEAMENTPOINT)
  3385. write_short(vip)
  3386. engfunc(EngFunc_WriteCoord, origin[0])
  3387. engfunc(EngFunc_WriteCoord, origin[1])
  3388. engfunc(EngFunc_WriteCoord, origin[2])
  3389. write_short(g_iLaser)
  3390. write_byte(10)
  3391. write_byte(10)
  3392. write_byte(10)
  3393. write_byte(10)
  3394. write_byte(10)
  3395. write_byte(0)
  3396. write_byte(120)
  3397. write_byte(190)
  3398. write_byte(200)
  3399. write_byte(10)
  3400. message_end()
  3401. }
  3402. }
  3403. }
  3404. }
  3405. }
  3406. }
  3407.  
  3408. // Ham Player Killed Post Forward
  3409. public fw_PlayerKilled_Post(victim, attacker, shouldgib)
  3410. {
  3411. // Last Zombie Check
  3412. fnCheckLastZombie()
  3413.  
  3414. // Determine whether the player killed himself
  3415. static selfkill
  3416. selfkill = (victim == attacker || !is_user_valid_connected(attacker)) ? true : false
  3417.  
  3418. // Respawn if deathmatch is enabled
  3419. if (get_pcvar_num(cvar_deathmatch))
  3420. {
  3421. // Respawn on suicide?
  3422. if (selfkill && !get_pcvar_num(cvar_respawnonsuicide))
  3423. return;
  3424.  
  3425. // Hattrick
  3426. //
  3427. // Respawn if human/zombie/nemesis/survivor?
  3428. // if ((g_zombie[victim] && !g_nemesis[victim] && !get_pcvar_num(cvar_respawnzomb)) ||
  3429. // (!g_zombie[victim] && !g_survivor[victim] && !get_pcvar_num(cvar_respawnhum)) ||
  3430. // (g_nemesis[victim] && !get_pcvar_num(cvar_respawnnem)) ||
  3431. // (g_survivor[victim] && !get_pcvar_num(cvar_respawnsurv)))
  3432. if ((g_zombie[victim] && !g_nemesis[victim] && !g_assassin[victim] && !get_pcvar_num(cvar_respawnzomb)) || \
  3433. (!g_zombie[victim] && !g_survivor[victim] && !g_sniper[victim] && !get_pcvar_num(cvar_respawnhum)) || \
  3434. (g_nemesis[victim] && !get_pcvar_num(cvar_respawnnem)) || \
  3435. (g_survivor[victim] && !get_pcvar_num(cvar_respawnsurv)) || \
  3436. (g_assassin[victim] && !get_pcvar_num(cvar_respawnassassin)) || \
  3437. (g_sniper[victim] && !get_pcvar_num(cvar_respawnsniper)))
  3438. return;
  3439.  
  3440. // Set the respawn task
  3441. set_task(get_pcvar_float(cvar_spawndelay), "respawn_player_task", victim+TASK_SPAWN)
  3442. }
  3443. }
  3444.  
  3445. // Ham Take Damage Forward
  3446. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  3447. {
  3448. // Non-player damage or self damage
  3449. if (victim == attacker || !is_user_valid_connected(attacker))
  3450. return HAM_IGNORED;
  3451.  
  3452. // New round starting or round ended
  3453. if (g_newround || g_endround)
  3454. return HAM_SUPERCEDE;
  3455.  
  3456. // Victim shouldn't take damage or victim is frozen
  3457. if (g_nodamage[victim] || get_user_godmode(victim) || (g_frozen[victim] && !(get_pcvar_num(cvar_damagewhilefrost))))
  3458. return HAM_SUPERCEDE;
  3459.  
  3460. // Prevent friendly fire
  3461. if (g_zombie[attacker] == g_zombie[victim])
  3462. return HAM_SUPERCEDE;
  3463.  
  3464. // Attacker is human...
  3465. if (!g_zombie[attacker])
  3466. {
  3467. if (g_vip[attacker] && containi(g_vip_flags[attacker], "D")!=-1)
  3468. {
  3469. damage *= 1.15;
  3470. SetHamParamFloat(4, damage);
  3471. }
  3472.  
  3473. if ((g_currentweapon[attacker] == CSW_AK47 || g_currentweapon[attacker] == CSW_DEAGLE) && (zp_get_gold_ak(attacker) || zp_get_gold_de(attacker)))
  3474. {
  3475. damage *= 1.5;
  3476. SetHamParamFloat(4, damage);
  3477. }
  3478.  
  3479. if (g_doubledamage[attacker])
  3480. {
  3481. damage *= 2.0;
  3482. SetHamParamFloat(4, damage);
  3483. }
  3484.  
  3485. // Hattrick
  3486. //
  3487. // Armor multiplier for the final damage on normal zombies
  3488. //if (!g_nemesis[victim])
  3489. if (!g_nemesis[victim] && !g_assassin[victim] && !g_sniper[attacker])
  3490. {
  3491. damage *= get_pcvar_float(cvar_zombiearmor)
  3492. SetHamParamFloat(4, damage)
  3493. }
  3494.  
  3495. // Hattrick
  3496. //
  3497. // Reward ammo packs to humans for damaging zombies?
  3498. // if ((get_pcvar_num(cvar_ammodamage_human) > 0) && (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo)))
  3499. if ((get_pcvar_num(cvar_ammodamage_human) > 0) && (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo)) && (!g_sniper[attacker] || !get_pcvar_num(cvar_sniperignoreammo)))
  3500. {
  3501. // Store damage dealt
  3502. g_damagedealt_human[attacker] += floatround(damage)
  3503.  
  3504. // Reward ammo packs for every [ammo damage] dealt
  3505. while (g_damagedealt_human[attacker] > get_pcvar_num(cvar_ammodamage_human))
  3506. {
  3507. g_ammopacks[attacker]++
  3508. g_damagedealt_human[attacker] -= get_pcvar_num(cvar_ammodamage_human)
  3509. }
  3510. }
  3511.  
  3512. // Hattrick
  3513. //
  3514. // Replace damage done by Sniper's weapon with the one set by the cvar
  3515. if (g_sniper[attacker] && g_currentweapon[attacker] == CSW_AWP)
  3516. SetHamParamFloat(4, get_pcvar_float(cvar_sniperdamage))
  3517.  
  3518. if (damage_type & DMG_MORTAR)
  3519. {
  3520. static str[32]
  3521. AddCommas(floatround(damage), str, 31);
  3522. zp_colored_print(attacker, "^x04[ZP]^x01 Damage to^x03 %s^x01 ::^x04 %s", g_playername[victim], str);
  3523. }
  3524.  
  3525. return HAM_IGNORED;
  3526. }
  3527.  
  3528. // Attacker is zombie...
  3529.  
  3530. // Prevent infection/damage by HE grenade (bugfix)
  3531. if (damage_type & DMG_HEGRENADE)
  3532. return HAM_SUPERCEDE;
  3533.  
  3534. // Hattrick
  3535. //
  3536. // Nemesis?
  3537. //if (g_nemesis[attacker])
  3538. if (g_nemesis[attacker] || g_assassin[attacker])
  3539. {
  3540. // Ignore nemesis damage override if damage comes from a 3rd party entity
  3541. // (to prevent this from affecting a sub-plugin's rockets e.g.)
  3542. if (inflictor == attacker)
  3543. {
  3544. // Hattrick
  3545. //
  3546. // Set nemesis damage
  3547. //SetHamParamFloat(4, get_pcvar_float(cvar_nemdamage))
  3548. SetHamParamFloat(4, g_nemesis[attacker] ? get_pcvar_float(cvar_nemdamage) : get_pcvar_float(cvar_assassindamage))
  3549. }
  3550.  
  3551. return HAM_IGNORED;
  3552. }
  3553.  
  3554. // Reward ammo packs to zombies for damaging humans?
  3555. if (get_pcvar_num(cvar_ammodamage_zombie) > 0)
  3556. {
  3557. // Store damage dealt
  3558. g_damagedealt_zombie[attacker] += floatround(damage)
  3559.  
  3560. // Reward ammo packs for every [ammo damage] dealt
  3561. while (g_damagedealt_zombie[attacker] > get_pcvar_num(cvar_ammodamage_zombie))
  3562. {
  3563. g_ammopacks[attacker]++
  3564. g_damagedealt_zombie[attacker] -= get_pcvar_num(cvar_ammodamage_zombie)
  3565. }
  3566. }
  3567.  
  3568. // Hattrick
  3569. //
  3570. // Last human or not an infection round
  3571. //if (g_survround || g_nemround || g_swarmround || g_avsround || gg_plagueround || fnGetHumans() == 1)
  3572. if (g_survround || g_sniperround || g_assassinround || g_avsround || g_armageddonround || g_nemround || g_swarmround || g_plagueround || fnGetHumans() == 1)
  3573. return HAM_IGNORED; // human is killed
  3574.  
  3575. // Does human armor need to be reduced before infecting?
  3576. if (get_pcvar_num(cvar_humanarmor))
  3577. {
  3578. // Get victim armor
  3579. static Float:armor
  3580. pev(victim, pev_armorvalue, armor)
  3581.  
  3582. // If he has some, block the infection and reduce armor instead
  3583. if (armor > 0.0)
  3584. {
  3585. emit_sound(victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3586. if (armor - damage > 0.0)
  3587. set_pev(victim, pev_armorvalue, armor - damage)
  3588. else
  3589. cs_set_user_armor(victim, 0, CS_ARMOR_NONE)
  3590. return HAM_SUPERCEDE;
  3591. }
  3592. }
  3593.  
  3594. // Infection allowed
  3595. zombieme(victim, attacker, 0, 0, 1) // turn into zombie
  3596. g_points[attacker]++
  3597. savePoints(attacker)
  3598. return HAM_SUPERCEDE;
  3599. }
  3600.  
  3601. // Ham Take Damage Post Forward
  3602. public fw_TakeDamage_Post(victim)
  3603. {
  3604. // --- Check if victim should be Pain Shock Free ---
  3605.  
  3606. // Check if proper CVARs are enabled
  3607. if (g_zombie[victim])
  3608. {
  3609. if (g_nemesis[victim])
  3610. {
  3611. if (!get_pcvar_num(cvar_nempainfree)) return;
  3612. }
  3613. // Hattrick
  3614. //
  3615. else if (g_assassin[victim])
  3616. {
  3617. if (!get_pcvar_num(cvar_assassinpainfree)) return;
  3618. }
  3619. else
  3620. {
  3621. switch (get_pcvar_num(cvar_zombiepainfree))
  3622. {
  3623. case 0: return;
  3624. case 2: if (!g_lastzombie[victim]) return;
  3625. case 3: if (!g_firstzombie[victim]) return;
  3626. }
  3627. }
  3628. }
  3629. else
  3630. {
  3631. if (g_survivor[victim])
  3632. {
  3633. if (!get_pcvar_num(cvar_survpainfree)) return;
  3634. }
  3635. // Hattrick
  3636. //
  3637. else if (g_sniper[victim])
  3638. {
  3639. if (!get_pcvar_num(cvar_sniperpainfree)) return;
  3640. }
  3641. else return;
  3642. }
  3643.  
  3644. // Prevent server crash if entity's private data not initalized
  3645. if (pev_valid(victim) != PDATA_SAFE)
  3646. return;
  3647.  
  3648. // Set pain shock free offset
  3649. set_pdata_float(victim, OFFSET_PAINSHOCK, 1.0, OFFSET_LINUX)
  3650. }
  3651.  
  3652. // Ham Trace Attack Forward
  3653. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  3654. {
  3655. // Non-player damage or self damage
  3656. if (victim == attacker || !is_user_valid_connected(attacker))
  3657. return HAM_IGNORED;
  3658.  
  3659. // New round starting or round ended
  3660. if (g_newround || g_endround)
  3661. return HAM_SUPERCEDE;
  3662.  
  3663. // Victim shouldn't take damage or victim is frozen
  3664. if (g_nodamage[victim] || get_user_godmode(victim) || (g_frozen[victim] && !get_pcvar_num(cvar_damagewhilefrost)))
  3665. return HAM_SUPERCEDE;
  3666.  
  3667. // Prevent friendly fire
  3668. if (g_zombie[attacker] == g_zombie[victim])
  3669. return HAM_SUPERCEDE;
  3670.  
  3671. // Victim isn't a zombie or not bullet damage, nothing else to do here
  3672. if (!g_zombie[victim] || !(damage_type & DMG_BULLET))
  3673. return HAM_IGNORED;
  3674.  
  3675. // Hattrick
  3676. //
  3677. // If zombie hitzones are enabled, check whether we hit an allowed one
  3678. //if (get_pcvar_num(cvar_hitzones) && !g_nemesis[victim] && !(get_pcvar_num(cvar_hitzones) & (1<<get_tr2(tracehandle, TR_iHitgroup))))
  3679. if (get_pcvar_num(cvar_hitzones) && !g_nemesis[victim] && !g_assassin[victim] && !(get_pcvar_num(cvar_hitzones) & (1<<get_tr2(tracehandle, TR_iHitgroup))))
  3680. return HAM_SUPERCEDE;
  3681.  
  3682. // Knockback disabled, nothing else to do here
  3683. if (!get_pcvar_num(cvar_knockback))
  3684. return HAM_IGNORED;
  3685.  
  3686. // Nemesis knockback disabled, nothing else to do here
  3687. if (g_nemesis[victim] && get_pcvar_float(cvar_nemknockback) == 0.0)
  3688. return HAM_IGNORED;
  3689.  
  3690. // Hattrick
  3691. //
  3692. // Nemesis knockback disabled, nothing else to do here
  3693. if (g_assassin[victim] && get_pcvar_float(cvar_assassinknockback) == 0.0)
  3694. return HAM_IGNORED;
  3695.  
  3696. // Get whether the victim is in a crouch state
  3697. static ducking
  3698. ducking = pev(victim, pev_flags) & (FL_DUCKING | FL_ONGROUND) == (FL_DUCKING | FL_ONGROUND)
  3699.  
  3700. // Zombie knockback when ducking disabled
  3701. if (ducking && get_pcvar_float(cvar_knockbackducking) == 0.0)
  3702. return HAM_IGNORED;
  3703.  
  3704. // Get distance between players
  3705. static origin1[3], origin2[3]
  3706. get_user_origin(victim, origin1)
  3707. get_user_origin(attacker, origin2)
  3708.  
  3709. // Max distance exceeded
  3710. if (get_distance(origin1, origin2) > get_pcvar_num(cvar_knockbackdist))
  3711. return HAM_IGNORED;
  3712.  
  3713. // Get victim's velocity
  3714. static Float:velocity[3]
  3715. pev(victim, pev_velocity, velocity)
  3716.  
  3717. // Use damage on knockback calculation
  3718. if (get_pcvar_num(cvar_knockbackdamage))
  3719. xs_vec_mul_scalar(direction, damage, direction)
  3720.  
  3721. // Use weapon power on knockback calculation
  3722. if (get_pcvar_num(cvar_knockbackpower) && kb_weapon_power[g_currentweapon[attacker]] > 0.0)
  3723. xs_vec_mul_scalar(direction, kb_weapon_power[g_currentweapon[attacker]], direction)
  3724.  
  3725. // Apply ducking knockback multiplier
  3726. if (ducking)
  3727. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_knockbackducking), direction)
  3728.  
  3729. // Apply zombie class/nemesis knockback multiplier
  3730. if (g_nemesis[victim])
  3731. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_nemknockback), direction)
  3732. // Hattrick
  3733. //
  3734. else if (g_assassin[victim])
  3735. xs_vec_mul_scalar(direction, get_pcvar_float(cvar_assassinknockback), direction)
  3736.  
  3737. else
  3738. xs_vec_mul_scalar(direction, g_zombie_knockback[victim], direction)
  3739.  
  3740. // Add up the new vector
  3741. xs_vec_add(velocity, direction, direction)
  3742.  
  3743. // Should knockback also affect vertical velocity?
  3744. if (!get_pcvar_num(cvar_knockbackzvel))
  3745. direction[2] = velocity[2]
  3746.  
  3747. // Set the knockback'd victim's velocity
  3748. set_pev(victim, pev_velocity, direction)
  3749.  
  3750. return HAM_IGNORED;
  3751. }
  3752.  
  3753. // Ham Reset MaxSpeed Post Forward
  3754. public fw_ResetMaxSpeed_Post(id)
  3755. {
  3756. // Freezetime active or player not alive
  3757. if (g_freezetime || !g_isalive[id])
  3758. return;
  3759.  
  3760. set_player_maxspeed(id)
  3761. }
  3762.  
  3763. // Ham Use Stationary Gun Forward
  3764. public fw_UseStationary(entity, caller, activator, use_type)
  3765. {
  3766. // Prevent zombies from using stationary guns
  3767. if (use_type == USE_USING && is_user_valid_connected(caller) && g_zombie[caller])
  3768. return HAM_SUPERCEDE;
  3769.  
  3770. return HAM_IGNORED;
  3771. }
  3772.  
  3773. // Ham Use Stationary Gun Post Forward
  3774. public fw_UseStationary_Post(entity, caller, activator, use_type)
  3775. {
  3776. // Someone stopped using a stationary gun
  3777. if (use_type == USE_STOPPED && is_user_valid_connected(caller))
  3778. replace_weapon_models(caller, g_currentweapon[caller]) // replace weapon models (bugfix)
  3779. }
  3780.  
  3781. // Ham Use Pushable Forward
  3782. public fw_UsePushable()
  3783. {
  3784. // Prevent speed bug with pushables?
  3785. if (get_pcvar_num(cvar_blockpushables))
  3786. return HAM_SUPERCEDE;
  3787.  
  3788. return HAM_IGNORED;
  3789. }
  3790.  
  3791. // Ham Weapon Touch Forward
  3792. public fw_TouchWeapon(weapon, id)
  3793. {
  3794. // Not a player
  3795. if (!is_user_valid_connected(id))
  3796. return HAM_IGNORED;
  3797.  
  3798. // Hattrick
  3799. //
  3800. // Dont pickup weapons if zombie or survivor (+PODBot MM fix)
  3801. //if (g_zombie[id] || (g_survivor[id] && !g_isbot[id]))
  3802. if (g_zombie[id] || (g_survivor[id] && !g_isbot[id]) || (g_sniper[id] && !g_isbot[id]))
  3803. return HAM_SUPERCEDE;
  3804.  
  3805. return HAM_IGNORED;
  3806. }
  3807.  
  3808. // Ham Weapon Pickup Forward
  3809. public fw_AddPlayerItem(id, weapon_ent)
  3810. {
  3811. // HACK: Retrieve our custom extra ammo from the weapon
  3812. static extra_ammo
  3813. extra_ammo = pev(weapon_ent, PEV_ADDITIONAL_AMMO)
  3814.  
  3815. // If present
  3816. if (extra_ammo)
  3817. {
  3818. // Get weapon's id
  3819. static weaponid
  3820. weaponid = cs_get_weapon_id(weapon_ent)
  3821.  
  3822. // Add to player's bpammo
  3823. ExecuteHamB(Ham_GiveAmmo, id, extra_ammo, AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  3824. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, 0)
  3825. }
  3826. }
  3827.  
  3828. // Ham Weapon Deploy Forward
  3829. public fw_Item_Deploy_Post(weapon_ent)
  3830. {
  3831. // Get weapon's owner
  3832. static owner
  3833. owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  3834.  
  3835. // Valid owner?
  3836. if (!pev_valid(owner))
  3837. return;
  3838.  
  3839. // Get weapon's id
  3840. static weaponid
  3841. weaponid = cs_get_weapon_id(weapon_ent)
  3842.  
  3843. // Store current weapon's id for reference
  3844. g_currentweapon[owner] = weaponid
  3845.  
  3846. // Replace weapon models with custom ones
  3847. replace_weapon_models(owner, weaponid)
  3848.  
  3849. // Zombie not holding an allowed weapon for some reason
  3850. if (g_zombie[owner] && !((1<<weaponid) & ZOMBIE_ALLOWED_WEAPONS_BITSUM))
  3851. {
  3852. // Switch to knife
  3853. g_currentweapon[owner] = CSW_KNIFE
  3854. engclient_cmd(owner, "weapon_knife")
  3855. }
  3856. }
  3857.  
  3858. // WeaponMod bugfix
  3859. //forward wpn_gi_reset_weapon(id);
  3860. public wpn_gi_reset_weapon(id)
  3861. {
  3862. // Replace knife model
  3863. replace_weapon_models(id, CSW_KNIFE)
  3864. }
  3865.  
  3866. new const g_countries[][]=
  3867. {
  3868. "N/A",
  3869. "Asia/Pacific Region", "Europe",
  3870. "Andorra", "United Arab Emirates",
  3871. "Afghanistan", "Antigua and Barbuda",
  3872. "Anguilla",
  3873. "Albania", "Armenia",
  3874. "Curacao",
  3875. "Angola",
  3876. "Antarctica", "Argentina",
  3877. "American Samoa", "Austria",
  3878. "Australia", "Aruba",
  3879. "Azerbaijan",
  3880. "Bosnia and Herzegovina", "Barbados",
  3881. "Bangladesh",
  3882. "Belgium", "Burkina Faso",
  3883. "Bulgaria", "Bahrain",
  3884. "Burundi", "Benin",
  3885. "Bermuda",
  3886. "Brunei Darussalam", "Bolivia",
  3887. "Brazil",
  3888. "Bahamas", "Bhutan",
  3889. "Bouvet Island", "Botswana",
  3890. "Belarus", "Belize",
  3891. "Canada",
  3892. "Cocos (Keeling) Islands",
  3893. "Congo, The Democratic Republic of the",
  3894. "Central African Republic",
  3895. "Congo", "Switzerland",
  3896. "Cote D'Ivoire", "Cook Islands",
  3897. "Chile", "Cameroon",
  3898. "China",
  3899. "Colombia", "Costa Rica",
  3900. "Cuba",
  3901. "Cape Verde", "Christmas Island",
  3902. "Cyprus", "Czech Republic",
  3903. "Germany", "Djibouti",
  3904. "Denmark",
  3905. "Dominica", "Dominican Republic",
  3906. "Algeria",
  3907. "Ecuador", "Estonia",
  3908. "Egypt", "Western Sahara",
  3909. "Eritrea", "Spain",
  3910. "Ethiopia",
  3911. "Finland", "Fiji",
  3912. "Falkland Islands (Malvinas)",
  3913. "Micronesia, Federated States of", "Faroe Islands",
  3914. "France", "sunt Maarten (Dutch part)",
  3915. "Gabon", "United Kingdom",
  3916. "Grenada",
  3917. "Georgia", "French Guiana",
  3918. "Ghana",
  3919. "Gibraltar", "Greenland",
  3920. "Gambia", "Guinea",
  3921. "Guadeloupe", "Equatorial Guinea",
  3922. "Greece",
  3923. "South Georgia and the South Sandwich Islands","Guatemala",
  3924. "Guam",
  3925. "Guinea-Bissau", "Guyana",
  3926. "Hong Kong",
  3927. "Heard Island and McDonald Islands",
  3928. "Honduras", "Croatia",
  3929. "Haiti",
  3930. "Hungary", "Indonesia",
  3931. "Ireland",
  3932. "Israel", "India",
  3933. "British Indian Ocean Territory", "Iraq",
  3934. "Iran, Islamic Republic of", "Iceland",
  3935. "Italy",
  3936. "Jamaica", "Jordan",
  3937. "Japan",
  3938. "Kenya", "Kyrgyzstan",
  3939. "Cambodia", "Kiribati",
  3940. "Comoros", "Saint Kitts and Nevis",
  3941. "Korea, Democratic People's Republic of", "Korea, Republic of",
  3942. "Kuwait",
  3943. "Cayman Islands",
  3944. "Kazakhstan",
  3945. "Lao People's Democratic Republic",
  3946. "Lebanon", "Saint Lucia",
  3947. "Liechtenstein", "Sri Lanka",
  3948. "Liberia",
  3949. "Lesotho", "Lithuania",
  3950. "Luxembourg",
  3951. "Latvia", "Libya",
  3952. "Morocco", "Monaco",
  3953. "Moldova, Republic of", "Madagascar",
  3954. "Marshall Islands", "Macedonia",
  3955. "Mali",
  3956. "Myanmar",
  3957. "Mongolia", "Macau",
  3958. "Northern Mariana Islands", "Martinique",
  3959. "Mauritania", "Montserrat",
  3960. "Malta",
  3961. "Mauritius", "Maldives",
  3962. "Malawi",
  3963. "Mexico", "Malaysia",
  3964. "Mozambique", "Namibia",
  3965. "New Caledonia", "Niger",
  3966. "Norfolk Island",
  3967. "Nigeria", "Nicaragua",
  3968. "Netherlands",
  3969. "Norway", "Nepal",
  3970. "Nauru", "Niue",
  3971. "New Zealand", "Oman",
  3972. "Panama",
  3973. "Peru", "French Polynesia",
  3974. "Papua New Guinea",
  3975. "Philippines", "Pakistan",
  3976. "Poland", "Saint Pierre and Miquelon",
  3977. "Pitcairn Islands", "Puerto Rico",
  3978. "Palestinian Territory", "Portugal",
  3979. "Palau",
  3980. "Paraguay",
  3981. "Qatar", "Reunion",
  3982. "Romania", "Russian Federation",
  3983. "Rwanda", "Saudi Arabia",
  3984. "Solomon Islands", "Seychelles",
  3985. "Sudan",
  3986. "Sweden",
  3987. "Singapore", "Saint Helena",
  3988. "Slovenia", "Svalbard and Jan Mayen",
  3989. "Slovakia", "Sierra Leone",
  3990. "San Marino",
  3991. "Senegal", "Somalia",
  3992. "Suriname",
  3993. "Sao Tome and Principe",
  3994. "El Salvador", "Syrian Arab Republic",
  3995. "Swaziland", "Turks and Caicos Islands",
  3996. "Chad", "French Southern Territories",
  3997. "Togo",
  3998. "Thailand",
  3999. "Tajikistan",
  4000. "Tokelau", "Turkmenistan",
  4001. "Tunisia", "Tonga",
  4002. "Timor-Leste", "Turkey",
  4003. "Trinidad and Tobago", "Tuvalu",
  4004. "Taiwan",
  4005. "Tanzania, United Republic of",
  4006. "Ukraine", "Uganda",
  4007. "United States Minor Outlying Islands", "United States",
  4008. "Uruguay", "Uzbekistan",
  4009. "Holy See (Vatican City State)",
  4010. "Saint Vincent and the Grenadines",
  4011. "Venezuela",
  4012. "Virgin Islands, British",
  4013. "Virgin Islands, U.S.", "Vietnam",
  4014. "Vanuatu", "Wallis and Futuna",
  4015. "Samoa", "Yemen",
  4016. "Mayotte",
  4017. "Serbia", "South Africa",
  4018. "Zambia",
  4019. "Montenegro", "Zimbabwe",
  4020. "Anonymous Proxy", "Satellite Provider",
  4021. "Other", "Aland Islands",
  4022. "Guernsey",
  4023. "Isle of Man", "Jersey",
  4024. "Saint Barthelemy",
  4025. "Saint Martin",
  4026. "Bonaire, Saint Eustatius and Saba",
  4027. "South Sudan", "Other"
  4028. };
  4029.  
  4030. // Client joins the game
  4031. public client_putinserver(id)
  4032. {
  4033. // Plugin disabled?
  4034. if (!g_pluginenabled) return;
  4035.  
  4036. // Player joined
  4037. g_isconnected[id] = true
  4038.  
  4039. // Cache player's name
  4040. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  4041.  
  4042. // Initialize player vars
  4043. reset_vars(id, 1)
  4044.  
  4045. // Load player stats?
  4046. if (get_pcvar_num(cvar_statssave)) load_stats(id)
  4047.  
  4048. // Hattrick
  4049. //
  4050. get_user_ip(id, g_ip[id], charsmax(g_ip[]), 1);
  4051. get_user_authid(id, g_steam[id], charsmax(g_steam[]));
  4052.  
  4053. // geoip_country_ex(g_ip[id], g_country[id], charsmax(g_country[]));
  4054. // geoip_city(g_ip[id], g_city[id], charsmax(g_city[]));
  4055.  
  4056. if (!g_country[id][0] || containi(g_country[id], "Err") != -1)
  4057. g_country[id] = "N/A";
  4058.  
  4059. if (!g_city[id][0] || containi(g_city[id], "Err") != -1)
  4060. g_city[id] = "N/A";
  4061.  
  4062. if (is_user_bot(id) && equali(g_country[id], "N/A"))
  4063. {
  4064. new irand = random_num(0, sizeof(g_countries) - 1)
  4065.  
  4066. if (random_num(0, 1) == 0)
  4067. copy(g_country[id],charsmax(g_country[]), g_countries[irand])
  4068. else
  4069. copy(g_country[id],charsmax(g_country[]), "Romania")
  4070.  
  4071. if (equali(g_country[id], "Romania"))
  4072. {
  4073. switch(random_num(0, 135))
  4074. {
  4075. case 0:copy(g_city[id],charsmax(g_city[]), "Cluj-Napoca")
  4076. case 1:copy(g_city[id],charsmax(g_city[]), "Bucharest")
  4077. case 2:copy(g_city[id],charsmax(g_city[]), "Tecuci")
  4078. case 3:copy(g_city[id],charsmax(g_city[]), "Techirghiol")
  4079. case 4:copy(g_city[id],charsmax(g_city[]), "Dej")
  4080. case 5:copy(g_city[id],charsmax(g_city[]), "Aiud")
  4081. case 6:copy(g_city[id],charsmax(g_city[]), "Tuzla")
  4082. case 7:copy(g_city[id],charsmax(g_city[]), "Agigea")
  4083. case 8:copy(g_city[id],charsmax(g_city[]), "Mangalia")
  4084. case 9:copy(g_city[id],charsmax(g_city[]), "Constanta")
  4085. case 10:copy(g_city[id],charsmax(g_city[]), "Vulcan")
  4086. case 11:copy(g_city[id],charsmax(g_city[]), "Targu Mures")
  4087. case 12:copy(g_city[id],charsmax(g_city[]), "Blaj")
  4088. case 13:copy(g_city[id],charsmax(g_city[]), "Alba Iulia")
  4089. case 14:copy(g_city[id],charsmax(g_city[]), "Sibiu")
  4090. case 15:copy(g_city[id],charsmax(g_city[]), "Brasov")
  4091. case 16:copy(g_city[id],charsmax(g_city[]), "Turnu Magurele")
  4092. case 17:copy(g_city[id],charsmax(g_city[]), "Arad")
  4093. case 18:copy(g_city[id],charsmax(g_city[]), "Turda")
  4094. case 19:copy(g_city[id],charsmax(g_city[]), "Campia Turzii")
  4095. case 20:copy(g_city[id],charsmax(g_city[]), "Ludus")
  4096. case 21:copy(g_city[id],charsmax(g_city[]), "Medias")
  4097. case 22:copy(g_city[id],charsmax(g_city[]), "Barlad")
  4098. case 23:copy(g_city[id],charsmax(g_city[]), "Marasesti")
  4099. case 24:copy(g_city[id],charsmax(g_city[]), "Ramnicu Sarat")
  4100. case 25:copy(g_city[id],charsmax(g_city[]), "Focsani")
  4101. case 26:copy(g_city[id],charsmax(g_city[]), "Bucure?ti")
  4102. case 27:copy(g_city[id],charsmax(g_city[]), "Cluj-napoca")
  4103. case 28:copy(g_city[id],charsmax(g_city[]), "Media?")
  4104. case 29:copy(g_city[id],charsmax(g_city[]), "Câmpia Turzii")
  4105. case 30:copy(g_city[id],charsmax(g_city[]), "Ludu?")
  4106. case 31:copy(g_city[id],charsmax(g_city[]), "Constan?a")
  4107. case 32:copy(g_city[id],charsmax(g_city[]), "Râmnicu Sarat")
  4108. case 33:copy(g_city[id],charsmax(g_city[]), "Târgu Mure?")
  4109. case 34:copy(g_city[id],charsmax(g_city[]), "Targu Jiu")
  4110. case 35:copy(g_city[id],charsmax(g_city[]), "Târgu Jiu")
  4111. case 36:copy(g_city[id],charsmax(g_city[]), "Bârlad")
  4112. case 37:copy(g_city[id],charsmax(g_city[]), "Turnu Magurele")
  4113. case 38:copy(g_city[id],charsmax(g_city[]), "Covasna")
  4114. case 39:copy(g_city[id],charsmax(g_city[]), "Timisoara")
  4115. case 40:copy(g_city[id],charsmax(g_city[]), "Timi?oara")
  4116. case 41:copy(g_city[id],charsmax(g_city[]), "N/A")
  4117. case 42:copy(g_city[id],charsmax(g_city[]), "Mure?")
  4118. case 43:copy(g_city[id],charsmax(g_city[]), "Calafat")
  4119. case 44:copy(g_city[id],charsmax(g_city[]), "Mures")
  4120. case 45:copy(g_city[id],charsmax(g_city[]), "Mures")
  4121. case 46:copy(g_city[id],charsmax(g_city[]), "Foc?ani")
  4122. case 47:copy(g_city[id],charsmax(g_city[]), "Bra?ov")
  4123. case 48:copy(g_city[id],charsmax(g_city[]), "Tulcea")
  4124. case 49:copy(g_city[id],charsmax(g_city[]), "Vama Veche")
  4125. case 50:copy(g_city[id],charsmax(g_city[]), "Sebe?")
  4126. case 51:copy(g_city[id],charsmax(g_city[]), "Sebes")
  4127. case 52:copy(g_city[id],charsmax(g_city[]), "Feleacu")
  4128. case 53:copy(g_city[id],charsmax(g_city[]), "Martinesti")
  4129. case 54:copy(g_city[id],charsmax(g_city[]), "Martine?ti")
  4130. case 55:copy(g_city[id],charsmax(g_city[]), "Craiova")
  4131. case 56:copy(g_city[id],charsmax(g_city[]), "Pitesti")
  4132. case 57:copy(g_city[id],charsmax(g_city[]), "Pite?ti")
  4133. case 58:copy(g_city[id],charsmax(g_city[]), "Tarnaveni")
  4134. case 59:copy(g_city[id],charsmax(g_city[]), "Târnaveni")
  4135. case 60:copy(g_city[id],charsmax(g_city[]), "Caransebes")
  4136. case 61:copy(g_city[id],charsmax(g_city[]), "Caransebe?")
  4137. case 62:copy(g_city[id],charsmax(g_city[]), "Miercurea Ciuc")
  4138. case 63:copy(g_city[id],charsmax(g_city[]), "Bucegi")
  4139. case 64:copy(g_city[id],charsmax(g_city[]), "Harghita")
  4140. case 65:copy(g_city[id],charsmax(g_city[]), "Balea")
  4141. case 66:copy(g_city[id],charsmax(g_city[]), "Bâlea")
  4142. case 67:copy(g_city[id],charsmax(g_city[]), "Vaslui")
  4143. case 68:copy(g_city[id],charsmax(g_city[]), "Botosani")
  4144. case 69:copy(g_city[id],charsmax(g_city[]), "Boto?ani")
  4145. case 70:copy(g_city[id],charsmax(g_city[]), "Iasi")
  4146. case 71:copy(g_city[id],charsmax(g_city[]), "Ia?i")
  4147. case 72:copy(g_city[id],charsmax(g_city[]), "Galati")
  4148. case 73:copy(g_city[id],charsmax(g_city[]), "Gala?i")
  4149. case 74:copy(g_city[id],charsmax(g_city[]), "Ploiesti")
  4150. case 75:copy(g_city[id],charsmax(g_city[]), "Ploie?ti")
  4151. case 76:copy(g_city[id],charsmax(g_city[]), "Oradea")
  4152. case 77:copy(g_city[id],charsmax(g_city[]), "Braila")
  4153. case 78:copy(g_city[id],charsmax(g_city[]), "Braila")
  4154. case 79:copy(g_city[id],charsmax(g_city[]), "Bacau")
  4155. case 80:copy(g_city[id],charsmax(g_city[]), "Bacau")
  4156. case 81:copy(g_city[id],charsmax(g_city[]), "Baia Mare")
  4157. case 82:copy(g_city[id],charsmax(g_city[]), "Buzau")
  4158. case 83:copy(g_city[id],charsmax(g_city[]), "Buzau")
  4159. case 84:copy(g_city[id],charsmax(g_city[]), "Satu Mare")
  4160. case 85:copy(g_city[id],charsmax(g_city[]), "Râmnicu Vâlcea")
  4161. case 86:copy(g_city[id],charsmax(g_city[]), "Ramnicu Valcea")
  4162. case 87:copy(g_city[id],charsmax(g_city[]), "Suceava")
  4163. case 88:copy(g_city[id],charsmax(g_city[]), "Piatra Neamt")
  4164. case 89:copy(g_city[id],charsmax(g_city[]), "Piatra Neam?")
  4165. case 90:copy(g_city[id],charsmax(g_city[]), "Targoviste")
  4166. case 91:copy(g_city[id],charsmax(g_city[]), "Târgovi?te")
  4167. case 92:copy(g_city[id],charsmax(g_city[]), "Bistrita")
  4168. case 93:copy(g_city[id],charsmax(g_city[]), "Bistri?a")
  4169. case 94:copy(g_city[id],charsmax(g_city[]), "Resita")
  4170. case 95:copy(g_city[id],charsmax(g_city[]), "Re?i?a")
  4171. case 96:copy(g_city[id],charsmax(g_city[]), "Slatina")
  4172. case 97:copy(g_city[id],charsmax(g_city[]), "Calarasi")
  4173. case 98:copy(g_city[id],charsmax(g_city[]), "Calara?i")
  4174. case 99:copy(g_city[id],charsmax(g_city[]), "Giurgiu")
  4175. case 100:copy(g_city[id],charsmax(g_city[]), "Deva")
  4176. case 101:copy(g_city[id],charsmax(g_city[]), "Hunedoara")
  4177. case 102:copy(g_city[id],charsmax(g_city[]), "Zalau")
  4178. case 103:copy(g_city[id],charsmax(g_city[]), "Zalau")
  4179. case 104:copy(g_city[id],charsmax(g_city[]), "Sfantu Gheorghe")
  4180. case 105:copy(g_city[id],charsmax(g_city[]), "Sfântu Gheorghe")
  4181. case 106:copy(g_city[id],charsmax(g_city[]), "Roman")
  4182. case 107:copy(g_city[id],charsmax(g_city[]), "Slobozia")
  4183. case 108:copy(g_city[id],charsmax(g_city[]), "Alexandria")
  4184. case 109:copy(g_city[id],charsmax(g_city[]), "Voluntari")
  4185. case 110:copy(g_city[id],charsmax(g_city[]), "Lugoj")
  4186. case 111:copy(g_city[id],charsmax(g_city[]), "Medgidia")
  4187. case 112:copy(g_city[id],charsmax(g_city[]), "Onesti")
  4188. case 113:copy(g_city[id],charsmax(g_city[]), "One?ti")
  4189. case 114:copy(g_city[id],charsmax(g_city[]), "Sighetu Marmatiei")
  4190. case 115:copy(g_city[id],charsmax(g_city[]), "Sighetu Marma?iei")
  4191. case 116:copy(g_city[id],charsmax(g_city[]), "Petrosani")
  4192. case 117:copy(g_city[id],charsmax(g_city[]), "Petro?ani")
  4193. case 118:copy(g_city[id],charsmax(g_city[]), "Odorheiu Secuiesc")
  4194. case 119:copy(g_city[id],charsmax(g_city[]), "Pascani")
  4195. case 120:copy(g_city[id],charsmax(g_city[]), "Pa?cani")
  4196. case 121:copy(g_city[id],charsmax(g_city[]), "Reghin")
  4197. case 122:copy(g_city[id],charsmax(g_city[]), "Navodari")
  4198. case 123:copy(g_city[id],charsmax(g_city[]), "Navodari")
  4199. case 124:copy(g_city[id],charsmax(g_city[]), "Campina")
  4200. case 125:copy(g_city[id],charsmax(g_city[]), "Câmpina")
  4201. case 126:copy(g_city[id],charsmax(g_city[]), "Mioveni")
  4202. case 127:copy(g_city[id],charsmax(g_city[]), "Campulung")
  4203. case 128:copy(g_city[id],charsmax(g_city[]), "Câmpulung")
  4204. case 129:copy(g_city[id],charsmax(g_city[]), "Caracal")
  4205. case 130:copy(g_city[id],charsmax(g_city[]), "Sacele")
  4206. case 131:copy(g_city[id],charsmax(g_city[]), "Sacele")
  4207. case 132:copy(g_city[id],charsmax(g_city[]), "Fagaras")
  4208. case 133:copy(g_city[id],charsmax(g_city[]), "Fagara?")
  4209. case 134:copy(g_city[id],charsmax(g_city[]), "Fete?ti")
  4210. case 135:copy(g_city[id],charsmax(g_city[]), "Fetesti")
  4211. }
  4212. }
  4213.  
  4214. if (equali(g_country[id], "Algeria"))
  4215. {
  4216. switch(random_num(0, 2))
  4217. {
  4218. case 0:copy(g_city[id], charsmax(g_city[]), "Constantine");
  4219. case 1:copy(g_city[id], charsmax(g_city[]), "Ain-defla");
  4220. case 2:copy(g_city[id], charsmax(g_city[]), "N/A");
  4221. }
  4222. }
  4223.  
  4224. if (equali(g_country[id], "Italy"))
  4225. {
  4226. switch(random_num(0, 2))
  4227. {
  4228. case 0:copy(g_city[id], charsmax(g_city[]), "Naples");
  4229. case 1:copy(g_city[id], charsmax(g_city[]), "Rome");
  4230. case 2:copy(g_city[id], charsmax(g_city[]), "N/A");
  4231. }
  4232. }
  4233.  
  4234. if (equali(g_country[id], "Japan"))
  4235. {
  4236. switch(random_num(0, 2))
  4237. {
  4238. case 0:copy(g_city[id], charsmax(g_city[]), "Tokyo");
  4239. case 1:copy(g_city[id], charsmax(g_city[]), "Kyoto");
  4240. case 2:copy(g_city[id], charsmax(g_city[]), "N/A");
  4241. }
  4242. }
  4243.  
  4244. if (equali(g_country[id], "Venezuela"))
  4245. {
  4246. switch(random_num(0, 1))
  4247. {
  4248. case 0:copy(g_city[id], charsmax(g_city[]), "Caracas");
  4249. case 1:copy(g_city[id], charsmax(g_city[]), "N/A");
  4250. }
  4251. }
  4252. }
  4253.  
  4254. if (!equali(g_country[id], "N/A"))
  4255. set_task(2.0, "printcon", id);
  4256.  
  4257. if (g_vip[id])
  4258. {
  4259. set_task(random_float(3.5, 12.0), "TaskVIP", id);
  4260. }
  4261.  
  4262. if (is_user_admin(id))
  4263. {
  4264. set_task(random_float(3.5, 12.0), "TaskAdmin", id);
  4265. }
  4266.  
  4267. // Set some tasks for humans only
  4268. if (!is_user_bot(id))
  4269. {
  4270. // Set the custom HUD display task if enabled
  4271. if (get_pcvar_num(cvar_huddisplay))
  4272. set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
  4273.  
  4274. // Disable minmodels for clients to see zombies properly
  4275. set_task(5.0, "disable_minmodels", id)
  4276. }
  4277. else
  4278. {
  4279. // Set bot flag
  4280. g_isbot[id] = true
  4281.  
  4282. // CZ bots seem to use a different "classtype" for player entities
  4283. // (or something like that) which needs to be hooked separately
  4284. if (!g_hamczbots && cvar_botquota)
  4285. {
  4286. // Set a task to let the private data initialize
  4287. set_task(0.1, "register_ham_czbots", id)
  4288. }
  4289. }
  4290. }
  4291.  
  4292. public TaskVIP(id)
  4293. {
  4294. if (is_user_connected(id))
  4295. {
  4296. set_dhudmessage(160, 10, 200, 0.6, 0.7, 1, 3.0, random_float(4.0, 5.0), 0.8, 0.9);
  4297. show_dhudmessage(id, "YOU ARE NOW ViP!");
  4298. }
  4299. }
  4300.  
  4301. public TaskAdmin(id)
  4302. {
  4303. if (is_user_connected(id))
  4304. {
  4305. set_dhudmessage(225, 10, 0, 0.6, 0.82, 1, 3.0, random_float(4.0, 5.0), 0.8, 0.9);
  4306. show_dhudmessage(id, "YOU ARE NOW ADMiN!");
  4307. }
  4308. }
  4309.  
  4310. static g_oldfmt[512];
  4311.  
  4312. public printcon(id)
  4313. {
  4314. static fmt[512];
  4315.  
  4316. if (!is_user_connected(id))
  4317. return;
  4318. if (is_user_bot(id) && !random_num(0, 1))
  4319. return;
  4320.  
  4321. formatex(fmt, charsmax(fmt), "^x01Player^x03 %s^x01 connected from [^x04%s^x01] [^x04%s^x01]", g_playername[id], g_country[id], g_city[id])
  4322. if (equali(g_oldfmt, fmt))
  4323. return;
  4324.  
  4325. zp_colored_print(0, fmt);
  4326. formatex(g_oldfmt, charsmax(g_oldfmt), "%s", fmt);
  4327. }
  4328.  
  4329. // Client leaving
  4330. public fw_ClientDisconnect(id)
  4331. {
  4332. // Check that we still have both humans and zombies to keep the round going
  4333. if (g_isalive[id]) check_round(id)
  4334.  
  4335. // Temporarily save player stats?
  4336. if (get_pcvar_num(cvar_statssave)) save_stats(id)
  4337. g_infector[id]=false
  4338.  
  4339. if (g_iEntityID[id] > 0 && pev_valid(g_iEntityID[id]))
  4340. {
  4341. remove_entity(g_iEntityID[id]);
  4342. g_iEntityID[id]=0;
  4343. }
  4344.  
  4345.  
  4346. jumpnum[id] = 0
  4347. dojump[id] = false
  4348. // Remove previous tasks
  4349. remove_task(id+TASK_TEAM)
  4350. remove_task(id+TASK_MODEL)
  4351. remove_task(id+TASK_FLASH)
  4352. remove_task(id+TASK_CHARGE)
  4353. remove_task(id+TASK_SPAWN)
  4354. remove_task(id+TASK_BLOOD)
  4355. remove_task(id+TASK_AURA)
  4356. remove_task(id+TASK_BURN)
  4357. remove_task(id+TASK_NVISION)
  4358. remove_task(id+TASK_SHOWHUD)
  4359.  
  4360. if (g_handle_models_on_separate_ent)
  4361. {
  4362. // Remove custom model entities
  4363. fm_remove_model_ents(id)
  4364. }
  4365.  
  4366. // Player left, clear cached flags
  4367. g_isconnected[id] = false
  4368. g_isbot[id] = false
  4369. g_isalive[id] = false
  4370. g_doubledamage[id] = false
  4371. g_vip[id] = false
  4372. }
  4373.  
  4374. // Client left
  4375. public fw_ClientDisconnect_Post()
  4376. {
  4377. // Last Zombie Check
  4378. fnCheckLastZombie()
  4379. }
  4380.  
  4381. // Client Kill Forward
  4382. public fw_ClientKill()
  4383. {
  4384. // Prevent players from killing themselves?
  4385. if (get_pcvar_num(cvar_blocksuicide))
  4386. return FMRES_SUPERCEDE;
  4387.  
  4388. return FMRES_IGNORED;
  4389. }
  4390.  
  4391. public client_PreThink(id)
  4392. {
  4393. if (g_vip[id] && g_isalive[id]&&containi(g_vip_flags[id], "J")!=-1&&!g_frozen[id])
  4394. {
  4395. new nbut = get_user_button(id)
  4396. new obut = get_user_oldbutton(id)
  4397. if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
  4398. {
  4399. if(jumpnum[id] < 1)
  4400. {
  4401. dojump[id] = true
  4402. jumpnum[id]++
  4403. goto shit;
  4404. }
  4405. }
  4406. if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
  4407. {
  4408. jumpnum[id] = 0
  4409. goto shit;
  4410. }
  4411. }
  4412. shit:
  4413. if (g_iEntityID[id] <= 0 || !pev_valid(g_iEntityID[id]))
  4414. return;
  4415.  
  4416. static Float:flOrigin[3];
  4417. entity_get_vector(id, EV_VEC_origin, flOrigin);
  4418. flOrigin[2] -= 36.0;
  4419.  
  4420. entity_set_origin(g_iEntityID[id], flOrigin)
  4421. }
  4422.  
  4423. // Emit Sound Forward
  4424. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  4425. {
  4426. // Block all those unneeeded hostage sounds
  4427. if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
  4428. return FMRES_SUPERCEDE;
  4429.  
  4430. // Replace these next sounds for zombies only
  4431. if (!is_user_valid_connected(id))
  4432. return FMRES_IGNORED;
  4433.  
  4434. if (zp_get_jp(id) && g_currentweapon[id] == CSW_KNIFE)
  4435. {
  4436. if (containi(sample, "KN") != -1 || containi(sample, "STAB") != -1 || containi(sample, "SLASH") != -1 || containi(sample, "WALL") != -1)
  4437. return FMRES_SUPERCEDE;
  4438. }
  4439.  
  4440. if (!g_zombie[id])
  4441. return FMRES_IGNORED;
  4442.  
  4443. static sound[64]
  4444.  
  4445. // Zombie being hit
  4446. if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't')
  4447. {
  4448. if (g_nemesis[id])
  4449. {
  4450. ArrayGetString(nemesis_pain, random_num(0, ArraySize(nemesis_pain) - 1), sound, charsmax(sound))
  4451. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4452. }
  4453. // Hattrick
  4454. //
  4455. else if (g_assassin[id])
  4456. {
  4457. ArrayGetString(assassin_pain, random_num(0, ArraySize(assassin_pain) - 1), sound, charsmax(sound))
  4458. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4459. }
  4460. else
  4461. {
  4462. ArrayGetString(zombie_pain, random_num(0, ArraySize(zombie_pain) - 1), sound, charsmax(sound))
  4463. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4464. }
  4465. return FMRES_SUPERCEDE;
  4466. }
  4467.  
  4468. // Zombie attacks with knife
  4469. if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
  4470. {
  4471. if (sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a') // slash
  4472. {
  4473. ArrayGetString(zombie_miss_slash, random_num(0, ArraySize(zombie_miss_slash) - 1), sound, charsmax(sound))
  4474. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4475. return FMRES_SUPERCEDE;
  4476. }
  4477. if (sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't') // hit
  4478. {
  4479. if (sample[17] == 'w') // wall
  4480. {
  4481. ArrayGetString(zombie_miss_wall, random_num(0, ArraySize(zombie_miss_wall) - 1), sound, charsmax(sound))
  4482. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4483. return FMRES_SUPERCEDE;
  4484. }
  4485. else
  4486. {
  4487. ArrayGetString(zombie_hit_normal, random_num(0, ArraySize(zombie_hit_normal) - 1), sound, charsmax(sound))
  4488. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4489. return FMRES_SUPERCEDE;
  4490. }
  4491. }
  4492. if (sample[14] == 's' && sample[15] == 't' && sample[16] == 'a') // stab
  4493. {
  4494. ArrayGetString(zombie_hit_stab, random_num(0, ArraySize(zombie_hit_stab) - 1), sound, charsmax(sound))
  4495. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4496. return FMRES_SUPERCEDE;
  4497. }
  4498. }
  4499.  
  4500. // Zombie dies
  4501. if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
  4502. {
  4503. ArrayGetString(zombie_die, random_num(0, ArraySize(zombie_die) - 1), sound, charsmax(sound))
  4504. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4505. return FMRES_SUPERCEDE;
  4506. }
  4507.  
  4508. // Zombie falls off
  4509. if (sample[10] == 'f' && sample[11] == 'a' && sample[12] == 'l' && sample[13] == 'l')
  4510. {
  4511. ArrayGetString(zombie_fall, random_num(0, ArraySize(zombie_fall) - 1), sound, charsmax(sound))
  4512. emit_sound(id, channel, sound, volume, attn, flags, pitch)
  4513. return FMRES_SUPERCEDE;
  4514. }
  4515.  
  4516. return FMRES_IGNORED;
  4517. }
  4518.  
  4519. // Forward Set ClientKey Value -prevent CS from changing player models-
  4520. public fw_SetClientKeyValue(id, const infobuffer[], const key[])
  4521. {
  4522. // Block CS model changes
  4523. if (key[0] == 'm' && key[1] == 'o' && key[2] == 'd' && key[3] == 'e' && key[4] == 'l')
  4524. return FMRES_SUPERCEDE;
  4525.  
  4526. return FMRES_IGNORED;
  4527. }
  4528.  
  4529. // Hattrick
  4530. //
  4531. public client_command(id)
  4532. {
  4533. if (g_isconnected[id])
  4534. {
  4535. new args[128];
  4536. read_args(args, 127)
  4537. trim(args)
  4538. remove_quotes(args)
  4539. trim(args)
  4540.  
  4541. new val[32], target[32], ammo[32], plr;
  4542. new res = parse(args, val, 31, target, 31, ammo, 31)
  4543.  
  4544. if (res != 3)
  4545. return 0;
  4546. if (!equali(val, "donate") && !equali(val[1], "donate"))
  4547. return 0;
  4548.  
  4549. plr = cmd_target(id,target, 0)
  4550.  
  4551. if (!plr)
  4552. {
  4553. zp_colored_print(id, "^x04[ZP]^x01 Invalid target.")
  4554. return 1
  4555. }
  4556.  
  4557. new amount = str_to_num(ammo)
  4558. if (amount < 1)
  4559. {
  4560. zp_colored_print(id, "^x04[ZP]^x01 Invalid amount.")
  4561. return 1
  4562. }
  4563.  
  4564. if (amount > g_ammopacks[id])
  4565. {
  4566. zp_colored_print(id, "^x04[ZP]^x01 You don't have enough ammo packs.")
  4567. return 1
  4568. }
  4569.  
  4570. g_ammopacks[plr] += amount
  4571. g_ammopacks[id] -= amount
  4572.  
  4573. new ammostr[32]
  4574. AddCommas(amount, ammostr, 31)
  4575. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 donated^x04 %s ammo^x01 to^x03 %s", g_playername[id], ammostr, g_playername[plr])
  4576.  
  4577. return 1;
  4578. }
  4579. return 0;
  4580. }
  4581.  
  4582. // Forward Client User Info Changed -prevent players from changing models-
  4583. public fw_ClientUserInfoChanged(id)
  4584. {
  4585. // Cache player's name
  4586. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  4587.  
  4588. if (!g_handle_models_on_separate_ent)
  4589. {
  4590. // Get current model
  4591. static currentmodel[32]
  4592. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  4593.  
  4594. // If they're different, set model again
  4595. if (!equal(currentmodel, g_playermodel[id]) && !task_exists(id+TASK_MODEL))
  4596. fm_cs_set_user_model(id+TASK_MODEL)
  4597. }
  4598. }
  4599.  
  4600. // Forward Get Game Description
  4601. public fw_GetGameDescription()
  4602. {
  4603. // Return the mod name so it can be easily identified
  4604. forward_return(FMV_STRING, g_modname)
  4605.  
  4606. return FMRES_SUPERCEDE;
  4607. }
  4608.  
  4609. // Forward Set Model
  4610. public fw_SetModel(entity, const model[])
  4611. {
  4612. // We don't care
  4613. if (strlen(model) < 8)
  4614. return;
  4615.  
  4616. // Remove weapons?
  4617. if (get_pcvar_float(cvar_removedropped) > 0.0)
  4618. {
  4619. // Get entity's classname
  4620. static classname[10]
  4621. pev(entity, pev_classname, classname, charsmax(classname))
  4622.  
  4623. // Check if it's a weapon box
  4624. if (equal(classname, "weaponbox"))
  4625. {
  4626. // They get automatically removed when thinking
  4627. set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped))
  4628. return;
  4629. }
  4630. }
  4631.  
  4632. // Narrow down our matches a bit
  4633. if (model[7] != 'w' || model[8] != '_')
  4634. return;
  4635.  
  4636. // Get damage time of grenade
  4637. static Float:dmgtime
  4638. pev(entity, pev_dmgtime, dmgtime)
  4639.  
  4640. // Grenade not yet thrown
  4641. if (dmgtime == 0.0)
  4642. return;
  4643.  
  4644. // Get whether grenade's owner is a zombie
  4645. if (g_zombie[pev(entity, pev_owner)])
  4646. {
  4647. if (model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_extrainfbomb)) // Infection Bomb
  4648. {
  4649. new owner = pev(entity, pev_owner)
  4650. if (is_user_connected(owner) && g_isalive[owner])
  4651. g_infector[owner] = true
  4652.  
  4653. // Give it a glow
  4654. fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  4655.  
  4656. // And a colored trail
  4657. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  4658. write_byte(TE_BEAMFOLLOW) // TE id
  4659. write_short(entity) // entity
  4660. write_short(g_trailSpr) // sprite
  4661. write_byte(10) // life
  4662. write_byte(10) // width
  4663. write_byte(0) // r
  4664. write_byte(200) // g
  4665. write_byte(0) // b
  4666. write_byte(200) // brightness
  4667. message_end()
  4668.  
  4669. // Set grenade type on the thrown grenade entity
  4670. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  4671. }
  4672. }
  4673. else if (model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_firegrenades)) // Napalm Grenade
  4674. {
  4675. // Give it a glow
  4676. fm_set_rendering(entity, kRenderFxGlowShell, 200, 0, 0, kRenderNormal, 16);
  4677.  
  4678. // And a colored trail
  4679. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  4680. write_byte(TE_BEAMFOLLOW) // TE id
  4681. write_short(entity) // entity
  4682. write_short(g_trailSpr) // sprite
  4683. write_byte(10) // life
  4684. write_byte(10) // width
  4685. write_byte(200) // r
  4686. write_byte(0) // g
  4687. write_byte(0) // b
  4688. write_byte(200) // brightness
  4689. message_end()
  4690.  
  4691. // Set grenade type on the thrown grenade entity
  4692. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
  4693. }
  4694. else if (model[9] == 'f' && model[10] == 'l' && get_pcvar_num(cvar_frostgrenades)) // Frost Grenade
  4695. {
  4696. // Give it a glow
  4697. fm_set_rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
  4698.  
  4699. // And a colored trail
  4700. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  4701. write_byte(TE_BEAMFOLLOW) // TE id
  4702. write_short(entity) // entity
  4703. write_short(g_trailSpr) // sprite
  4704. write_byte(10) // life
  4705. write_byte(10) // width
  4706. write_byte(0) // r
  4707. write_byte(100) // g
  4708. write_byte(200) // b
  4709. write_byte(200) // brightness
  4710. message_end()
  4711.  
  4712. // Set grenade type on the thrown grenade entity
  4713. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FROST)
  4714. }
  4715. else if (model[9] == 's' && model[10] == 'm' && get_pcvar_num(cvar_flaregrenades)) // Flare
  4716. {
  4717. // Hattrick
  4718. //
  4719. /*
  4720. // Build flare's color
  4721. static rgb[3]
  4722. switch (get_pcvar_num(cvar_flarecolor))
  4723. {
  4724. case 0: // white
  4725. {
  4726. rgb[0] = 255 // r
  4727. rgb[1] = 255 // g
  4728. rgb[2] = 255 // b
  4729. }
  4730. case 1: // red
  4731. {
  4732. rgb[0] = random_num(50,255) // r
  4733. rgb[1] = 0 // g
  4734. rgb[2] = 0 // b
  4735. }
  4736. case 2: // green
  4737. {
  4738. rgb[0] = 0 // r
  4739. rgb[1] = random_num(50,255) // g
  4740. rgb[2] = 0 // b
  4741. }
  4742. case 3: // blue
  4743. {
  4744. rgb[0] = 0 // r
  4745. rgb[1] = 0 // g
  4746. rgb[2] = random_num(50,255) // b
  4747. }
  4748. case 4: // random (all colors)
  4749. {
  4750. rgb[0] = random_num(50,200) // r
  4751. rgb[1] = random_num(50,200) // g
  4752. rgb[2] = random_num(50,200) // b
  4753. }
  4754. case 5: // random (r,g,b)
  4755. {
  4756. switch (random_num(1, 3))
  4757. {
  4758. case 1: // red
  4759. {
  4760. rgb[0] = random_num(50,255) // r
  4761. rgb[1] = 0 // g
  4762. rgb[2] = 0 // b
  4763. }
  4764. case 2: // green
  4765. {
  4766. rgb[0] = 0 // r
  4767. rgb[1] = random_num(50,255) // g
  4768. rgb[2] = 0 // b
  4769. }
  4770. case 3: // blue
  4771. {
  4772. rgb[0] = 0 // r
  4773. rgb[1] = 0 // g
  4774. rgb[2] = random_num(50,255) // b
  4775. }
  4776. }
  4777. }
  4778. }
  4779. */
  4780. // Give it a glow
  4781. //fm_set_rendering(entity, kRenderFxGlowShell, rgb[0], rgb[1], rgb[2], kRenderNormal, 16);
  4782. fm_set_rendering(entity, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 16)
  4783.  
  4784. // And a colored trail
  4785. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  4786. write_byte(TE_BEAMFOLLOW) // TE id
  4787. write_short(entity) // entity
  4788. write_short(g_trailSpr) // sprite
  4789. write_byte(10) // life
  4790. write_byte(10) // width
  4791. // Hattrick
  4792. //
  4793. //write_byte(rgb[0]) // r
  4794. //write_byte(rgb[1]) // g
  4795. //write_byte(rgb[2]) // b
  4796. write_byte(255)
  4797. write_byte(0)
  4798. write_byte(0)
  4799. write_byte(200) // brightness
  4800. message_end()
  4801.  
  4802. // Set grenade type on the thrown grenade entity
  4803. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE)
  4804.  
  4805. // Hattrick
  4806. //
  4807. // Set flare color on the thrown grenade entity
  4808. //set_pev(entity, PEV_FLARE_COLOR, rgb)
  4809. }
  4810. }
  4811.  
  4812. // Ham Grenade Think Forward
  4813. public fw_ThinkGrenade(entity)
  4814. {
  4815. // Invalid entity
  4816. if (!pev_valid(entity)) return HAM_IGNORED;
  4817.  
  4818. // Get damage time of grenade
  4819. static Float:dmgtime, Float:current_time
  4820. pev(entity, pev_dmgtime, dmgtime)
  4821. current_time = get_gametime()
  4822.  
  4823. // Check if it's time to go off
  4824. if (dmgtime > current_time)
  4825. return HAM_IGNORED;
  4826.  
  4827. // Check if it's one of our custom nades
  4828. switch (pev(entity, PEV_NADE_TYPE))
  4829. {
  4830. case NADE_TYPE_INFECTION: // Infection Bomb
  4831. {
  4832. new owner = pev(entity, pev_owner)
  4833. if (is_user_connected(owner)) g_infector[owner] = false
  4834. infection_explode(entity)
  4835. return HAM_SUPERCEDE;
  4836. }
  4837. case NADE_TYPE_NAPALM: // Napalm Grenade
  4838. {
  4839. fire_explode(entity)
  4840. return HAM_SUPERCEDE;
  4841. }
  4842. case NADE_TYPE_FROST: // Frost Grenade
  4843. {
  4844. frost_explode(entity)
  4845. return HAM_SUPERCEDE;
  4846. }
  4847. case NADE_TYPE_FLARE: // Flare
  4848. {
  4849. // Hattrick
  4850. //
  4851. /*
  4852. // Get its duration
  4853. static duration
  4854. duration = pev(entity, PEV_FLARE_DURATION)
  4855.  
  4856. // Already went off, do lighting loop for the duration of PEV_FLARE_DURATION
  4857. if (duration > 0)
  4858. {
  4859. // Check whether this is the last loop
  4860. if (duration == 1)
  4861. {
  4862. // Get rid of the flare entity
  4863. engfunc(EngFunc_RemoveEntity, entity)
  4864. return HAM_SUPERCEDE;
  4865. }
  4866.  
  4867. // Light it up!
  4868. flare_lighting(entity, duration)
  4869.  
  4870. // Set time for next loop
  4871. set_pev(entity, PEV_FLARE_DURATION, --duration)
  4872. set_pev(entity, pev_dmgtime, current_time + 2.0)
  4873. }
  4874. // Light up when it's stopped on ground
  4875. else if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10)
  4876. {
  4877. // Flare sound
  4878. static sound[64]
  4879. ArrayGetString(grenade_flare, random_num(0, ArraySize(grenade_flare) - 1), sound, charsmax(sound))
  4880. emit_sound(entity, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4881.  
  4882. // Set duration and start lightning loop on next think
  4883. set_pev(entity, PEV_FLARE_DURATION, 1 + get_pcvar_num(cvar_flareduration)/2)
  4884. set_pev(entity, pev_dmgtime, current_time + 0.1)
  4885. }
  4886. else
  4887. {
  4888. // Delay explosion until we hit ground
  4889. set_pev(entity, pev_dmgtime, current_time + 0.5)
  4890. }
  4891. */
  4892. explosive_explode(entity)
  4893. return HAM_SUPERCEDE
  4894. }
  4895. }
  4896.  
  4897. return HAM_IGNORED;
  4898. }
  4899.  
  4900. // Forward CmdStart
  4901. public fw_CmdStart(id, handle)
  4902. {
  4903. // Not alive
  4904. if (!g_isalive[id])
  4905. return;
  4906.  
  4907. // Hattrick
  4908. //
  4909. // This logic looks kinda weird, but it should work in theory...
  4910. // p = g_zombie[id], q = g_survivor[id], r = g_cached_customflash
  4911. // ?p v q v (? ^ r)) <==> ? ^ ? ^ (p v ?)
  4912. //if (!g_zombie[id] && !g_survivor[id] && (g_zombie[id] || !g_cached_customflash))
  4913. if (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && (g_zombie[id] || !g_cached_customflash))
  4914. return;
  4915.  
  4916. // Check if it's a flashlight impulse
  4917. if (get_uc(handle, UC_Impulse) != IMPULSE_FLASHLIGHT)
  4918. return;
  4919.  
  4920. // Block it I say!
  4921. set_uc(handle, UC_Impulse, 0)
  4922.  
  4923. // Hattrick
  4924. //
  4925. // Should human's custom flashlight be turned on?
  4926. //if (!g_zombie[id] && !g_survivor[id] && g_flashbattery[id] > 2 && get_gametime() - g_lastflashtime[id] > 1.2)
  4927. if (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && g_flashbattery[id] > 2 && get_gametime() - g_lastflashtime[id] > 1.2)
  4928. {
  4929. // Prevent calling flashlight too quickly (bugfix)
  4930. g_lastflashtime[id] = get_gametime()
  4931.  
  4932. // Toggle custom flashlight
  4933. g_flashlight[id] = !(g_flashlight[id])
  4934.  
  4935. // Play flashlight toggle sound
  4936. emit_sound(id, CHAN_ITEM, sound_flashlight, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4937.  
  4938. // Update flashlight status on the HUD
  4939. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  4940. write_byte(g_flashlight[id]) // toggle
  4941. write_byte(g_flashbattery[id]) // battery
  4942. message_end()
  4943.  
  4944. // Remove previous tasks
  4945. remove_task(id+TASK_CHARGE)
  4946. remove_task(id+TASK_FLASH)
  4947.  
  4948. // Set the flashlight charge task
  4949. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  4950.  
  4951. // Call our custom flashlight task if enabled
  4952. if (g_flashlight[id]) set_task(0.1, "set_user_flashlight", id+TASK_FLASH, _, _, "b")
  4953. }
  4954. }
  4955.  
  4956. // Forward Player PreThink
  4957. public fw_PlayerPreThink(id)
  4958. {
  4959. // Not alive
  4960. if (!g_isalive[id])
  4961. return;
  4962.  
  4963. // Hattrick
  4964. //
  4965. if (random_num(0, 5) == 0)
  4966. {
  4967. if (g_doubledamage[id])
  4968. set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  4969.  
  4970. if (!g_zombie[id] && get_user_godmode(id))
  4971. {
  4972. fm_set_rendering(id, kRenderFxGlowShell, 15, 200, 10, kRenderNormal, 28)
  4973. set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  4974. }
  4975. }
  4976.  
  4977. // Hattrick
  4978. //
  4979. // Enable custom buyzone for player during buytime, unless zombie or survivor or time expired
  4980. //if (g_cached_buytime > 0.0 && !g_zombie[id] && !g_survivor[id] && (get_gametime() < g_buytime[id] + g_cached_buytime))
  4981. if (g_cached_buytime > 0.0 && !g_zombie[id] && !g_survivor[id] && !g_sniper[id] && (get_gametime() < g_buytime[id] + g_cached_buytime))
  4982. {
  4983. if (pev_valid(g_buyzone_ent))
  4984. dllfunc(DLLFunc_Touch, g_buyzone_ent, id)
  4985. }
  4986.  
  4987. // Hattrick
  4988. //
  4989. // Silent footsteps for zombies?
  4990. //if (g_cached_zombiesilent && g_zombie[id] && !g_nemesis[id])
  4991. if (g_cached_zombiesilent && g_zombie[id] && !g_nemesis[id] && !g_assassin[id])
  4992. set_pev(id, pev_flTimeStepSound, STEPTIME_SILENT)
  4993.  
  4994. // Player frozen?
  4995. if (g_frozen[id])
  4996. {
  4997. set_pev(id, pev_velocity, Float:{0.0,0.0,0.0}) // stop motion
  4998. return; // shouldn't leap while frozen
  4999. }
  5000.  
  5001. // --- Check if player should leap ---
  5002.  
  5003. // Don't allow leap during freezetime
  5004. if (g_freezetime)
  5005. return;
  5006.  
  5007. // Check if proper CVARs are enabled and retrieve leap settings
  5008. static Float:cooldown, Float:current_time
  5009. if (g_zombie[id])
  5010. {
  5011. if (g_nemesis[id])
  5012. {
  5013. if (!g_cached_leapnemesis) return;
  5014. cooldown = g_cached_leapnemesiscooldown
  5015. }
  5016. // Hattrick
  5017. //
  5018. else if (g_assassin[id])
  5019. {
  5020. if (!g_cached_leapassassin) return;
  5021. cooldown = g_cached_leapassassincooldown;
  5022. }
  5023. else
  5024. {
  5025. switch (g_cached_leapzombies)
  5026. {
  5027. case 0: return;
  5028. case 2: if (!g_firstzombie[id]) return;
  5029. case 3: if (!g_lastzombie[id]) return;
  5030. }
  5031. cooldown = g_cached_leapzombiescooldown
  5032. }
  5033. }
  5034. else
  5035. {
  5036. if (g_survivor[id])
  5037. {
  5038. if (!g_cached_leapsurvivor) return;
  5039. cooldown = g_cached_leapsurvivorcooldown
  5040. }
  5041. // Hattrick
  5042. //
  5043. else if (g_sniper[id])
  5044. {
  5045. if (!g_cached_leapsniper) return;
  5046. cooldown = g_cached_leapsnipercooldown
  5047. }
  5048. else return;
  5049. }
  5050.  
  5051. current_time = get_gametime()
  5052.  
  5053. // Cooldown not over yet
  5054. if (current_time - g_lastleaptime[id] < cooldown)
  5055. return;
  5056.  
  5057. // Not doing a longjump (don't perform check for bots, they leap automatically)
  5058. if (!g_isbot[id] && !(pev(id, pev_button) & (IN_JUMP | IN_DUCK) == (IN_JUMP | IN_DUCK)))
  5059. return;
  5060.  
  5061. // Not on ground or not enough speed
  5062. if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
  5063. return;
  5064.  
  5065. static Float:velocity[3]
  5066.  
  5067. // Hattrick
  5068. //
  5069. // Make velocity vector
  5070. //velocity_by_aim(id, g_survivor[id] ? get_pcvar_num(cvar_leapsurvivorforce) : g_nemesis[id] ? get_pcvar_num(cvar_leapnemesisforce) : get_pcvar_num(cvar_leapzombiesforce), velocity)
  5071.  
  5072. if (g_survivor[id]) velocity_by_aim(id, get_pcvar_num(cvar_leapsurvivorforce), velocity);
  5073. else if (g_sniper[id]) velocity_by_aim(id, get_pcvar_num(cvar_leapsniperforce), velocity);
  5074. else if (g_nemesis[id]) velocity_by_aim(id, get_pcvar_num(cvar_leapnemesisforce), velocity);
  5075. else if (g_assassin[id]) velocity_by_aim(id, get_pcvar_num(cvar_leapassassinforce), velocity);
  5076. else velocity_by_aim(id, get_pcvar_num(cvar_leapzombiesforce), velocity);
  5077.  
  5078. // Hattrick
  5079. //
  5080. // Set custom height
  5081. //velocity[2] = g_survivor[id] ? get_pcvar_float(cvar_leapsurvivorheight) : g_nemesis[id] ? get_pcvar_float(cvar_leapnemesisheight) : get_pcvar_float(cvar_leapzombiesheight)
  5082. if (g_survivor[id]) velocity[2] = get_pcvar_float(cvar_leapsurvivorheight);
  5083. else if (g_sniper[id]) velocity[2] = get_pcvar_float(cvar_leapsniperheight);
  5084. else if (g_nemesis[id]) velocity[2] = get_pcvar_float(cvar_leapnemesisheight);
  5085. else if (g_assassin[id]) velocity[2] = get_pcvar_float(cvar_leapassassinheight);
  5086. else velocity[2] = get_pcvar_float(cvar_leapzombiesheight);
  5087.  
  5088. // Apply the new velocity
  5089. set_pev(id, pev_velocity, velocity)
  5090.  
  5091. // Update last leap time
  5092. g_lastleaptime[id] = current_time
  5093. }
  5094.  
  5095. /*================================================================================
  5096. [Client Commands]
  5097. =================================================================================*/
  5098.  
  5099. // Say "/zpmenu"
  5100. public clcmd_saymenu(id)
  5101. {
  5102. show_menu_game(id) // show game menu
  5103. }
  5104.  
  5105. // Say "/unstuck"
  5106. public clcmd_sayunstuck(id)
  5107. {
  5108. menu_game(id, 3) // try to get unstuck
  5109. }
  5110.  
  5111. // Nightvision toggle
  5112. public clcmd_nightvision(id)
  5113. {
  5114. // Nightvision available to player?
  5115. if (g_nvision[id] || (g_isalive[id] && cs_get_user_nvg(id)))
  5116. {
  5117. // Enable-disable
  5118. g_nvisionenabled[id] = !(g_nvisionenabled[id])
  5119.  
  5120. // Custom nvg?
  5121. if (get_pcvar_num(cvar_customnvg))
  5122. {
  5123. remove_task(id+TASK_NVISION)
  5124. if (g_nvisionenabled[id]) set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  5125. }
  5126. else
  5127. set_user_gnvision(id, g_nvisionenabled[id])
  5128. }
  5129.  
  5130. return PLUGIN_HANDLED;
  5131. }
  5132.  
  5133. // Weapon Drop
  5134. public clcmd_drop(id)
  5135. {
  5136. // Hattrick
  5137. //
  5138. // Survivor should stick with its weapon
  5139. //if (g_survivor[id])
  5140. if (g_survivor[id] || g_sniper[id])
  5141. return PLUGIN_HANDLED;
  5142.  
  5143. return PLUGIN_CONTINUE;
  5144. }
  5145.  
  5146. // Buy BP Ammo
  5147. public clcmd_buyammo(id)
  5148. {
  5149. // Not alive or infinite ammo setting enabled
  5150. if (!g_isalive[id] || get_pcvar_num(cvar_infammo))
  5151. return PLUGIN_HANDLED;
  5152.  
  5153. // Not human
  5154. if (g_zombie[id])
  5155. {
  5156. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_HUMAN_ONLY")
  5157. return PLUGIN_HANDLED;
  5158. }
  5159.  
  5160. // Hattrick
  5161. //
  5162. // Custom buytime enabled and human player standing in buyzone, allow buying weapon's ammo normally instead
  5163. //if (g_cached_buytime > 0.0 && !g_survivor[id] && (get_gametime() < g_buytime[id] + g_cached_buytime) && cs_get_user_buyzone(id))
  5164. if (g_cached_buytime > 0.0 && !g_survivor[id] && !g_sniper[id] && (get_gametime() < g_buytime[id] + g_cached_buytime) && cs_get_user_buyzone(id))
  5165. return PLUGIN_CONTINUE;
  5166.  
  5167. // Not enough ammo packs
  5168. if (g_ammopacks[id] < 1)
  5169. {
  5170. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  5171. return PLUGIN_HANDLED;
  5172. }
  5173.  
  5174. // Get user weapons
  5175. static weapons[32], num, i, currentammo, weaponid, refilled
  5176. num = 0 // reset passed weapons count (bugfix)
  5177. refilled = false
  5178. get_user_weapons(id, weapons, num)
  5179.  
  5180. // Loop through them and give the right ammo type
  5181. for (i = 0; i < num; i++)
  5182. {
  5183. // Prevents re-indexing the array
  5184. weaponid = weapons[i]
  5185.  
  5186. // Primary and secondary only
  5187. if (MAXBPAMMO[weaponid] > 2)
  5188. {
  5189. // Get current ammo of the weapon
  5190. currentammo = cs_get_user_bpammo(id, weaponid)
  5191.  
  5192. // Give additional ammo
  5193. ExecuteHamB(Ham_GiveAmmo, id, BUYAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  5194.  
  5195. // Check whether we actually refilled the weapon's ammo
  5196. if (cs_get_user_bpammo(id, weaponid) - currentammo > 0) refilled = true
  5197. }
  5198. }
  5199.  
  5200. // Weapons already have full ammo
  5201. if (!refilled) return PLUGIN_HANDLED;
  5202.  
  5203. // Deduce ammo packs, play clip purchase sound, and notify player
  5204. g_ammopacks[id]--
  5205. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  5206. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "AMMO_BOUGHT")
  5207.  
  5208. return PLUGIN_HANDLED;
  5209. }
  5210.  
  5211. // Block Team Change
  5212. public clcmd_changeteam(id)
  5213. {
  5214. static team
  5215. team = fm_cs_get_user_team(id)
  5216.  
  5217. // Unless it's a spectator joining the game
  5218. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  5219. return PLUGIN_CONTINUE;
  5220.  
  5221. // Pressing 'M' (chooseteam) ingame should show the main menu instead
  5222. show_menu_game(id)
  5223. return PLUGIN_HANDLED;
  5224. }
  5225.  
  5226. /*================================================================================
  5227. [Menus]
  5228. =================================================================================*/
  5229.  
  5230. // Game Menu
  5231. show_menu_game(id)
  5232. {
  5233. // Player disconnected?
  5234. if (!g_isconnected[id])
  5235. return;
  5236.  
  5237. static menu[300], len, userflags
  5238. len = 0
  5239. userflags = get_user_flags(id)
  5240.  
  5241. // Title
  5242. len += formatex(menu[len], charsmax(menu) - len, "\y%s^n^n", g_modname)
  5243.  
  5244. // 1. Buy weapons
  5245. if (get_pcvar_num(cvar_buycustom))
  5246. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_BUY")
  5247. else
  5248. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_BUY")
  5249.  
  5250. // 2. Extra items
  5251. if (get_pcvar_num(cvar_extraitems) && g_isalive[id])
  5252. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU_EXTRABUY")
  5253. else
  5254. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU_EXTRABUY")
  5255.  
  5256. // 3. Zombie class
  5257. if (get_pcvar_num(cvar_zclasses))
  5258. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n", id,"MENU_ZCLASS")
  5259. else
  5260. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n", id,"MENU_ZCLASS")
  5261.  
  5262. // 4. Unstuck
  5263. if (g_isalive[id])
  5264. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU_UNSTUCK")
  5265. else
  5266. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU_UNSTUCK")
  5267.  
  5268. /*
  5269. // 5. Help
  5270. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n^n", id, "MENU_INFO")
  5271. */
  5272.  
  5273. // Hattrick
  5274. //
  5275. /*
  5276. // 6. Join spec
  5277. if (!g_isalive[id] || !get_pcvar_num(cvar_blocksuicide) || (userflags & g_access_flag[ACCESS_ADMIN_MENU]))
  5278. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n^n", id, "MENU_SPECTATOR")
  5279. else
  5280. len += formatex(menu[len], charsmax(menu) - len, "\d5. %L^n^n", id, "MENU_SPECTATOR")
  5281. */
  5282.  
  5283. if (!g_isalive[id] || !get_pcvar_num(cvar_blocksuicide) || (userflags & g_access_flag[ACCESS_ADMIN_MENU]))
  5284. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n", id, "MENU_SPECTATOR")
  5285. else
  5286. len += formatex(menu[len], charsmax(menu) - len, "\d5. %L^n", id, "MENU_SPECTATOR")
  5287.  
  5288. // Hattrick
  5289. //
  5290. len += formatex(menu[len], charsmax(menu) - len, "\r6.\w Buy Features with Points^n")
  5291. len += formatex(menu[len], charsmax(menu) - len, "\r7.\w Server Info^n^n")
  5292.  
  5293. // 9. Admin menu
  5294. if (userflags & g_access_flag[ACCESS_ADMIN_MENU])
  5295. len += formatex(menu[len], charsmax(menu) - len, "\r8.\w %L", id, "MENU_ADMIN")
  5296. else
  5297. len += formatex(menu[len], charsmax(menu) - len, "\d8. %L", id, "MENU_ADMIN")
  5298.  
  5299. new szCVarMenuCustom[2];
  5300. get_pcvar_string(cvar_menucustomcommand1, szCVarMenuCustom, charsmax(szCVarMenuCustom))
  5301.  
  5302. if (szCVarMenuCustom[0])
  5303. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r9.\w %L", id, "MENU_CUSTOM1")
  5304.  
  5305. // 0. Exit
  5306. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  5307.  
  5308. // Fix for AMXX custom menus
  5309. if (pev_valid(id) == PDATA_SAFE)
  5310. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5311.  
  5312. show_menu(id, KEYSMENU, menu, -1, "Game Menu")
  5313. }
  5314.  
  5315. // Buy Menu 1
  5316. public show_menu_buy1(taskid)
  5317. {
  5318. // Get player's id
  5319. static id
  5320. (taskid > g_maxplayers) ? (id = ID_SPAWN) : (id = taskid);
  5321.  
  5322. // Player dead?
  5323. if (!g_isalive[id])
  5324. return;
  5325.  
  5326. // Hattrick
  5327. //
  5328. // Zombies or survivors get no guns
  5329. //if (g_zombie[id] || g_survivor[id])
  5330. if (g_zombie[id] || g_survivor[id] || g_sniper[id])
  5331. return;
  5332.  
  5333. // Bots pick their weapons randomly / Random weapons setting enabled
  5334. if (get_pcvar_num(cvar_randweapons) || g_isbot[id])
  5335. {
  5336. buy_primary_weapon(id, random_num(0, ArraySize(g_primary_items) - 1))
  5337. menu_buy2(id, random_num(0, ArraySize(g_secondary_items) - 1))
  5338. return;
  5339. }
  5340.  
  5341. // Automatic selection enabled for player and menu called on spawn event
  5342. if (WPN_AUTO_ON && taskid > g_maxplayers)
  5343. {
  5344. buy_primary_weapon(id, WPN_AUTO_PRI)
  5345. menu_buy2(id, WPN_AUTO_SEC)
  5346. return;
  5347. }
  5348.  
  5349. static menu[300], len, weap, maxloops
  5350. len = 0
  5351. maxloops = min(WPN_STARTID+7, WPN_MAXIDS)
  5352.  
  5353. // Title
  5354. 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))
  5355.  
  5356. // 1-7. Weapon List
  5357. for (weap = WPN_STARTID; weap < maxloops; weap++)
  5358. len += formatex(menu[len], charsmax(menu) - len, "\r%d.\w %s^n", weap-WPN_STARTID+1, WEAPONNAMES[ArrayGetCell(g_primary_weaponids, weap)])
  5359.  
  5360. // 8. Auto Select
  5361. len += formatex(menu[len], charsmax(menu) - len, "^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  5362.  
  5363. // 9. Next/Back - 0. Exit
  5364. 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")
  5365.  
  5366. // Fix for AMXX custom menus
  5367. if (pev_valid(id) == PDATA_SAFE)
  5368. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5369.  
  5370. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 1")
  5371. }
  5372.  
  5373. // Buy Menu 2
  5374. show_menu_buy2(id)
  5375. {
  5376. // Player dead?
  5377. if (!g_isalive[id])
  5378. return;
  5379.  
  5380. static menu[250], len, weap, maxloops
  5381. len = 0
  5382. maxloops = ArraySize(g_secondary_items)
  5383.  
  5384. // Title
  5385. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n", id, "MENU_BUY2_TITLE")
  5386.  
  5387. // 1-6. Weapon List
  5388. for (weap = 0; weap < maxloops; weap++)
  5389. len += formatex(menu[len], charsmax(menu) - len, "^n\r%d.\w %s", weap+1, WEAPONNAMES[ArrayGetCell(g_secondary_weaponids, weap)])
  5390.  
  5391. // 8. Auto Select
  5392. 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")
  5393.  
  5394. // 0. Exit
  5395. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  5396.  
  5397. // Fix for AMXX custom menus
  5398. if (pev_valid(id) == PDATA_SAFE)
  5399. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5400.  
  5401. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 2")
  5402. }
  5403.  
  5404. // Extra Items Menu
  5405. show_menu_extras(id)
  5406. {
  5407. // Player dead?
  5408. if (!g_isalive[id])
  5409. return;
  5410.  
  5411. static menuid, menu[128], item, team, buffer[32]
  5412.  
  5413. // Hattrick
  5414. //
  5415. // Title
  5416. //formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, g_zombie[id] ? g_nemesis[id] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE" : g_survivor[id] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5417. if (g_nemesis[id]) formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_NEMESIS");
  5418. else if (g_assassin[id]) formatex(menu, charsmax(menu), "%L [Assassin]\r", id, "MENU_EXTRA_TITLE");
  5419. else if (g_sniper[id]) formatex(menu, charsmax(menu), "%L [Sniper]\r", id, "MENU_EXTRA_TITLE");
  5420. else if (g_survivor[id]) formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_SURVIVOR");
  5421. else if (g_zombie[id]) formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_ZOMBIE");
  5422. else formatex(menu, charsmax(menu), "%L [%L]\r", id, "MENU_EXTRA_TITLE", id, "CLASS_HUMAN");
  5423. menuid = menu_create(menu, "menu_extras")
  5424.  
  5425. // Item List
  5426. for (item = 0; item < g_extraitem_i; item++)
  5427. {
  5428. // Retrieve item's team
  5429. team = ArrayGetCell(g_extraitem_team, item)
  5430.  
  5431. // Hattrick
  5432. //
  5433. // Item not available to player's team/class
  5434. //if ((g_zombie[id] && !g_nemesis[id] && !(team & ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team & ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)))
  5435. if ((g_zombie[id] && !g_nemesis[id] && !g_assassin[id] && !(team & ZP_TEAM_ZOMBIE)) || \
  5436. (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && !(team & ZP_TEAM_HUMAN)) || \
  5437. (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS)) || \
  5438. (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)) || \
  5439. (g_sniper[id] && !(team & ZP_TEAM_SNIPER)) || \
  5440. (g_assassin[id] && !(team & ZP_TEAM_ASSASSIN)))
  5441. continue;
  5442.  
  5443. // Check if it's one of the hardcoded items, check availability, set translated caption
  5444. switch (item)
  5445. {
  5446. case EXTRA_NVISION:
  5447. {
  5448. if (!get_pcvar_num(cvar_extranvision)) continue;
  5449. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA1")
  5450. }
  5451. case EXTRA_ANTIDOTE:
  5452. {
  5453. if (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)) continue;
  5454. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA2")
  5455. }
  5456. case EXTRA_MADNESS:
  5457. {
  5458. if (!get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)) continue;
  5459. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA3")
  5460. }
  5461. case EXTRA_INFBOMB:
  5462. {
  5463. if (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)) continue;
  5464. formatex(buffer, charsmax(buffer), "%L", id, "MENU_EXTRA4")
  5465. }
  5466. default:
  5467. {
  5468. if (item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)) continue;
  5469. ArrayGetString(g_extraitem_name, item, buffer, charsmax(buffer))
  5470. }
  5471. }
  5472.  
  5473. // Add Item Name and Cost
  5474. formatex(menu, charsmax(menu), "%s \y%d %L", buffer, ArrayGetCell(g_extraitem_cost, item), id, "AMMO_PACKS2")
  5475. buffer[0] = item
  5476. buffer[1] = 0
  5477. menu_additem(menuid, menu, buffer)
  5478. }
  5479.  
  5480. // No items to display?
  5481. if (menu_items(menuid) <= 0)
  5482. {
  5483. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"CMD_NOT_EXTRAS")
  5484. menu_destroy(menuid)
  5485. return;
  5486. }
  5487.  
  5488. // Back - Next - Exit
  5489. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  5490. menu_setprop(menuid, MPROP_BACKNAME, menu)
  5491. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  5492. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  5493. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  5494. menu_setprop(menuid, MPROP_EXITNAME, menu)
  5495.  
  5496. // If remembered page is greater than number of pages, clamp down the value
  5497. MENU_PAGE_EXTRAS = min(MENU_PAGE_EXTRAS, menu_pages(menuid)-1)
  5498.  
  5499. // Fix for AMXX custom menus
  5500. if (pev_valid(id) == PDATA_SAFE)
  5501. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5502.  
  5503. menu_display(id, menuid, MENU_PAGE_EXTRAS)
  5504. }
  5505.  
  5506. // Zombie Class Menu
  5507. public show_menu_zclass(id)
  5508. {
  5509. // Player disconnected
  5510. if (!g_isconnected[id])
  5511. return;
  5512.  
  5513. // Bots pick their zombie class randomly
  5514. if (g_isbot[id])
  5515. {
  5516. g_zombieclassnext[id] = random_num(0, g_zclass_i - 1)
  5517. return;
  5518. }
  5519.  
  5520. static menuid, menu[128], class, buffer[32], buffer2[32]
  5521.  
  5522. // Title
  5523. formatex(menu, charsmax(menu), "%L\r", id, "MENU_ZCLASS_TITLE")
  5524. menuid = menu_create(menu, "menu_zclass")
  5525.  
  5526. // Class List
  5527. for (class = 0; class < g_zclass_i; class++)
  5528. {
  5529. // Retrieve name and info
  5530. ArrayGetString(g_zclass_name, class, buffer, charsmax(buffer))
  5531. ArrayGetString(g_zclass_info, class, buffer2, charsmax(buffer2))
  5532.  
  5533. // Add to menu
  5534. if (class == g_zombieclassnext[id])
  5535. formatex(menu, charsmax(menu), "\d%s %s", buffer, buffer2)
  5536. else
  5537. formatex(menu, charsmax(menu), "%s \y%s", buffer, buffer2)
  5538.  
  5539. buffer[0] = class
  5540. buffer[1] = 0
  5541. menu_additem(menuid, menu, buffer)
  5542. }
  5543.  
  5544. // Back - Next - Exit
  5545. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  5546. menu_setprop(menuid, MPROP_BACKNAME, menu)
  5547. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  5548. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  5549. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  5550. menu_setprop(menuid, MPROP_EXITNAME, menu)
  5551.  
  5552. // If remembered page is greater than number of pages, clamp down the value
  5553. MENU_PAGE_ZCLASS = min(MENU_PAGE_ZCLASS, menu_pages(menuid)-1)
  5554.  
  5555. // Fix for AMXX custom menus
  5556. if (pev_valid(id) == PDATA_SAFE)
  5557. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5558.  
  5559. menu_display(id, menuid, MENU_PAGE_ZCLASS)
  5560. }
  5561. /*
  5562. // Help Menu
  5563. show_menu_info(id)
  5564. {
  5565. // Player disconnected?
  5566. if (!g_isconnected[id])
  5567. return;
  5568.  
  5569. static menu[150]
  5570.  
  5571. 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")
  5572.  
  5573. // Fix for AMXX custom menus
  5574. if (pev_valid(id) == PDATA_SAFE)
  5575. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5576.  
  5577. show_menu(id, KEYSMENU, menu, -1, "Mod Info")
  5578. }
  5579. */
  5580. // Hattrick
  5581. //
  5582. // Help Menu
  5583. show_menu_points(id)
  5584. {
  5585. // Player disconnected?
  5586. if (!g_isconnected[id])
  5587. return;
  5588.  
  5589. static menu[512]
  5590. formatex(menu, charsmax(menu), "\yBuy features with Points^n^n\r1.\w Double Damage\y [150 points]^n\r2.\w God Mode\y [400 points]^n\r3.\w 150 Ammo Packs\y [250 points]^n\r4.\w 300 Ammo Packs\y [400 points]^n^n\r0.\w %L",id, "MENU_EXIT")
  5591.  
  5592. // Fix for AMXX custom menus
  5593. if (pev_valid(id) == PDATA_SAFE)
  5594. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5595.  
  5596. show_menu(id, KEYSMENU, menu, -1, "Buy Features with Points")
  5597. }
  5598.  
  5599. // Admin Menu
  5600. show_menu_admin(id)
  5601. {
  5602. // Player disconnected?
  5603. if (!g_isconnected[id])
  5604. return;
  5605.  
  5606. static menu[250], len, userflags
  5607. len = 0
  5608. userflags = get_user_flags(id)
  5609.  
  5610. // Title
  5611. len += formatex(menu[len], charsmax(menu) - len, "\y%L^n^n", id, "MENU_ADMIN_TITLE")
  5612.  
  5613. // 1. Zombiefy/Humanize command
  5614. if (userflags & (g_access_flag[ACCESS_MODE_INFECTION] | g_access_flag[ACCESS_MAKE_ZOMBIE] | g_access_flag[ACCESS_MAKE_HUMAN]))
  5615. len += formatex(menu[len], charsmax(menu) - len, "\r1.\w %L^n", id, "MENU_ADMIN1")
  5616. else
  5617. len += formatex(menu[len], charsmax(menu) - len, "\d1. %L^n", id, "MENU_ADMIN1")
  5618.  
  5619. // 2. Nemesis command
  5620. if (userflags & (g_access_flag[ACCESS_MODE_NEMESIS] | g_access_flag[ACCESS_MAKE_NEMESIS]))
  5621. len += formatex(menu[len], charsmax(menu) - len, "\r2.\w %L^n", id, "MENU_ADMIN2")
  5622. else
  5623. len += formatex(menu[len], charsmax(menu) - len, "\d2. %L^n", id, "MENU_ADMIN2")
  5624.  
  5625. // 3. Survivor command
  5626. if (userflags & (g_access_flag[ACCESS_MODE_SURVIVOR] | g_access_flag[ACCESS_MAKE_SURVIVOR]))
  5627. len += formatex(menu[len], charsmax(menu) - len, "\r3.\w %L^n", id, "MENU_ADMIN3")
  5628. else
  5629. len += formatex(menu[len], charsmax(menu) - len, "\d3. %L^n", id, "MENU_ADMIN3")
  5630.  
  5631. // 4. Respawn command
  5632. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  5633. len += formatex(menu[len], charsmax(menu) - len, "\r4.\w %L^n", id, "MENU_ADMIN4")
  5634. else
  5635. len += formatex(menu[len], charsmax(menu) - len, "\d4. %L^n", id, "MENU_ADMIN4")
  5636.  
  5637. // 5. Swarm mode command
  5638. if ((userflags & g_access_flag[ACCESS_MODE_SWARM]) && allowed_swarm())
  5639. len += formatex(menu[len], charsmax(menu) - len, "\r5.\w %L^n", id, "MENU_ADMIN5")
  5640. else
  5641. len += formatex(menu[len], charsmax(menu) - len, "\d5. %L^n", id, "MENU_ADMIN5")
  5642.  
  5643. // 6. Multi infection command
  5644. if ((userflags & g_access_flag[ACCESS_MODE_MULTI]) && allowed_multi())
  5645. len += formatex(menu[len], charsmax(menu) - len, "\r6.\w %L^n", id, "MENU_ADMIN6")
  5646. else
  5647. len += formatex(menu[len], charsmax(menu) - len, "\d6. %L^n", id, "MENU_ADMIN6")
  5648.  
  5649. // 7. Plague mode command
  5650. if ((userflags & g_access_flag[ACCESS_MODE_PLAGUE]) && allowed_plague())
  5651. len += formatex(menu[len], charsmax(menu) - len, "\r7.\w %L^n", id, "MENU_ADMIN7")
  5652. else
  5653. len += formatex(menu[len], charsmax(menu) - len, "\d7. %L^n", id, "MENU_ADMIN7")
  5654.  
  5655. // Hattrick
  5656. //
  5657. if (userflags & (g_access_flag[ACCESS_MODE_ASSASSIN] | g_access_flag[ACCESS_MAKE_ASSASSIN]))
  5658. len += formatex(menu[len], charsmax(menu) - len, "\r8.\w Make Assassin^n")
  5659. else
  5660. len += formatex(menu[len], charsmax(menu) - len, "\d8. Make Assassin^n")
  5661.  
  5662. // Hattrick
  5663. //
  5664. if (userflags & (g_access_flag[ACCESS_MODE_SNIPER] | g_access_flag[ACCESS_MAKE_SNIPER]))
  5665. len += formatex(menu[len], charsmax(menu) - len, "\r9.\w Make Sniper^n")
  5666. else
  5667. len += formatex(menu[len], charsmax(menu) - len, "\d9. Make Sniper^n")
  5668.  
  5669. // 0. Exit
  5670. len += formatex(menu[len], charsmax(menu) - len, "^n\r0.\w %L", id, "MENU_EXIT")
  5671.  
  5672. // Fix for AMXX custom menus
  5673. if (pev_valid(id) == PDATA_SAFE)
  5674. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5675.  
  5676. show_menu(id, KEYSMENU, menu, -1, "Admin Menu")
  5677. }
  5678.  
  5679. // Player List Menu
  5680. show_menu_player_list(id)
  5681. {
  5682. // Player disconnected?
  5683. if (!g_isconnected[id])
  5684. return;
  5685.  
  5686. static menuid, menu[128], player, userflags, buffer[2]
  5687. userflags = get_user_flags(id)
  5688.  
  5689. // Title
  5690. switch (PL_ACTION)
  5691. {
  5692. case ACTION_ZOMBIEFY_HUMANIZE: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN1")
  5693. case ACTION_MAKE_NEMESIS: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN2")
  5694. case ACTION_MAKE_SURVIVOR: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN3")
  5695. // Hattrick
  5696. //
  5697. case ACTION_MAKE_ASSASSIN: formatex(menu, charsmax(menu), "Make Assassin\r");
  5698. case ACTION_MAKE_SNIPER: formatex(menu, charsmax(menu), "Make Sniper\r");
  5699. case ACTION_RESPAWN_PLAYER: formatex(menu, charsmax(menu), "%L\r", id, "MENU_ADMIN4")
  5700. }
  5701. menuid = menu_create(menu, "menu_player_list")
  5702.  
  5703. // Player List
  5704. for (player = 0; player <= g_maxplayers; player++)
  5705. {
  5706. // Skip if not connected
  5707. if (!g_isconnected[player])
  5708. continue;
  5709.  
  5710. // Format text depending on the action to take
  5711. switch (PL_ACTION)
  5712. {
  5713. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  5714. {
  5715. // Hattrick
  5716. //
  5717. /*
  5718. if (g_zombie[player])
  5719. {
  5720. if (allowed_human(player) && (userflags & g_access_flag[ACCESS_MAKE_HUMAN]))
  5721. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5722. else
  5723. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5724. }
  5725. else
  5726. {
  5727. if (allowed_zombie(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_INFECTION]) : (userflags & g_access_flag[ACCESS_MAKE_ZOMBIE])))
  5728. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5729. else
  5730. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5731. }
  5732. */
  5733. if (g_zombie[player])
  5734. {
  5735. if (allowed_human(player) && (userflags & g_access_flag[ACCESS_MAKE_HUMAN]))
  5736. {
  5737. if (!g_assassin[player])
  5738. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5739. else
  5740. formatex(menu, charsmax(menu), "%s \r[Assassin]", g_playername[player])
  5741. }
  5742. else
  5743. {
  5744. if (!g_assassin[player])
  5745. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5746. else
  5747. formatex(menu, charsmax(menu), "\d%s [Assassin]", g_playername[player])
  5748. }
  5749. }
  5750. else
  5751. {
  5752. if (allowed_zombie(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_INFECTION]) : (userflags & g_access_flag[ACCESS_MAKE_ZOMBIE])))
  5753. {
  5754. if (!g_sniper[player])
  5755. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5756. else
  5757. formatex(menu, charsmax(menu), "%s \r[Sniper]", g_playername[player])
  5758. }
  5759. else
  5760. {
  5761. if (!g_sniper[player])
  5762. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5763. else
  5764. formatex(menu, charsmax(menu), "\d%s [Sniper]", g_playername[player])
  5765. }
  5766. }
  5767. }
  5768. case ACTION_MAKE_NEMESIS: // Nemesis command
  5769. {
  5770. // Hattrick
  5771. //
  5772. /*
  5773. if (allowed_nemesis(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_NEMESIS]) : (userflags & g_access_flag[ACCESS_MAKE_NEMESIS])))
  5774. {
  5775. if (g_zombie[player])
  5776. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5777. else
  5778. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5779. }
  5780. else
  5781. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_zombie[player] ? g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE" : g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5782. */
  5783. if (allowed_nemesis(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_NEMESIS]) : (userflags & g_access_flag[ACCESS_MAKE_NEMESIS])))
  5784. {
  5785. if (g_zombie[player])
  5786. {
  5787. if (!g_assassin[player])
  5788. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5789. else
  5790. formatex(menu, charsmax(menu), "%s \r[Assassin]", g_playername[player])
  5791. }
  5792. else
  5793. {
  5794. if (!g_sniper[player])
  5795. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5796. else
  5797. formatex(menu, charsmax(menu), "%s \r[Sniper]", g_playername[player])
  5798. }
  5799. }
  5800. else
  5801. {
  5802. if (g_nemesis[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS");
  5803. else if (g_survivor[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR");
  5804. else if (g_assassin[player]) formatex(menu, charsmax(menu), "\d%s [Assassin]", g_playername[player]);
  5805. else if (g_sniper[player]) formatex(menu, charsmax(menu), "\d%s [Sniper]", g_playername[player]);
  5806. else if (g_zombie[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE");
  5807. else formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN");
  5808. }
  5809. }
  5810. // Hattrick
  5811. //
  5812. case ACTION_MAKE_ASSASSIN: // Nemesis command
  5813. {
  5814. if (allowed_assassin(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_ASSASSIN]) : (userflags & g_access_flag[ACCESS_MAKE_ASSASSIN])))
  5815. {
  5816. if (g_zombie[player])
  5817. {
  5818. if (!g_assassin[player])
  5819. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5820. else
  5821. formatex(menu, charsmax(menu), "%s \r[Assassin]", g_playername[player])
  5822. }
  5823. else
  5824. {
  5825. if (!g_sniper[player])
  5826. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5827. else
  5828. formatex(menu, charsmax(menu), "%s \r[Sniper]", g_playername[player])
  5829. }
  5830. }
  5831. else
  5832. {
  5833. if (g_nemesis[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS");
  5834. else if (g_survivor[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR");
  5835. else if (g_assassin[player]) formatex(menu, charsmax(menu), "\d%s [Assassin]", g_playername[player]);
  5836. else if (g_sniper[player]) formatex(menu, charsmax(menu), "\d%s [Sniper]", g_playername[player]);
  5837. else if (g_zombie[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE");
  5838. else formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN");
  5839. }
  5840. }
  5841. case ACTION_MAKE_SURVIVOR: // Survivor command
  5842. {
  5843. // Hattrick
  5844. //
  5845. /*
  5846. if (allowed_survivor(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SURVIVOR]) : (userflags & g_access_flag[ACCESS_MAKE_SURVIVOR])))
  5847. {
  5848. if (g_zombie[player])
  5849. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5850. else
  5851. formatex(menu, charsmax(menu), "%s \y[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5852. }
  5853. else
  5854. formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_zombie[player] ? g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE" : g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5855. */
  5856. if (allowed_survivor(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SURVIVOR]) : (userflags & g_access_flag[ACCESS_MAKE_SURVIVOR])))
  5857. {
  5858. if (g_zombie[player])
  5859. {
  5860. if (!g_assassin[player])
  5861. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5862. else
  5863. formatex(menu, charsmax(menu), "%s \r[Assassin]", g_playername[player])
  5864. }
  5865. else
  5866. {
  5867. if (!g_sniper[player])
  5868. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5869. else
  5870. formatex(menu, charsmax(menu), "%s \r[Sniper]", g_playername[player])
  5871. }
  5872. }
  5873. else
  5874. {
  5875. if (g_nemesis[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS");
  5876. else if (g_survivor[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR");
  5877. else if (g_assassin[player]) formatex(menu, charsmax(menu), "\d%s [Assassin]", g_playername[player]);
  5878. else if (g_sniper[player]) formatex(menu, charsmax(menu), "\d%s [Sniper]", g_playername[player]);
  5879. else if (g_zombie[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE");
  5880. else formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN");
  5881. }
  5882. }
  5883. // Hattrick
  5884. //
  5885. case ACTION_MAKE_SNIPER: // Survivor command
  5886. {
  5887. if (allowed_sniper(player) && (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SNIPER]) : (userflags & g_access_flag[ACCESS_MAKE_SNIPER])))
  5888. {
  5889. if (g_zombie[player])
  5890. {
  5891. if (!g_assassin[player])
  5892. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE")
  5893. else
  5894. formatex(menu, charsmax(menu), "%s \r[Assassin]", g_playername[player])
  5895. }
  5896. else
  5897. {
  5898. if (!g_sniper[player])
  5899. formatex(menu, charsmax(menu), "%s \r[%L]", g_playername[player], id, g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")
  5900. else
  5901. formatex(menu, charsmax(menu), "%s \r[Sniper]", g_playername[player])
  5902. }
  5903. }
  5904. else
  5905. {
  5906. if (g_nemesis[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_NEMESIS");
  5907. else if (g_survivor[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_SURVIVOR");
  5908. else if (g_assassin[player]) formatex(menu, charsmax(menu), "\d%s [Assassin]", g_playername[player]);
  5909. else if (g_sniper[player]) formatex(menu, charsmax(menu), "\d%s [Sniper]", g_playername[player]);
  5910. else if (g_zombie[player]) formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_ZOMBIE");
  5911. else formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, "CLASS_HUMAN");
  5912. }
  5913. }
  5914. case ACTION_RESPAWN_PLAYER: // Respawn command
  5915. {
  5916. if (allowed_respawn(player) && (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS]))
  5917. formatex(menu, charsmax(menu), "%s", g_playername[player])
  5918. else
  5919. formatex(menu, charsmax(menu), "\d%s", g_playername[player])
  5920. }
  5921. }
  5922.  
  5923. // Add player
  5924. buffer[0] = player
  5925. buffer[1] = 0
  5926. menu_additem(menuid, menu, buffer)
  5927. }
  5928.  
  5929. // Back - Next - Exit
  5930. formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  5931. menu_setprop(menuid, MPROP_BACKNAME, menu)
  5932. formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  5933. menu_setprop(menuid, MPROP_NEXTNAME, menu)
  5934. formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  5935. menu_setprop(menuid, MPROP_EXITNAME, menu)
  5936.  
  5937. // If remembered page is greater than number of pages, clamp down the value
  5938. MENU_PAGE_PLAYERS = min(MENU_PAGE_PLAYERS, menu_pages(menuid)-1)
  5939.  
  5940. // Fix for AMXX custom menus
  5941. if (pev_valid(id) == PDATA_SAFE)
  5942. set_pdata_int(id, OFFSET_CSMENUCODE, 0, OFFSET_LINUX)
  5943.  
  5944. menu_display(id, menuid, MENU_PAGE_PLAYERS)
  5945. }
  5946.  
  5947. /*================================================================================
  5948. [Menu Handlers]
  5949. =================================================================================*/
  5950.  
  5951. // Game Menu
  5952. public menu_game(id, key)
  5953. {
  5954. // Player disconnected?
  5955. if (!g_isconnected[id])
  5956. return PLUGIN_HANDLED;
  5957.  
  5958. switch (key)
  5959. {
  5960. case 0: // Buy Weapons
  5961. {
  5962. // Custom buy menus enabled?
  5963. if (get_pcvar_num(cvar_buycustom))
  5964. {
  5965. // Disable the remember selection setting
  5966. WPN_AUTO_ON = 0
  5967. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "BUY_ENABLED")
  5968.  
  5969. // Show menu if player hasn't yet bought anything
  5970. if (g_canbuy[id]) show_menu_buy1(id)
  5971. }
  5972. else
  5973. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5974. }
  5975. case 1: // Extra Items
  5976. {
  5977. // Extra items enabled?
  5978. if (get_pcvar_num(cvar_extraitems))
  5979. {
  5980. // Check whether the player is able to buy anything
  5981. if (g_isalive[id])
  5982. show_menu_extras(id)
  5983. else
  5984. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5985. }
  5986. else
  5987. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_EXTRAS")
  5988. }
  5989. case 2: // Zombie Classes
  5990. {
  5991. // Zombie classes enabled?
  5992. if (get_pcvar_num(cvar_zclasses))
  5993. show_menu_zclass(id)
  5994. else
  5995. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ZCLASSES")
  5996. }
  5997. case 3: // Unstuck
  5998. {
  5999. // Check if player is stuck
  6000. if (g_isalive[id])
  6001. {
  6002. if (is_player_stuck(id))
  6003. {
  6004. // Move to an initial spawn
  6005. if (get_pcvar_num(cvar_randspawn))
  6006. do_random_spawn(id) // random spawn (including CSDM)
  6007. else
  6008. do_random_spawn(id, 1) // regular spawn
  6009. }
  6010. else
  6011. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_STUCK")
  6012. }
  6013. else
  6014. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6015. }
  6016. //case 4: // Help Menu
  6017. //{
  6018. // show_menu_info(id)
  6019. //}
  6020. case 4: // Join Spectator
  6021. {
  6022. // Player alive?
  6023. if (g_isalive[id])
  6024. {
  6025. // Prevent abuse by non-admins if block suicide setting is enabled
  6026. if (get_pcvar_num(cvar_blocksuicide) && !(get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU]))
  6027. {
  6028. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6029. return PLUGIN_HANDLED;
  6030. }
  6031.  
  6032. // Check that we still have both humans and zombies to keep the round going
  6033. check_round(id)
  6034.  
  6035. // Kill him before he switches team
  6036. dllfunc(DLLFunc_ClientKill, id)
  6037. }
  6038.  
  6039. // Temporarily save player stats?
  6040. if (get_pcvar_num(cvar_statssave)) save_stats(id)
  6041.  
  6042. // Remove previous tasks
  6043. remove_task(id+TASK_TEAM)
  6044. remove_task(id+TASK_MODEL)
  6045. remove_task(id+TASK_FLASH)
  6046. remove_task(id+TASK_CHARGE)
  6047. remove_task(id+TASK_SPAWN)
  6048. remove_task(id+TASK_BLOOD)
  6049. remove_task(id+TASK_AURA)
  6050. remove_task(id+TASK_BURN)
  6051.  
  6052. // Then move him to the spectator team
  6053. fm_cs_set_user_team(id, FM_CS_TEAM_SPECTATOR)
  6054. fm_user_team_update(id)
  6055. }
  6056. // Hattrick
  6057. //
  6058. case 5:
  6059. {
  6060. show_menu_points(id);
  6061. }
  6062. case 6:
  6063. {
  6064. show_motd(id, "addons/Server Info (HELP)/motd.html", "Server Info (HELP)");
  6065. }
  6066. case 7: // Admin Menu
  6067. {
  6068. // Check if player has the required access
  6069. if (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MENU])
  6070. show_menu_admin(id)
  6071. else
  6072. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6073. }
  6074. case 8:
  6075. {
  6076. static szCVarMenuCustom[254];
  6077. get_pcvar_string(cvar_menucustomcommand1, szCVarMenuCustom, charsmax(szCVarMenuCustom))
  6078.  
  6079. if (szCVarMenuCustom[0])
  6080. client_cmd(id, szCVarMenuCustom)
  6081. }
  6082. }
  6083.  
  6084. return PLUGIN_HANDLED;
  6085. }
  6086.  
  6087. // Hattrick
  6088. //
  6089. // Game Menu
  6090. public menu_points(id, key)
  6091. {
  6092. // Player disconnected?
  6093. if (!g_isconnected[id])
  6094. return PLUGIN_HANDLED;
  6095.  
  6096. switch (key)
  6097. {
  6098. case 0: // Buy Weapons
  6099. {
  6100. if (g_points[id] < 150)
  6101. zp_colored_print(id, "^x04[ZP]^x01 You don't have enough points.");
  6102.  
  6103. else if (!g_isalive[id])
  6104. zp_colored_print(id, "^x04[ZP]^x01 You are dead now.");
  6105.  
  6106. else if (g_zombie[id])
  6107. zp_colored_print(id, "^x04[ZP]^x01 You are a zombie now.")
  6108.  
  6109. else
  6110. {
  6111. g_points[id] -= 150;
  6112. savePoints(id);
  6113. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 HAS BOUGHT^x04 DOUBLE DAMAGE^x01.", g_playername[id]);
  6114. g_doubledamage[id] = true
  6115. set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  6116. }
  6117. }
  6118. case 1: // Extra Items
  6119. {
  6120. if (g_points[id] < 400)
  6121. zp_colored_print(id, "^x04[ZP]^x01 You don't have enough points.");
  6122.  
  6123. else if (!g_isalive[id])
  6124. zp_colored_print(id, "^x04[ZP]^x01 You are dead now.");
  6125.  
  6126. else if (g_zombie[id])
  6127. zp_colored_print(id, "^x04[ZP]^x01 You are zombie, this feature is for humans only.")
  6128.  
  6129. else
  6130. {
  6131. g_points[id] -= 400;
  6132. savePoints(id);
  6133. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 HAS BOUGHT^x04 GOD MODE^x01.", g_playername[id]);
  6134. set_user_godmode(id, 1)
  6135. if (!g_zombie[id])
  6136. fm_set_rendering(id, kRenderFxGlowShell, 15, 200, 10, kRenderNormal, 28)
  6137. set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  6138. }
  6139. }
  6140. case 2: // Zombie Classes
  6141. {
  6142. if (g_points[id] < 250)
  6143. zp_colored_print(id, "^x04[ZP]^x01 You don't have enough points.");
  6144.  
  6145. else
  6146. {
  6147. g_points[id] -= 250;
  6148. g_ammopacks[id] += 150;
  6149. savePoints(id);
  6150. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 HAS BOUGHT^x04 150 AMMO PACKS^x01.", g_playername[id]);
  6151. }
  6152. }
  6153. case 3: // Unstuck
  6154. {
  6155. if (g_points[id] < 400)
  6156. zp_colored_print(id, "^x04[ZP]^x01 You don't have enough points.");
  6157.  
  6158. else
  6159. {
  6160. g_points[id] -= 400;
  6161. g_ammopacks[id] += 300;
  6162. savePoints(id);
  6163. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 HAS BOUGHT^x04 300 AMMO PACKS^x01.", g_playername[id]);
  6164. }
  6165. }
  6166. }
  6167.  
  6168. return PLUGIN_HANDLED;
  6169. }
  6170.  
  6171. // Buy Menu 1
  6172. public menu_buy1(id, key)
  6173. {
  6174. // Player dead?
  6175. if (!g_isalive[id])
  6176. return PLUGIN_HANDLED;
  6177.  
  6178. // Hattrick
  6179. //
  6180. // Zombies or survivors get no guns
  6181. //if (g_zombie[id] || g_survivor[id])
  6182. if (g_zombie[id] || g_survivor[id] || g_sniper[id])
  6183. return PLUGIN_HANDLED;
  6184.  
  6185. // Special keys / weapon list exceeded
  6186. if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
  6187. {
  6188. switch (key)
  6189. {
  6190. case MENU_KEY_AUTOSELECT: // toggle auto select
  6191. {
  6192. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  6193. }
  6194. case MENU_KEY_NEXT: // next/back
  6195. {
  6196. if (WPN_STARTID+7 < WPN_MAXIDS)
  6197. WPN_STARTID += 7
  6198. else
  6199. WPN_STARTID = 0
  6200. }
  6201. case MENU_KEY_EXIT: // exit
  6202. {
  6203. return PLUGIN_HANDLED;
  6204. }
  6205. }
  6206.  
  6207. // Show buy menu again
  6208. show_menu_buy1(id)
  6209. return PLUGIN_HANDLED;
  6210. }
  6211.  
  6212. // Store selected weapon id
  6213. WPN_AUTO_PRI = WPN_SELECTION
  6214.  
  6215. // Buy primary weapon
  6216. buy_primary_weapon(id, WPN_AUTO_PRI)
  6217.  
  6218. // Show pistols menu
  6219. show_menu_buy2(id)
  6220.  
  6221. return PLUGIN_HANDLED;
  6222. }
  6223.  
  6224. // Buy Primary Weapon
  6225. buy_primary_weapon(id, selection)
  6226. {
  6227. // Drop previous weapons
  6228. drop_weapons(id, 1)
  6229. drop_weapons(id, 2)
  6230.  
  6231. // Strip off from weapons
  6232. fm_strip_user_weapons(id)
  6233. fm_give_item(id, "weapon_knife")
  6234.  
  6235. // Get weapon's id and name
  6236. static weaponid, wname[32]
  6237. weaponid = ArrayGetCell(g_primary_weaponids, selection)
  6238. ArrayGetString(g_primary_items, selection, wname, charsmax(wname))
  6239.  
  6240. // Give the new weapon and full ammo
  6241. fm_give_item(id, wname)
  6242. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  6243.  
  6244. // Weapons bought
  6245. g_canbuy[id] = false
  6246.  
  6247. // Give additional items
  6248. static i
  6249. for (i = 0; i < ArraySize(g_additional_items); i++)
  6250. {
  6251. ArrayGetString(g_additional_items, i, wname, charsmax(wname))
  6252. fm_give_item(id, wname)
  6253. }
  6254. }
  6255.  
  6256. // Buy Menu 2
  6257. public menu_buy2(id, key)
  6258. {
  6259. // Player dead?
  6260. if (!g_isalive[id])
  6261. return PLUGIN_HANDLED;
  6262.  
  6263. // Hattrick
  6264. //
  6265. // Zombies or survivors get no guns
  6266. //if (g_zombie[id] || g_survivor[id])
  6267. if (g_zombie[id] || g_survivor[id] || g_sniper[id])
  6268. return PLUGIN_HANDLED;
  6269.  
  6270. // Special keys / weapon list exceeded
  6271. if (key >= ArraySize(g_secondary_items))
  6272. {
  6273. // Toggle autoselect
  6274. if (key == MENU_KEY_AUTOSELECT)
  6275. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  6276.  
  6277. // Reshow menu unless user exited
  6278. if (key != MENU_KEY_EXIT)
  6279. show_menu_buy2(id)
  6280.  
  6281. return PLUGIN_HANDLED;
  6282. }
  6283.  
  6284. // Store selected weapon
  6285. WPN_AUTO_SEC = key
  6286.  
  6287. // Drop secondary gun again, in case we picked another (bugfix)
  6288. drop_weapons(id, 2)
  6289.  
  6290. // Get weapon's id
  6291. static weaponid, wname[32]
  6292. weaponid = ArrayGetCell(g_secondary_weaponids, key)
  6293. ArrayGetString(g_secondary_items, key, wname, charsmax(wname))
  6294.  
  6295. // Give the new weapon and full ammo
  6296. fm_give_item(id, wname)
  6297. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  6298.  
  6299. return PLUGIN_HANDLED;
  6300. }
  6301.  
  6302. // Extra Items Menu
  6303. public menu_extras(id, menuid, item)
  6304. {
  6305. // Player disconnected?
  6306. if (!is_user_connected(id))
  6307. {
  6308. menu_destroy(menuid)
  6309. return PLUGIN_HANDLED;
  6310. }
  6311.  
  6312. // Remember player's menu page
  6313. static menudummy
  6314. player_menu_info(id, menudummy, menudummy, MENU_PAGE_EXTRAS)
  6315.  
  6316. // Menu was closed
  6317. if (item == MENU_EXIT)
  6318. {
  6319. menu_destroy(menuid)
  6320. return PLUGIN_HANDLED;
  6321. }
  6322.  
  6323. // Dead players are not allowed to buy items
  6324. if (!g_isalive[id])
  6325. {
  6326. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6327. menu_destroy(menuid)
  6328. return PLUGIN_HANDLED;
  6329. }
  6330.  
  6331. // Retrieve extra item id
  6332. static buffer[2], dummy, itemid
  6333. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  6334. itemid = buffer[0]
  6335.  
  6336. // Attempt to buy the item
  6337. buy_extra_item(id, itemid)
  6338. menu_destroy(menuid)
  6339. return PLUGIN_HANDLED;
  6340. }
  6341.  
  6342. // Buy Extra Item
  6343. buy_extra_item(id, itemid, ignorecost = 0)
  6344. {
  6345. // Retrieve item's team
  6346. static team
  6347. team = ArrayGetCell(g_extraitem_team, itemid)
  6348.  
  6349. // Hattrick
  6350. //
  6351. // Check for team/class specific items
  6352. //if ((g_zombie[id] && !g_nemesis[id] && !(team & ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team & ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)))
  6353. if ((g_zombie[id] && !g_nemesis[id] && !g_assassin[id] && !(team & ZP_TEAM_ZOMBIE)) || \
  6354. (!g_zombie[id] && !g_survivor[id] && !g_sniper[id] && !(team & ZP_TEAM_HUMAN)) || \
  6355. (g_nemesis[id] && !(team & ZP_TEAM_NEMESIS)) || \
  6356. (g_survivor[id] && !(team & ZP_TEAM_SURVIVOR)) || \
  6357. (g_sniper[id] && !(team & ZP_TEAM_SNIPER)) || \
  6358. (g_assassin[id] && !(team & ZP_TEAM_ASSASSIN)))
  6359. {
  6360. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6361. return;
  6362. }
  6363.  
  6364. // Check for unavailable items
  6365. if ((itemid == EXTRA_NVISION && !get_pcvar_num(cvar_extranvision))
  6366. || (itemid == EXTRA_ANTIDOTE && (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)))
  6367. || (itemid == EXTRA_MADNESS && (!get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)))
  6368. || (itemid == EXTRA_INFBOMB && (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)))
  6369. || (itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)))
  6370. {
  6371. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6372. return;
  6373. }
  6374.  
  6375. // Hattrick
  6376. //
  6377. // Check for hard coded items with special conditions
  6378. //if ((itemid == EXTRA_ANTIDOTE && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround || fnGetZombies() <= 1 || (get_pcvar_num(cvar_deathmatch) && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() == 1)))
  6379. //|| (itemid == EXTRA_MADNESS && g_nodamage[id]) || (itemid == EXTRA_INFBOMB && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround)))
  6380. if ((itemid == EXTRA_ANTIDOTE && (g_endround || g_avsround || g_armageddonround || g_swarmround || g_nemround || g_assassinround || g_sniperround || g_survround || g_plagueround || fnGetZombies() <= 1 || (get_pcvar_num(cvar_deathmatch) && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() == 1)))
  6381. || (itemid == EXTRA_MADNESS && g_nodamage[id]) || (itemid == EXTRA_INFBOMB && (g_endround || g_swarmround ||g_armageddonround||g_avsround|| g_nemround || g_assassinround || g_sniperround || g_survround || g_plagueround)))
  6382. {
  6383. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_CANTUSE")
  6384. return;
  6385. }
  6386.  
  6387. // Ignore item's cost?
  6388. if (!ignorecost)
  6389. {
  6390. // Check that we have enough ammo packs
  6391. if (g_ammopacks[id] < ArrayGetCell(g_extraitem_cost, itemid))
  6392. {
  6393. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  6394. return;
  6395. }
  6396.  
  6397. // Deduce item cost
  6398. g_ammopacks[id] -= ArrayGetCell(g_extraitem_cost, itemid)
  6399. }
  6400.  
  6401. // Check which kind of item we're buying
  6402. switch (itemid)
  6403. {
  6404. case EXTRA_NVISION: // Night Vision
  6405. {
  6406. g_nvision[id] = true
  6407.  
  6408. if (!g_isbot[id])
  6409. {
  6410. g_nvisionenabled[id] = true
  6411.  
  6412. // Custom nvg?
  6413. if (get_pcvar_num(cvar_customnvg))
  6414. {
  6415. remove_task(id+TASK_NVISION)
  6416. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  6417. }
  6418. else
  6419. set_user_gnvision(id, 1)
  6420. }
  6421. else
  6422. cs_set_user_nvg(id, 1)
  6423. }
  6424. case EXTRA_ANTIDOTE: // Antidote
  6425. {
  6426. // Increase antidote purchase count for this round
  6427. g_antidotecounter++
  6428.  
  6429. humanme(id, 0, 0)
  6430. }
  6431. case EXTRA_MADNESS: // Zombie Madness
  6432. {
  6433. // Increase madness purchase count for this round
  6434. g_madnesscounter++
  6435.  
  6436. g_nodamage[id] = true
  6437. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  6438. set_task(get_pcvar_float(cvar_madnessduration), "madness_over", id+TASK_BLOOD)
  6439.  
  6440. static sound[64]
  6441. ArrayGetString(zombie_madness, random_num(0, ArraySize(zombie_madness) - 1), sound, charsmax(sound))
  6442. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  6443. }
  6444. case EXTRA_INFBOMB: // Infection Bomb
  6445. {
  6446. // Increase infection bomb purchase count for this round
  6447. g_infbombcounter++
  6448.  
  6449. g_infector[id] = true
  6450.  
  6451. // Already own one
  6452. if (user_has_weapon(id, CSW_HEGRENADE))
  6453. {
  6454. // Increase BP ammo on it instead
  6455. cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1)
  6456.  
  6457. // Flash ammo in hud
  6458. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  6459. write_byte(AMMOID[CSW_HEGRENADE]) // ammo id
  6460. write_byte(1) // ammo amount
  6461. message_end()
  6462.  
  6463. // Play clip purchase sound
  6464. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  6465.  
  6466. return; // stop here
  6467. }
  6468.  
  6469. // Give weapon to the player
  6470. fm_give_item(id, "weapon_hegrenade")
  6471. }
  6472. default:
  6473. {
  6474. if (itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1) // Weapons
  6475. {
  6476. // Get weapon's id and name
  6477. static weaponid, wname[32]
  6478. ArrayGetString(g_extraweapon_items, itemid - EXTRA_WEAPONS_STARTID, wname, charsmax(wname))
  6479. weaponid = cs_weapon_name_to_id(wname)
  6480.  
  6481. // If we are giving a primary/secondary weapon
  6482. if (MAXBPAMMO[weaponid] > 2)
  6483. {
  6484. // Make user drop the previous one
  6485. if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
  6486. drop_weapons(id, 1)
  6487. else
  6488. drop_weapons(id, 2)
  6489.  
  6490. // Give full BP ammo for the new one
  6491. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  6492. }
  6493. // If we are giving a grenade which the user already owns
  6494. else if (user_has_weapon(id, weaponid))
  6495. {
  6496. // Increase BP ammo on it instead
  6497. cs_set_user_bpammo(id, weaponid, cs_get_user_bpammo(id, weaponid) + 1)
  6498.  
  6499. // Flash ammo in hud
  6500. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  6501. write_byte(AMMOID[weaponid]) // ammo id
  6502. write_byte(1) // ammo amount
  6503. message_end()
  6504.  
  6505. // Play clip purchase sound
  6506. emit_sound(id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  6507.  
  6508. return; // stop here
  6509. }
  6510.  
  6511. // Give weapon to the player
  6512. fm_give_item(id, wname)
  6513. }
  6514. else // Custom additions
  6515. {
  6516. // Item selected forward
  6517. ExecuteForward(g_fwExtraItemSelected, g_fwDummyResult, id, itemid);
  6518.  
  6519. // Item purchase blocked, restore buyer's ammo packs
  6520. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && !ignorecost)
  6521. g_ammopacks[id] += ArrayGetCell(g_extraitem_cost, itemid)
  6522. }
  6523. }
  6524. }
  6525. }
  6526.  
  6527. // Zombie Class Menu
  6528. public menu_zclass(id, menuid, item)
  6529. {
  6530. // Player disconnected?
  6531. if (!is_user_connected(id))
  6532. {
  6533. menu_destroy(menuid)
  6534. return PLUGIN_HANDLED;
  6535. }
  6536.  
  6537. // Remember player's menu page
  6538. static menudummy
  6539. player_menu_info(id, menudummy, menudummy, MENU_PAGE_ZCLASS)
  6540.  
  6541. // Menu was closed
  6542. if (item == MENU_EXIT)
  6543. {
  6544. menu_destroy(menuid)
  6545. return PLUGIN_HANDLED;
  6546. }
  6547.  
  6548. // Retrieve zombie class id
  6549. static buffer[2], dummy, classid
  6550. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  6551. classid = buffer[0]
  6552.  
  6553. // Store selection for the next infection
  6554. g_zombieclassnext[id] = classid
  6555.  
  6556. static name[32]
  6557. ArrayGetString(g_zclass_name, g_zombieclassnext[id], name, charsmax(name))
  6558.  
  6559. // Hattrick
  6560. //
  6561. // Show selected zombie class info and stats
  6562. //zp_colored_print(id, "^x04[ZP]^x01 %L: %s", id, "ZOMBIE_SELECT", name)
  6563. //zp_colored_print(id, "^x04[ZP]^x01 %L: %d %L: %d %L: %d %L: %d%%", id, "ZOMBIE_ATTRIB1", ArrayGetCell(g_zclass_hp, g_zombieclassnext[id]), id, "ZOMBIE_ATTRIB2", ArrayGetCell(g_zclass_spd, g_zombieclassnext[id]),
  6564. //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))
  6565.  
  6566. static hp[32];
  6567. AddCommas(ArrayGetCell(g_zclass_hp, g_zombieclassnext[id]), hp, 31);
  6568. zp_colored_print(id, "^x04[ZP]^x01 %L:^x04 %s", id, "ZOMBIE_SELECT", name)
  6569. zp_colored_print(id, "^x04[ZP]^x01 %L:^x04 %s^x01 %L:^x04 %d^x01 %L:^x04 %d^x01 %L:^x04 %d%%", id, "ZOMBIE_ATTRIB1", \
  6570. hp, \
  6571. id, "ZOMBIE_ATTRIB2", ArrayGetCell(g_zclass_spd, g_zombieclassnext[id]),
  6572. id, "ZOMBIE_ATTRIB3", floatround(Float:ArrayGetCell(g_zclass_grav, g_zombieclassnext[id]) * 800.0), \
  6573. id, "ZOMBIE_ATTRIB4", floatround(Float:ArrayGetCell(g_zclass_kb, g_zombieclassnext[id]) * 100.0))
  6574.  
  6575. menu_destroy(menuid)
  6576. return PLUGIN_HANDLED;
  6577. }
  6578. /*
  6579. // Info Menu
  6580. public menu_info(id, key)
  6581. {
  6582. // Player disconnected?
  6583. if (!g_isconnected[id])
  6584. return PLUGIN_HANDLED;
  6585.  
  6586. static motd[1500], len
  6587. len = 0
  6588.  
  6589. switch (key)
  6590. {
  6591. case 0: // General
  6592. {
  6593. static weather, lighting[2]
  6594. weather = 0
  6595. get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
  6596. strtolower(lighting)
  6597.  
  6598. // Hattrick
  6599. //
  6600. //len += formatex(motd[len], charsmax(motd) - len, "%L ", id, "MOTD_INFO11", "Zombie Plague", PLUGIN_VERSION, "MeRcyLeZZ")
  6601. len += formatex(motd[len], charsmax(motd) - len, "%L ", id, "MOTD_INFO11", "Zombie Plague", PLUGIN_VERSION, "Hattrick")
  6602. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO12")
  6603. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_A")
  6604.  
  6605. if (g_ambience_fog)
  6606. {
  6607. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_FOG")
  6608. weather++
  6609. }
  6610. if (g_ambience_rain)
  6611. {
  6612. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_RAIN")
  6613. weather++
  6614. }
  6615. if (g_ambience_snow)
  6616. {
  6617. len += formatex(motd[len], charsmax(motd) - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_SNOW")
  6618. weather++
  6619. }
  6620. if (weather < 1) len += formatex(motd[len], charsmax(motd) - len, " %L", id, "MOTD_DISABLED")
  6621.  
  6622. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_B", lighting)
  6623. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_C", id, get_pcvar_num(cvar_triggered) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6624. 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)))
  6625. 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")
  6626. 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")
  6627. if (get_pcvar_num(cvar_deathmatch)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_G", floatround(get_pcvar_float(cvar_spawnprotection)))
  6628. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_H", id, get_pcvar_num(cvar_randspawn) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6629. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_I", id, get_pcvar_num(cvar_extraitems) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6630. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_J", id, get_pcvar_num(cvar_zclasses) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6631. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_K", id, get_pcvar_num(cvar_customnvg) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6632. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO1_L", id, g_cached_customflash ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6633.  
  6634. show_motd(id, motd)
  6635. }
  6636. case 1: // Humans
  6637. {
  6638. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2")
  6639. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_A", get_pcvar_num(cvar_humanhp))
  6640. if (get_pcvar_num(cvar_humanlasthp) > 0) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_B", get_pcvar_num(cvar_humanlasthp))
  6641. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_C", get_pcvar_num(cvar_humanspd))
  6642. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_D", floatround(get_pcvar_float(cvar_humangravity) * 800.0))
  6643. 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")
  6644. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_F", get_pcvar_num(cvar_ammodamage_human))
  6645. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_G", id, get_pcvar_num(cvar_firegrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6646. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_H", id, get_pcvar_num(cvar_frostgrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6647. // Hattrick
  6648. //
  6649. //len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_I", id, get_pcvar_num(cvar_flaregrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6650. len += formatex(motd[len], charsmax(motd) - len, "<br>Explosive Grenades: %s", get_pcvar_num(cvar_flaregrenades) ? "Enabled" : "Disabled")
  6651. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO2_J", id, get_pcvar_num(cvar_knockback) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6652.  
  6653. show_motd(id, motd)
  6654. }
  6655. case 2: // Zombies
  6656. {
  6657. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3")
  6658. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_A", ArrayGetCell(g_zclass_hp, 0))
  6659. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_B", floatround(float(ArrayGetCell(g_zclass_hp, 0)) * get_pcvar_float(cvar_zombiefirsthp)))
  6660. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_C", floatround(get_pcvar_float(cvar_zombiearmor) * 100.0))
  6661. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_D", ArrayGetCell(g_zclass_spd, 0))
  6662. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_E", floatround(Float:ArrayGetCell(g_zclass_grav, 0) * 800.0))
  6663. if (get_pcvar_num(cvar_zombiebonushp)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_F", get_pcvar_num(cvar_zombiebonushp))
  6664. 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")
  6665. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_H", id, get_pcvar_num(cvar_zombiebleeding) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6666. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO3_I", get_pcvar_num(cvar_ammoinfect))
  6667.  
  6668. show_motd(id, motd)
  6669. }
  6670. case 3: // Gameplay Modes
  6671. {
  6672. static nemhp[8], survhp[8], assassinhp[8], sniperhp[8];
  6673.  
  6674. // Get nemesis and survivor health
  6675. num_to_str(get_pcvar_num(cvar_nemhp), nemhp, charsmax(nemhp))
  6676. num_to_str(get_pcvar_num(cvar_survhp), survhp, charsmax(survhp))
  6677. num_to_str(get_pcvar_num(cvar_assassinhp), assassinhp, charsmax(assassinhp))
  6678. num_to_str(get_pcvar_num(cvar_sniperhp), sniperhp, charsmax(sniperhp))
  6679.  
  6680. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4")
  6681. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_A", id, get_pcvar_num(cvar_nem) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6682. if (get_pcvar_num(cvar_nem))
  6683. {
  6684. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_B", get_pcvar_num(cvar_nemchance))
  6685. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_C", get_pcvar_num(cvar_nemhp) > 0 ? nemhp : "[Auto]")
  6686. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_D", get_pcvar_num(cvar_nemspd))
  6687. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_E", floatround(get_pcvar_float(cvar_nemgravity) * 800.0))
  6688. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_F", id, g_cached_leapnemesis ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6689. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_G", id, get_pcvar_num(cvar_nempainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6690. }
  6691. // Hattrick
  6692. //
  6693.  
  6694. len += formatex(motd[len], charsmax(motd) - len, "<br><br>Assassin: %s", get_pcvar_num(cvar_assassin) ? "Enabled" : "Disabled")
  6695. if (get_pcvar_num(cvar_assassin))
  6696. {
  6697. len += formatex(motd[len], charsmax(motd) - len, "<br>Assassin Chance: 1 in %d", get_pcvar_num(cvar_assassinchance))
  6698. len += formatex(motd[len], charsmax(motd) - len, "<br>Assassin Health: %s", get_pcvar_num(cvar_assassinhp) > 0 ? assassinhp : "[Auto]")
  6699. len += formatex(motd[len], charsmax(motd) - len, "<br>Assassin Damage: %d", get_pcvar_num(cvar_assassindamage))
  6700. }
  6701.  
  6702. // Hattrick
  6703. //
  6704. len += formatex(motd[len], charsmax(motd) - len, "<br><br>Sniper: %s", get_pcvar_num(cvar_sniper) ? "Enabled" : "Disabled")
  6705. if (get_pcvar_num(cvar_sniper))
  6706. {
  6707. len += formatex(motd[len], charsmax(motd) - len, "<br>Sniper Chance: 1 in %d", get_pcvar_num(cvar_sniperchance))
  6708. len += formatex(motd[len], charsmax(motd) - len, "<br>Sniper Health: %s", get_pcvar_num(cvar_sniperhp) > 0 ? sniperhp : "[Auto]")
  6709. len += formatex(motd[len], charsmax(motd) - len, "<br>Sniper Damage: %d", get_pcvar_num(cvar_sniperdamage))
  6710. }
  6711.  
  6712. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_H", id, get_pcvar_num(cvar_surv) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6713. if (get_pcvar_num(cvar_surv))
  6714. {
  6715. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_I", get_pcvar_num(cvar_survchance))
  6716. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_J", get_pcvar_num(cvar_survhp) > 0 ? survhp : "[Auto]")
  6717. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_K", get_pcvar_num(cvar_survspd))
  6718. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_L", floatround(get_pcvar_float(cvar_survgravity) * 800.0))
  6719. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_M", id, g_cached_leapsurvivor ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6720. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_N", id, get_pcvar_num(cvar_survpainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6721. }
  6722. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_O", id, get_pcvar_num(cvar_swarm) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6723. if (get_pcvar_num(cvar_swarm)) len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_P", get_pcvar_num(cvar_swarmchance))
  6724. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_Q", id, get_pcvar_num(cvar_multi) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6725. if (get_pcvar_num(cvar_multi))
  6726. {
  6727. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_R", get_pcvar_num(cvar_multichance))
  6728. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_S", floatround(get_pcvar_float(cvar_multiratio) * 100.0))
  6729. }
  6730. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_T", id, get_pcvar_num(cvar_plague) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  6731. if (get_pcvar_num(cvar_plague))
  6732. {
  6733. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_U", get_pcvar_num(cvar_plaguechance))
  6734. len += formatex(motd[len], charsmax(motd) - len, "%L", id, "MOTD_INFO4_V", floatround(get_pcvar_float(cvar_plagueratio) * 100.0))
  6735. }
  6736.  
  6737. show_motd(id, motd)
  6738. }
  6739. default: return PLUGIN_HANDLED;
  6740. }
  6741.  
  6742. // Show help menu again if user wishes to read another topic
  6743. show_menu_info(id)
  6744.  
  6745. return PLUGIN_HANDLED;
  6746. }
  6747. */
  6748. // Admin Menu
  6749. public menu_admin(id, key)
  6750. {
  6751. // Player disconnected?
  6752. if (!g_isconnected[id])
  6753. return PLUGIN_HANDLED;
  6754.  
  6755. static userflags
  6756. userflags = get_user_flags(id)
  6757.  
  6758. switch (key)
  6759. {
  6760. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  6761. {
  6762. if (userflags & (g_access_flag[ACCESS_MODE_INFECTION] | g_access_flag[ACCESS_MAKE_ZOMBIE] | g_access_flag[ACCESS_MAKE_HUMAN]))
  6763. {
  6764. // Show player list for admin to pick a target
  6765. PL_ACTION = ACTION_ZOMBIEFY_HUMANIZE
  6766. show_menu_player_list(id)
  6767. }
  6768. else
  6769. {
  6770. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6771. show_menu_admin(id)
  6772. }
  6773. }
  6774. case ACTION_MAKE_NEMESIS: // Nemesis command
  6775. {
  6776. if (userflags & (g_access_flag[ACCESS_MODE_NEMESIS] | g_access_flag[ACCESS_MAKE_NEMESIS]))
  6777. {
  6778. // Show player list for admin to pick a target
  6779. PL_ACTION = ACTION_MAKE_NEMESIS
  6780. show_menu_player_list(id)
  6781. }
  6782. else
  6783. {
  6784. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6785. show_menu_admin(id)
  6786. }
  6787. }
  6788. // Hattrick
  6789. //
  6790. case ACTION_MAKE_ASSASSIN: // Nemesis command
  6791. {
  6792. if (userflags & (g_access_flag[ACCESS_MODE_ASSASSIN] | g_access_flag[ACCESS_MAKE_ASSASSIN]))
  6793. {
  6794. // Show player list for admin to pick a target
  6795. PL_ACTION = ACTION_MAKE_ASSASSIN
  6796. show_menu_player_list(id)
  6797. }
  6798. else
  6799. {
  6800. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6801. show_menu_admin(id)
  6802. }
  6803. }
  6804. case ACTION_MAKE_SURVIVOR: // Survivor command
  6805. {
  6806. if (userflags & (g_access_flag[ACCESS_MODE_SURVIVOR] | g_access_flag[ACCESS_MAKE_SURVIVOR]))
  6807. {
  6808. // Show player list for admin to pick a target
  6809. PL_ACTION = ACTION_MAKE_SURVIVOR
  6810. show_menu_player_list(id)
  6811. }
  6812. else
  6813. {
  6814. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6815. show_menu_admin(id)
  6816. }
  6817. }
  6818. // Hattrick
  6819. //
  6820. case ACTION_MAKE_SNIPER: // Survivor command
  6821. {
  6822. if (userflags & (g_access_flag[ACCESS_MODE_SNIPER] | g_access_flag[ACCESS_MAKE_SNIPER]))
  6823. {
  6824. // Show player list for admin to pick a target
  6825. PL_ACTION = ACTION_MAKE_SNIPER
  6826. show_menu_player_list(id)
  6827. }
  6828. else
  6829. {
  6830. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6831. show_menu_admin(id)
  6832. }
  6833. }
  6834. case ACTION_RESPAWN_PLAYER: // Respawn command
  6835. {
  6836. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  6837. {
  6838. // Show player list for admin to pick a target
  6839. PL_ACTION = ACTION_RESPAWN_PLAYER
  6840. show_menu_player_list(id)
  6841. }
  6842. else
  6843. {
  6844. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6845. show_menu_admin(id)
  6846. }
  6847. }
  6848. case ACTION_MODE_SWARM: // Swarm Mode command
  6849. {
  6850. if (userflags & g_access_flag[ACCESS_MODE_SWARM])
  6851. {
  6852. if (allowed_swarm())
  6853. command_swarm(id)
  6854. else
  6855. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6856. }
  6857. else
  6858. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6859.  
  6860. show_menu_admin(id)
  6861. }
  6862. case ACTION_MODE_MULTI: // Multiple Infection command
  6863. {
  6864. if (userflags & g_access_flag[ACCESS_MODE_MULTI])
  6865. {
  6866. if (allowed_multi())
  6867. command_multi(id)
  6868. else
  6869. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6870. }
  6871. else
  6872. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6873.  
  6874. show_menu_admin(id)
  6875. }
  6876. case ACTION_MODE_PLAGUE: // Plague Mode command
  6877. {
  6878. if (userflags & g_access_flag[ACCESS_MODE_PLAGUE])
  6879. {
  6880. if (allowed_plague())
  6881. command_plague(id)
  6882. else
  6883. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6884. }
  6885. else
  6886. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6887.  
  6888. show_menu_admin(id)
  6889. }
  6890. }
  6891.  
  6892. return PLUGIN_HANDLED;
  6893. }
  6894.  
  6895. // Player List Menu
  6896. public menu_player_list(id, menuid, item)
  6897. {
  6898. // Player disconnected?
  6899. if (!is_user_connected(id))
  6900. {
  6901. menu_destroy(menuid)
  6902. return PLUGIN_HANDLED;
  6903. }
  6904.  
  6905. // Remember player's menu page
  6906. static menudummy
  6907. player_menu_info(id, menudummy, menudummy, MENU_PAGE_PLAYERS)
  6908.  
  6909. // Menu was closed
  6910. if (item == MENU_EXIT)
  6911. {
  6912. menu_destroy(menuid)
  6913. show_menu_admin(id)
  6914. return PLUGIN_HANDLED;
  6915. }
  6916.  
  6917. // Retrieve player id
  6918. static buffer[2], dummy, playerid
  6919. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy)
  6920. playerid = buffer[0]
  6921.  
  6922. // Perform action on player
  6923.  
  6924. // Get admin flags
  6925. static userflags
  6926. userflags = get_user_flags(id)
  6927.  
  6928. // Make sure it's still connected
  6929. if (g_isconnected[playerid])
  6930. {
  6931. // Perform the right action if allowed
  6932. switch (PL_ACTION)
  6933. {
  6934. case ACTION_ZOMBIEFY_HUMANIZE: // Zombiefy/Humanize command
  6935. {
  6936. if (g_zombie[playerid])
  6937. {
  6938. if (userflags & g_access_flag[ACCESS_MAKE_HUMAN])
  6939. {
  6940. if (allowed_human(playerid))
  6941. command_human(id, playerid)
  6942. else
  6943. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6944. }
  6945. else
  6946. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6947. }
  6948. else
  6949. {
  6950. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_INFECTION]) : (userflags & g_access_flag[ACCESS_MAKE_ZOMBIE]))
  6951. {
  6952. if (allowed_zombie(playerid))
  6953. command_zombie(id, playerid)
  6954. else
  6955. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6956. }
  6957. else
  6958. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6959. }
  6960. }
  6961. case ACTION_MAKE_NEMESIS: // Nemesis command
  6962. {
  6963. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_NEMESIS]) : (userflags & g_access_flag[ACCESS_MAKE_NEMESIS]))
  6964. {
  6965. if (allowed_nemesis(playerid))
  6966. command_nemesis(id, playerid)
  6967. else
  6968. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6969. }
  6970. else
  6971. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6972. }
  6973. // Hattrick
  6974. //
  6975. case ACTION_MAKE_ASSASSIN: // Nemesis command
  6976. {
  6977. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_ASSASSIN]) : (userflags & g_access_flag[ACCESS_MAKE_ASSASSIN]))
  6978. {
  6979. if (allowed_assassin(playerid))
  6980. command_assassin(id, playerid)
  6981. else
  6982. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6983. }
  6984. else
  6985. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6986. }
  6987. case ACTION_MAKE_SURVIVOR: // Survivor command
  6988. {
  6989. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SURVIVOR]) : (userflags & g_access_flag[ACCESS_MAKE_SURVIVOR]))
  6990. {
  6991. if (allowed_survivor(playerid))
  6992. command_survivor(id, playerid)
  6993. else
  6994. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  6995. }
  6996. else
  6997. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  6998. }
  6999. // Hattrick
  7000. //
  7001. case ACTION_MAKE_SNIPER: // Survivor command
  7002. {
  7003. if (g_newround ? (userflags & g_access_flag[ACCESS_MODE_SNIPER]) : (userflags & g_access_flag[ACCESS_MAKE_SNIPER]))
  7004. {
  7005. if (allowed_sniper(playerid))
  7006. command_sniper(id, playerid)
  7007. else
  7008. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  7009. }
  7010. else
  7011. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  7012. }
  7013. case ACTION_RESPAWN_PLAYER: // Respawn command
  7014. {
  7015. if (userflags & g_access_flag[ACCESS_RESPAWN_PLAYERS])
  7016. {
  7017. if (allowed_respawn(playerid))
  7018. command_respawn(id, playerid)
  7019. else
  7020. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  7021. }
  7022. else
  7023. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  7024. }
  7025. }
  7026. }
  7027. else
  7028. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  7029.  
  7030. menu_destroy(menuid)
  7031. show_menu_player_list(id)
  7032. return PLUGIN_HANDLED;
  7033. }
  7034.  
  7035. // CS Buy Menus
  7036. public menu_cs_buy(id, key)
  7037. {
  7038. // Hattrick
  7039. //
  7040. // Prevent buying if zombie/survivor (bugfix)
  7041. //if (g_zombie[id] || g_survivor[id])
  7042. if (g_zombie[id] || g_survivor[id] || g_sniper[id])
  7043. return PLUGIN_HANDLED;
  7044.  
  7045. return PLUGIN_CONTINUE;
  7046. }
  7047.  
  7048. /*================================================================================
  7049. [Admin Commands]
  7050. =================================================================================*/
  7051.  
  7052. // zp_toggle [1/0]
  7053. public cmd_toggle(id, level, cid)
  7054. {
  7055. // Check for access flag - Enable/Disable Mod
  7056. if (!cmd_access(id, g_access_flag[ACCESS_ENABLE_MOD], cid, 2))
  7057. return PLUGIN_HANDLED;
  7058.  
  7059. // Retrieve arguments
  7060. new arg[2]
  7061. read_argv(1, arg, charsmax(arg))
  7062.  
  7063. // Mod already enabled/disabled
  7064. if (str_to_num(arg) == g_pluginenabled)
  7065. return PLUGIN_HANDLED;
  7066.  
  7067. // Set toggle cvar
  7068. set_pcvar_num(cvar_toggle, str_to_num(arg))
  7069. client_print(id, print_console, "Zombie Plague %L.", id, str_to_num(arg) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  7070.  
  7071. // Retrieve map name
  7072. new mapname[32]
  7073. get_mapname(mapname, charsmax(mapname))
  7074.  
  7075. // Restart current map
  7076. server_cmd("changelevel %s", mapname)
  7077.  
  7078. return PLUGIN_HANDLED;
  7079. }
  7080.  
  7081. // zp_zombie [target]
  7082. public cmd_zombie(id, level, cid)
  7083. {
  7084. // Check for access flag depending on the resulting action
  7085. if (g_newround)
  7086. {
  7087. // Start Mode Infection
  7088. if (!cmd_access(id, g_access_flag[ACCESS_MODE_INFECTION], cid, 2))
  7089. return PLUGIN_HANDLED;
  7090. }
  7091. else
  7092. {
  7093. // Make Zombie
  7094. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_ZOMBIE], cid, 2))
  7095. return PLUGIN_HANDLED;
  7096. }
  7097.  
  7098. // Retrieve arguments
  7099. static arg[32], player
  7100. read_argv(1, arg, charsmax(arg))
  7101. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7102.  
  7103. // Invalid target
  7104. if (!player) return PLUGIN_HANDLED;
  7105.  
  7106. // Target not allowed to be zombie
  7107. if (!allowed_zombie(player))
  7108. {
  7109. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7110. return PLUGIN_HANDLED
  7111. }
  7112.  
  7113. command_zombie(id, player)
  7114.  
  7115. return PLUGIN_HANDLED;
  7116. }
  7117.  
  7118. // zp_human [target]
  7119. public cmd_human(id, level, cid)
  7120. {
  7121. // Check for access flag - Make Human
  7122. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_HUMAN], cid, 2))
  7123. return PLUGIN_HANDLED;
  7124.  
  7125. // Retrieve arguments
  7126. static arg[32], player
  7127. read_argv(1, arg, charsmax(arg))
  7128. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7129.  
  7130. // Invalid target
  7131. if (!player) return PLUGIN_HANDLED;
  7132.  
  7133. // Target not allowed to be human
  7134. if (!allowed_human(player))
  7135. {
  7136. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7137. return PLUGIN_HANDLED;
  7138. }
  7139.  
  7140. command_human(id, player)
  7141.  
  7142. return PLUGIN_HANDLED;
  7143. }
  7144.  
  7145. // zp_survivor [target]
  7146. public cmd_survivor(id, level, cid)
  7147. {
  7148. // Check for access flag depending on the resulting action
  7149. if (g_newround)
  7150. {
  7151. // Start Mode Survivor
  7152. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SURVIVOR], cid, 2))
  7153. return PLUGIN_HANDLED;
  7154. }
  7155. else
  7156. {
  7157. // Make Survivor
  7158. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_SURVIVOR], cid, 2))
  7159. return PLUGIN_HANDLED;
  7160. }
  7161.  
  7162. // Retrieve arguments
  7163. static arg[32], player
  7164. read_argv(1, arg, charsmax(arg))
  7165. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7166.  
  7167. // Invalid target
  7168. if (!player) return PLUGIN_HANDLED;
  7169.  
  7170. // Target not allowed to be survivor
  7171. if (!allowed_survivor(player))
  7172. {
  7173. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7174. return PLUGIN_HANDLED;
  7175. }
  7176.  
  7177. command_survivor(id, player)
  7178.  
  7179. return PLUGIN_HANDLED;
  7180. }
  7181.  
  7182. // Hattrick
  7183. //
  7184. // zp_survivor [target]
  7185. public cmd_sniper(id, level, cid)
  7186. {
  7187. // Check for access flag depending on the resulting action
  7188. if (g_newround)
  7189. {
  7190. // Start Mode Survivor
  7191. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SNIPER], cid, 2))
  7192. return PLUGIN_HANDLED;
  7193. }
  7194. else
  7195. {
  7196. // Make Survivor
  7197. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_SNIPER], cid, 2))
  7198. return PLUGIN_HANDLED;
  7199. }
  7200.  
  7201. // Retrieve arguments
  7202. static arg[32], player
  7203. read_argv(1, arg, charsmax(arg))
  7204. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7205.  
  7206. // Invalid target
  7207. if (!player) return PLUGIN_HANDLED;
  7208.  
  7209. // Target not allowed to be survivor
  7210. if (!allowed_sniper(player))
  7211. {
  7212. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7213. return PLUGIN_HANDLED;
  7214. }
  7215.  
  7216. command_sniper(id, player)
  7217.  
  7218. return PLUGIN_HANDLED;
  7219. }
  7220.  
  7221. // zp_nemesis [target]
  7222. public cmd_nemesis(id, level, cid)
  7223. {
  7224. // Check for access flag depending on the resulting action
  7225. if (g_newround)
  7226. {
  7227. // Start Mode Nemesis
  7228. if (!cmd_access(id, g_access_flag[ACCESS_MODE_NEMESIS], cid, 2))
  7229. return PLUGIN_HANDLED;
  7230. }
  7231. else
  7232. {
  7233. // Make Nemesis
  7234. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_NEMESIS], cid, 2))
  7235. return PLUGIN_HANDLED;
  7236. }
  7237.  
  7238. // Retrieve arguments
  7239. static arg[32], player
  7240. read_argv(1, arg, charsmax(arg))
  7241. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7242.  
  7243. // Invalid target
  7244. if (!player) return PLUGIN_HANDLED;
  7245.  
  7246. // Target not allowed to be nemesis
  7247. if (!allowed_nemesis(player))
  7248. {
  7249. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7250. return PLUGIN_HANDLED;
  7251. }
  7252.  
  7253. command_nemesis(id, player)
  7254.  
  7255. return PLUGIN_HANDLED;
  7256. }
  7257.  
  7258. // Hattrick
  7259. //
  7260. // zp_nemesis [target]
  7261. public cmd_reset_points(id, level, cid)
  7262. {
  7263. if (!cmd_access(id, g_access_flag[ACCESS_GIVE_POINTS], cid, 1))
  7264. return PLUGIN_HANDLED;
  7265.  
  7266. new vault=nvault_open("points")
  7267. if (vault != INVALID_HANDLE)
  7268. {
  7269. for (new i = 1; i <= g_maxplayers;i++)
  7270. {
  7271. g_points[i]=0
  7272. }
  7273. nvault_prune(vault,0,get_systime())
  7274. nvault_close(vault)
  7275. vault = INVALID_HANDLE
  7276.  
  7277. zp_colored_print(0,"^x04[ZP]^x03 %s^x01 has reset all points.", g_playername[id]);
  7278. return 1;
  7279. }
  7280.  
  7281. console_print(id, "Failed to reset points.");
  7282. return PLUGIN_HANDLED;
  7283. }
  7284.  
  7285. // Hattrick
  7286. //
  7287. // zp_nemesis [target]
  7288. public cmd_points(id, level, cid)
  7289. {
  7290. if (!cmd_access(id, g_access_flag[ACCESS_GIVE_POINTS], cid, 3))
  7291. return PLUGIN_HANDLED;
  7292.  
  7293. // Retrieve arguments
  7294. static arg[32], amount[16], player, points
  7295. read_argv(1, arg, charsmax(arg))
  7296. read_argv(2, amount, charsmax(amount))
  7297.  
  7298. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7299.  
  7300. // Invalid target
  7301. if (!player) return PLUGIN_HANDLED;
  7302.  
  7303. points = str_to_num(amount);
  7304.  
  7305. if (points < 1)
  7306. return PLUGIN_HANDLED;
  7307.  
  7308. g_points[player] += points;
  7309. savePoints(player);
  7310.  
  7311. new str[32];
  7312. AddCommas(points, str, 31);
  7313. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 gave^x04 %s points^x01 to^x03 %s", g_playername[id], str, g_playername[player])
  7314. return PLUGIN_HANDLED;
  7315. }
  7316.  
  7317. // Hattrick
  7318. //
  7319. // zp_nemesis [target]
  7320. public cmd_subtract_points(id, level, cid)
  7321. {
  7322. if (!cmd_access(id, g_access_flag[ACCESS_GIVE_POINTS], cid, 3))
  7323. return PLUGIN_HANDLED;
  7324.  
  7325. // Retrieve arguments
  7326. static arg[32], amount[16], player, points
  7327. read_argv(1, arg, charsmax(arg))
  7328. read_argv(2, amount, charsmax(amount))
  7329.  
  7330. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7331.  
  7332. // Invalid target
  7333. if (!player) return PLUGIN_HANDLED;
  7334.  
  7335. points = str_to_num(amount);
  7336.  
  7337. if (points < 1)
  7338. return PLUGIN_HANDLED;
  7339.  
  7340. g_points[player] -= points;
  7341. savePoints(player);
  7342.  
  7343. new str[32];
  7344. AddCommas(points, str, 31);
  7345. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 removed^x04 %s points^x01 from^x03 %s", g_playername[id], str, g_playername[player])
  7346. return PLUGIN_HANDLED;
  7347. }
  7348.  
  7349. // Hattrick
  7350. //
  7351. // zp_nemesis [target]
  7352. public cmd_ammo(id, level, cid)
  7353. {
  7354. if (!cmd_access(id, g_access_flag[ACCESS_GIVE_AMMO], cid, 3))
  7355. return PLUGIN_HANDLED;
  7356.  
  7357. new vault = nvault_open("ammo");
  7358. new giventotal=0
  7359.  
  7360. if (vault != INVALID_HANDLE)
  7361. {
  7362. giventotal = nvault_get(vault, g_ip[id]);
  7363. nvault_close(vault)
  7364. vault = INVALID_HANDLE
  7365. }
  7366.  
  7367. // Retrieve arguments
  7368. static arg[32], amount[16], player, ammo
  7369. read_argv(1, arg, charsmax(arg))
  7370. read_argv(2, amount, charsmax(amount))
  7371.  
  7372. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7373.  
  7374. // Invalid target
  7375. if (!player) return PLUGIN_HANDLED;
  7376.  
  7377. ammo = str_to_num(amount);
  7378.  
  7379. if (ammo < 1)
  7380. return PLUGIN_HANDLED;
  7381.  
  7382. if ( ammo + giventotal > get_pcvar_num(g_maxammo))
  7383. {
  7384. console_print(id, ">> You are exceeding the limit per map (%d).",get_pcvar_num(g_maxammo));
  7385. return PLUGIN_HANDLED
  7386. }
  7387.  
  7388. vault = nvault_open("ammo");
  7389. if (vault != INVALID_HANDLE)
  7390. {
  7391. new tmp[32];
  7392. num_to_str(ammo + giventotal, tmp, 31)
  7393.  
  7394. nvault_set(vault, g_ip[id], tmp)
  7395.  
  7396. nvault_close(vault)
  7397. vault = INVALID_HANDLE
  7398. }
  7399.  
  7400. g_ammopacks[player] += ammo;
  7401.  
  7402. new str[32];
  7403. AddCommas(ammo, str, 31)
  7404. zp_colored_print(0, "^x04[ZP]^x03 %s^x01 gave^x04 %s ammo^x01 to^x03 %s", g_playername[id], str, g_playername[player])
  7405. return PLUGIN_HANDLED;
  7406. }
  7407.  
  7408. // Hattrick
  7409. //
  7410. // zp_nemesis [target]
  7411. public cmd_assassin(id, level, cid)
  7412. {
  7413. // Check for access flag depending on the resulting action
  7414. if (g_newround)
  7415. {
  7416. // Start Mode Nemesis
  7417. if (!cmd_access(id, g_access_flag[ACCESS_MODE_ASSASSIN], cid, 2))
  7418. return PLUGIN_HANDLED;
  7419. }
  7420. else
  7421. {
  7422. // Make Nemesis
  7423. if (!cmd_access(id, g_access_flag[ACCESS_MAKE_ASSASSIN], cid, 2))
  7424. return PLUGIN_HANDLED;
  7425. }
  7426.  
  7427. // Retrieve arguments
  7428. static arg[32], player
  7429. read_argv(1, arg, charsmax(arg))
  7430. player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  7431.  
  7432. // Invalid target
  7433. if (!player) return PLUGIN_HANDLED;
  7434.  
  7435. // Target not allowed to be nemesis
  7436. if (!allowed_assassin(player))
  7437. {
  7438. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7439. return PLUGIN_HANDLED;
  7440. }
  7441.  
  7442. command_assassin(id, player)
  7443.  
  7444. return PLUGIN_HANDLED;
  7445. }
  7446.  
  7447.  
  7448.  
  7449. // zp_respawn [target]
  7450. public cmd_respawn(id, level, cid)
  7451. {
  7452. // Check for access flag - Respawn
  7453. if (!cmd_access(id, g_access_flag[ACCESS_RESPAWN_PLAYERS], cid, 2))
  7454. return PLUGIN_HANDLED;
  7455.  
  7456. // Retrieve arguments
  7457. static arg[32], player
  7458. read_argv(1, arg, charsmax(arg))
  7459. player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  7460.  
  7461. // Invalid target
  7462. if (!player) return PLUGIN_HANDLED;
  7463.  
  7464. // Target not allowed to be respawned
  7465. if (!allowed_respawn(player))
  7466. {
  7467. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7468. return PLUGIN_HANDLED;
  7469. }
  7470.  
  7471. command_respawn(id, player)
  7472.  
  7473. return PLUGIN_HANDLED;
  7474. }
  7475.  
  7476. // zp_swarm
  7477. public cmd_swarm(id, level, cid)
  7478. {
  7479. // Check for access flag - Mode Swarm
  7480. if (!cmd_access(id, g_access_flag[ACCESS_MODE_SWARM], cid, 1))
  7481. return PLUGIN_HANDLED;
  7482.  
  7483. // Swarm mode not allowed
  7484. if (!allowed_swarm())
  7485. {
  7486. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7487. return PLUGIN_HANDLED;
  7488. }
  7489.  
  7490. command_swarm(id)
  7491.  
  7492. return PLUGIN_HANDLED;
  7493. }
  7494.  
  7495. public cmd_avs(id, level, cid)
  7496. {
  7497. // Check for access flag - Mode Swarm
  7498. if (!cmd_access(id, g_access_flag[ACCESS_MODE_AVS], cid, 1))
  7499. return PLUGIN_HANDLED;
  7500.  
  7501. // Swarm mode not allowed
  7502. if (!allowed_avs())
  7503. {
  7504. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7505. return PLUGIN_HANDLED;
  7506. }
  7507.  
  7508. command_avs(id)
  7509.  
  7510. return PLUGIN_HANDLED;
  7511. }
  7512.  
  7513. public cmd_armageddon(id, level, cid)
  7514. {
  7515. // Check for access flag - Mode Swarm
  7516. if (!cmd_access(id, g_access_flag[ACCESS_MODE_ARMAGEDDON], cid, 1))
  7517. return PLUGIN_HANDLED;
  7518.  
  7519. // Swarm mode not allowed
  7520. if (!allowed_armageddon())
  7521. {
  7522. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7523. return PLUGIN_HANDLED;
  7524. }
  7525.  
  7526. command_armageddon(id)
  7527.  
  7528. return PLUGIN_HANDLED;
  7529. }
  7530.  
  7531. // zp_multi
  7532. public cmd_multi(id, level, cid)
  7533. {
  7534. // Check for access flag - Mode Multi
  7535. if (!cmd_access(id, g_access_flag[ACCESS_MODE_MULTI], cid, 1))
  7536. return PLUGIN_HANDLED;
  7537.  
  7538. // Multi infection mode not allowed
  7539. if (!allowed_multi())
  7540. {
  7541. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7542. return PLUGIN_HANDLED;
  7543. }
  7544.  
  7545. command_multi(id)
  7546.  
  7547. return PLUGIN_HANDLED;
  7548. }
  7549.  
  7550. // zp_plague
  7551. public cmd_plague(id, level, cid)
  7552. {
  7553. // Check for access flag - Mode Plague
  7554. if (!cmd_access(id, g_access_flag[ACCESS_MODE_PLAGUE], cid, 1))
  7555. return PLUGIN_HANDLED;
  7556.  
  7557. // Plague mode not allowed
  7558. if (!allowed_plague())
  7559. {
  7560. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  7561. return PLUGIN_HANDLED;
  7562. }
  7563.  
  7564. command_plague(id)
  7565.  
  7566. return PLUGIN_HANDLED;
  7567. }
  7568.  
  7569. /*================================================================================
  7570. [Message Hooks]
  7571. =================================================================================*/
  7572.  
  7573. // Current Weapon info
  7574. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  7575. {
  7576. // Not alive or zombie
  7577. if (!g_isalive[msg_entity] || g_zombie[msg_entity])
  7578. return;
  7579.  
  7580. // Not an active weapon
  7581. if (get_msg_arg_int(1) != 1)
  7582. return;
  7583.  
  7584. // Hattrick
  7585. //
  7586. if (get_pcvar_num(cvar_infammo) <= 1 && !g_sniper[msg_entity] && !g_survivor[msg_entity] && !g_vip[msg_entity])
  7587. return;
  7588.  
  7589. if (g_sniper[msg_entity] && get_pcvar_num(cvar_sniperinfammo) <= 1)
  7590. return;
  7591.  
  7592. // Unlimited clip disabled for class
  7593. if (g_survivor[msg_entity] && get_pcvar_num(cvar_survinfammo) <= 1)
  7594. return;
  7595.  
  7596. if (g_vip[msg_entity] && containi(g_vip_flags[msg_entity], "C")==-1)
  7597. return;
  7598.  
  7599. // Get weapon's id
  7600. static weapon
  7601. weapon = get_msg_arg_int(2)
  7602.  
  7603. // Unlimited Clip Ammo for this weapon?
  7604. if (MAXBPAMMO[weapon] > 2)
  7605. {
  7606. // Max out clip ammo
  7607. static weapon_ent
  7608. weapon_ent = fm_cs_get_current_weapon_ent(msg_entity)
  7609. if (pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
  7610.  
  7611. // HUD should show full clip all the time
  7612. set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
  7613. }
  7614. }
  7615.  
  7616. // Take off player's money
  7617. public message_money(msg_id, msg_dest, msg_entity)
  7618. {
  7619. // Remove money setting enabled?
  7620. if (!get_pcvar_num(cvar_removemoney))
  7621. return PLUGIN_CONTINUE;
  7622.  
  7623. fm_cs_set_user_money(msg_entity, 0)
  7624. return PLUGIN_HANDLED;
  7625. }
  7626.  
  7627. // Fix for the HL engine bug when HP is multiples of 256
  7628. public message_health(msg_id, msg_dest, msg_entity)
  7629. {
  7630. // Get player's health
  7631. static health
  7632. health = get_msg_arg_int(1)
  7633.  
  7634. // Don't bother
  7635. if (health < 256) return;
  7636.  
  7637. // Check if we need to fix it
  7638. if (health % 256 == 0)
  7639. fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
  7640.  
  7641. // HUD can only show as much as 255 hp
  7642. set_msg_arg_int(1, get_msg_argtype(1), 255)
  7643. }
  7644.  
  7645. // Block flashlight battery messages if custom flashlight is enabled instead
  7646. public message_flashbat()
  7647. {
  7648. if (g_cached_customflash)
  7649. return PLUGIN_HANDLED;
  7650.  
  7651. return PLUGIN_CONTINUE;
  7652. }
  7653.  
  7654. // Flashbangs should only affect zombies
  7655. public message_screenfade(msg_id, msg_dest, msg_entity)
  7656. {
  7657. 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)
  7658. return PLUGIN_CONTINUE;
  7659.  
  7660. // Nemesis shouldn't be FBed
  7661. if (g_zombie[msg_entity] && !g_nemesis[msg_entity])
  7662. {
  7663. // Set flash color to nighvision's
  7664. set_msg_arg_int(4, get_msg_argtype(4), get_pcvar_num(cvar_nvgcolor[0]))
  7665. set_msg_arg_int(5, get_msg_argtype(5), get_pcvar_num(cvar_nvgcolor[1]))
  7666. set_msg_arg_int(6, get_msg_argtype(6), get_pcvar_num(cvar_nvgcolor[2]))
  7667. return PLUGIN_CONTINUE;
  7668. }
  7669.  
  7670. return PLUGIN_HANDLED;
  7671. }
  7672.  
  7673. // Prevent spectators' nightvision from being turned off when switching targets, etc.
  7674. public message_nvgtoggle()
  7675. {
  7676. return PLUGIN_HANDLED;
  7677. }
  7678.  
  7679. // Set correct model on player corpses
  7680. public message_clcorpse()
  7681. {
  7682. set_msg_arg_string(1, g_playermodel[get_msg_arg_int(12)])
  7683. }
  7684.  
  7685. // Prevent zombies from seeing any weapon pickup icon
  7686. public message_weappickup(msg_id, msg_dest, msg_entity)
  7687. {
  7688. if (g_zombie[msg_entity])
  7689. return PLUGIN_HANDLED;
  7690.  
  7691. return PLUGIN_CONTINUE;
  7692. }
  7693.  
  7694. // Prevent zombies from seeing any ammo pickup icon
  7695. public message_ammopickup(msg_id, msg_dest, msg_entity)
  7696. {
  7697. if (g_zombie[msg_entity])
  7698. return PLUGIN_HANDLED;
  7699.  
  7700. return PLUGIN_CONTINUE;
  7701. }
  7702.  
  7703. // Block hostage HUD display
  7704. public message_scenario()
  7705. {
  7706. if (get_msg_args() > 1)
  7707. {
  7708. static sprite[8]
  7709. get_msg_arg_string(2, sprite, charsmax(sprite))
  7710.  
  7711. if (equal(sprite, "hostage"))
  7712. return PLUGIN_HANDLED;
  7713. }
  7714.  
  7715. return PLUGIN_CONTINUE;
  7716. }
  7717.  
  7718. // Block hostages from appearing on radar
  7719. public message_hostagepos()
  7720. {
  7721. return PLUGIN_HANDLED;
  7722. }
  7723.  
  7724. // Block some text messages
  7725. public message_textmsg()
  7726. {
  7727. static textmsg[22]
  7728. get_msg_arg_string(2, textmsg, charsmax(textmsg))
  7729.  
  7730. // Game restarting, reset scores and call round end to balance the teams
  7731. if (equal(textmsg, "#Game_will_restart_in"))
  7732. {
  7733. logevent_round_end()
  7734. g_scorehumans = 0
  7735. g_scorezombies = 0
  7736. }
  7737. // Game commencing, reset scores only (round end is automatically triggered)
  7738. else if (equal(textmsg, "#Game_Commencing"))
  7739. {
  7740. g_gamecommencing = true
  7741. g_scorehumans = 0
  7742. g_scorezombies = 0
  7743. }
  7744. // Block round end related messages
  7745. else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
  7746. {
  7747. return PLUGIN_HANDLED;
  7748. }
  7749.  
  7750. return PLUGIN_CONTINUE;
  7751. }
  7752.  
  7753. // Block CS round win audio messages, since we're playing our own instead
  7754. public message_sendaudio()
  7755. {
  7756. static audio[17]
  7757. get_msg_arg_string(2, audio, charsmax(audio))
  7758.  
  7759. if(equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
  7760. return PLUGIN_HANDLED;
  7761.  
  7762. return PLUGIN_CONTINUE;
  7763. }
  7764.  
  7765. // Send actual team scores (T = zombies // CT = humans)
  7766. public message_teamscore()
  7767. {
  7768. static team[2]
  7769. get_msg_arg_string(1, team, charsmax(team))
  7770.  
  7771. switch (team[0])
  7772. {
  7773. // CT
  7774. case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_scorehumans)
  7775. // Terrorist
  7776. case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_scorezombies)
  7777. }
  7778. }
  7779.  
  7780. // Team Switch (or player joining a team for first time)
  7781. public message_teaminfo(msg_id, msg_dest)
  7782. {
  7783. // Only hook global messages
  7784. if (msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
  7785.  
  7786. // Don't pick up our own TeamInfo messages for this player (bugfix)
  7787. if (g_switchingteam) return;
  7788.  
  7789. // Get player's id
  7790. static id
  7791. id = get_msg_arg_int(1)
  7792.  
  7793. // Invalid player id? (bugfix)
  7794. if (!(1 <= id <= g_maxplayers)) return;
  7795.  
  7796. // Enable spectators' nightvision if not spawning right away
  7797. set_task(0.2, "spec_nvision", id)
  7798.  
  7799. // Round didn't start yet, nothing to worry about
  7800. if (g_newround) return;
  7801.  
  7802. // Get his new team
  7803. static team[2]
  7804. get_msg_arg_string(2, team, charsmax(team))
  7805.  
  7806. // Perform some checks to see if they should join a different team instead
  7807. switch (team[0])
  7808. {
  7809. case 'C': // CT
  7810. {
  7811. // Hattrick
  7812. //
  7813. //if (g_survround && fnGetHumans()) // survivor alive --> switch to T and spawn as zombie
  7814. if ((g_survround || g_sniperround) && fnGetHumans())
  7815. {
  7816. g_respawn_as_zombie[id] = true;
  7817. remove_task(id+TASK_TEAM)
  7818. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  7819. set_msg_arg_string(2, "TERRORIST")
  7820. }
  7821. else if (!fnGetZombies()) // no zombies alive --> switch to T and spawn as zombie
  7822. {
  7823. g_respawn_as_zombie[id] = true;
  7824. remove_task(id+TASK_TEAM)
  7825. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  7826. set_msg_arg_string(2, "TERRORIST")
  7827. }
  7828. }
  7829. case 'T': // Terrorist
  7830. {
  7831. // Hattrick
  7832. //
  7833. //if ((g_swarmround || g_survround) && fnGetHumans()) // survivor alive or swarm round w/ humans --> spawn as zombie
  7834. if ((g_swarmround || g_avsround || g_armageddonround || g_survround || g_sniper) && fnGetHumans())
  7835. {
  7836. g_respawn_as_zombie[id] = true;
  7837. }
  7838. else if (fnGetZombies()) // zombies alive --> switch to CT
  7839. {
  7840. remove_task(id+TASK_TEAM)
  7841. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  7842. set_msg_arg_string(2, "CT")
  7843. }
  7844. }
  7845. }
  7846. }
  7847.  
  7848. /*================================================================================
  7849. [Main Functions]
  7850. =================================================================================*/
  7851.  
  7852. // Make Zombie Task
  7853. public make_zombie_task()
  7854. {
  7855. // Call make a zombie with no specific mode
  7856. make_a_zombie(MODE_NONE, 0)
  7857. }
  7858.  
  7859. // Make a Zombie Function
  7860. make_a_zombie(mode, id)
  7861. {
  7862. // Get alive players count
  7863. static iPlayersnum
  7864. iPlayersnum = fnGetAlive()
  7865.  
  7866. // Not enough players, come back later!
  7867. if (iPlayersnum < 1)
  7868. {
  7869. set_task(2.0, "make_zombie_task", TASK_MAKEZOMBIE)
  7870. return;
  7871. }
  7872.  
  7873. // Round started!
  7874. g_newround = false
  7875.  
  7876. // Set up some common vars
  7877. static forward_id, sound[64], iZombies, iMaxZombies
  7878.  
  7879. 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)) || mode == MODE_SURVIVOR)
  7880. {
  7881. // Survivor Mode
  7882. g_survround = true
  7883. g_lastmode = MODE_SURVIVOR
  7884.  
  7885. // Choose player randomly?
  7886. if (mode == MODE_NONE)
  7887. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  7888.  
  7889. // Remember id for calling our forward later
  7890. forward_id = id
  7891.  
  7892. // Turn player into a survivor
  7893. humanme(id, 1, 0)
  7894.  
  7895. // Turn the remaining players into zombies
  7896. for (id = 1; id <= g_maxplayers; id++)
  7897. {
  7898. // Not alive
  7899. if (!g_isalive[id])
  7900. continue;
  7901.  
  7902. // Survivor or already a zombie
  7903. if (g_survivor[id] || g_zombie[id])
  7904. continue;
  7905.  
  7906. // Turn into a zombie
  7907. zombieme(id, 0, 0, 1, 0)
  7908. }
  7909.  
  7910. // Play survivor sound
  7911. ArrayGetString(sound_survivor, random_num(0, ArraySize(sound_survivor) - 1), sound, charsmax(sound))
  7912. PlaySound(sound);
  7913.  
  7914. // Show Survivor HUD notice
  7915. set_hudmessage(20, 20, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  7916. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SURVIVOR", g_playername[forward_id])
  7917.  
  7918. // Mode fully started!
  7919. g_modestarted = true
  7920.  
  7921. // Round start forward
  7922. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SURVIVOR, forward_id);
  7923. }
  7924. // Hattrick
  7925. //
  7926. else 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)) || mode == MODE_SNIPER)
  7927. {
  7928. // Survivor Mode
  7929. g_sniperround = true
  7930. g_lastmode = MODE_SNIPER
  7931.  
  7932. // Choose player randomly?
  7933. if (mode == MODE_NONE)
  7934. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  7935.  
  7936. // Remember id for calling our forward later
  7937. forward_id = id
  7938.  
  7939. // Turn player into a survivor
  7940. humanme_sniper(id)
  7941.  
  7942. // Turn the remaining players into zombies
  7943. for (id = 1; id <= g_maxplayers; id++)
  7944. {
  7945. // Not alive
  7946. if (!g_isalive[id])
  7947. continue;
  7948.  
  7949. // Survivor or already a zombie
  7950. if (g_sniper[id] || g_zombie[id])
  7951. continue;
  7952.  
  7953. // Turn into a zombie
  7954. zombieme(id, 0, 0, 1, 0)
  7955. }
  7956.  
  7957. // Play survivor sound
  7958. ArrayGetString(sound_sniper, random_num(0, ArraySize(sound_sniper) - 1), sound, charsmax(sound))
  7959. PlaySound(sound);
  7960.  
  7961. // Show Survivor HUD notice
  7962. set_hudmessage(20, 20, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  7963. ShowSyncHudMsg(0, g_MsgSync, "%s is a Sniper !!!", g_playername[forward_id])
  7964.  
  7965. // Mode fully started!
  7966. g_modestarted = true
  7967.  
  7968. // Round start forward
  7969. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SNIPER, forward_id);
  7970. }
  7971.  
  7972. else 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)) || mode == MODE_SWARM)
  7973. {
  7974. // Swarm Mode
  7975. g_swarmround = true
  7976. g_lastmode = MODE_SWARM
  7977.  
  7978. // Make sure there are alive players on both teams (BUGFIX)
  7979. if (!fnGetAliveTs())
  7980. {
  7981. // Move random player to T team
  7982. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  7983. remove_task(id+TASK_TEAM)
  7984. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  7985. fm_user_team_update(id)
  7986. }
  7987. else if (!fnGetAliveCTs())
  7988. {
  7989. // Move random player to CT team
  7990. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  7991. remove_task(id+TASK_TEAM)
  7992. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  7993. fm_user_team_update(id)
  7994. }
  7995.  
  7996. // Turn every T into a zombie
  7997. for (id = 1; id <= g_maxplayers; id++)
  7998. {
  7999. // Not alive
  8000. if (!g_isalive[id])
  8001. continue;
  8002.  
  8003. // Not a Terrorist
  8004. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
  8005. continue;
  8006.  
  8007. // Turn into a zombie
  8008. zombieme(id, 0, 0, 1, 0)
  8009. }
  8010.  
  8011. // Play swarm sound
  8012. ArrayGetString(sound_swarm, random_num(0, ArraySize(sound_swarm) - 1), sound, charsmax(sound))
  8013. PlaySound(sound);
  8014.  
  8015. // Show Swarm HUD notice
  8016. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8017. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SWARM")
  8018.  
  8019. // Mode fully started!
  8020. g_modestarted = true
  8021.  
  8022. // Round start forward
  8023. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SWARM, 0);
  8024. }
  8025. else if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_ARMAGEDDON) && random_num(1, get_pcvar_num(cvar_armageddonchance)) == get_pcvar_num(cvar_armageddon) && iPlayersnum >= get_pcvar_num(cvar_armageddonminplayers)) || mode == MODE_ARMAGEDDON)
  8026. {
  8027. // Swarm Mode
  8028. g_armageddonround = true
  8029. g_lastmode = MODE_ARMAGEDDON
  8030.  
  8031. // Make sure there are alive players on both teams (BUGFIX)
  8032. if (!fnGetAliveTs())
  8033. {
  8034. // Move random player to T team
  8035. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8036. remove_task(id+TASK_TEAM)
  8037. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  8038. fm_user_team_update(id)
  8039. }
  8040. else if (!fnGetAliveCTs())
  8041. {
  8042. // Move random player to CT team
  8043. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8044. remove_task(id+TASK_TEAM)
  8045. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  8046. fm_user_team_update(id)
  8047. }
  8048.  
  8049. // Turn every T into a zombie
  8050. for (id = 1; id <= g_maxplayers; id++)
  8051. {
  8052. // Not alive
  8053. if (!g_isalive[id])
  8054. continue;
  8055.  
  8056. // Not a Terrorist
  8057. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
  8058. continue;
  8059.  
  8060. // Turn into a zombie
  8061. zombieme(id, 0, 1, 0, 0)
  8062. }
  8063.  
  8064. // Turn every T into a zombie
  8065. for (id = 1; id <= g_maxplayers; id++)
  8066. {
  8067. // Not alive
  8068. if (!g_isalive[id])
  8069. continue;
  8070.  
  8071. // Not a Terrorist
  8072. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT)
  8073. continue;
  8074.  
  8075. // Turn into a zombie
  8076. humanme(id, 1, 0)
  8077. }
  8078.  
  8079. // Play swarm sound
  8080. ArrayGetString(sound_swarm, random_num(0, ArraySize(sound_swarm) - 1), sound, charsmax(sound))
  8081. PlaySound(sound);
  8082.  
  8083. // Show Swarm HUD notice
  8084. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8085. ShowSyncHudMsg(0, g_MsgSync, "Armageddon Round !!")
  8086.  
  8087. // Mode fully started!
  8088. g_modestarted = true
  8089.  
  8090. // Round start forward
  8091. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_ARMAGEDDON, 0);
  8092. }
  8093. else if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_AVS) && random_num(1, get_pcvar_num(cvar_avschance)) == get_pcvar_num(cvar_avs) && iPlayersnum >= get_pcvar_num(cvar_avsminplayers)) || mode == MODE_AVS)
  8094. {
  8095. // Swarm Mode
  8096. g_avsround = true
  8097. g_lastmode = MODE_AVS
  8098.  
  8099. // Make sure there are alive players on both teams (BUGFIX)
  8100. if (!fnGetAliveTs())
  8101. {
  8102. // Move random player to T team
  8103. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8104. remove_task(id+TASK_TEAM)
  8105. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  8106. fm_user_team_update(id)
  8107. }
  8108. else if (!fnGetAliveCTs())
  8109. {
  8110. // Move random player to CT team
  8111. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8112. remove_task(id+TASK_TEAM)
  8113. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  8114. fm_user_team_update(id)
  8115. }
  8116.  
  8117. // Turn every T into a zombie
  8118. for (id = 1; id <= g_maxplayers; id++)
  8119. {
  8120. // Not alive
  8121. if (!g_isalive[id])
  8122. continue;
  8123.  
  8124. // Not a Terrorist
  8125. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
  8126. continue;
  8127.  
  8128. // Turn into a zombie
  8129. zombieme_assassin(id, 0, 0)
  8130. }
  8131.  
  8132. // Turn every T into a zombie
  8133. for (id = 1; id <= g_maxplayers; id++)
  8134. {
  8135. // Not alive
  8136. if (!g_isalive[id])
  8137. continue;
  8138.  
  8139. // Not a Terrorist
  8140. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT)
  8141. continue;
  8142.  
  8143. // Turn into a zombie
  8144. humanme_sniper(id);
  8145. }
  8146.  
  8147. // Play swarm sound
  8148. ArrayGetString(sound_swarm, random_num(0, ArraySize(sound_swarm) - 1), sound, charsmax(sound))
  8149. PlaySound(sound);
  8150.  
  8151. // Show Swarm HUD notice
  8152. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8153. ShowSyncHudMsg(0, g_MsgSync, "Assassins VS Snipers Round !!")
  8154.  
  8155. // Mode fully started!
  8156. g_modestarted = true
  8157.  
  8158. // Round start forward
  8159. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_AVS, 0);
  8160. }
  8161. else 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) && 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)) || mode == MODE_MULTI)
  8162. {
  8163. // Multi Infection Mode
  8164. g_lastmode = MODE_MULTI
  8165.  
  8166. // iMaxZombies is rounded up, in case there aren't enough players
  8167. iMaxZombies = floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil)
  8168. iZombies = 0
  8169.  
  8170. // Randomly turn iMaxZombies players into zombies
  8171. while (iZombies < iMaxZombies)
  8172. {
  8173. // Keep looping through all players
  8174. if (++id > g_maxplayers) id = 1
  8175.  
  8176. // Dead or already a zombie
  8177. if (!g_isalive[id] || g_zombie[id])
  8178. continue;
  8179.  
  8180. // Random chance
  8181. if (random_num(0, 1))
  8182. {
  8183. // Turn into a zombie
  8184. zombieme(id, 0, 0, 1, 0)
  8185. iZombies++
  8186. }
  8187. }
  8188.  
  8189. // Turn the remaining players into humans
  8190. for (id = 1; id <= g_maxplayers; id++)
  8191. {
  8192. // Only those of them who aren't zombies
  8193. if (!g_isalive[id] || g_zombie[id])
  8194. continue;
  8195.  
  8196. // Switch to CT
  8197. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  8198. {
  8199. remove_task(id+TASK_TEAM)
  8200. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  8201. fm_user_team_update(id)
  8202. }
  8203. }
  8204.  
  8205. // Play multi infection sound
  8206. ArrayGetString(sound_multi, random_num(0, ArraySize(sound_multi) - 1), sound, charsmax(sound))
  8207. PlaySound(sound);
  8208.  
  8209. // Show Multi Infection HUD notice
  8210. set_hudmessage(200, 50, 0, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8211. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_MULTI")
  8212.  
  8213. // Mode fully started!
  8214. g_modestarted = true
  8215.  
  8216. // Round start forward
  8217. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_MULTI, 0);
  8218. }
  8219. else 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) && floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) >= 1
  8220. && 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 && iPlayersnum >= get_pcvar_num(cvar_plagueminplayers)) || mode == MODE_PLAGUE)
  8221. {
  8222. // Plague Mode
  8223. g_plagueround = true
  8224. g_lastmode = MODE_PLAGUE
  8225.  
  8226. // Turn specified amount of players into Survivors
  8227. static iSurvivors, iMaxSurvivors
  8228. iMaxSurvivors = get_pcvar_num(cvar_plaguesurvnum)
  8229. iSurvivors = 0
  8230.  
  8231. while (iSurvivors < iMaxSurvivors)
  8232. {
  8233. // Choose random guy
  8234. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8235.  
  8236. // Already a survivor?
  8237. if (g_survivor[id])
  8238. continue;
  8239.  
  8240. // If not, turn him into one
  8241. humanme(id, 1, 0)
  8242. iSurvivors++
  8243.  
  8244. // Apply survivor health multiplier
  8245. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguesurvhpmulti)))
  8246. }
  8247.  
  8248. // Turn specified amount of players into Nemesis
  8249. static iNemesis, iMaxNemesis
  8250. iMaxNemesis = get_pcvar_num(cvar_plaguenemnum)
  8251. iNemesis = 0
  8252.  
  8253. while (iNemesis < iMaxNemesis)
  8254. {
  8255. // Choose random guy
  8256. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8257.  
  8258. // Already a survivor or nemesis?
  8259. if (g_survivor[id] || g_nemesis[id])
  8260. continue;
  8261.  
  8262. // If not, turn him into one
  8263. zombieme(id, 0, 1, 0, 0)
  8264. iNemesis++
  8265.  
  8266. // Apply nemesis health multiplier
  8267. fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguenemhpmulti)))
  8268. }
  8269.  
  8270. // iMaxZombies is rounded up, in case there aren't enough players
  8271. iMaxZombies = floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)
  8272. iZombies = 0
  8273.  
  8274. // Randomly turn iMaxZombies players into zombies
  8275. while (iZombies < iMaxZombies)
  8276. {
  8277. // Keep looping through all players
  8278. if (++id > g_maxplayers) id = 1
  8279.  
  8280. // Dead or already a zombie or survivor
  8281. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  8282. continue;
  8283.  
  8284. // Random chance
  8285. if (random_num(0, 1))
  8286. {
  8287. // Turn into a zombie
  8288. zombieme(id, 0, 0, 1, 0)
  8289. iZombies++
  8290. }
  8291. }
  8292.  
  8293. // Turn the remaining players into humans
  8294. for (id = 1; id <= g_maxplayers; id++)
  8295. {
  8296. // Only those of them who arent zombies or survivor
  8297. if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
  8298. continue;
  8299.  
  8300. // Switch to CT
  8301. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  8302. {
  8303. remove_task(id+TASK_TEAM)
  8304. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  8305. fm_user_team_update(id)
  8306. }
  8307. }
  8308.  
  8309. // Play plague sound
  8310. ArrayGetString(sound_plague, random_num(0, ArraySize(sound_plague) - 1), sound, charsmax(sound))
  8311. PlaySound(sound);
  8312.  
  8313. // Show Plague HUD notice
  8314. set_hudmessage(0, 50, 200, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8315. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_PLAGUE")
  8316.  
  8317. // Mode fully started!
  8318. g_modestarted = true
  8319.  
  8320. // Round start forward
  8321. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_PLAGUE, 0);
  8322. }
  8323. else
  8324. {
  8325. // Single Infection Mode or Nemesis Mode
  8326.  
  8327. // Choose player randomly?
  8328. if (mode == MODE_NONE)
  8329. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  8330.  
  8331. // Remember id for calling our forward later
  8332. forward_id = id
  8333.  
  8334. 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)) || mode == MODE_NEMESIS)
  8335. {
  8336. // Nemesis Mode
  8337. g_nemround = true
  8338. g_lastmode = MODE_NEMESIS
  8339.  
  8340. // Turn player into nemesis
  8341. zombieme(id, 0, 1, 0, 0)
  8342. }
  8343. // Hattrick
  8344. //
  8345. else 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)) || mode == MODE_ASSASSIN)
  8346. {
  8347. // Nemesis Mode
  8348. g_assassinround = true
  8349. g_lastmode = MODE_ASSASSIN
  8350.  
  8351. // Turn player into nemesis
  8352. zombieme_assassin(id, 0, 0)
  8353. }
  8354.  
  8355. else
  8356. {
  8357. // Single Infection Mode
  8358. g_lastmode = MODE_INFECTION
  8359.  
  8360. // Turn player into the first zombie
  8361. zombieme(id, 0, 0, 0, 0)
  8362. }
  8363.  
  8364. // Remaining players should be humans (CTs)
  8365. for (id = 1; id <= g_maxplayers; id++)
  8366. {
  8367. // Not alive
  8368. if (!g_isalive[id])
  8369. continue;
  8370.  
  8371. // First zombie/nemesis
  8372. if (g_zombie[id])
  8373. continue;
  8374.  
  8375. // Switch to CT
  8376. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  8377. {
  8378. remove_task(id+TASK_TEAM)
  8379. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  8380. fm_user_team_update(id)
  8381. }
  8382. }
  8383.  
  8384. if (g_nemround)
  8385. {
  8386. // Play Nemesis sound
  8387. ArrayGetString(sound_nemesis, random_num(0, ArraySize(sound_nemesis) - 1), sound, charsmax(sound))
  8388. PlaySound(sound);
  8389.  
  8390. // Show Nemesis HUD notice
  8391. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8392. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_NEMESIS", g_playername[forward_id])
  8393.  
  8394. // Mode fully started!
  8395. g_modestarted = true
  8396.  
  8397. // Round start forward
  8398. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_NEMESIS, forward_id);
  8399. }
  8400. // Hattrick
  8401. //
  8402. else if (g_assassinround)
  8403. {
  8404. // Play Nemesis sound
  8405. ArrayGetString(sound_assassin, random_num(0, ArraySize(sound_assassin) - 1), sound, charsmax(sound))
  8406. PlaySound(sound);
  8407.  
  8408. // Show Nemesis HUD notice
  8409. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  8410. ShowSyncHudMsg(0, g_MsgSync, "%s is an Assassin !!!", g_playername[forward_id])
  8411.  
  8412. // Mode fully started!
  8413. g_modestarted = true
  8414.  
  8415. // Round start forward
  8416. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_ASSASSIN, forward_id);
  8417.  
  8418. new ent = -1
  8419. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "light")) != 0)
  8420. dllfunc(DLLFunc_Use, ent, 0);
  8421. }
  8422. else
  8423. {
  8424. // Show First Zombie HUD notice
  8425. set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  8426. ShowSyncHudMsg(0, g_MsgSync, "%L",LANG_PLAYER, "NOTICE_FIRST", g_playername[forward_id])
  8427.  
  8428. // Mode fully started!
  8429. g_modestarted = true
  8430.  
  8431. // Round start forward
  8432. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_INFECTION, forward_id);
  8433. }
  8434. }
  8435.  
  8436. // Hattrick
  8437. //
  8438. // Start ambience sounds after a mode begins
  8439. // 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) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround))
  8440. if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) ||
  8441. (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) ||
  8442. (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && g_sniperround) ||
  8443. (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && g_assassinround) ||
  8444. (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) ||
  8445. (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && (g_plagueround || g_armageddonround || g_avsround)) ||
  8446. (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_assassinround && !g_sniperround && !g_armageddonround && !g_avsround && !g_survround && !g_swarmround && !g_plagueround))
  8447. {
  8448. remove_task(TASK_AMBIENCESOUNDS)
  8449. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  8450. }
  8451. }
  8452.  
  8453. // Zombie Me Function (player id, infector, turn into a nemesis, silent mode, deathmsg and rewards)
  8454. zombieme(id, infector, nemesis, silentmode, rewards)
  8455. {
  8456. // User infect attempt forward
  8457. ExecuteForward(g_fwUserInfect_attempt, g_fwDummyResult, id, infector, nemesis)
  8458.  
  8459. // One or more plugins blocked the infection. Only allow this after making sure it's
  8460. // not going to leave us with no zombies. Take into account a last player leaving case.
  8461. // BUGFIX: only allow after a mode has started, to prevent blocking first zombie e.g.
  8462. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetZombies() > g_lastplayerleaving)
  8463. return;
  8464.  
  8465. // Pre user infect forward
  8466. ExecuteForward(g_fwUserInfected_pre, g_fwDummyResult, id, infector, nemesis)
  8467.  
  8468. // Show zombie class menu if they haven't chosen any (e.g. just connected)
  8469. if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
  8470. set_task(0.2, "show_menu_zclass", id)
  8471.  
  8472. // Set selected zombie class
  8473. g_zombieclass[id] = g_zombieclassnext[id]
  8474. // If no class selected yet, use the first (default) one
  8475. if (g_zombieclass[id] == ZCLASS_NONE) g_zombieclass[id] = 0
  8476.  
  8477. // Way to go...
  8478. g_zombie[id] = true
  8479. g_nemesis[id] = false
  8480. g_survivor[id] = false
  8481. g_firstzombie[id] = false
  8482.  
  8483. // Hattrick
  8484. //
  8485. g_assassin[id] = false
  8486. g_sniper[id] = false
  8487.  
  8488. // Remove survivor's aura (bugfix)
  8489. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  8490.  
  8491. // Remove spawn protection (bugfix)
  8492. g_nodamage[id] = false
  8493. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  8494.  
  8495. // Reset burning duration counter (bugfix)
  8496. g_burning_duration[id] = 0
  8497.  
  8498. // Show deathmsg and reward infector?
  8499. if (rewards && infector)
  8500. {
  8501. // Send death notice and fix the "dead" attrib on scoreboard
  8502. SendDeathMsg(infector, id)
  8503. FixDeadAttrib(id)
  8504.  
  8505. // Reward frags, deaths, health, and ammo packs
  8506. UpdateFrags(infector, id, get_pcvar_num(cvar_fragsinfect), 1, 1)
  8507. g_ammopacks[infector] += get_pcvar_num(cvar_ammoinfect)
  8508. fm_set_user_health(infector, pev(infector, pev_health) + get_pcvar_num(cvar_zombiebonushp))
  8509. }
  8510.  
  8511. // Cache speed, knockback, and name for player's class
  8512. g_zombie_spd[id] = float(ArrayGetCell(g_zclass_spd, g_zombieclass[id]))
  8513. g_zombie_knockback[id] = Float:ArrayGetCell(g_zclass_kb, g_zombieclass[id])
  8514. ArrayGetString(g_zclass_name, g_zombieclass[id], g_zombie_classname[id], charsmax(g_zombie_classname[]))
  8515.  
  8516. // Set zombie attributes based on the mode
  8517. static sound[64]
  8518. if (!silentmode)
  8519. {
  8520. if (nemesis)
  8521. {
  8522. // Nemesis
  8523. g_nemesis[id] = true
  8524.  
  8525. // Set health [0 = auto]
  8526. if (get_pcvar_num(cvar_nemhp) == 0)
  8527. {
  8528. if (get_pcvar_num(cvar_nembasehp) == 0)
  8529. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, 0) * fnGetAlive())
  8530. else
  8531. fm_set_user_health(id, get_pcvar_num(cvar_nembasehp) * fnGetAlive())
  8532. }
  8533. else
  8534. fm_set_user_health(id, get_pcvar_num(cvar_nemhp))
  8535.  
  8536. // Set gravity, if frozen set the restore gravity value instead
  8537. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_nemgravity))
  8538. else g_frozen_gravity[id] = get_pcvar_float(cvar_nemgravity)
  8539.  
  8540. // Set nemesis maxspeed
  8541. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  8542. }
  8543. else if (fnGetZombies() == 1)
  8544. {
  8545. // First zombie
  8546. g_firstzombie[id] = true
  8547.  
  8548. // Set health
  8549. fm_set_user_health(id, floatround(float(ArrayGetCell(g_zclass_hp, g_zombieclass[id])) * get_pcvar_float(cvar_zombiefirsthp)))
  8550.  
  8551. // Set gravity, if frozen set the restore gravity value instead
  8552. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  8553. else g_frozen_gravity[id] = Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id])
  8554.  
  8555. // Set zombie maxspeed
  8556. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  8557.  
  8558. // Infection sound
  8559. ArrayGetString(zombie_infect, random_num(0, ArraySize(zombie_infect) - 1), sound, charsmax(sound))
  8560. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  8561. }
  8562. else
  8563. {
  8564. // Infected by someone
  8565.  
  8566. // Set health
  8567. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, g_zombieclass[id]))
  8568.  
  8569. // Set gravity, if frozen set the restore gravity value instead
  8570. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  8571. else g_frozen_gravity[id] = Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id])
  8572.  
  8573. // Set zombie maxspeed
  8574. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  8575.  
  8576. // Infection sound
  8577. ArrayGetString(zombie_infect, random_num(0, ArraySize(zombie_infect) - 1), sound, charsmax(sound))
  8578. emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  8579.  
  8580. // Show Infection HUD notice
  8581. set_hudmessage(255, 0, 0, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  8582.  
  8583. if (infector) // infected by someone?
  8584. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT2", g_playername[id], g_playername[infector])
  8585. else
  8586. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT", g_playername[id])
  8587. }
  8588. }
  8589. else
  8590. {
  8591. // Silent mode, no HUD messages, no infection sounds
  8592.  
  8593. // Set health
  8594. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, g_zombieclass[id]))
  8595.  
  8596. // Set gravity, if frozen set the restore gravity value instead
  8597. if (!g_frozen[id]) set_pev(id, pev_gravity, Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id]))
  8598. else g_frozen_gravity[id] = Float:ArrayGetCell(g_zclass_grav, g_zombieclass[id])
  8599.  
  8600. // Set zombie maxspeed
  8601. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  8602. }
  8603.  
  8604. // Remove previous tasks
  8605. remove_task(id+TASK_MODEL)
  8606. remove_task(id+TASK_BLOOD)
  8607. remove_task(id+TASK_AURA)
  8608. remove_task(id+TASK_BURN)
  8609.  
  8610. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  8611. {
  8612. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  8613. write_byte(id)
  8614. write_byte(4)
  8615. message_end()
  8616. }
  8617.  
  8618. // Switch to T
  8619. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T) // need to change team?
  8620. {
  8621. remove_task(id+TASK_TEAM)
  8622. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  8623. fm_user_team_update(id)
  8624. }
  8625.  
  8626. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  8627. {
  8628. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  8629. write_byte(id)
  8630. write_byte(4)
  8631. message_end()
  8632.  
  8633. set_task(0.155, "makevip", id, _, _, "a", 3)
  8634. }
  8635.  
  8636. // Custom models stuff
  8637. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  8638. already_has_model = false
  8639.  
  8640. if (g_handle_models_on_separate_ent)
  8641. {
  8642. // Set the right model
  8643. if (g_nemesis[id])
  8644. {
  8645. iRand = random_num(0, ArraySize(model_nemesis) - 1)
  8646. ArrayGetString(model_nemesis, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8647. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_nemesis, iRand))
  8648. }
  8649. else
  8650. {
  8651. if (get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  8652. {
  8653. iRand = random_num(0, ArraySize(model_admin_zombie) - 1)
  8654. ArrayGetString(model_admin_zombie, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8655. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_zombie, iRand))
  8656. }
  8657. else
  8658. {
  8659. iRand = random_num(ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]), ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]) - 1)
  8660. ArrayGetString(g_zclass_playermodel, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8661. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_zclass_modelindex, iRand))
  8662. }
  8663. }
  8664.  
  8665. // Set model on player model entity
  8666. fm_set_playermodel_ent(id)
  8667.  
  8668. // Nemesis glow / remove glow on player model entity, unless frozen
  8669. if (!g_frozen[id])
  8670. {
  8671. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  8672. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  8673. else
  8674. fm_set_rendering(g_ent_playermodel[id])
  8675. }
  8676. }
  8677. else
  8678. {
  8679. // Get current model for comparing it with the current one
  8680. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  8681.  
  8682. // Set the right model, after checking that we don't already have it
  8683. if (g_nemesis[id])
  8684. {
  8685. size = ArraySize(model_nemesis)
  8686. for (i = 0; i < size; i++)
  8687. {
  8688. ArrayGetString(model_nemesis, i, tempmodel, charsmax(tempmodel))
  8689. if (equal(currentmodel, tempmodel)) already_has_model = true
  8690. }
  8691.  
  8692. if (!already_has_model)
  8693. {
  8694. iRand = random_num(0, size - 1)
  8695. ArrayGetString(model_nemesis, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8696. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_nemesis, iRand))
  8697. }
  8698. }
  8699. else
  8700. {
  8701. if (get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  8702. {
  8703. size = ArraySize(model_admin_zombie)
  8704. for (i = 0; i < size; i++)
  8705. {
  8706. ArrayGetString(model_admin_zombie, i, tempmodel, charsmax(tempmodel))
  8707. if (equal(currentmodel, tempmodel)) already_has_model = true
  8708. }
  8709.  
  8710. if (!already_has_model)
  8711. {
  8712. iRand = random_num(0, size - 1)
  8713. ArrayGetString(model_admin_zombie, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8714. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_zombie, iRand))
  8715. }
  8716. }
  8717. else
  8718. {
  8719. for (i = ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]); i < ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]); i++)
  8720. {
  8721. ArrayGetString(g_zclass_playermodel, i, tempmodel, charsmax(tempmodel))
  8722. if (equal(currentmodel, tempmodel)) already_has_model = true
  8723. }
  8724.  
  8725. if (!already_has_model)
  8726. {
  8727. iRand = random_num(ArrayGetCell(g_zclass_modelsstart, g_zombieclass[id]), ArrayGetCell(g_zclass_modelsend, g_zombieclass[id]) - 1)
  8728. ArrayGetString(g_zclass_playermodel, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8729. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_zclass_modelindex, iRand))
  8730. }
  8731. }
  8732. }
  8733.  
  8734. // Need to change the model?
  8735. if (!already_has_model)
  8736. {
  8737. // An additional delay is offset at round start
  8738. // since SVC_BAD is more likely to be triggered there
  8739. if (g_newround)
  8740. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  8741. else
  8742. fm_user_model_update(id+TASK_MODEL)
  8743. }
  8744.  
  8745. // Nemesis glow / remove glow, unless frozen
  8746. if (!g_frozen[id])
  8747. {
  8748. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  8749. fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  8750. else
  8751. fm_set_rendering(id)
  8752. }
  8753. }
  8754.  
  8755. // Remove any zoom (bugfix)
  8756. cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  8757.  
  8758. // Remove armor
  8759. cs_set_user_armor(id, 0, CS_ARMOR_NONE)
  8760.  
  8761. // Drop weapons when infected
  8762. drop_weapons(id, 1)
  8763. drop_weapons(id, 2)
  8764.  
  8765. // Strip zombies from guns and give them a knife
  8766. fm_strip_user_weapons(id)
  8767. fm_give_item(id, "weapon_knife")
  8768.  
  8769. // Fancy effects
  8770. infection_effects(id)
  8771.  
  8772. // Nemesis aura task
  8773. if (g_nemesis[id] && get_pcvar_num(cvar_nemaura))
  8774. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  8775.  
  8776. // Remove CS nightvision if player owns one (bugfix)
  8777. if (cs_get_user_nvg(id))
  8778. {
  8779. cs_set_user_nvg(id, 0)
  8780. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  8781. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  8782. }
  8783.  
  8784. // Give Zombies Night Vision?
  8785. if (get_pcvar_num(cvar_nvggive))
  8786. {
  8787. g_nvision[id] = true
  8788.  
  8789. if (!g_isbot[id])
  8790. {
  8791. // Turn on Night Vision automatically?
  8792. if (get_pcvar_num(cvar_nvggive) == 1)
  8793. {
  8794. g_nvisionenabled[id] = true
  8795.  
  8796. // Custom nvg?
  8797. if (get_pcvar_num(cvar_customnvg))
  8798. {
  8799. remove_task(id+TASK_NVISION)
  8800. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  8801. }
  8802. else
  8803. set_user_gnvision(id, 1)
  8804. }
  8805. // Turn off nightvision when infected (bugfix)
  8806. else if (g_nvisionenabled[id])
  8807. {
  8808. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  8809. else set_user_gnvision(id, 0)
  8810. g_nvisionenabled[id] = false
  8811. }
  8812. }
  8813. else
  8814. cs_set_user_nvg(id, 1); // turn on NVG for bots
  8815. }
  8816. // Disable nightvision when infected (bugfix)
  8817. else if (g_nvision[id])
  8818. {
  8819. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  8820. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  8821. g_nvision[id] = false
  8822. g_nvisionenabled[id] = false
  8823. }
  8824.  
  8825. // Set custom FOV?
  8826. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  8827. {
  8828. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  8829. write_byte(get_pcvar_num(cvar_zombiefov)) // fov angle
  8830. message_end()
  8831. }
  8832.  
  8833. // Call the bloody task
  8834. if (!g_nemesis[id] && get_pcvar_num(cvar_zombiebleeding))
  8835. set_task(0.7, "make_blood", id+TASK_BLOOD, _, _, "b")
  8836.  
  8837. // Idle sounds task
  8838. if (!g_nemesis[id])
  8839. set_task(random_float(50.0, 70.0), "zombie_play_idle", id+TASK_BLOOD, _, _, "b")
  8840.  
  8841. // Turn off zombie's flashlight
  8842. turn_off_flashlight(id)
  8843.  
  8844. // Post user infect forward
  8845. ExecuteForward(g_fwUserInfected_post, g_fwDummyResult, id, infector, nemesis)
  8846.  
  8847. // Last Zombie Check
  8848. fnCheckLastZombie()
  8849. }
  8850.  
  8851. // Hattrick
  8852. //
  8853. // Zombie Me Function (player id, infector, turn into a nemesis, silent mode, deathmsg and rewards)
  8854. zombieme_assassin(id, infector, rewards)
  8855. {
  8856. // User infect attempt forward
  8857. ExecuteForward(g_fwUserInfect_attempt, g_fwDummyResult, id, infector, 1 /* nemesis */)
  8858.  
  8859. // One or more plugins blocked the infection. Only allow this after making sure it's
  8860. // not going to leave us with no zombies. Take into account a last player leaving case.
  8861. // BUGFIX: only allow after a mode has started, to prevent blocking first zombie e.g.
  8862. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetZombies() > g_lastplayerleaving)
  8863. return;
  8864.  
  8865. // Pre user infect forward
  8866. ExecuteForward(g_fwUserInfected_pre, g_fwDummyResult, id, infector, 1 /* nemesis */)
  8867.  
  8868. // Show zombie class menu if they haven't chosen any (e.g. just connected)
  8869. if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
  8870. set_task(0.2, "show_menu_zclass", id)
  8871.  
  8872. // Set selected zombie class
  8873. g_zombieclass[id] = g_zombieclassnext[id]
  8874. // If no class selected yet, use the first (default) one
  8875. if (g_zombieclass[id] == ZCLASS_NONE) g_zombieclass[id] = 0
  8876.  
  8877. // Way to go...
  8878. g_zombie[id] = true
  8879. g_nemesis[id] = false
  8880. g_sniper[id] = false
  8881. g_assassin[id] = false
  8882. g_survivor[id] = false
  8883. g_firstzombie[id] = false
  8884.  
  8885. // Remove survivor's aura (bugfix)
  8886. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  8887.  
  8888. // Remove spawn protection (bugfix)
  8889. g_nodamage[id] = false
  8890. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  8891.  
  8892. // Reset burning duration counter (bugfix)
  8893. g_burning_duration[id] = 0
  8894.  
  8895. // Show deathmsg and reward infector?
  8896. if (rewards && infector)
  8897. {
  8898. // Send death notice and fix the "dead" attrib on scoreboard
  8899. SendDeathMsg(infector, id)
  8900. FixDeadAttrib(id)
  8901.  
  8902. // Reward frags, deaths, health, and ammo packs
  8903. UpdateFrags(infector, id, get_pcvar_num(cvar_fragsinfect), 1, 1)
  8904. g_ammopacks[infector] += get_pcvar_num(cvar_ammoinfect)
  8905. fm_set_user_health(infector, pev(infector, pev_health) + get_pcvar_num(cvar_zombiebonushp))
  8906. }
  8907.  
  8908. // Cache speed, knockback, and name for player's class
  8909. g_zombie_spd[id] = float(ArrayGetCell(g_zclass_spd, g_zombieclass[id]))
  8910. g_zombie_knockback[id] = Float:ArrayGetCell(g_zclass_kb, g_zombieclass[id])
  8911. ArrayGetString(g_zclass_name, g_zombieclass[id], g_zombie_classname[id], charsmax(g_zombie_classname[]))
  8912.  
  8913. // Nemesis
  8914. g_assassin[id] = true
  8915.  
  8916. // Set health [0 = auto]
  8917. if (get_pcvar_num(cvar_assassinhp) == 0)
  8918. {
  8919. if (get_pcvar_num(cvar_assassinbasehp) == 0)
  8920. fm_set_user_health(id, ArrayGetCell(g_zclass_hp, 0) * fnGetAlive())
  8921. else
  8922. fm_set_user_health(id, get_pcvar_num(cvar_assassinbasehp) * fnGetAlive())
  8923. }
  8924. else
  8925. fm_set_user_health(id, get_pcvar_num(cvar_assassinhp))
  8926.  
  8927. // Set gravity, if frozen set the restore gravity value instead
  8928. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_assassingravity))
  8929. else g_frozen_gravity[id] = get_pcvar_float(cvar_assassingravity)
  8930.  
  8931. // Set nemesis maxspeed
  8932. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  8933.  
  8934. // Remove previous tasks
  8935. remove_task(id+TASK_MODEL)
  8936. remove_task(id+TASK_BLOOD)
  8937. remove_task(id+TASK_AURA)
  8938. remove_task(id+TASK_BURN)
  8939.  
  8940. // Switch to T
  8941. if (fm_cs_get_user_team(id) != FM_CS_TEAM_T) // need to change team?
  8942. {
  8943. remove_task(id+TASK_TEAM)
  8944. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  8945. fm_user_team_update(id)
  8946. }
  8947.  
  8948. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  8949. {
  8950. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  8951. write_byte(id)
  8952. write_byte(4)
  8953. message_end()
  8954.  
  8955. set_task(0.155, "makevip", id, _, _, "a", 3)
  8956. }
  8957.  
  8958. // Custom models stuff
  8959. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  8960. already_has_model = false
  8961.  
  8962. if (g_handle_models_on_separate_ent)
  8963. {
  8964. iRand = random_num(0, ArraySize(model_assassin) - 1)
  8965. ArrayGetString(model_assassin, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8966. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_assassin, iRand))
  8967.  
  8968. // Set model on player model entity
  8969. fm_set_playermodel_ent(id)
  8970.  
  8971. // Nemesis glow / remove glow on player model entity, unless frozen
  8972. if (!g_frozen[id])
  8973. {
  8974. if (get_pcvar_num(cvar_assassinglow))
  8975. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  8976. else
  8977. fm_set_rendering(g_ent_playermodel[id])
  8978. }
  8979. }
  8980. else
  8981. {
  8982. // Get current model for comparing it with the current one
  8983. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  8984.  
  8985. size = ArraySize(model_assassin)
  8986. for (i = 0; i < size; i++)
  8987. {
  8988. ArrayGetString(model_assassin, i, tempmodel, charsmax(tempmodel))
  8989. if (equal(currentmodel, tempmodel)) already_has_model = true
  8990. }
  8991.  
  8992. if (!already_has_model)
  8993. {
  8994. iRand = random_num(0, size - 1)
  8995. ArrayGetString(model_assassin, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  8996. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_assassin, iRand))
  8997. }
  8998.  
  8999. // Need to change the model?
  9000. if (!already_has_model)
  9001. {
  9002. // An additional delay is offset at round start
  9003. // since SVC_BAD is more likely to be triggered there
  9004. if (g_newround)
  9005. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  9006. else
  9007. fm_user_model_update(id+TASK_MODEL)
  9008. }
  9009.  
  9010. // Nemesis glow / remove glow, unless frozen
  9011. if (!g_frozen[id])
  9012. {
  9013. if (get_pcvar_num(cvar_assassinglow))
  9014. fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  9015. else
  9016. fm_set_rendering(id)
  9017. }
  9018. }
  9019.  
  9020. // Remove any zoom (bugfix)
  9021. cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  9022.  
  9023. // Remove armor
  9024. cs_set_user_armor(id, 0, CS_ARMOR_NONE)
  9025.  
  9026. // Drop weapons when infected
  9027. drop_weapons(id, 1)
  9028. drop_weapons(id, 2)
  9029.  
  9030. // Strip zombies from guns and give them a knife
  9031. fm_strip_user_weapons(id)
  9032. fm_give_item(id, "weapon_knife")
  9033.  
  9034. // Fancy effects
  9035. infection_effects(id)
  9036.  
  9037. // Nemesis aura task
  9038. if (get_pcvar_num(cvar_assassinaura))
  9039. set_task(0.1, "zombie_aura", id+TASK_AURA, _, _, "b")
  9040.  
  9041. // Remove CS nightvision if player owns one (bugfix)
  9042. if (cs_get_user_nvg(id))
  9043. {
  9044. cs_set_user_nvg(id, 0)
  9045. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9046. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9047. }
  9048.  
  9049. // Give Zombies Night Vision?
  9050. if (get_pcvar_num(cvar_nvggive))
  9051. {
  9052. g_nvision[id] = true
  9053.  
  9054. if (!g_isbot[id])
  9055. {
  9056. // Turn on Night Vision automatically?
  9057. if (get_pcvar_num(cvar_nvggive) == 1)
  9058. {
  9059. g_nvisionenabled[id] = true
  9060.  
  9061. // Custom nvg?
  9062. if (get_pcvar_num(cvar_customnvg))
  9063. {
  9064. remove_task(id+TASK_NVISION)
  9065. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  9066. }
  9067. else
  9068. set_user_gnvision(id, 1)
  9069. }
  9070. // Turn off nightvision when infected (bugfix)
  9071. else if (g_nvisionenabled[id])
  9072. {
  9073. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9074. else set_user_gnvision(id, 0)
  9075. g_nvisionenabled[id] = false
  9076. }
  9077. }
  9078. else
  9079. cs_set_user_nvg(id, 1); // turn on NVG for bots
  9080. }
  9081. // Disable nightvision when infected (bugfix)
  9082. else if (g_nvision[id])
  9083. {
  9084. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9085. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9086. g_nvision[id] = false
  9087. g_nvisionenabled[id] = false
  9088. }
  9089.  
  9090. // Set custom FOV?
  9091. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  9092. {
  9093. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  9094. write_byte(get_pcvar_num(cvar_zombiefov)) // fov angle
  9095. message_end()
  9096. }
  9097.  
  9098. // Turn off zombie's flashlight
  9099. turn_off_flashlight(id)
  9100.  
  9101. // Post user infect forward
  9102. ExecuteForward(g_fwUserInfected_post, g_fwDummyResult, id, infector, 1 /* nemesis */)
  9103.  
  9104. // Last Zombie Check
  9105. fnCheckLastZombie()
  9106. }
  9107.  
  9108. // Function Human Me (player id, turn into a survivor, silent mode)
  9109. humanme(id, survivor, silentmode)
  9110. {
  9111. // User humanize attempt forward
  9112. ExecuteForward(g_fwUserHumanize_attempt, g_fwDummyResult, id, survivor)
  9113.  
  9114. // One or more plugins blocked the "humanization". Only allow this after making sure it's
  9115. // not going to leave us with no humans. Take into account a last player leaving case.
  9116. // BUGFIX: only allow after a mode has started, to prevent blocking first survivor e.g.
  9117. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetHumans() > g_lastplayerleaving)
  9118. return;
  9119.  
  9120. // Pre user humanize forward
  9121. ExecuteForward(g_fwUserHumanized_pre, g_fwDummyResult, id, survivor)
  9122.  
  9123. // Remove previous tasks
  9124. remove_task(id+TASK_MODEL)
  9125. remove_task(id+TASK_BLOOD)
  9126. remove_task(id+TASK_AURA)
  9127. remove_task(id+TASK_BURN)
  9128. remove_task(id+TASK_NVISION)
  9129.  
  9130. // Reset some vars
  9131. g_zombie[id] = false
  9132. g_nemesis[id] = false
  9133. g_survivor[id] = false
  9134. g_firstzombie[id] = false
  9135. g_canbuy[id] = true
  9136. g_buytime[id] = get_gametime()
  9137.  
  9138. // Hattrick
  9139. //
  9140. g_assassin[id] = false
  9141. g_sniper[id] = false
  9142.  
  9143. // Remove survivor's aura (bugfix)
  9144. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  9145.  
  9146. // Remove spawn protection (bugfix)
  9147. g_nodamage[id] = false
  9148. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  9149.  
  9150. // Reset burning duration counter (bugfix)
  9151. g_burning_duration[id] = 0
  9152.  
  9153. // Remove CS nightvision if player owns one (bugfix)
  9154. if (cs_get_user_nvg(id))
  9155. {
  9156. cs_set_user_nvg(id, 0)
  9157. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9158. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9159. }
  9160.  
  9161. // Drop previous weapons
  9162. drop_weapons(id, 1)
  9163. drop_weapons(id, 2)
  9164.  
  9165. // Strip off from weapons
  9166. fm_strip_user_weapons(id)
  9167. fm_give_item(id, "weapon_knife")
  9168.  
  9169. // Set human attributes based on the mode
  9170. if (survivor)
  9171. {
  9172. // Survivor
  9173. g_survivor[id] = true
  9174.  
  9175. // Set Health [0 = auto]
  9176. if (get_pcvar_num(cvar_survhp) == 0)
  9177. {
  9178. if (get_pcvar_num(cvar_survbasehp) == 0)
  9179. fm_set_user_health(id, get_pcvar_num(cvar_humanhp) * fnGetAlive())
  9180. else
  9181. fm_set_user_health(id, get_pcvar_num(cvar_survbasehp) * fnGetAlive())
  9182. }
  9183. else
  9184. fm_set_user_health(id, get_pcvar_num(cvar_survhp))
  9185.  
  9186. // Set gravity, if frozen set the restore gravity value instead
  9187. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_survgravity))
  9188. else g_frozen_gravity[id] = get_pcvar_float(cvar_survgravity)
  9189.  
  9190. // Set survivor maxspeed
  9191. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  9192.  
  9193. // Hattrick
  9194. //
  9195. // Give survivor his own weapon
  9196. static survweapon[32]
  9197. //get_pcvar_string(cvar_survweapon, survweapon, charsmax(survweapon))
  9198. copy(survweapon, charsmax(survweapon), "weapon_ak47")
  9199. fm_give_item(id, survweapon)
  9200. 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)])
  9201. copy(survweapon, charsmax(survweapon), "weapon_xm1014")
  9202. fm_give_item(id, survweapon)
  9203. 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)])
  9204.  
  9205. // Turn off his flashlight
  9206. turn_off_flashlight(id)
  9207.  
  9208. // Give the survivor a bright light
  9209. if (get_pcvar_num(cvar_survaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  9210.  
  9211. // Survivor bots will also need nightvision to see in the dark
  9212. if (g_isbot[id])
  9213. {
  9214. g_nvision[id] = true
  9215. cs_set_user_nvg(id, 1)
  9216. }
  9217. }
  9218. else
  9219. {
  9220. // Human taking an antidote
  9221.  
  9222. // Set health
  9223. fm_set_user_health(id, get_pcvar_num(cvar_humanhp))
  9224.  
  9225. // Set gravity, if frozen set the restore gravity value instead
  9226. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity))
  9227. else g_frozen_gravity[id] = get_pcvar_float(cvar_humangravity)
  9228.  
  9229. // Set human maxspeed
  9230. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  9231.  
  9232. // Show custom buy menu?
  9233. if (get_pcvar_num(cvar_buycustom))
  9234. set_task(0.2, "show_menu_buy1", id+TASK_SPAWN)
  9235.  
  9236. // Silent mode = no HUD messages, no antidote sound
  9237. if (!silentmode)
  9238. {
  9239. // Antidote sound
  9240. static sound[64]
  9241. ArrayGetString(sound_antidote, random_num(0, ArraySize(sound_antidote) - 1), sound, charsmax(sound))
  9242. emit_sound(id, CHAN_ITEM, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  9243.  
  9244. // Show Antidote HUD notice
  9245. set_hudmessage(0, 0, 255, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  9246. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_ANTIDOTE", g_playername[id])
  9247. }
  9248. }
  9249.  
  9250. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  9251. {
  9252. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  9253. write_byte(id)
  9254. write_byte(4)
  9255. message_end()
  9256.  
  9257. set_task(0.155, "makevip", id, _, _, "a", 3)
  9258. }
  9259.  
  9260. // Switch to CT
  9261. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  9262. {
  9263. remove_task(id+TASK_TEAM)
  9264. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  9265. fm_user_team_update(id)
  9266. }
  9267.  
  9268. // Custom models stuff
  9269. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  9270. already_has_model = false
  9271.  
  9272. if (g_handle_models_on_separate_ent)
  9273. {
  9274. // Set the right model
  9275. if (g_survivor[id])
  9276. {
  9277. iRand = random_num(0, ArraySize(model_survivor) - 1)
  9278. ArrayGetString(model_survivor, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9279. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_survivor, iRand))
  9280. }
  9281. else
  9282. {
  9283. if (g_vip[id] && containi(g_vip_flags[id], "M") != -1)
  9284. {
  9285. iRand = random_num(0, ArraySize(model_vip) - 1)
  9286. ArrayGetString(model_vip, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9287. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip, iRand))
  9288. }
  9289. else if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  9290. {
  9291. iRand = random_num(0, ArraySize(model_admin_human) - 1)
  9292. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9293. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  9294. }
  9295. else
  9296. {
  9297. iRand = random_num(0, ArraySize(model_human) - 1)
  9298. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9299. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  9300. }
  9301. }
  9302.  
  9303. // Set model on player model entity
  9304. fm_set_playermodel_ent(id)
  9305.  
  9306. // Set survivor glow / remove glow on player model entity, unless frozen
  9307. if (!g_frozen[id])
  9308. {
  9309. if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  9310. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  9311. else
  9312. fm_set_rendering(g_ent_playermodel[id])
  9313. }
  9314. }
  9315. else
  9316. {
  9317. // Get current model for comparing it with the current one
  9318. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  9319.  
  9320. // Set the right model, after checking that we don't already have it
  9321. if (g_survivor[id])
  9322. {
  9323. size = ArraySize(model_survivor)
  9324. for (i = 0; i < size; i++)
  9325. {
  9326. ArrayGetString(model_survivor, i, tempmodel, charsmax(tempmodel))
  9327. if (equal(currentmodel, tempmodel)) already_has_model = true
  9328. }
  9329.  
  9330. if (!already_has_model)
  9331. {
  9332. iRand = random_num(0, size - 1)
  9333. ArrayGetString(model_survivor, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9334. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_survivor, iRand))
  9335. }
  9336. }
  9337. else
  9338. {
  9339. if (g_vip[id] && containi(g_vip_flags[id], "M") != -1)
  9340. {
  9341. size = ArraySize(model_vip)
  9342. for (i = 0; i < size; i++)
  9343. {
  9344. ArrayGetString(model_vip, i, tempmodel, charsmax(tempmodel))
  9345. if (equal(currentmodel, tempmodel)) already_has_model = true
  9346. }
  9347.  
  9348. if (!already_has_model)
  9349. {
  9350. iRand = random_num(0, size - 1)
  9351. ArrayGetString(model_vip, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9352. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip, iRand))
  9353. }
  9354. }
  9355. else if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
  9356. {
  9357. size = ArraySize(model_admin_human)
  9358. for (i = 0; i < size; i++)
  9359. {
  9360. ArrayGetString(model_admin_human, i, tempmodel, charsmax(tempmodel))
  9361. if (equal(currentmodel, tempmodel)) already_has_model = true
  9362. }
  9363.  
  9364. if (!already_has_model)
  9365. {
  9366. iRand = random_num(0, size - 1)
  9367. ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9368. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
  9369. }
  9370. }
  9371. else
  9372. {
  9373. size = ArraySize(model_human)
  9374. for (i = 0; i < size; i++)
  9375. {
  9376. ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
  9377. if (equal(currentmodel, tempmodel)) already_has_model = true
  9378. }
  9379.  
  9380. if (!already_has_model)
  9381. {
  9382. iRand = random_num(0, size - 1)
  9383. ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9384. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
  9385. }
  9386. }
  9387. }
  9388.  
  9389. // Need to change the model?
  9390. if (!already_has_model)
  9391. {
  9392. // An additional delay is offset at round start
  9393. // since SVC_BAD is more likely to be triggered there
  9394. if (g_newround)
  9395. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  9396. else
  9397. fm_user_model_update(id+TASK_MODEL)
  9398. }
  9399.  
  9400. // Set survivor glow / remove glow, unless frozen
  9401. if (!g_frozen[id])
  9402. {
  9403. if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  9404. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  9405. else
  9406. fm_set_rendering(id)
  9407. }
  9408. }
  9409.  
  9410. // Restore FOV?
  9411. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  9412. {
  9413. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  9414. write_byte(90) // angle
  9415. message_end()
  9416. }
  9417.  
  9418. // Disable nightvision when turning into human/survivor (bugfix)
  9419. if (g_nvision[id])
  9420. {
  9421. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9422. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9423. g_nvision[id] = false
  9424. g_nvisionenabled[id] = false
  9425. }
  9426.  
  9427. // Post user humanize forward
  9428. ExecuteForward(g_fwUserHumanized_post, g_fwDummyResult, id, survivor)
  9429.  
  9430. // Last Zombie Check
  9431. fnCheckLastZombie()
  9432. }
  9433.  
  9434. // Hattrick
  9435. //
  9436. // Function Human Me (player id, turn into a survivor, silent mode)
  9437. humanme_sniper(id)
  9438. {
  9439. // User humanize attempt forward
  9440. ExecuteForward(g_fwUserHumanize_attempt, g_fwDummyResult, id, 1 /* survivor */)
  9441.  
  9442. // One or more plugins blocked the "humanization". Only allow this after making sure it's
  9443. // not going to leave us with no humans. Take into account a last player leaving case.
  9444. // BUGFIX: only allow after a mode has started, to prevent blocking first survivor e.g.
  9445. if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetHumans() > g_lastplayerleaving)
  9446. return;
  9447.  
  9448. // Pre user humanize forward
  9449. ExecuteForward(g_fwUserHumanized_pre, g_fwDummyResult, id, 1 /* survivor */)
  9450.  
  9451. // Remove previous tasks
  9452. remove_task(id+TASK_MODEL)
  9453. remove_task(id+TASK_BLOOD)
  9454. remove_task(id+TASK_AURA)
  9455. remove_task(id+TASK_BURN)
  9456. remove_task(id+TASK_NVISION)
  9457.  
  9458. // Reset some vars
  9459. g_zombie[id] = false
  9460. g_nemesis[id] = false
  9461. g_survivor[id] = false
  9462. g_firstzombie[id] = false
  9463. g_assassin[id] = false
  9464. g_sniper[id] = false
  9465. g_canbuy[id] = true
  9466. g_buytime[id] = get_gametime()
  9467.  
  9468. // Remove survivor's aura (bugfix)
  9469. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  9470.  
  9471. // Remove spawn protection (bugfix)
  9472. g_nodamage[id] = false
  9473. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  9474.  
  9475. // Reset burning duration counter (bugfix)
  9476. g_burning_duration[id] = 0
  9477.  
  9478. // Remove CS nightvision if player owns one (bugfix)
  9479. if (cs_get_user_nvg(id))
  9480. {
  9481. cs_set_user_nvg(id, 0)
  9482. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9483. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9484. }
  9485.  
  9486. // Drop previous weapons
  9487. drop_weapons(id, 1)
  9488. drop_weapons(id, 2)
  9489.  
  9490. // Strip off from weapons
  9491. fm_strip_user_weapons(id)
  9492. fm_give_item(id, "weapon_knife")
  9493.  
  9494. // Survivor
  9495. g_sniper[id] = true
  9496.  
  9497. // Set Health [0 = auto]
  9498. if (get_pcvar_num(cvar_sniperhp) == 0)
  9499. {
  9500. if (get_pcvar_num(cvar_sniperbasehp) == 0)
  9501. fm_set_user_health(id, get_pcvar_num(cvar_humanhp) * fnGetAlive())
  9502. else
  9503. fm_set_user_health(id, get_pcvar_num(cvar_sniperbasehp) * fnGetAlive())
  9504. }
  9505. else
  9506. fm_set_user_health(id, get_pcvar_num(cvar_sniperhp))
  9507.  
  9508. // Set gravity, if frozen set the restore gravity value instead
  9509. if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_snipergravity))
  9510. else g_frozen_gravity[id] = get_pcvar_float(cvar_snipergravity)
  9511.  
  9512. // Set survivor maxspeed
  9513. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  9514.  
  9515. // Give survivor his own weapon
  9516. new survweapon[32];
  9517.  
  9518. copy(survweapon, charsmax(survweapon), "weapon_awp")
  9519. fm_give_item(id, survweapon)
  9520. 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)])
  9521.  
  9522. // Turn off his flashlight
  9523. turn_off_flashlight(id)
  9524.  
  9525. // Give the survivor a bright light
  9526. if (get_pcvar_num(cvar_sniperaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  9527.  
  9528. // Survivor bots will also need nightvision to see in the dark
  9529. if (g_isbot[id])
  9530. {
  9531. g_nvision[id] = true
  9532. cs_set_user_nvg(id, 1)
  9533. }
  9534.  
  9535. // Switch to CT
  9536. if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
  9537. {
  9538. remove_task(id+TASK_TEAM)
  9539. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  9540. fm_user_team_update(id)
  9541. }
  9542.  
  9543. if(g_vip[id] && containi(g_vip_flags[id], "S") != -1)
  9544. {
  9545. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  9546. write_byte(id)
  9547. write_byte(4)
  9548. message_end()
  9549.  
  9550. set_task(0.155, "makevip", id, _, _, "a", 3)
  9551. }
  9552.  
  9553. // Custom models stuff
  9554. static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
  9555. already_has_model = false
  9556.  
  9557. if (g_handle_models_on_separate_ent)
  9558. {
  9559. iRand = random_num(0, ArraySize(model_sniper) - 1)
  9560. ArrayGetString(model_sniper, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9561. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_sniper, iRand))
  9562.  
  9563. // Set model on player model entity
  9564. fm_set_playermodel_ent(id)
  9565.  
  9566. // Set survivor glow / remove glow on player model entity, unless frozen
  9567. if (!g_frozen[id])
  9568. {
  9569. if (get_pcvar_num(cvar_sniperglow))
  9570. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 120, 200, kRenderNormal, 25)
  9571. else
  9572. fm_set_rendering(g_ent_playermodel[id])
  9573. }
  9574. }
  9575. else
  9576. {
  9577. // Get current model for comparing it with the current one
  9578. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  9579.  
  9580. // Set the right model, after checking that we don't already have it
  9581. size = ArraySize(model_sniper)
  9582.  
  9583. for (i = 0; i < size; i++)
  9584. {
  9585. ArrayGetString(model_sniper, i, tempmodel, charsmax(tempmodel))
  9586. if (equal(currentmodel, tempmodel)) already_has_model = true
  9587. }
  9588.  
  9589. if (!already_has_model)
  9590. {
  9591. iRand = random_num(0, size - 1)
  9592. ArrayGetString(model_sniper, iRand, g_playermodel[id], charsmax(g_playermodel[]))
  9593. if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_sniper, iRand))
  9594. }
  9595.  
  9596. // Need to change the model?
  9597. if (!already_has_model)
  9598. {
  9599. // An additional delay is offset at round start
  9600. // since SVC_BAD is more likely to be triggered there
  9601. if (g_newround)
  9602. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  9603. else
  9604. fm_user_model_update(id+TASK_MODEL)
  9605. }
  9606.  
  9607. // Set survivor glow / remove glow, unless frozen
  9608. if (!g_frozen[id])
  9609. {
  9610. if (get_pcvar_num(cvar_sniperglow))
  9611. fm_set_rendering(id, kRenderFxGlowShell, 0, 120, 200, kRenderNormal, 25)
  9612. else
  9613. fm_set_rendering(id)
  9614. }
  9615. }
  9616.  
  9617. // Restore FOV?
  9618. if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
  9619. {
  9620. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  9621. write_byte(90) // angle
  9622. message_end()
  9623. }
  9624.  
  9625. // Disable nightvision when turning into human/survivor (bugfix)
  9626. if (g_nvision[id])
  9627. {
  9628. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  9629. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  9630. g_nvision[id] = false
  9631. g_nvisionenabled[id] = false
  9632. }
  9633.  
  9634. // Post user humanize forward
  9635. ExecuteForward(g_fwUserHumanized_post, g_fwDummyResult, id, 1 /*survivor*/)
  9636.  
  9637. // Last Zombie Check
  9638. fnCheckLastZombie()
  9639. }
  9640.  
  9641. /*================================================================================
  9642. [Other Functions and Tasks]
  9643. =================================================================================*/
  9644.  
  9645. public cache_cvars()
  9646. {
  9647. g_cached_zombiesilent = get_pcvar_num(cvar_zombiesilent)
  9648. g_cached_customflash = get_pcvar_num(cvar_customflash)
  9649. g_cached_leapzombies = get_pcvar_num(cvar_leapzombies)
  9650. g_cached_leapzombiescooldown = get_pcvar_float(cvar_leapzombiescooldown)
  9651. g_cached_leapnemesis = get_pcvar_num(cvar_leapnemesis)
  9652. g_cached_leapnemesiscooldown = get_pcvar_float(cvar_leapnemesiscooldown)
  9653. g_cached_leapsurvivor = get_pcvar_num(cvar_leapsurvivor)
  9654. g_cached_leapsurvivorcooldown = get_pcvar_float(cvar_leapsurvivorcooldown)
  9655.  
  9656. // Hattrick
  9657. //
  9658. g_cached_leapassassin = get_pcvar_num(cvar_leapassassin)
  9659. g_cached_leapassassincooldown = get_pcvar_float(cvar_leapassassincooldown)
  9660. g_cached_leapsniper = get_pcvar_num(cvar_leapsniper)
  9661. g_cached_leapsnipercooldown = get_pcvar_float(cvar_leapsnipercooldown)
  9662.  
  9663. g_cached_buytime = get_pcvar_float(cvar_buyzonetime)
  9664. }
  9665.  
  9666. load_customization_from_files()
  9667. {
  9668. // Build customization file path
  9669. new path[64]
  9670. get_configsdir(path, charsmax(path))
  9671. format(path, charsmax(path), "%s/%s", path, ZP_CUSTOMIZATION_FILE)
  9672.  
  9673. // File not present
  9674. if (!file_exists(path))
  9675. {
  9676. new error[100]
  9677. formatex(error, charsmax(error), "Cannot load customization file %s!", path)
  9678. set_fail_state(error)
  9679. return;
  9680. }
  9681.  
  9682. // Set up some vars to hold parsing info
  9683. new linedata[1024], key[64], value[960], section, teams
  9684.  
  9685. // Open customization file for reading
  9686. new file = fopen(path, "rt")
  9687.  
  9688. while (file && !feof(file))
  9689. {
  9690. // Read one line at a time
  9691. fgets(file, linedata, charsmax(linedata))
  9692.  
  9693. // Replace newlines with a null character to prevent headaches
  9694. replace(linedata, charsmax(linedata), "^n", "")
  9695.  
  9696. // Blank line or comment
  9697. if (!linedata[0] || linedata[0] == ';') continue;
  9698.  
  9699. // New section starting
  9700. if (linedata[0] == '[')
  9701. {
  9702. section++
  9703. continue;
  9704. }
  9705.  
  9706. // Get key and value(s)
  9707. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  9708.  
  9709. // Trim spaces
  9710. trim(key)
  9711. trim(value)
  9712.  
  9713. switch (section)
  9714. {
  9715. case SECTION_ACCESS_FLAGS:
  9716. {
  9717. if (equal(key, "ENABLE/DISABLE MOD"))
  9718. g_access_flag[ACCESS_ENABLE_MOD] = read_flags(value)
  9719. else if (equal(key, "ADMIN MENU"))
  9720. g_access_flag[ACCESS_ADMIN_MENU] = read_flags(value)
  9721. else if (equal(key, "START MODE INFECTION"))
  9722. g_access_flag[ACCESS_MODE_INFECTION] = read_flags(value)
  9723. else if (equal(key, "START MODE NEMESIS"))
  9724. g_access_flag[ACCESS_MODE_NEMESIS] = read_flags(value)
  9725. else if (equal(key, "START MODE SURVIVOR"))
  9726. g_access_flag[ACCESS_MODE_SURVIVOR] = read_flags(value)
  9727.  
  9728. // Hattrick
  9729. //
  9730. else if (equal(key, "START MODE SNIPER"))
  9731. g_access_flag[ACCESS_MODE_SNIPER] = read_flags(value);
  9732.  
  9733. else if (equal(key, "START MODE ASSASSIN"))
  9734. g_access_flag[ACCESS_MODE_ASSASSIN] = read_flags(value);
  9735.  
  9736. else if (equal(key, "START MODE ARMAGEDDON"))
  9737. g_access_flag[ACCESS_MODE_ARMAGEDDON] = read_flags(value);
  9738. else if (equal(key, "START MODE AVS"))
  9739. g_access_flag[ACCESS_MODE_AVS] = read_flags(value);
  9740.  
  9741. else if (equal(key, "START MODE SWARM"))
  9742. g_access_flag[ACCESS_MODE_SWARM] = read_flags(value)
  9743. else if (equal(key, "START MODE MULTI"))
  9744. g_access_flag[ACCESS_MODE_MULTI] = read_flags(value)
  9745. else if (equal(key, "START MODE PLAGUE"))
  9746. g_access_flag[ACCESS_MODE_PLAGUE] = read_flags(value)
  9747. else if (equal(key, "MAKE ZOMBIE"))
  9748. g_access_flag[ACCESS_MAKE_ZOMBIE] = read_flags(value)
  9749. else if (equal(key, "MAKE HUMAN"))
  9750. g_access_flag[ACCESS_MAKE_HUMAN] = read_flags(value)
  9751. else if (equal(key, "MAKE NEMESIS"))
  9752. g_access_flag[ACCESS_MAKE_NEMESIS] = read_flags(value)
  9753. else if (equal(key, "GIVE POINTS"))
  9754. g_access_flag[ACCESS_GIVE_POINTS] = read_flags(value)
  9755. else if (equal(key, "GIVE AMMO"))
  9756. g_access_flag[ACCESS_GIVE_AMMO] = read_flags(value)
  9757.  
  9758. // Hattrick
  9759. //
  9760. else if (equal(key, "MAKE ASSASSIN"))
  9761. g_access_flag[ACCESS_MAKE_ASSASSIN] = read_flags(value)
  9762.  
  9763. else if (equal(key, "MAKE SNIPER"))
  9764. g_access_flag[ACCESS_MAKE_SNIPER] = read_flags(value)
  9765.  
  9766. else if (equal(key, "MAKE SURVIVOR"))
  9767. g_access_flag[ACCESS_MAKE_SURVIVOR] = read_flags(value)
  9768. else if (equal(key, "RESPAWN PLAYERS"))
  9769. g_access_flag[ACCESS_RESPAWN_PLAYERS] = read_flags(value)
  9770. else if (equal(key, "ADMIN MODELS"))
  9771. g_access_flag[ACCESS_ADMIN_MODELS] = read_flags(value)
  9772. }
  9773. case SECTION_PLAYER_MODELS:
  9774. {
  9775. if (equal(key, "HUMAN"))
  9776. {
  9777. // Parse models
  9778. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9779. {
  9780. // Trim spaces
  9781. trim(key)
  9782. trim(value)
  9783.  
  9784. // Add to models array
  9785. ArrayPushString(model_human, key)
  9786. }
  9787. }
  9788. else if (equal(key, "NEMESIS"))
  9789. {
  9790. // Parse models
  9791. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9792. {
  9793. // Trim spaces
  9794. trim(key)
  9795. trim(value)
  9796.  
  9797. // Add to models array
  9798. ArrayPushString(model_nemesis, key)
  9799. }
  9800. }
  9801. // Hattrick
  9802. //
  9803. else if (equal(key, "ASSASSIN"))
  9804. {
  9805. // Parse models
  9806. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9807. {
  9808. // Trim spaces
  9809. trim(key)
  9810. trim(value)
  9811.  
  9812. // Add to models array
  9813. ArrayPushString(model_assassin, key)
  9814. }
  9815. }
  9816. else if (equal(key, "SURVIVOR"))
  9817. {
  9818. // Parse models
  9819. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9820. {
  9821. // Trim spaces
  9822. trim(key)
  9823. trim(value)
  9824.  
  9825. // Add to models array
  9826. ArrayPushString(model_survivor, key)
  9827. }
  9828. }
  9829. // Hattrick
  9830. //
  9831. else if (equal(key, "SNIPER"))
  9832. {
  9833. // Parse models
  9834. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9835. {
  9836. // Trim spaces
  9837. trim(key)
  9838. trim(value)
  9839.  
  9840. // Add to models array
  9841. ArrayPushString(model_sniper, key)
  9842. }
  9843. }
  9844. else if (equal(key, "ADMIN ZOMBIE"))
  9845. {
  9846. // Parse models
  9847. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9848. {
  9849. // Trim spaces
  9850. trim(key)
  9851. trim(value)
  9852.  
  9853. // Add to models array
  9854. ArrayPushString(model_admin_zombie, key)
  9855. }
  9856. }
  9857. else if (equal(key, "ADMIN HUMAN"))
  9858. {
  9859. // Parse models
  9860. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9861. {
  9862. // Trim spaces
  9863. trim(key)
  9864. trim(value)
  9865.  
  9866. // Add to models array
  9867. ArrayPushString(model_admin_human, key)
  9868. }
  9869. }
  9870. else if (equal(key, "VIP"))
  9871. {
  9872. // Parse models
  9873. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9874. {
  9875. // Trim spaces
  9876. trim(key)
  9877. trim(value)
  9878.  
  9879. // Add to models array
  9880. ArrayPushString(model_vip, key)
  9881. }
  9882. }
  9883. else if (equal(key, "FORCE CONSISTENCY"))
  9884. g_force_consistency = str_to_num(value)
  9885. else if (equal(key, "SAME MODELS FOR ALL"))
  9886. g_same_models_for_all = str_to_num(value)
  9887. else if (g_same_models_for_all && equal(key, "ZOMBIE"))
  9888. {
  9889. // Parse models
  9890. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9891. {
  9892. // Trim spaces
  9893. trim(key)
  9894. trim(value)
  9895.  
  9896. // Add to models array
  9897. ArrayPushString(g_zclass_playermodel, key)
  9898.  
  9899. // Precache model and retrieve its modelindex
  9900. formatex(linedata, charsmax(linedata), "models/player/%s/%s.mdl", key, key)
  9901. ArrayPushCell(g_zclass_modelindex, engfunc(EngFunc_PrecacheModel, linedata))
  9902. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, linedata)
  9903. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, linedata)
  9904. // Precache modelT.mdl files too
  9905. copy(linedata[strlen(linedata)-4], charsmax(linedata) - (strlen(linedata)-4), "T.mdl")
  9906. if (file_exists(linedata)) engfunc(EngFunc_PrecacheModel, linedata)
  9907. }
  9908. }
  9909. }
  9910. case SECTION_WEAPON_MODELS:
  9911. {
  9912. if (equal(key, "V_KNIFE HUMAN"))
  9913. copy(model_vknife_human, charsmax(model_vknife_human), value)
  9914. else if (equal(key, "V_KNIFE NEMESIS"))
  9915. copy(model_vknife_nemesis, charsmax(model_vknife_nemesis), value)
  9916.  
  9917. // Hattrick
  9918. //
  9919. else if (equal(key, "V_KNIFE ASSASSIN"))
  9920. copy(model_vknife_assassin, charsmax(model_vknife_assassin), value)
  9921.  
  9922. else if (equal(key, "V_AWP SNIPER"))
  9923. copy(model_vawp_sniper, charsmax(model_vawp_sniper), value)
  9924. else if (equal(key, "P_AWP SNIPER"))
  9925. copy(model_pawp_sniper, charsmax(model_pawp_sniper), value)
  9926.  
  9927. // Hattrick
  9928. //
  9929. // else if (equal(key, "V_M249 SURVIVOR")) // backwards compatibility with old configs
  9930. // copy(model_vweapon_survivor, charsmax(model_vweapon_survivor), value)
  9931. // else if (equal(key, "V_WEAPON SURVIVOR"))
  9932. // copy(model_vweapon_survivor, charsmax(model_vweapon_survivor), value)
  9933.  
  9934.  
  9935.  
  9936. else if (equal(key, "GRENADE INFECT"))
  9937. copy(model_grenade_infect, charsmax(model_grenade_infect), value)
  9938. else if (equal(key, "GRENADE FIRE"))
  9939. copy(model_grenade_fire, charsmax(model_grenade_fire), value)
  9940. else if (equal(key, "GRENADE FROST"))
  9941. copy(model_grenade_frost, charsmax(model_grenade_frost), value)
  9942. else if (equal(key, "GRENADE FLARE"))
  9943. copy(model_grenade_flare, charsmax(model_grenade_flare), value)
  9944. else if (equal(key, "V_KNIFE ADMIN HUMAN"))
  9945. copy(model_vknife_admin_human, charsmax(model_vknife_admin_human), value)
  9946. else if (equal(key, "V_KNIFE ADMIN ZOMBIE"))
  9947. copy(model_vknife_admin_zombie, charsmax(model_vknife_admin_zombie), value)
  9948. }
  9949. case SECTION_GRENADE_SPRITES:
  9950. {
  9951. if (equal(key, "TRAIL"))
  9952. copy(sprite_grenade_trail, charsmax(sprite_grenade_trail), value)
  9953. else if (equal(key, "RING"))
  9954. copy(sprite_grenade_ring, charsmax(sprite_grenade_ring), value)
  9955. else if (equal(key, "FIRE"))
  9956. copy(sprite_grenade_fire, charsmax(sprite_grenade_fire), value)
  9957. else if (equal(key, "SMOKE"))
  9958. copy(sprite_grenade_smoke, charsmax(sprite_grenade_smoke), value)
  9959. else if (equal(key, "GLASS"))
  9960. copy(sprite_grenade_glass, charsmax(sprite_grenade_glass), value)
  9961. }
  9962. case SECTION_SOUNDS:
  9963. {
  9964. if (equal(key, "WIN ZOMBIES"))
  9965. {
  9966. // Parse sounds
  9967. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9968. {
  9969. // Trim spaces
  9970. trim(key)
  9971. trim(value)
  9972.  
  9973. // Add to sounds array
  9974. ArrayPushString(sound_win_zombies, key)
  9975. ArrayPushCell(sound_win_zombies_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  9976. }
  9977. }
  9978. else if (equal(key, "WIN HUMANS"))
  9979. {
  9980. // Parse sounds
  9981. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9982. {
  9983. // Trim spaces
  9984. trim(key)
  9985. trim(value)
  9986.  
  9987. // Add to sounds array
  9988. ArrayPushString(sound_win_humans, key)
  9989. ArrayPushCell(sound_win_humans_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  9990. }
  9991. }
  9992. else if (equal(key, "WIN NO ONE"))
  9993. {
  9994. // Parse sounds
  9995. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  9996. {
  9997. // Trim spaces
  9998. trim(key)
  9999. trim(value)
  10000.  
  10001. // Add to sounds array
  10002. ArrayPushString(sound_win_no_one, key)
  10003. ArrayPushCell(sound_win_no_one_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10004. }
  10005. }
  10006. else if (equal(key, "ZOMBIE INFECT"))
  10007. {
  10008. // Parse sounds
  10009. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10010. {
  10011. // Trim spaces
  10012. trim(key)
  10013. trim(value)
  10014.  
  10015. // Add to sounds array
  10016. ArrayPushString(zombie_infect, key)
  10017. }
  10018. }
  10019. else if (equal(key, "ZOMBIE PAIN"))
  10020. {
  10021. // Parse sounds
  10022. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10023. {
  10024. // Trim spaces
  10025. trim(key)
  10026. trim(value)
  10027.  
  10028. // Add to sounds array
  10029. ArrayPushString(zombie_pain, key)
  10030. }
  10031. }
  10032. else if (equal(key, "NEMESIS PAIN"))
  10033. {
  10034. // Parse sounds
  10035. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10036. {
  10037. // Trim spaces
  10038. trim(key)
  10039. trim(value)
  10040.  
  10041. // Add to sounds array
  10042. ArrayPushString(nemesis_pain, key)
  10043. }
  10044. }
  10045. // HATTRICK
  10046. //
  10047. else if (equal(key, "ASSASSIN PAIN"))
  10048. {
  10049. // Parse sounds
  10050. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10051. {
  10052. // Trim spaces
  10053. trim(key)
  10054. trim(value)
  10055.  
  10056. // Add to sounds array
  10057. ArrayPushString(assassin_pain, key)
  10058. }
  10059. }
  10060. else if (equal(key, "ZOMBIE DIE"))
  10061. {
  10062. // Parse sounds
  10063. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10064. {
  10065. // Trim spaces
  10066. trim(key)
  10067. trim(value)
  10068.  
  10069. // Add to sounds array
  10070. ArrayPushString(zombie_die, key)
  10071. }
  10072. }
  10073. else if (equal(key, "ZOMBIE FALL"))
  10074. {
  10075. // Parse sounds
  10076. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10077. {
  10078. // Trim spaces
  10079. trim(key)
  10080. trim(value)
  10081.  
  10082. // Add to sounds array
  10083. ArrayPushString(zombie_fall, key)
  10084. }
  10085. }
  10086. else if (equal(key, "ZOMBIE MISS SLASH"))
  10087. {
  10088. // Parse sounds
  10089. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10090. {
  10091. // Trim spaces
  10092. trim(key)
  10093. trim(value)
  10094.  
  10095. // Add to sounds array
  10096. ArrayPushString(zombie_miss_slash, key)
  10097. }
  10098. }
  10099. else if (equal(key, "ZOMBIE MISS WALL"))
  10100. {
  10101. // Parse sounds
  10102. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10103. {
  10104. // Trim spaces
  10105. trim(key)
  10106. trim(value)
  10107.  
  10108. // Add to sounds array
  10109. ArrayPushString(zombie_miss_wall, key)
  10110. }
  10111. }
  10112. else if (equal(key, "ZOMBIE HIT NORMAL"))
  10113. {
  10114. // Parse sounds
  10115. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10116. {
  10117. // Trim spaces
  10118. trim(key)
  10119. trim(value)
  10120.  
  10121. // Add to sounds array
  10122. ArrayPushString(zombie_hit_normal, key)
  10123. }
  10124. }
  10125. else if (equal(key, "ZOMBIE HIT STAB"))
  10126. {
  10127. // Parse sounds
  10128. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10129. {
  10130. // Trim spaces
  10131. trim(key)
  10132. trim(value)
  10133.  
  10134. // Add to sounds array
  10135. ArrayPushString(zombie_hit_stab, key)
  10136. }
  10137. }
  10138. else if (equal(key, "ZOMBIE IDLE"))
  10139. {
  10140. // Parse sounds
  10141. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10142. {
  10143. // Trim spaces
  10144. trim(key)
  10145. trim(value)
  10146.  
  10147. // Add to sounds array
  10148. ArrayPushString(zombie_idle, key)
  10149. }
  10150. }
  10151. else if (equal(key, "ZOMBIE IDLE LAST"))
  10152. {
  10153. // Parse sounds
  10154. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10155. {
  10156. // Trim spaces
  10157. trim(key)
  10158. trim(value)
  10159.  
  10160. // Add to sounds array
  10161. ArrayPushString(zombie_idle_last, key)
  10162. }
  10163. }
  10164. else if (equal(key, "ZOMBIE MADNESS"))
  10165. {
  10166. // Parse sounds
  10167. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10168. {
  10169. // Trim spaces
  10170. trim(key)
  10171. trim(value)
  10172.  
  10173. // Add to sounds array
  10174. ArrayPushString(zombie_madness, key)
  10175. }
  10176. }
  10177. else if (equal(key, "ROUND NEMESIS"))
  10178. {
  10179. // Parse sounds
  10180. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10181. {
  10182. // Trim spaces
  10183. trim(key)
  10184. trim(value)
  10185.  
  10186. // Add to sounds array
  10187. ArrayPushString(sound_nemesis, key)
  10188. }
  10189. }
  10190. else if (equal(key, "ROUND SURVIVOR"))
  10191. {
  10192. // Parse sounds
  10193. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10194. {
  10195. // Trim spaces
  10196. trim(key)
  10197. trim(value)
  10198.  
  10199. // Add to sounds array
  10200. ArrayPushString(sound_survivor, key)
  10201. }
  10202. }
  10203.  
  10204. // Hattrick
  10205. //
  10206. else if (equal(key, "ROUND SNIPER"))
  10207. {
  10208. // Parse sounds
  10209. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10210. {
  10211. // Trim spaces
  10212. trim(key)
  10213. trim(value)
  10214.  
  10215. // Add to sounds array
  10216. ArrayPushString(sound_sniper, key)
  10217. }
  10218. }
  10219.  
  10220. else if (equal(key, "ROUND ASSASSIN"))
  10221. {
  10222. // Parse sounds
  10223. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10224. {
  10225. // Trim spaces
  10226. trim(key)
  10227. trim(value)
  10228.  
  10229. // Add to sounds array
  10230. ArrayPushString(sound_assassin, key)
  10231. }
  10232. }
  10233.  
  10234. else if (equal(key, "ROUND SWARM"))
  10235. {
  10236. // Parse sounds
  10237. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10238. {
  10239. // Trim spaces
  10240. trim(key)
  10241. trim(value)
  10242.  
  10243. // Add to sounds array
  10244. ArrayPushString(sound_swarm, key)
  10245. }
  10246. }
  10247. else if (equal(key, "ROUND MULTI"))
  10248. {
  10249. // Parse sounds
  10250. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10251. {
  10252. // Trim spaces
  10253. trim(key)
  10254. trim(value)
  10255.  
  10256. // Add to sounds array
  10257. ArrayPushString(sound_multi, key)
  10258. }
  10259. }
  10260. else if (equal(key, "ROUND PLAGUE"))
  10261. {
  10262. // Parse sounds
  10263. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10264. {
  10265. // Trim spaces
  10266. trim(key)
  10267. trim(value)
  10268.  
  10269. // Add to sounds array
  10270. ArrayPushString(sound_plague, key)
  10271. }
  10272. }
  10273. else if (equal(key, "GRENADE INFECT EXPLODE"))
  10274. {
  10275. // Parse sounds
  10276. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10277. {
  10278. // Trim spaces
  10279. trim(key)
  10280. trim(value)
  10281.  
  10282. // Add to sounds array
  10283. ArrayPushString(grenade_infect, key)
  10284. }
  10285. }
  10286. else if (equal(key, "GRENADE INFECT PLAYER"))
  10287. {
  10288. // Parse sounds
  10289. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10290. {
  10291. // Trim spaces
  10292. trim(key)
  10293. trim(value)
  10294.  
  10295. // Add to sounds array
  10296. ArrayPushString(grenade_infect_player, key)
  10297. }
  10298. }
  10299. else if (equal(key, "GRENADE FIRE EXPLODE"))
  10300. {
  10301. // Parse sounds
  10302. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10303. {
  10304. // Trim spaces
  10305. trim(key)
  10306. trim(value)
  10307.  
  10308. // Add to sounds array
  10309. ArrayPushString(grenade_fire, key)
  10310. }
  10311. }
  10312. else if (equal(key, "GRENADE FIRE PLAYER"))
  10313. {
  10314. // Parse sounds
  10315. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10316. {
  10317. // Trim spaces
  10318. trim(key)
  10319. trim(value)
  10320.  
  10321. // Add to sounds array
  10322. ArrayPushString(grenade_fire_player, key)
  10323. }
  10324. }
  10325. else if (equal(key, "GRENADE FROST EXPLODE"))
  10326. {
  10327. // Parse sounds
  10328. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10329. {
  10330. // Trim spaces
  10331. trim(key)
  10332. trim(value)
  10333.  
  10334. // Add to sounds array
  10335. ArrayPushString(grenade_frost, key)
  10336. }
  10337. }
  10338. else if (equal(key, "GRENADE FROST PLAYER"))
  10339. {
  10340. // Parse sounds
  10341. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10342. {
  10343. // Trim spaces
  10344. trim(key)
  10345. trim(value)
  10346.  
  10347. // Add to sounds array
  10348. ArrayPushString(grenade_frost_player, key)
  10349. }
  10350. }
  10351. else if (equal(key, "GRENADE FROST BREAK"))
  10352. {
  10353. // Parse sounds
  10354. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10355. {
  10356. // Trim spaces
  10357. trim(key)
  10358. trim(value)
  10359.  
  10360. // Add to sounds array
  10361. ArrayPushString(grenade_frost_break, key)
  10362. }
  10363. }
  10364. // Hattrick
  10365. //
  10366. /*
  10367. else if (equal(key, "GRENADE FLARE"))
  10368. {
  10369. // Parse sounds
  10370. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10371. {
  10372. // Trim spaces
  10373. trim(key)
  10374. trim(value)
  10375.  
  10376. // Add to sounds array
  10377. ArrayPushString(grenade_flare, key)
  10378. }
  10379. }
  10380. */
  10381. else if (equal(key, "ANTIDOTE"))
  10382. {
  10383. // Parse sounds
  10384. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10385. {
  10386. // Trim spaces
  10387. trim(key)
  10388. trim(value)
  10389.  
  10390. // Add to sounds array
  10391. ArrayPushString(sound_antidote, key)
  10392. }
  10393. }
  10394. else if (equal(key, "THUNDER"))
  10395. {
  10396. // Parse sounds
  10397. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10398. {
  10399. // Trim spaces
  10400. trim(key)
  10401. trim(value)
  10402.  
  10403. // Add to sounds array
  10404. ArrayPushString(sound_thunder, key)
  10405. }
  10406. }
  10407. }
  10408. case SECTION_AMBIENCE_SOUNDS:
  10409. {
  10410. if (equal(key, "INFECTION ENABLE"))
  10411. g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] = str_to_num(value)
  10412. else if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && equal(key, "INFECTION SOUNDS"))
  10413. {
  10414. // Parse sounds
  10415. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10416. {
  10417. // Trim spaces
  10418. trim(key)
  10419. trim(value)
  10420.  
  10421. // Add to sounds array
  10422. ArrayPushString(sound_ambience1, key)
  10423. ArrayPushCell(sound_ambience1_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10424. }
  10425. }
  10426. else if (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && equal(key, "INFECTION DURATIONS"))
  10427. {
  10428. // Parse sounds
  10429. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10430. {
  10431. // Trim spaces
  10432. trim(key)
  10433. trim(value)
  10434.  
  10435. // Add to sounds array
  10436. ArrayPushCell(sound_ambience1_duration, str_to_num(key))
  10437. }
  10438. }
  10439. else if (equal(key, "NEMESIS ENABLE"))
  10440. g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] = str_to_num(value)
  10441. else if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && equal(key, "NEMESIS SOUNDS"))
  10442. {
  10443. // Parse sounds
  10444. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10445. {
  10446. // Trim spaces
  10447. trim(key)
  10448. trim(value)
  10449.  
  10450. // Add to sounds array
  10451. ArrayPushString(sound_ambience2, key)
  10452. ArrayPushCell(sound_ambience2_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10453. }
  10454. }
  10455. else if (g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && equal(key, "NEMESIS DURATIONS"))
  10456. {
  10457. // Parse sounds
  10458. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10459. {
  10460. // Trim spaces
  10461. trim(key)
  10462. trim(value)
  10463.  
  10464. // Add to sounds array
  10465. ArrayPushCell(sound_ambience2_duration, str_to_num(key))
  10466. }
  10467. }
  10468.  
  10469. // Hattrick
  10470. //
  10471.  
  10472. else if (equal(key, "ASSASSIN ENABLE"))
  10473. g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] = str_to_num(value)
  10474. else if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && equal(key, "ASSASSIN SOUNDS"))
  10475. {
  10476. // Parse sounds
  10477. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10478. {
  10479. // Trim spaces
  10480. trim(key)
  10481. trim(value)
  10482.  
  10483. // Add to sounds array
  10484. ArrayPushString(sound_ambience6, key)
  10485. ArrayPushCell(sound_ambience6_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10486. }
  10487. }
  10488. else if (g_ambience_sounds[AMBIENCE_SOUNDS_ASSASSIN] && equal(key, "ASSASSIN DURATIONS"))
  10489. {
  10490. // Parse sounds
  10491. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10492. {
  10493. // Trim spaces
  10494. trim(key)
  10495. trim(value)
  10496.  
  10497. // Add to sounds array
  10498. ArrayPushCell(sound_ambience6_duration, str_to_num(key))
  10499. }
  10500. }
  10501.  
  10502.  
  10503.  
  10504. else if (equal(key, "SURVIVOR ENABLE"))
  10505. g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] = str_to_num(value)
  10506. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && equal(key, "SURVIVOR SOUNDS"))
  10507. {
  10508. // Parse sounds
  10509. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10510. {
  10511. // Trim spaces
  10512. trim(key)
  10513. trim(value)
  10514.  
  10515. // Add to sounds array
  10516. ArrayPushString(sound_ambience3, key)
  10517. ArrayPushCell(sound_ambience3_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10518. }
  10519. }
  10520. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && equal(key, "SURVIVOR DURATIONS"))
  10521. {
  10522. // Parse sounds
  10523. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10524. {
  10525. // Trim spaces
  10526. trim(key)
  10527. trim(value)
  10528.  
  10529. // Add to sounds array
  10530. ArrayPushCell(sound_ambience3_duration, str_to_num(key))
  10531. }
  10532. }
  10533.  
  10534. // Hattrick
  10535. //
  10536.  
  10537. else if (equal(key, "SNIPER ENABLE"))
  10538. g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] = str_to_num(value)
  10539. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && equal(key, "SNIPER SOUNDS"))
  10540. {
  10541. // Parse sounds
  10542. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10543. {
  10544. // Trim spaces
  10545. trim(key)
  10546. trim(value)
  10547.  
  10548. // Add to sounds array
  10549. ArrayPushString(sound_ambience7, key)
  10550. ArrayPushCell(sound_ambience7_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10551. }
  10552. }
  10553. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SNIPER] && equal(key, "SNIPER DURATIONS"))
  10554. {
  10555. // Parse sounds
  10556. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10557. {
  10558. // Trim spaces
  10559. trim(key)
  10560. trim(value)
  10561.  
  10562. // Add to sounds array
  10563. ArrayPushCell(sound_ambience7_duration, str_to_num(key))
  10564. }
  10565. }
  10566.  
  10567. else if (equal(key, "SWARM ENABLE"))
  10568. g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] = str_to_num(value)
  10569. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && equal(key, "SWARM SOUNDS"))
  10570. {
  10571. // Parse sounds
  10572. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10573. {
  10574. // Trim spaces
  10575. trim(key)
  10576. trim(value)
  10577.  
  10578. // Add to sounds array
  10579. ArrayPushString(sound_ambience4, key)
  10580. ArrayPushCell(sound_ambience4_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10581. }
  10582. }
  10583. else if (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && equal(key, "SWARM DURATIONS"))
  10584. {
  10585. // Parse sounds
  10586. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10587. {
  10588. // Trim spaces
  10589. trim(key)
  10590. trim(value)
  10591.  
  10592. // Add to sounds array
  10593. ArrayPushCell(sound_ambience4_duration, str_to_num(key))
  10594. }
  10595. }
  10596. else if (equal(key, "PLAGUE ENABLE"))
  10597. g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] = str_to_num(value)
  10598. else if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && equal(key, "PLAGUE SOUNDS"))
  10599. {
  10600. // Parse sounds
  10601. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10602. {
  10603. // Trim spaces
  10604. trim(key)
  10605. trim(value)
  10606.  
  10607. // Add to sounds array
  10608. ArrayPushString(sound_ambience5, key)
  10609. ArrayPushCell(sound_ambience5_ismp3, equal(key[strlen(key)-4], ".mp3") ? 1 : 0)
  10610. }
  10611. }
  10612. else if (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && equal(key, "PLAGUE DURATIONS"))
  10613. {
  10614. // Parse sounds
  10615. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10616. {
  10617. // Trim spaces
  10618. trim(key)
  10619. trim(value)
  10620.  
  10621. // Add to sounds array
  10622. ArrayPushCell(sound_ambience5_duration, str_to_num(key))
  10623. }
  10624. }
  10625. }
  10626. case SECTION_BUY_MENU_WEAPONS:
  10627. {
  10628. if (equal(key, "PRIMARY"))
  10629. {
  10630. // Parse weapons
  10631. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10632. {
  10633. // Trim spaces
  10634. trim(key)
  10635. trim(value)
  10636.  
  10637. // Add to weapons array
  10638. ArrayPushString(g_primary_items, key)
  10639. ArrayPushCell(g_primary_weaponids, cs_weapon_name_to_id(key))
  10640. }
  10641. }
  10642. else if (equal(key, "SECONDARY"))
  10643. {
  10644. // Parse weapons
  10645. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10646. {
  10647. // Trim spaces
  10648. trim(key)
  10649. trim(value)
  10650.  
  10651. // Add to weapons array
  10652. ArrayPushString(g_secondary_items, key)
  10653. ArrayPushCell(g_secondary_weaponids, cs_weapon_name_to_id(key))
  10654. }
  10655. }
  10656. else if (equal(key, "ADDITIONAL ITEMS"))
  10657. {
  10658. // Parse weapons
  10659. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10660. {
  10661. // Trim spaces
  10662. trim(key)
  10663. trim(value)
  10664.  
  10665. // Add to weapons array
  10666. ArrayPushString(g_additional_items, key)
  10667. }
  10668. }
  10669. }
  10670. case SECTION_EXTRA_ITEMS_WEAPONS:
  10671. {
  10672. if (equal(key, "NAMES"))
  10673. {
  10674. // Parse weapon items
  10675. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10676. {
  10677. // Trim spaces
  10678. trim(key)
  10679. trim(value)
  10680.  
  10681. // Add to weapons array
  10682. ArrayPushString(g_extraweapon_names, key)
  10683. }
  10684. }
  10685. else if (equal(key, "ITEMS"))
  10686. {
  10687. // Parse weapon items
  10688. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10689. {
  10690. // Trim spaces
  10691. trim(key)
  10692. trim(value)
  10693.  
  10694. // Add to weapons array
  10695. ArrayPushString(g_extraweapon_items, key)
  10696. }
  10697. }
  10698. else if (equal(key, "COSTS"))
  10699. {
  10700. // Parse weapon items
  10701. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10702. {
  10703. // Trim spaces
  10704. trim(key)
  10705. trim(value)
  10706.  
  10707. // Add to weapons array
  10708. ArrayPushCell(g_extraweapon_costs, str_to_num(key))
  10709. }
  10710. }
  10711. }
  10712. case SECTION_HARD_CODED_ITEMS_COSTS:
  10713. {
  10714. if (equal(key, "NIGHT VISION"))
  10715. g_extra_costs2[EXTRA_NVISION] = str_to_num(value)
  10716. else if (equal(key, "ANTIDOTE"))
  10717. g_extra_costs2[EXTRA_ANTIDOTE] = str_to_num(value)
  10718. else if (equal(key, "ZOMBIE MADNESS"))
  10719. g_extra_costs2[EXTRA_MADNESS] = str_to_num(value)
  10720. else if (equal(key, "INFECTION BOMB"))
  10721. g_extra_costs2[EXTRA_INFBOMB] = str_to_num(value)
  10722. }
  10723. case SECTION_WEATHER_EFFECTS:
  10724. {
  10725. if (equal(key, "RAIN"))
  10726. g_ambience_rain = str_to_num(value)
  10727. else if (equal(key, "SNOW"))
  10728. g_ambience_snow = str_to_num(value)
  10729. else if (equal(key, "FOG"))
  10730. g_ambience_fog = str_to_num(value)
  10731. else if (equal(key, "FOG DENSITY"))
  10732. copy(g_fog_density, charsmax(g_fog_density), value)
  10733. else if (equal(key, "FOG COLOR"))
  10734. copy(g_fog_color, charsmax(g_fog_color), value)
  10735. }
  10736. case SECTION_SKY:
  10737. {
  10738. if (equal(key, "ENABLE"))
  10739. g_sky_enable = str_to_num(value)
  10740. else if (equal(key, "SKY NAMES"))
  10741. {
  10742. // Parse sky names
  10743. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10744. {
  10745. // Trim spaces
  10746. trim(key)
  10747. trim(value)
  10748.  
  10749. // Add to skies array
  10750. ArrayPushString(g_sky_names, key)
  10751.  
  10752. // Preache custom sky files
  10753. formatex(linedata, charsmax(linedata), "gfx/env/%sbk.tga", key)
  10754. engfunc(EngFunc_PrecacheGeneric, linedata)
  10755. formatex(linedata, charsmax(linedata), "gfx/env/%sdn.tga", key)
  10756. engfunc(EngFunc_PrecacheGeneric, linedata)
  10757. formatex(linedata, charsmax(linedata), "gfx/env/%sft.tga", key)
  10758. engfunc(EngFunc_PrecacheGeneric, linedata)
  10759. formatex(linedata, charsmax(linedata), "gfx/env/%slf.tga", key)
  10760. engfunc(EngFunc_PrecacheGeneric, linedata)
  10761. formatex(linedata, charsmax(linedata), "gfx/env/%srt.tga", key)
  10762. engfunc(EngFunc_PrecacheGeneric, linedata)
  10763. formatex(linedata, charsmax(linedata), "gfx/env/%sup.tga", key)
  10764. engfunc(EngFunc_PrecacheGeneric, linedata)
  10765. }
  10766. }
  10767. }
  10768. case SECTION_LIGHTNING:
  10769. {
  10770. if (equal(key, "LIGHTS"))
  10771. {
  10772. // Parse lights
  10773. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10774. {
  10775. // Trim spaces
  10776. trim(key)
  10777. trim(value)
  10778.  
  10779. // Add to lightning array
  10780. ArrayPushString(lights_thunder, key)
  10781. }
  10782. }
  10783. }
  10784. case SECTION_ZOMBIE_DECALS:
  10785. {
  10786. if (equal(key, "DECALS"))
  10787. {
  10788. // Parse decals
  10789. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10790. {
  10791. // Trim spaces
  10792. trim(key)
  10793. trim(value)
  10794.  
  10795. // Add to zombie decals array
  10796. ArrayPushCell(zombie_decals, str_to_num(key))
  10797. }
  10798. }
  10799. }
  10800. case SECTION_KNOCKBACK:
  10801. {
  10802. // Format weapon entity name
  10803. strtolower(key)
  10804. format(key, charsmax(key), "weapon_%s", key)
  10805.  
  10806. // Add value to knockback power array
  10807. kb_weapon_power[cs_weapon_name_to_id(key)] = str_to_float(value)
  10808. }
  10809. case SECTION_OBJECTIVE_ENTS:
  10810. {
  10811. if (equal(key, "CLASSNAMES"))
  10812. {
  10813. // Parse classnames
  10814. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10815. {
  10816. // Trim spaces
  10817. trim(key)
  10818. trim(value)
  10819.  
  10820. // Add to objective ents array
  10821. ArrayPushString(g_objective_ents, key)
  10822. }
  10823. }
  10824. }
  10825. case SECTION_SVC_BAD:
  10826. {
  10827. if (equal(key, "MODELCHANGE DELAY"))
  10828. g_modelchange_delay = str_to_float(value)
  10829. else if (equal(key, "HANDLE MODELS ON SEPARATE ENT"))
  10830. g_handle_models_on_separate_ent = str_to_num(value)
  10831. else if (equal(key, "SET MODELINDEX OFFSET"))
  10832. g_set_modelindex_offset = str_to_num(value)
  10833. }
  10834. }
  10835. }
  10836. if (file) fclose(file)
  10837.  
  10838. // Build zombie classes file path
  10839. get_configsdir(path, charsmax(path))
  10840. format(path, charsmax(path), "%s/%s", path, ZP_ZOMBIECLASSES_FILE)
  10841.  
  10842. // Parse if present
  10843. if (file_exists(path))
  10844. {
  10845. // Open zombie classes file for reading
  10846. file = fopen(path, "rt")
  10847.  
  10848. while (file && !feof(file))
  10849. {
  10850. // Read one line at a time
  10851. fgets(file, linedata, charsmax(linedata))
  10852.  
  10853. // Replace newlines with a null character to prevent headaches
  10854. replace(linedata, charsmax(linedata), "^n", "")
  10855.  
  10856. // Blank line or comment
  10857. if (!linedata[0] || linedata[0] == ';') continue;
  10858.  
  10859. // New class starting
  10860. if (linedata[0] == '[')
  10861. {
  10862. // Remove first and last characters (braces)
  10863. linedata[strlen(linedata) - 1] = 0
  10864. copy(linedata, charsmax(linedata), linedata[1])
  10865.  
  10866. // Store its real name for future reference
  10867. ArrayPushString(g_zclass2_realname, linedata)
  10868. continue;
  10869. }
  10870.  
  10871. // Get key and value(s)
  10872. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  10873.  
  10874. // Trim spaces
  10875. trim(key)
  10876. trim(value)
  10877.  
  10878. if (equal(key, "NAME"))
  10879. ArrayPushString(g_zclass2_name, value)
  10880. else if (equal(key, "INFO"))
  10881. ArrayPushString(g_zclass2_info, value)
  10882. else if (equal(key, "MODELS"))
  10883. {
  10884. // Set models start index
  10885. ArrayPushCell(g_zclass2_modelsstart, ArraySize(g_zclass2_playermodel))
  10886.  
  10887. // Parse class models
  10888. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10889. {
  10890. // Trim spaces
  10891. trim(key)
  10892. trim(value)
  10893.  
  10894. // Add to class models array
  10895. ArrayPushString(g_zclass2_playermodel, key)
  10896. ArrayPushCell(g_zclass2_modelindex, -1)
  10897. }
  10898.  
  10899. // Set models end index
  10900. ArrayPushCell(g_zclass2_modelsend, ArraySize(g_zclass2_playermodel))
  10901. }
  10902. else if (equal(key, "CLAWMODEL"))
  10903. ArrayPushString(g_zclass2_clawmodel, value)
  10904. else if (equal(key, "HEALTH"))
  10905. ArrayPushCell(g_zclass2_hp, str_to_num(value))
  10906. else if (equal(key, "SPEED"))
  10907. ArrayPushCell(g_zclass2_spd, str_to_num(value))
  10908. else if (equal(key, "GRAVITY"))
  10909. ArrayPushCell(g_zclass2_grav, str_to_float(value))
  10910. else if (equal(key, "KNOCKBACK"))
  10911. ArrayPushCell(g_zclass2_kb, str_to_float(value))
  10912. }
  10913. if (file) fclose(file)
  10914. }
  10915.  
  10916. // Build extra items file path
  10917. get_configsdir(path, charsmax(path))
  10918. format(path, charsmax(path), "%s/%s", path, ZP_EXTRAITEMS_FILE)
  10919.  
  10920. // Parse if present
  10921. if (file_exists(path))
  10922. {
  10923. // Open extra items file for reading
  10924. file = fopen(path, "rt")
  10925.  
  10926. while (file && !feof(file))
  10927. {
  10928. // Read one line at a time
  10929. fgets(file, linedata, charsmax(linedata))
  10930.  
  10931. // Replace newlines with a null character to prevent headaches
  10932. replace(linedata, charsmax(linedata), "^n", "")
  10933.  
  10934. // Blank line or comment
  10935. if (!linedata[0] || linedata[0] == ';') continue;
  10936.  
  10937. // New item starting
  10938. if (linedata[0] == '[')
  10939. {
  10940. // Remove first and last characters (braces)
  10941. linedata[strlen(linedata) - 1] = 0
  10942. copy(linedata, charsmax(linedata), linedata[1])
  10943.  
  10944. // Store its real name for future reference
  10945. ArrayPushString(g_extraitem2_realname, linedata)
  10946. continue;
  10947. }
  10948.  
  10949. // Get key and value(s)
  10950. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  10951.  
  10952. // Trim spaces
  10953. trim(key)
  10954. trim(value)
  10955.  
  10956. if (equal(key, "NAME"))
  10957. ArrayPushString(g_extraitem2_name, value)
  10958. else if (equal(key, "COST"))
  10959. ArrayPushCell(g_extraitem2_cost, str_to_num(value))
  10960. else if (equal(key, "TEAMS"))
  10961. {
  10962. // Clear teams bitsum
  10963. teams = 0
  10964.  
  10965. // Parse teams
  10966. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  10967. {
  10968. // Trim spaces
  10969. trim(key)
  10970. trim(value)
  10971.  
  10972. if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_ZOMBIE]))
  10973. teams |= ZP_TEAM_ZOMBIE
  10974. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_HUMAN]))
  10975. teams |= ZP_TEAM_HUMAN
  10976. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_NEMESIS]))
  10977. teams |= ZP_TEAM_NEMESIS
  10978. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_SURVIVOR]))
  10979. teams |= ZP_TEAM_SURVIVOR
  10980. // Hattrick
  10981. //
  10982. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_ASSASSIN]))
  10983. teams |= ZP_TEAM_ASSASSIN
  10984. else if (equal(key, ZP_TEAM_NAMES[ZP_TEAM_SNIPER]))
  10985. teams |= ZP_TEAM_SNIPER
  10986. }
  10987.  
  10988. // Add to teams array
  10989. ArrayPushCell(g_extraitem2_team, teams)
  10990. }
  10991. }
  10992. if (file) fclose(file)
  10993. }
  10994. }
  10995.  
  10996. save_customization()
  10997. {
  10998. new i, k, buffer[512]
  10999.  
  11000. // Build zombie classes file path
  11001. new path[64]
  11002. get_configsdir(path, charsmax(path))
  11003. format(path, charsmax(path), "%s/%s", path, ZP_ZOMBIECLASSES_FILE)
  11004.  
  11005. // Open zombie classes file for appending data
  11006. new file = fopen(path, "at"), size = ArraySize(g_zclass_name)
  11007.  
  11008. // Add any new zombie classes data at the end if needed
  11009. for (i = 0; i < size; i++)
  11010. {
  11011. if (ArrayGetCell(g_zclass_new, i))
  11012. {
  11013. // Add real name
  11014. ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))
  11015. format(buffer, charsmax(buffer), "^n[%s]", buffer)
  11016. fputs(file, buffer)
  11017.  
  11018. // Add caption
  11019. ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))
  11020. format(buffer, charsmax(buffer), "^nNAME = %s", buffer)
  11021. fputs(file, buffer)
  11022.  
  11023. // Add info
  11024. ArrayGetString(g_zclass_info, i, buffer, charsmax(buffer))
  11025. format(buffer, charsmax(buffer), "^nINFO = %s", buffer)
  11026. fputs(file, buffer)
  11027.  
  11028. // Add models
  11029. for (k = ArrayGetCell(g_zclass_modelsstart, i); k < ArrayGetCell(g_zclass_modelsend, i); k++)
  11030. {
  11031. if (k == ArrayGetCell(g_zclass_modelsstart, i))
  11032. {
  11033. // First model, overwrite buffer
  11034. ArrayGetString(g_zclass_playermodel, k, buffer, charsmax(buffer))
  11035. }
  11036. else
  11037. {
  11038. // Successive models, append to buffer
  11039. ArrayGetString(g_zclass_playermodel, k, path, charsmax(path))
  11040. format(buffer, charsmax(buffer), "%s , %s", buffer, path)
  11041. }
  11042. }
  11043. format(buffer, charsmax(buffer), "^nMODELS = %s", buffer)
  11044. fputs(file, buffer)
  11045.  
  11046. // Add clawmodel
  11047. ArrayGetString(g_zclass_clawmodel, i, buffer, charsmax(buffer))
  11048. format(buffer, charsmax(buffer), "^nCLAWMODEL = %s", buffer)
  11049. fputs(file, buffer)
  11050.  
  11051. // Add health
  11052. formatex(buffer, charsmax(buffer), "^nHEALTH = %d", ArrayGetCell(g_zclass_hp, i))
  11053. fputs(file, buffer)
  11054.  
  11055. // Add speed
  11056. formatex(buffer, charsmax(buffer), "^nSPEED = %d", ArrayGetCell(g_zclass_spd, i))
  11057. fputs(file, buffer)
  11058.  
  11059. // Add gravity
  11060. formatex(buffer, charsmax(buffer), "^nGRAVITY = %.2f", Float:ArrayGetCell(g_zclass_grav, i))
  11061. fputs(file, buffer)
  11062.  
  11063. // Add knockback
  11064. formatex(buffer, charsmax(buffer), "^nKNOCKBACK = %.2f^n", Float:ArrayGetCell(g_zclass_kb, i))
  11065. fputs(file, buffer)
  11066. }
  11067. }
  11068. fclose(file)
  11069.  
  11070. // Build extra items file path
  11071. get_configsdir(path, charsmax(path))
  11072. format(path, charsmax(path), "%s/%s", path, ZP_EXTRAITEMS_FILE)
  11073.  
  11074. // Open extra items file for appending data
  11075. file = fopen(path, "at")
  11076. size = ArraySize(g_extraitem_name)
  11077.  
  11078. // Add any new extra items data at the end if needed
  11079. for (i = EXTRAS_CUSTOM_STARTID; i < size; i++)
  11080. {
  11081. if (ArrayGetCell(g_extraitem_new, i))
  11082. {
  11083. // Add real name
  11084. ArrayGetString(g_extraitem_name, i, buffer, charsmax(buffer))
  11085. format(buffer, charsmax(buffer), "^n[%s]", buffer)
  11086. fputs(file, buffer)
  11087.  
  11088. // Add caption
  11089. ArrayGetString(g_extraitem_name, i, buffer, charsmax(buffer))
  11090. format(buffer, charsmax(buffer), "^nNAME = %s", buffer)
  11091. fputs(file, buffer)
  11092.  
  11093. // Add cost
  11094. formatex(buffer, charsmax(buffer), "^nCOST = %d", ArrayGetCell(g_extraitem_cost, i))
  11095. fputs(file, buffer)
  11096.  
  11097. // Add team
  11098. formatex(buffer, charsmax(buffer), "^nTEAMS = %s^n", ZP_TEAM_NAMES[ArrayGetCell(g_extraitem_team, i)])
  11099. fputs(file, buffer)
  11100. }
  11101. }
  11102. fclose(file)
  11103.  
  11104. // Free arrays containing class/item overrides
  11105. ArrayDestroy(g_zclass2_realname)
  11106. ArrayDestroy(g_zclass2_name)
  11107. ArrayDestroy(g_zclass2_info)
  11108. ArrayDestroy(g_zclass2_modelsstart)
  11109. ArrayDestroy(g_zclass2_modelsend)
  11110. ArrayDestroy(g_zclass2_playermodel)
  11111. ArrayDestroy(g_zclass2_modelindex)
  11112. ArrayDestroy(g_zclass2_clawmodel)
  11113. ArrayDestroy(g_zclass2_hp)
  11114. ArrayDestroy(g_zclass2_spd)
  11115. ArrayDestroy(g_zclass2_grav)
  11116. ArrayDestroy(g_zclass2_kb)
  11117. ArrayDestroy(g_zclass_new)
  11118. ArrayDestroy(g_extraitem2_realname)
  11119. ArrayDestroy(g_extraitem2_name)
  11120. ArrayDestroy(g_extraitem2_cost)
  11121. ArrayDestroy(g_extraitem2_team)
  11122. ArrayDestroy(g_extraitem_new)
  11123. }
  11124.  
  11125. // Register Ham Forwards for CZ bots
  11126. public register_ham_czbots(id)
  11127. {
  11128. // Make sure it's a CZ bot and it's still connected
  11129. if (g_hamczbots || !g_isconnected[id] || !get_pcvar_num(cvar_botquota))
  11130. return;
  11131.  
  11132. RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
  11133. RegisterHamFromEntity(Ham_Killed, id, "fw_PlayerKilled")
  11134. RegisterHamFromEntity(Ham_Killed, id, "fw_PlayerKilled_Post", 1)
  11135. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  11136. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage_Post", 1)
  11137. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  11138. RegisterHamFromEntity(Ham_Player_ResetMaxSpeed, id, "fw_ResetMaxSpeed_Post", 1)
  11139.  
  11140. // Ham forwards for CZ bots succesfully registered
  11141. g_hamczbots = true
  11142.  
  11143. // If the bot has already spawned, call the forward manually for him
  11144. if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
  11145. }
  11146.  
  11147. // Disable minmodels task
  11148. public disable_minmodels(id)
  11149. {
  11150. if (!g_isconnected[id]) return;
  11151. client_cmd(id, "cl_minmodels 0")
  11152. }
  11153.  
  11154. // Bots automatically buy extra items
  11155. public bot_buy_extras(taskid)
  11156. {
  11157. // Hattrick
  11158. //
  11159. // Nemesis or Survivor bots have nothing to buy by default
  11160. //if (!g_isalive[ID_SPAWN] || g_survivor[ID_SPAWN] || g_nemesis[ID_SPAWN])
  11161. if (!g_isalive[ID_SPAWN] || g_survivor[ID_SPAWN] || g_nemesis[ID_SPAWN] || g_sniper[ID_SPAWN] || g_assassin[ID_SPAWN])
  11162. return;
  11163.  
  11164. if (!g_zombie[ID_SPAWN]) // human bots
  11165. {
  11166. // Attempt to buy Night Vision
  11167. buy_extra_item(ID_SPAWN, EXTRA_NVISION)
  11168.  
  11169. // Attempt to buy a weapon
  11170. buy_extra_item(ID_SPAWN, random_num(EXTRA_WEAPONS_STARTID, EXTRAS_CUSTOM_STARTID-1))
  11171. }
  11172. else // zombie bots
  11173. {
  11174. // Attempt to buy an Antidote
  11175. buy_extra_item(ID_SPAWN, EXTRA_ANTIDOTE)
  11176. }
  11177. }
  11178.  
  11179. // Refill BP Ammo Task
  11180. public refill_bpammo(const args[], id)
  11181. {
  11182. // Player died or turned into a zombie
  11183. if (!g_isalive[id] || g_zombie[id])
  11184. return;
  11185.  
  11186. set_msg_block(g_msgAmmoPickup, BLOCK_ONCE)
  11187. ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[REFILL_WEAPONID], AMMOTYPE[REFILL_WEAPONID], MAXBPAMMO[REFILL_WEAPONID])
  11188. }
  11189.  
  11190. // Balance Teams Task
  11191. balance_teams()
  11192. {
  11193. // Get amount of users playing
  11194. static iPlayersnum
  11195. iPlayersnum = fnGetPlaying()
  11196.  
  11197. // No players, don't bother
  11198. if (iPlayersnum < 1) return;
  11199.  
  11200. // Split players evenly
  11201. static iTerrors, iMaxTerrors, id, team[33]
  11202. iMaxTerrors = iPlayersnum/2
  11203. iTerrors = 0
  11204.  
  11205. // First, set everyone to CT
  11206. for (id = 1; id <= g_maxplayers; id++)
  11207. {
  11208. // Skip if not connected
  11209. if (!g_isconnected[id])
  11210. continue;
  11211.  
  11212. team[id] = fm_cs_get_user_team(id)
  11213.  
  11214. // Skip if not playing
  11215. if (team[id] == FM_CS_TEAM_SPECTATOR || team[id] == FM_CS_TEAM_UNASSIGNED)
  11216. continue;
  11217.  
  11218. // Set team
  11219. remove_task(id+TASK_TEAM)
  11220. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  11221. team[id] = FM_CS_TEAM_CT
  11222. }
  11223.  
  11224. // Then randomly set half of the players to Terrorists
  11225. while (iTerrors < iMaxTerrors)
  11226. {
  11227. // Keep looping through all players
  11228. if (++id > g_maxplayers) id = 1
  11229.  
  11230. // Skip if not connected
  11231. if (!g_isconnected[id])
  11232. continue;
  11233.  
  11234. // Skip if not playing or already a Terrorist
  11235. if (team[id] != FM_CS_TEAM_CT)
  11236. continue;
  11237.  
  11238. // Random chance
  11239. if (random_num(0, 1))
  11240. {
  11241. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  11242. team[id] = FM_CS_TEAM_T
  11243. iTerrors++
  11244. }
  11245. }
  11246. }
  11247.  
  11248. // Welcome Message Task
  11249. public welcome_msg()
  11250. {
  11251. // Hattrick
  11252. //
  11253.  
  11254. // Show mod info
  11255. // zp_colored_print(0, "^x01**** ^x04%s^x01 ****", g_modname)
  11256. new srvname[64];
  11257. get_pcvar_string(g_srvname, srvname, 63);
  11258. if (!strlen(srvname))
  11259. get_cvar_string("hostname", srvname, 63);
  11260. zp_colored_print(0, "^x01****^x04 %s^x01 ||^x03 ZOMBiE PLAGUE 6.3^x01 by^x04 JonglerulDePalarii^x01 ****", srvname)
  11261. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO1")
  11262. if (!get_pcvar_num(cvar_infammo)) zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO2")
  11263.  
  11264. // Show T-virus HUD notice
  11265. set_hudmessage(0, 125, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  11266. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_VIRUS_FREE")
  11267. }
  11268.  
  11269. // Respawn Player Task (deathmatch)
  11270. public respawn_player_task(taskid)
  11271. {
  11272. // Already alive or round ended
  11273. if (g_isalive[ID_SPAWN] || g_endround)
  11274. return;
  11275.  
  11276. // Get player's team
  11277. static team
  11278. team = fm_cs_get_user_team(ID_SPAWN)
  11279.  
  11280. // Player moved to spectators
  11281. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  11282. return;
  11283.  
  11284. // Hattrick
  11285. //
  11286. // Respawn player automatically if allowed on current round
  11287. //if ((!g_survround || get_pcvar_num(cvar_allowrespawnsurv)) && (!g_swarmround || get_pcvar_num(cvar_allowrespawnswarm)) && (!g_nemround || get_pcvar_num(cvar_allowrespawnnem)) && (!g_plagueround || get_pcvar_num(cvar_allowrespawnplague)))
  11288. if ((!g_survround || get_pcvar_num(cvar_allowrespawnsurv)) && \
  11289. (!g_swarmround || get_pcvar_num(cvar_allowrespawnswarm)) && \
  11290. (!g_avsround || get_pcvar_num(cvar_allowrespawnavs)) && \
  11291. (!g_armageddonround || get_pcvar_num(cvar_allowrespawnarmageddon)) && \
  11292. (!g_nemround || get_pcvar_num(cvar_allowrespawnnem)) && \
  11293. (!g_assassinround || get_pcvar_num(cvar_allowrespawnassassin)) && \
  11294. (!g_sniperround || get_pcvar_num(cvar_allowrespawnsniper)) &&
  11295. (!g_plagueround || get_pcvar_num(cvar_allowrespawnplague)))
  11296. {
  11297. // Hattrick
  11298. //
  11299. // Infection rounds = none of the above
  11300. //if (!get_pcvar_num(cvar_allowrespawninfection) && !g_survround && !g_nemround && !g_swarmround && !g_plagueround)
  11301. if (!get_pcvar_num(cvar_allowrespawninfection) && !g_survround && !g_nemround && !g_assassinround && !g_sniperround && !g_avsround && !g_armageddonround && !g_swarmround && !g_plagueround)
  11302. return;
  11303.  
  11304. // Hattrick
  11305. //
  11306. // Respawn if only the last human is left? (ignore this setting on survivor rounds)
  11307. //if (!g_survround && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() <= 1)
  11308. if (!g_survround && !g_sniperround && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() <= 1)
  11309. return;
  11310.  
  11311. // Respawn as zombie?
  11312. 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))
  11313. g_respawn_as_zombie[ID_SPAWN] = true
  11314.  
  11315. // Hattrick
  11316. //
  11317. // Override respawn as zombie setting on nemesis and survivor rounds
  11318. //if (g_survround) g_respawn_as_zombie[ID_SPAWN] = true
  11319. //else if (g_nemround) g_respawn_as_zombie[ID_SPAWN] = false
  11320. if (g_survround || g_sniperround) g_respawn_as_zombie[ID_SPAWN] = true
  11321. else if (g_nemround || g_assassinround) g_respawn_as_zombie[ID_SPAWN] = false
  11322.  
  11323. respawn_player_manually(ID_SPAWN)
  11324. }
  11325. }
  11326.  
  11327. // Respawn Player Check Task (if killed by worldspawn)
  11328. public respawn_player_check_task(taskid)
  11329. {
  11330. // Successfully spawned or round ended
  11331. if (g_isalive[ID_SPAWN] || g_endround)
  11332. return;
  11333.  
  11334. // Get player's team
  11335. static team
  11336. team = fm_cs_get_user_team(ID_SPAWN)
  11337.  
  11338. // Player moved to spectators
  11339. if (team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED)
  11340. return;
  11341.  
  11342. // If player was being spawned as a zombie, set the flag again
  11343. if (g_zombie[ID_SPAWN]) g_respawn_as_zombie[ID_SPAWN] = true
  11344. else g_respawn_as_zombie[ID_SPAWN] = false
  11345.  
  11346. respawn_player_manually(ID_SPAWN)
  11347. }
  11348.  
  11349. // Respawn Player Manually (called after respawn checks are done)
  11350. respawn_player_manually(id)
  11351. {
  11352. // Set proper team before respawning, so that the TeamInfo message that's sent doesn't confuse PODBots
  11353. if (g_respawn_as_zombie[id])
  11354. fm_cs_set_user_team(id, FM_CS_TEAM_T)
  11355. else
  11356. fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  11357.  
  11358. // Respawning a player has never been so easy
  11359. ExecuteHamB(Ham_CS_RoundRespawn, id)
  11360. }
  11361.  
  11362. // Check Round Task -check that we still have both zombies and humans on a round-
  11363. check_round(leaving_player)
  11364. {
  11365. //lcheck()
  11366.  
  11367. // Round ended or make_a_zombie task still active
  11368. if (g_endround || task_exists(TASK_MAKEZOMBIE))
  11369. return;
  11370.  
  11371. // Get alive players count
  11372. static iPlayersnum, id
  11373. iPlayersnum = fnGetAlive()
  11374.  
  11375. // Last alive player, don't bother
  11376. if (iPlayersnum < 2)
  11377. return;
  11378.  
  11379. // Last zombie disconnecting
  11380. if (g_zombie[leaving_player] && fnGetZombies() == 1)
  11381. {
  11382. // Only one CT left, don't bother
  11383. if (fnGetHumans() == 1 && fnGetCTs() == 1)
  11384. return;
  11385.  
  11386. // Pick a random one to take his place
  11387. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) { /* keep looping */ }
  11388.  
  11389. // Show last zombie left notice
  11390. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_ZOMBIE_LEFT", g_playername[id])
  11391.  
  11392. // Set player leaving flag
  11393. g_lastplayerleaving = true
  11394.  
  11395. // Turn into a Nemesis or just a zombie?
  11396. if (g_nemesis[leaving_player])
  11397. zombieme(id, 0, 1, 0, 0)
  11398. // Hattrick
  11399. //
  11400. else if (g_assassin[leaving_player])
  11401. zombieme_assassin(id, 0, 0)
  11402. else
  11403. zombieme(id, 0, 0, 0, 0)
  11404.  
  11405. // Remove player leaving flag
  11406. g_lastplayerleaving = false
  11407.  
  11408. // Hattrick
  11409. //
  11410. // If Nemesis, set chosen player's health to that of the one who's leaving
  11411. //if (get_pcvar_num(cvar_keephealthondisconnect) && g_nemesis[leaving_player])
  11412. if (get_pcvar_num(cvar_keephealthondisconnect) && (g_nemesis[leaving_player] || g_assassin[leaving_player]))
  11413. fm_set_user_health(id, pev(leaving_player, pev_health))
  11414. }
  11415.  
  11416. // Last human disconnecting
  11417. else if (!g_zombie[leaving_player] && fnGetHumans() == 1)
  11418. {
  11419. // Only one T left, don't bother
  11420. if (fnGetZombies() == 1 && fnGetTs() == 1)
  11421. return;
  11422.  
  11423. // Pick a random one to take his place
  11424. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) { /* keep looping */ }
  11425.  
  11426. // Show last human left notice
  11427. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_HUMAN_LEFT", g_playername[id])
  11428.  
  11429. // Set player leaving flag
  11430. g_lastplayerleaving = true
  11431.  
  11432. // Turn into a Survivor or just a human?
  11433. if (g_survivor[leaving_player])
  11434. humanme(id, 1, 0)
  11435. // Hattrick
  11436. //
  11437. else if (g_sniper[leaving_player])
  11438. humanme_sniper(id)
  11439. else
  11440. humanme(id, 0, 0)
  11441.  
  11442. // Remove player leaving flag
  11443. g_lastplayerleaving = false
  11444.  
  11445. // Hattrick
  11446. //
  11447. // If Survivor, set chosen player's health to that of the one who's leaving
  11448. //if (get_pcvar_num(cvar_keephealthondisconnect) && g_survivor[leaving_player])
  11449. if (get_pcvar_num(cvar_keephealthondisconnect) && (g_survivor[leaving_player] || g_sniper[leaving_player]))
  11450. fm_set_user_health(id, pev(leaving_player, pev_health))
  11451. }
  11452. }
  11453.  
  11454. // Lighting Effects Task
  11455. public lighting_effects()
  11456. {
  11457. // Cache some CVAR values at every 5 secs
  11458. cache_cvars()
  11459.  
  11460. // Get lighting style
  11461. static lighting[2]
  11462. get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
  11463. strtolower(lighting)
  11464.  
  11465. // Lighting disabled? ["0"]
  11466. if (lighting[0] == '0')
  11467. {
  11468. // Hattrick
  11469. //
  11470. if (g_assassinround)
  11471. engfunc(EngFunc_LightStyle, 0, "a")
  11472.  
  11473. return;
  11474. }
  11475.  
  11476. // Darkest light settings?
  11477. if (lighting[0] >= 'a' && lighting[0] <= 'd')
  11478. {
  11479. static thunderclap_in_progress, Float:thunder
  11480. thunderclap_in_progress = task_exists(TASK_THUNDER)
  11481. thunder = get_pcvar_float(cvar_thunder)
  11482.  
  11483. // Set thunderclap tasks if not existant
  11484. if (thunder > 0.0 && !task_exists(TASK_THUNDER_PRE) && !thunderclap_in_progress)
  11485. {
  11486. g_lights_i = 0
  11487. ArrayGetString(lights_thunder, random_num(0, ArraySize(lights_thunder) - 1), g_lights_cycle, charsmax(g_lights_cycle))
  11488. g_lights_cycle_len = strlen(g_lights_cycle)
  11489. set_task(thunder, "thunderclap", TASK_THUNDER_PRE)
  11490. }
  11491.  
  11492. // Set lighting only when no thunderclaps are going on
  11493. if (!thunderclap_in_progress) engfunc(EngFunc_LightStyle, 0, g_assassinround ? "a" : lighting)
  11494. }
  11495. else
  11496. {
  11497. // Remove thunderclap tasks
  11498. remove_task(TASK_THUNDER_PRE)
  11499. remove_task(TASK_THUNDER)
  11500.  
  11501. // Set lighting
  11502. engfunc(EngFunc_LightStyle, 0, g_assassinround ? "a" : lighting)
  11503. }
  11504. }
  11505.  
  11506. // Thunderclap task
  11507. public thunderclap()
  11508. {
  11509. // Play thunder sound
  11510. if (g_lights_i == 0)
  11511. {
  11512. static sound[64]
  11513. ArrayGetString(sound_thunder, random_num(0, ArraySize(sound_thunder) - 1), sound, charsmax(sound))
  11514. PlaySound(sound)
  11515. }
  11516.  
  11517. // Set lighting
  11518. static light[2]
  11519. light[0] = g_lights_cycle[g_lights_i]
  11520. engfunc(EngFunc_LightStyle, 0, light)
  11521.  
  11522. g_lights_i++
  11523.  
  11524. // Lighting cycle end?
  11525. if (g_lights_i >= g_lights_cycle_len)
  11526. {
  11527. remove_task(TASK_THUNDER)
  11528. lighting_effects()
  11529. }
  11530. // Lighting cycle start?
  11531. else if (!task_exists(TASK_THUNDER))
  11532. set_task(0.1, "thunderclap", TASK_THUNDER, _, _, "b")
  11533. }
  11534.  
  11535. // Ambience Sound Effects Task
  11536. public ambience_sound_effects(taskid)
  11537. {
  11538. // Play a random sound depending on the round
  11539. static sound[64], iRand, duration
  11540.  
  11541. if (g_nemround) // Nemesis Mode
  11542. {
  11543. iRand = random_num(0, ArraySize(sound_ambience2) - 1)
  11544. ArrayGetString(sound_ambience2, iRand, sound, charsmax(sound))
  11545. duration = ArrayGetCell(sound_ambience2_duration, iRand)
  11546. }
  11547. // Hattrick
  11548. //
  11549. else if (g_assassinround)
  11550. {
  11551. iRand = random_num(0, ArraySize(sound_ambience6) - 1)
  11552. ArrayGetString(sound_ambience6, iRand, sound, charsmax(sound))
  11553. duration = ArrayGetCell(sound_ambience6_duration, iRand)
  11554. }
  11555. // Hattrick
  11556. //
  11557. else if (g_sniperround)
  11558. {
  11559. iRand = random_num(0, ArraySize(sound_ambience7) - 1)
  11560. ArrayGetString(sound_ambience7, iRand, sound, charsmax(sound))
  11561. duration = ArrayGetCell(sound_ambience7_duration, iRand)
  11562. }
  11563. else if (g_survround) // Survivor Mode
  11564. {
  11565. iRand = random_num(0, ArraySize(sound_ambience3) - 1)
  11566. ArrayGetString(sound_ambience3, iRand, sound, charsmax(sound))
  11567. duration = ArrayGetCell(sound_ambience3_duration, iRand)
  11568. }
  11569. else if (g_swarmround) // Swarm Mode
  11570. {
  11571. iRand = random_num(0, ArraySize(sound_ambience4) - 1)
  11572. ArrayGetString(sound_ambience4, iRand, sound, charsmax(sound))
  11573. duration = ArrayGetCell(sound_ambience4_duration, iRand)
  11574. }
  11575. else if (g_plagueround || g_avsround || g_armageddonround) // Plague Mode
  11576. {
  11577. iRand = random_num(0, ArraySize(sound_ambience5) - 1)
  11578. ArrayGetString(sound_ambience5, iRand, sound, charsmax(sound))
  11579. duration = ArrayGetCell(sound_ambience5_duration, iRand)
  11580. }
  11581. else // Infection Mode
  11582. {
  11583. iRand = random_num(0, ArraySize(sound_ambience1) - 1)
  11584. ArrayGetString(sound_ambience1, iRand, sound, charsmax(sound))
  11585. duration = ArrayGetCell(sound_ambience1_duration, iRand)
  11586. }
  11587.  
  11588. // Play it on clients
  11589. PlaySound(sound)
  11590.  
  11591. // Set the task for when the sound is done playing
  11592. set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  11593. }
  11594.  
  11595. // Ambience Sounds Stop Task
  11596. ambience_sound_stop()
  11597. {
  11598. client_cmd(0, "mp3 stop; stopsound")
  11599. }
  11600.  
  11601. // Flashlight Charge Task
  11602. public flashlight_charge(taskid)
  11603. {
  11604. // Drain or charge?
  11605. if (g_flashlight[ID_CHARGE])
  11606. g_flashbattery[ID_CHARGE] -= get_pcvar_num(cvar_flashdrain)
  11607. else
  11608. g_flashbattery[ID_CHARGE] += get_pcvar_num(cvar_flashcharge)
  11609.  
  11610. // Battery fully charged
  11611. if (g_flashbattery[ID_CHARGE] >= 100)
  11612. {
  11613. // Don't exceed 100%
  11614. g_flashbattery[ID_CHARGE] = 100
  11615.  
  11616. // Update flashlight battery on HUD
  11617. message_begin(MSG_ONE, g_msgFlashBat, _, ID_CHARGE)
  11618. write_byte(100) // battery
  11619. message_end()
  11620.  
  11621. // Task not needed anymore
  11622. remove_task(taskid);
  11623. return;
  11624. }
  11625.  
  11626. // Battery depleted
  11627. if (g_flashbattery[ID_CHARGE] <= 0)
  11628. {
  11629. // Turn it off
  11630. g_flashlight[ID_CHARGE] = false
  11631. g_flashbattery[ID_CHARGE] = 0
  11632.  
  11633. // Play flashlight toggle sound
  11634. emit_sound(ID_CHARGE, CHAN_ITEM, sound_flashlight, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11635.  
  11636. // Update flashlight status on HUD
  11637. message_begin(MSG_ONE, g_msgFlashlight, _, ID_CHARGE)
  11638. write_byte(0) // toggle
  11639. write_byte(0) // battery
  11640. message_end()
  11641.  
  11642. // Remove flashlight task for this player
  11643. remove_task(ID_CHARGE+TASK_FLASH)
  11644. }
  11645. else
  11646. {
  11647. // Update flashlight battery on HUD
  11648. message_begin(MSG_ONE_UNRELIABLE, g_msgFlashBat, _, ID_CHARGE)
  11649. write_byte(g_flashbattery[ID_CHARGE]) // battery
  11650. message_end()
  11651. }
  11652. }
  11653.  
  11654. // Remove Spawn Protection Task
  11655. public remove_spawn_protection(taskid)
  11656. {
  11657. // Not alive
  11658. if (!g_isalive[ID_SPAWN])
  11659. return;
  11660.  
  11661. // Remove spawn protection
  11662. g_nodamage[ID_SPAWN] = false
  11663. set_pev(ID_SPAWN, pev_effects, pev(ID_SPAWN, pev_effects) & ~EF_NODRAW)
  11664. }
  11665.  
  11666. // Hide Player's Money Task
  11667. public task_hide_money(taskid)
  11668. {
  11669. // Not alive
  11670. if (!g_isalive[ID_SPAWN])
  11671. return;
  11672.  
  11673. // Hide money
  11674. message_begin(MSG_ONE, g_msgHideWeapon, _, ID_SPAWN)
  11675. write_byte(HIDE_MONEY) // what to hide bitsum
  11676. message_end()
  11677.  
  11678. // Hide the HL crosshair that's drawn
  11679. message_begin(MSG_ONE, g_msgCrosshair, _, ID_SPAWN)
  11680. write_byte(0) // toggle
  11681. message_end()
  11682. }
  11683.  
  11684. // Turn Off Flashlight and Restore Batteries
  11685. turn_off_flashlight(id)
  11686. {
  11687. // Restore batteries for the next use
  11688. fm_cs_set_user_batteries(id, 100)
  11689.  
  11690. // Check if flashlight is on
  11691. if (pev(id, pev_effects) & EF_DIMLIGHT)
  11692. {
  11693. // Turn it off
  11694. set_pev(id, pev_impulse, IMPULSE_FLASHLIGHT)
  11695. }
  11696. else
  11697. {
  11698. // Clear any stored flashlight impulse (bugfix)
  11699. set_pev(id, pev_impulse, 0)
  11700. }
  11701.  
  11702. // Turn off custom flashlight
  11703. if (g_cached_customflash)
  11704. {
  11705. // Turn it off
  11706. g_flashlight[id] = false
  11707. g_flashbattery[id] = 100
  11708.  
  11709. // Update flashlight HUD
  11710. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  11711. write_byte(0) // toggle
  11712. write_byte(100) // battery
  11713. message_end()
  11714.  
  11715. // Remove previous tasks
  11716. remove_task(id+TASK_CHARGE)
  11717. remove_task(id+TASK_FLASH)
  11718. }
  11719. }
  11720.  
  11721. // Infection Bomb Explosion
  11722. infection_explode(ent)
  11723. {
  11724. // Round ended (bugfix)
  11725. if (g_endround) return;
  11726.  
  11727. // Get origin
  11728. static Float:originF[3]
  11729. pev(ent, pev_origin, originF)
  11730.  
  11731. // Make the explosion
  11732. create_blast(originF)
  11733.  
  11734. // Infection nade explode sound
  11735. static sound[64]
  11736. ArrayGetString(grenade_infect, random_num(0, ArraySize(grenade_infect) - 1), sound, charsmax(sound))
  11737. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11738.  
  11739. // Get attacker
  11740. static attacker
  11741. attacker = pev(ent, pev_owner)
  11742.  
  11743. // Infection bomb owner disconnected? (bugfix)
  11744. if (!is_user_valid_connected(attacker))
  11745. {
  11746. // Get rid of the grenade
  11747. engfunc(EngFunc_RemoveEntity, ent)
  11748. return;
  11749. }
  11750.  
  11751. // Collisions
  11752. static victim
  11753. victim = -1
  11754.  
  11755. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  11756. {
  11757. // Only effect alive non-spawnprotected humans
  11758. if (!is_user_valid_alive(victim) || g_zombie[victim] || g_nodamage[victim] || get_user_godmode(victim))
  11759. continue;
  11760.  
  11761. // Last human is killed
  11762. if (fnGetHumans() == 1)
  11763. {
  11764. ExecuteHamB(Ham_Killed, victim, attacker, 0)
  11765. continue;
  11766. }
  11767.  
  11768. // Infected victim's sound
  11769. ArrayGetString(grenade_infect_player, random_num(0, ArraySize(grenade_infect_player) - 1), sound, charsmax(sound))
  11770. emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11771.  
  11772. // Turn into zombie
  11773. zombieme(victim, attacker, 0, 1, 1)
  11774. }
  11775.  
  11776. // Get rid of the grenade
  11777. engfunc(EngFunc_RemoveEntity, ent)
  11778. }
  11779.  
  11780. // Fire Grenade Explosion
  11781. fire_explode(ent)
  11782. {
  11783. // Get origin
  11784. static Float:originF[3]
  11785. pev(ent, pev_origin, originF)
  11786.  
  11787. // Make the explosion
  11788. create_blast2(originF)
  11789.  
  11790. // Fire nade explode sound
  11791. static sound[64]
  11792. ArrayGetString(grenade_fire, random_num(0, ArraySize(grenade_fire) - 1), sound, charsmax(sound))
  11793. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11794.  
  11795. // Collisions
  11796. static victim
  11797. victim = -1
  11798.  
  11799. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  11800. {
  11801. // Only effect alive zombies
  11802. if (!is_user_valid_alive(victim) || !g_zombie[victim] || g_nodamage[victim] || get_user_godmode(victim))
  11803. continue;
  11804.  
  11805. // Heat icon?
  11806. if (get_pcvar_num(cvar_hudicons))
  11807. {
  11808. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  11809. write_byte(0) // damage save
  11810. write_byte(0) // damage take
  11811. write_long(DMG_BURN) // damage type
  11812. write_coord(0) // x
  11813. write_coord(0) // y
  11814. write_coord(0) // z
  11815. message_end()
  11816. }
  11817.  
  11818. // Hattrick
  11819. //
  11820. //if (g_nemesis[victim]) // fire duration (nemesis is fire resistant)
  11821. if (g_nemesis[victim] || g_assassin[victim])
  11822. g_burning_duration[victim] += get_pcvar_num(cvar_fireduration)
  11823. else
  11824. g_burning_duration[victim] += get_pcvar_num(cvar_fireduration) * 5
  11825.  
  11826. // Set burning task on victim if not present
  11827. if (!task_exists(victim+TASK_BURN))
  11828. set_task(0.2, "burning_flame", victim+TASK_BURN, _, _, "b")
  11829. }
  11830.  
  11831. // Get rid of the grenade
  11832. engfunc(EngFunc_RemoveEntity, ent)
  11833. }
  11834.  
  11835. // Frost Grenade Explosion
  11836. frost_explode(ent)
  11837. {
  11838. // Get origin
  11839. static Float:originF[3]
  11840. pev(ent, pev_origin, originF)
  11841.  
  11842. // Make the explosion
  11843. create_blast3(originF)
  11844.  
  11845. // Frost nade explode sound
  11846. static sound[64]
  11847. ArrayGetString(grenade_frost, random_num(0, ArraySize(grenade_frost) - 1), sound, charsmax(sound))
  11848. emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11849.  
  11850. // Collisions
  11851. static victim
  11852. victim = -1
  11853.  
  11854. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  11855. {
  11856. // Only effect alive unfrozen zombies
  11857. if (!is_user_valid_alive(victim) || !g_zombie[victim] || g_frozen[victim] || get_user_godmode(victim) || g_nodamage[victim])
  11858. continue;
  11859.  
  11860. // Hattrick
  11861. //
  11862. // Nemesis shouldn't be frozen
  11863. //if (g_nemesis[victim])
  11864. if (g_nemesis[victim] || g_assassin[victim])
  11865. {
  11866. // Get player's origin
  11867. static origin2[3]
  11868. get_user_origin(victim, origin2)
  11869.  
  11870. // Broken glass sound
  11871. ArrayGetString(grenade_frost_break, random_num(0, ArraySize(grenade_frost_break) - 1), sound, charsmax(sound))
  11872. emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11873.  
  11874. // Glass shatter
  11875. message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
  11876. write_byte(TE_BREAKMODEL) // TE id
  11877. write_coord(origin2[0]) // x
  11878. write_coord(origin2[1]) // y
  11879. write_coord(origin2[2]+24) // z
  11880. write_coord(16) // size x
  11881. write_coord(16) // size y
  11882. write_coord(16) // size z
  11883. write_coord(random_num(-50, 50)) // velocity x
  11884. write_coord(random_num(-50, 50)) // velocity y
  11885. write_coord(25) // velocity z
  11886. write_byte(10) // random velocity
  11887. write_short(g_glassSpr) // model
  11888. write_byte(10) // count
  11889. write_byte(25) // life
  11890. write_byte(BREAK_GLASS) // flags
  11891. message_end()
  11892.  
  11893. continue;
  11894. }
  11895.  
  11896. // Freeze icon?
  11897. if (get_pcvar_num(cvar_hudicons))
  11898. {
  11899. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  11900. write_byte(0) // damage save
  11901. write_byte(0) // damage take
  11902. write_long(DMG_DROWN) // damage type - DMG_FREEZE
  11903. write_coord(0) // x
  11904. write_coord(0) // y
  11905. write_coord(0) // z
  11906. message_end()
  11907. }
  11908.  
  11909. // Light blue glow while frozen
  11910. if (g_handle_models_on_separate_ent)
  11911. fm_set_rendering(g_ent_playermodel[victim], kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  11912. else
  11913. fm_set_rendering(victim, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  11914.  
  11915. if (g_iEntityID[victim] <= 0)
  11916. {
  11917. new iEnt = 0;
  11918. if (get_cvar_num("zp_zombiefrost_enable_icecube"))
  11919. iEnt= create_entity("info_target");
  11920.  
  11921. if (iEnt <= 0 || !pev_valid(iEnt))
  11922. return;
  11923.  
  11924. g_iEntityID[victim] = iEnt;
  11925. client_PreThink(victim)
  11926.  
  11927. entity_set_model(iEnt, "sprites/674628.spr")
  11928. entity_set_int(iEnt, EV_INT_body, 1)
  11929. entity_set_size(iEnt, Float:{ -19.0, -19.0, -37.0 }, Float:{ 19.0, 19.0, 37.0 }) //17.0, 17.0, 36.0
  11930. entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER) //SOLID_BBOX
  11931. entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_NOCLIP) //MOVETYPE_FLY MOVETYPE_FOLLOW
  11932. // entity_set_edict(iEnt, EV_ENT_aiment, victim); //necessary for MOVETYPE_FOLLOW
  11933. set_rendering(iEnt, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255)
  11934. }
  11935. // Freeze sound
  11936. ArrayGetString(grenade_frost_player, random_num(0, ArraySize(grenade_frost_player) - 1), sound, charsmax(sound))
  11937. emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  11938.  
  11939. // Add a blue tint to their screen
  11940. message_begin(MSG_ONE, g_msgScreenFade, _, victim)
  11941. write_short(0) // duration
  11942. write_short(0) // hold time
  11943. write_short(FFADE_STAYOUT) // fade type
  11944. write_byte(0) // red
  11945. write_byte(50) // green
  11946. write_byte(200) // blue
  11947. write_byte(100) // alpha
  11948. message_end()
  11949.  
  11950. // Set the frozen flag
  11951. g_frozen[victim] = true
  11952.  
  11953. // Save player's old gravity (bugfix)
  11954. pev(victim, pev_gravity, g_frozen_gravity[victim])
  11955.  
  11956. // Prevent from jumping
  11957. if (pev(victim, pev_flags) & FL_ONGROUND)
  11958. set_pev(victim, pev_gravity, 999999.9) // set really high
  11959. else
  11960. set_pev(victim, pev_gravity, 0.000001) // no gravity
  11961.  
  11962. // Prevent from moving
  11963. ExecuteHamB(Ham_Player_ResetMaxSpeed, victim)
  11964.  
  11965. // Set a task to remove the freeze
  11966. set_task(get_pcvar_float(cvar_freezeduration), "remove_freeze", victim)
  11967. }
  11968.  
  11969. // Get rid of the grenade
  11970. engfunc(EngFunc_RemoveEntity, ent)
  11971. }
  11972.  
  11973. // Hattrick
  11974. //
  11975. // Frost Grenade Explosion
  11976. explosive_explode(ent)
  11977. {
  11978. // Get origin
  11979. static Float:originF[3], victim, Float:dmg, Float:HP
  11980. pev(ent, pev_origin, originF)
  11981.  
  11982. // Make the explosion
  11983. create_blast4(originF)
  11984.  
  11985. // Collisions
  11986. victim = -1
  11987.  
  11988. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  11989. write_byte(TE_EXPLOSION)
  11990. engfunc(EngFunc_WriteCoord, originF[0])
  11991. engfunc(EngFunc_WriteCoord, originF[1])
  11992. engfunc(EngFunc_WriteCoord, originF[2] + random_float(15.0, 25.0))
  11993. write_short(g_zexplo)
  11994. write_byte(15)
  11995. write_byte(0)
  11996. write_byte(TE_EXPLFLAG_NONE)
  11997. message_end()
  11998.  
  11999. new owner = pev(ent, pev_owner);
  12000.  
  12001. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  12002. {
  12003. // Only effect alive unfrozen zombies
  12004. if (!is_user_valid_alive(victim) || !g_zombie[victim] || get_user_godmode(victim) || g_nodamage[victim] || (g_frozen[victim] && !get_pcvar_num(cvar_damagewhilefrost)))
  12005. continue;
  12006.  
  12007. // Add a blue tint to their screen
  12008. message_begin(MSG_ONE, g_msgScreenFade, _, victim)
  12009. write_short(0) // duration
  12010. write_short(0) // hold time
  12011. write_short(FFADE_STAYOUT) // fade type
  12012. write_byte(220) // red
  12013. write_byte(0) // green
  12014. write_byte(0) // blue
  12015. write_byte(100) // alpha
  12016. message_end()
  12017.  
  12018. if (is_user_connected(owner))
  12019. {
  12020. dmg = 920.0 - entity_range(owner, victim);
  12021. if (dmg > 0.0)
  12022. {
  12023. HP=entity_get_float(victim,EV_FL_health);
  12024.  
  12025. if (HP-dmg > 0.0)
  12026. ExecuteHamB(Ham_TakeDamage, victim, ent, owner, dmg, DMG_MORTAR)
  12027. else
  12028. ExecuteHamB(Ham_Killed, victim, owner, 2)
  12029. }
  12030. }
  12031. }
  12032.  
  12033. // Get rid of the grenade
  12034. engfunc(EngFunc_RemoveEntity, ent)
  12035. }
  12036.  
  12037. // Remove freeze task
  12038. public remove_freeze(id)
  12039. {
  12040. if (g_iEntityID[id]> 0 && pev_valid(g_iEntityID[id]))
  12041. {
  12042. remove_entity(g_iEntityID[id])
  12043. g_iEntityID[id]=0
  12044. }
  12045. // Not alive or not frozen anymore
  12046. if (!g_isalive[id] || !g_frozen[id])
  12047. return;
  12048.  
  12049. // Unfreeze
  12050. g_frozen[id] = false;
  12051.  
  12052. // Restore gravity and maxspeed (bugfix)
  12053. set_pev(id, pev_gravity, g_frozen_gravity[id])
  12054. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  12055.  
  12056. // Restore rendering
  12057. if (g_handle_models_on_separate_ent)
  12058. {
  12059. // Nemesis or Survivor glow / remove glow on player model entity
  12060. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  12061. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  12062. // Hattrick
  12063. //
  12064. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  12065. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  12066.  
  12067. else if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  12068. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  12069.  
  12070. // Hattrick
  12071. //
  12072. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  12073. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 120, 200, kRenderNormal, 25)
  12074. else
  12075. fm_set_rendering(g_ent_playermodel[id])
  12076. }
  12077. else
  12078. {
  12079. // Nemesis or Survivor glow / remove glow
  12080. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow))
  12081. fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  12082. // Hattrick
  12083. //
  12084. else if (g_assassin[id] && get_pcvar_num(cvar_assassinglow))
  12085. fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  12086.  
  12087. else if (g_survivor[id] && get_pcvar_num(cvar_survglow))
  12088. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  12089. // Hattrick
  12090. //
  12091. else if (g_sniper[id] && get_pcvar_num(cvar_sniperglow))
  12092. fm_set_rendering(id, kRenderFxGlowShell, 0, 120, 200, kRenderNormal, 25)
  12093. else
  12094. fm_set_rendering(id)
  12095. }
  12096.  
  12097. // Gradually remove screen's blue tint
  12098. message_begin(MSG_ONE, g_msgScreenFade, _, id)
  12099. write_short(UNIT_SECOND) // duration
  12100. write_short(0) // hold time
  12101. write_short(FFADE_IN) // fade type
  12102. write_byte(0) // red
  12103. write_byte(50) // green
  12104. write_byte(200) // blue
  12105. write_byte(100) // alpha
  12106. message_end()
  12107.  
  12108. // Broken glass sound
  12109. static sound[64]
  12110. ArrayGetString(grenade_frost_break, random_num(0, ArraySize(grenade_frost_break) - 1), sound, charsmax(sound))
  12111. emit_sound(id, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  12112.  
  12113. // Get player's origin
  12114. static origin2[3]
  12115. get_user_origin(id, origin2)
  12116.  
  12117. // Glass shatter
  12118. message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
  12119. write_byte(TE_BREAKMODEL) // TE id
  12120. write_coord(origin2[0]) // x
  12121. write_coord(origin2[1]) // y
  12122. write_coord(origin2[2]+24) // z
  12123. write_coord(16) // size x
  12124. write_coord(16) // size y
  12125. write_coord(16) // size z
  12126. write_coord(random_num(-50, 50)) // velocity x
  12127. write_coord(random_num(-50, 50)) // velocity y
  12128. write_coord(25) // velocity z
  12129. write_byte(10) // random velocity
  12130. write_short(g_glassSpr) // model
  12131. write_byte(10) // count
  12132. write_byte(25) // life
  12133. write_byte(BREAK_GLASS) // flags
  12134. message_end()
  12135.  
  12136. ExecuteForward(g_fwUserUnfrozen, g_fwDummyResult, id);
  12137. }
  12138.  
  12139. // Remove Stuff Task
  12140. public remove_stuff()
  12141. {
  12142. static ent
  12143.  
  12144. // Remove rotating doors
  12145. if (get_pcvar_num(cvar_removedoors) > 0)
  12146. {
  12147. ent = -1;
  12148. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door_rotating")) != 0)
  12149. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  12150. }
  12151.  
  12152. // Remove all doors
  12153. if (get_pcvar_num(cvar_removedoors) > 1)
  12154. {
  12155. ent = -1;
  12156. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door")) != 0)
  12157. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  12158. }
  12159.  
  12160. // Triggered lights
  12161. if (!get_pcvar_num(cvar_triggered))
  12162. {
  12163. ent = -1
  12164. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "light")) != 0)
  12165. {
  12166. dllfunc(DLLFunc_Use, ent, 0); // turn off the light
  12167. set_pev(ent, pev_targetname, 0) // prevent it from being triggered
  12168. }
  12169. }
  12170. }
  12171.  
  12172. // Set Custom Weapon Models
  12173. replace_weapon_models(id, weaponid)
  12174. {
  12175. switch (weaponid)
  12176. {
  12177. case CSW_AK47:
  12178. {
  12179. if (zp_get_gold_ak(id))
  12180. {
  12181. set_pev(id, pev_viewmodel2, "models/ZombieOutstanding/v_golden_ak47.mdl")
  12182. set_pev(id, pev_weaponmodel2, "models/ZombieOutstanding/p_golden_ak47.mdl")
  12183. }
  12184. }
  12185. case CSW_DEAGLE:
  12186. {
  12187. if (zp_get_gold_de(id))
  12188. {
  12189. set_pev(id, pev_viewmodel2, "models/ZombieOutstanding/v_golden_deagle.mdl")
  12190. set_pev(id, pev_weaponmodel2, "models/ZombieOutstanding/p_golden_deagle.mdl")
  12191. }
  12192. }
  12193. case CSW_KNIFE: // Custom knife models
  12194. {
  12195. if (g_zombie[id])
  12196. {
  12197. if (g_nemesis[id]) // Nemesis
  12198. {
  12199. set_pev(id, pev_viewmodel2, model_vknife_nemesis)
  12200. set_pev(id, pev_weaponmodel2, "")
  12201. }
  12202. // Hattrick
  12203. //
  12204. else if (g_assassin[id])
  12205. {
  12206. set_pev(id, pev_viewmodel2, model_vknife_assassin)
  12207. set_pev(id, pev_weaponmodel2, "")
  12208. }
  12209. else // Zombies
  12210. {
  12211. // Admin knife models?
  12212. if (get_pcvar_num(cvar_adminknifemodelszombie) && get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS])
  12213. {
  12214. set_pev(id, pev_viewmodel2, model_vknife_admin_zombie)
  12215. set_pev(id, pev_weaponmodel2, "")
  12216. }
  12217. else
  12218. {
  12219. static clawmodel[100]
  12220. ArrayGetString(g_zclass_clawmodel, g_zombieclass[id], clawmodel, charsmax(clawmodel))
  12221. format(clawmodel, charsmax(clawmodel), "models/zombie_plague/%s", clawmodel)
  12222. set_pev(id, pev_viewmodel2, clawmodel)
  12223. set_pev(id, pev_weaponmodel2, "")
  12224. }
  12225. }
  12226. }
  12227. else // Humans
  12228. {
  12229. // Admin knife models?
  12230. if (get_pcvar_num(cvar_adminknifemodelshuman) && get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS])
  12231. {
  12232. if (!zp_get_jp(id))
  12233. {
  12234. set_pev(id, pev_viewmodel2, model_vknife_admin_human)
  12235. set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
  12236. }
  12237. }
  12238. else
  12239. {
  12240. if (!zp_get_jp(id))
  12241. {
  12242. set_pev(id, pev_viewmodel2, model_vknife_human)
  12243. set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
  12244. }
  12245. }
  12246. if (zp_get_jp(id))
  12247. {
  12248. set_pev(id, pev_viewmodel2, "models/v_egon.mdl")
  12249. set_pev(id, pev_weaponmodel2, "models/p_egon.mdl")
  12250. }
  12251. }
  12252. }
  12253. case CSW_HEGRENADE: // Infection bomb or fire grenade
  12254. {
  12255. if (g_zombie[id])
  12256. set_pev(id, pev_viewmodel2, model_grenade_infect)
  12257. else
  12258. set_pev(id, pev_viewmodel2, model_grenade_fire)
  12259. }
  12260. case CSW_FLASHBANG: // Frost grenade
  12261. {
  12262. set_pev(id, pev_viewmodel2, model_grenade_frost)
  12263. }
  12264. case CSW_SMOKEGRENADE: // Flare grenade
  12265. {
  12266. set_pev(id, pev_viewmodel2, model_grenade_flare)
  12267. }
  12268. case CSW_AWP:
  12269. {
  12270. if (g_sniper[id])
  12271. {
  12272. set_pev(id, pev_viewmodel2, model_vawp_sniper);
  12273. set_pev(id, pev_weaponmodel2, model_pawp_sniper);
  12274. }
  12275. }
  12276. }
  12277.  
  12278. // Hattrick
  12279. //
  12280. // Survivor's custom weapon model
  12281. //static survweaponname[32]
  12282. //get_pcvar_string(cvar_survweapon, survweaponname, charsmax(survweaponname))
  12283. //if (g_survivor[id] && weaponid == cs_weapon_name_to_id(survweaponname))
  12284. // set_pev(id, pev_viewmodel2, model_vweapon_survivor)
  12285.  
  12286. // Update model on weaponmodel ent
  12287. if (g_handle_models_on_separate_ent) fm_set_weaponmodel_ent(id)
  12288. }
  12289.  
  12290. // Reset Player Vars
  12291. reset_vars(id, resetall)
  12292. {
  12293. g_zombie[id] = false
  12294. g_nemesis[id] = false
  12295. g_survivor[id] = false
  12296. g_firstzombie[id] = false
  12297. g_lastzombie[id] = false
  12298. g_lasthuman[id] = false
  12299. g_frozen[id] = false
  12300.  
  12301. // Hattrick
  12302. //
  12303. g_sniper[id] = false
  12304. g_assassin[id] = false
  12305.  
  12306. g_nodamage[id] = false
  12307. g_respawn_as_zombie[id] = false
  12308. g_nvision[id] = false
  12309. g_nvisionenabled[id] = false
  12310. g_flashlight[id] = false
  12311. g_flashbattery[id] = 100
  12312. g_canbuy[id] = true
  12313. g_burning_duration[id] = 0
  12314.  
  12315. if (resetall)
  12316. {
  12317. g_ammopacks[id] = get_pcvar_num(cvar_startammopacks)
  12318. g_zombieclass[id] = ZCLASS_NONE
  12319. g_zombieclassnext[id] = ZCLASS_NONE
  12320. g_damagedealt_human[id] = 0
  12321. g_damagedealt_zombie[id] = 0
  12322. WPN_AUTO_ON = 0
  12323. WPN_STARTID = 0
  12324. PL_ACTION = 0
  12325. MENU_PAGE_ZCLASS = 0
  12326. MENU_PAGE_EXTRAS = 0
  12327. MENU_PAGE_PLAYERS = 0
  12328. }
  12329. }
  12330.  
  12331. // Set spectators nightvision
  12332. public spec_nvision(id)
  12333. {
  12334. // Not connected, alive, or bot
  12335. if (!g_isconnected[id] || g_isalive[id] || g_isbot[id])
  12336. return;
  12337.  
  12338. // Give Night Vision?
  12339. if (get_pcvar_num(cvar_nvggive))
  12340. {
  12341. g_nvision[id] = true
  12342.  
  12343. // Turn on Night Vision automatically?
  12344. if (get_pcvar_num(cvar_nvggive) == 1)
  12345. {
  12346. g_nvisionenabled[id] = true
  12347.  
  12348. // Custom nvg?
  12349. if (get_pcvar_num(cvar_customnvg))
  12350. {
  12351. remove_task(id+TASK_NVISION)
  12352. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  12353. }
  12354. else
  12355. set_user_gnvision(id, 1)
  12356. }
  12357. }
  12358. }
  12359.  
  12360. // Show HUD Task
  12361. public ShowHUD(taskid)
  12362. {
  12363. static id
  12364. id = ID_SHOWHUD;
  12365.  
  12366. // Player died?
  12367. if (!g_isalive[id])
  12368. {
  12369. // Get spectating target
  12370. id = pev(id, PEV_SPEC_TARGET)
  12371.  
  12372. // Target not alive
  12373. if (!g_isalive[id]) return;
  12374. }
  12375.  
  12376. // Format classname
  12377. static class[32], red, green, blue
  12378.  
  12379. if (g_zombie[id]) // zombies
  12380. {
  12381. // Hattrick
  12382. //
  12383. //red = 200
  12384. //green = 250
  12385. //blue = 0
  12386. red = 205
  12387. green = 30
  12388. blue = 0
  12389.  
  12390. if (g_nemesis[id])
  12391. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
  12392. // Hattrick
  12393. //
  12394. else if (g_assassin[id])
  12395. formatex(class, charsmax(class), "Assassin")
  12396. else
  12397. copy(class, charsmax(class), g_zombie_classname[id])
  12398. }
  12399. else // humans
  12400. {
  12401. // Hattrick
  12402. //
  12403. //red = 0
  12404. //green = 0
  12405. //blue = 255
  12406. red = 0
  12407. green = 120
  12408. blue = 190
  12409.  
  12410. if (g_survivor[id])
  12411. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
  12412. // Hattrick
  12413. //
  12414. else if (g_sniper[id])
  12415. formatex(class, charsmax(class), "Sniper");
  12416. else
  12417. formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_HUMAN")
  12418. }
  12419. static hp[32], armor[32], ammo[32], points[32];
  12420. // Spectating someone else?
  12421. if (id != ID_SHOWHUD)
  12422. {
  12423. // Hattrick
  12424. //
  12425. // Show name, health, class, and ammo packs
  12426. //set_hudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  12427. set_hudmessage(238, 170, 25, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  12428.  
  12429. // Hattrick
  12430. //
  12431. // ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L %s^nHP: %d - %L %s - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id])
  12432.  
  12433. AddCommas(get_user_health(id), hp, 31);
  12434. AddCommas(get_user_armor(id), armor, 31);
  12435. AddCommas(g_ammopacks[id], ammo, 31);
  12436. AddCommas(g_points[id], points, 31);
  12437. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L %s%s^n%s, HP: %s Armor: %s Ammo: %s Points: %s^nFrom: %s, %s", ID_SHOWHUD, "SPECTATING", g_vip[id] ? "(ViP ®)" : "", g_playername[id], class, hp, armor, ammo, points, g_country[id], g_city[id])
  12438. }
  12439. else
  12440. {
  12441. // Show health, class and ammo packs
  12442. set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  12443.  
  12444. // Hattrick
  12445. //
  12446. AddCommas(get_user_health(ID_SHOWHUD), hp, 31);
  12447. AddCommas(get_user_armor(ID_SHOWHUD), armor, 31);
  12448. AddCommas(g_ammopacks[ID_SHOWHUD], ammo, 31);
  12449. AddCommas(g_points[ID_SHOWHUD], points, 31);
  12450. // ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d - %L %s - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD])
  12451. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%s, HP: %s Armor: %s Ammo: %s Points: %s", class, hp, armor, ammo, points)
  12452. }
  12453. }
  12454.  
  12455. // Play idle zombie sounds
  12456. public zombie_play_idle(taskid)
  12457. {
  12458. // Round ended/new one starting
  12459. if (g_endround || g_newround)
  12460. return;
  12461.  
  12462. static sound[64]
  12463.  
  12464. // Last zombie?
  12465. if (g_lastzombie[ID_BLOOD])
  12466. {
  12467. ArrayGetString(zombie_idle_last, random_num(0, ArraySize(zombie_idle_last) - 1), sound, charsmax(sound))
  12468. emit_sound(ID_BLOOD, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  12469. }
  12470. else
  12471. {
  12472. ArrayGetString(zombie_idle, random_num(0, ArraySize(zombie_idle) - 1), sound, charsmax(sound))
  12473. emit_sound(ID_BLOOD, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  12474. }
  12475. }
  12476.  
  12477. // Madness Over Task
  12478. public madness_over(taskid)
  12479. {
  12480. g_nodamage[ID_BLOOD] = false
  12481. }
  12482.  
  12483. // Place user at a random spawn
  12484. do_random_spawn(id, regularspawns = 0)
  12485. {
  12486. static hull, sp_index, i
  12487.  
  12488. // Get whether the player is crouching
  12489. hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  12490.  
  12491. // Use regular spawns?
  12492. if (!regularspawns)
  12493. {
  12494. // No spawns?
  12495. if (!g_spawnCount)
  12496. return;
  12497.  
  12498. // Choose random spawn to start looping at
  12499. sp_index = random_num(0, g_spawnCount - 1)
  12500.  
  12501. // Try to find a clear spawn
  12502. for (i = sp_index + 1; /*no condition*/; i++)
  12503. {
  12504. // Start over when we reach the end
  12505. if (i >= g_spawnCount) i = 0
  12506.  
  12507. // Free spawn space?
  12508. if (is_hull_vacant(g_spawns[i], hull))
  12509. {
  12510. // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  12511. engfunc(EngFunc_SetOrigin, id, g_spawns[i])
  12512. break;
  12513. }
  12514.  
  12515. // Loop completed, no free space found
  12516. if (i == sp_index) break;
  12517. }
  12518. }
  12519. else
  12520. {
  12521. // No spawns?
  12522. if (!g_spawnCount2)
  12523. return;
  12524.  
  12525. // Choose random spawn to start looping at
  12526. sp_index = random_num(0, g_spawnCount2 - 1)
  12527.  
  12528. // Try to find a clear spawn
  12529. for (i = sp_index + 1; /*no condition*/; i++)
  12530. {
  12531. // Start over when we reach the end
  12532. if (i >= g_spawnCount2) i = 0
  12533.  
  12534. // Free spawn space?
  12535. if (is_hull_vacant(g_spawns2[i], hull))
  12536. {
  12537. // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  12538. engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
  12539. break;
  12540. }
  12541.  
  12542. // Loop completed, no free space found
  12543. if (i == sp_index) break;
  12544. }
  12545. }
  12546. }
  12547.  
  12548. // Get Zombies -returns alive zombies number-
  12549. fnGetZombies()
  12550. {
  12551. static iZombies, id
  12552. iZombies = 0
  12553.  
  12554. for (id = 1; id <= g_maxplayers; id++)
  12555. {
  12556. if (g_isalive[id] && g_zombie[id])
  12557. iZombies++
  12558. }
  12559.  
  12560. return iZombies;
  12561. }
  12562.  
  12563. // Get Humans -returns alive humans number-
  12564. fnGetHumans()
  12565. {
  12566. static iHumans, id
  12567. iHumans = 0
  12568.  
  12569. for (id = 1; id <= g_maxplayers; id++)
  12570. {
  12571. if (g_isalive[id] && !g_zombie[id])
  12572. iHumans++
  12573. }
  12574.  
  12575. return iHumans;
  12576. }
  12577.  
  12578. // Get Nemesis -returns alive nemesis number-
  12579. fnGetNemesis()
  12580. {
  12581. static iNemesis, id
  12582. iNemesis = 0
  12583.  
  12584. for (id = 1; id <= g_maxplayers; id++)
  12585. {
  12586. if (g_isalive[id] && g_nemesis[id])
  12587. iNemesis++
  12588. }
  12589.  
  12590. return iNemesis;
  12591. }
  12592.  
  12593. // Hattrick
  12594. //
  12595. // Get Nemesis -returns alive nemesis number-
  12596. fnGetAssassins()
  12597. {
  12598. static iNemesis, id
  12599. iNemesis = 0
  12600.  
  12601. for (id = 1; id <= g_maxplayers; id++)
  12602. {
  12603. if (g_isalive[id] && g_assassin[id])
  12604. iNemesis++
  12605. }
  12606.  
  12607. return iNemesis;
  12608. }
  12609.  
  12610. // Get Survivors -returns alive survivors number-
  12611. fnGetSurvivors()
  12612. {
  12613. static iSurvivors, id
  12614. iSurvivors = 0
  12615.  
  12616. for (id = 1; id <= g_maxplayers; id++)
  12617. {
  12618. if (g_isalive[id] && g_survivor[id])
  12619. iSurvivors++
  12620. }
  12621.  
  12622. return iSurvivors;
  12623. }
  12624.  
  12625. // Hattrick
  12626. //
  12627. // Get Survivors -returns alive survivors number-
  12628. fnGetSnipers()
  12629. {
  12630. static iSurvivors, id
  12631. iSurvivors = 0
  12632.  
  12633. for (id = 1; id <= g_maxplayers; id++)
  12634. {
  12635. if (g_isalive[id] && g_sniper[id])
  12636. iSurvivors++
  12637. }
  12638.  
  12639. return iSurvivors;
  12640. }
  12641.  
  12642. // Get Alive -returns alive players number-
  12643. fnGetAlive()
  12644. {
  12645. static iAlive, id
  12646. iAlive = 0
  12647.  
  12648. for (id = 1; id <= g_maxplayers; id++)
  12649. {
  12650. if (g_isalive[id])
  12651. iAlive++
  12652. }
  12653.  
  12654. return iAlive;
  12655. }
  12656.  
  12657. // Get Random Alive -returns index of alive player number n -
  12658. fnGetRandomAlive(n)
  12659. {
  12660. static iAlive, id
  12661. iAlive = 0
  12662.  
  12663. for (id = 1; id <= g_maxplayers; id++)
  12664. {
  12665. if (g_isalive[id])
  12666. iAlive++
  12667.  
  12668. if (iAlive == n)
  12669. return id;
  12670. }
  12671.  
  12672. return -1;
  12673. }
  12674.  
  12675. // Get Playing -returns number of users playing-
  12676. fnGetPlaying()
  12677. {
  12678. static iPlaying, id, team
  12679. iPlaying = 0
  12680.  
  12681. for (id = 1; id <= g_maxplayers; id++)
  12682. {
  12683. if (g_isconnected[id])
  12684. {
  12685. team = fm_cs_get_user_team(id)
  12686.  
  12687. if (team != FM_CS_TEAM_SPECTATOR && team != FM_CS_TEAM_UNASSIGNED)
  12688. iPlaying++
  12689. }
  12690. }
  12691.  
  12692. return iPlaying;
  12693. }
  12694.  
  12695. // Get CTs -returns number of CTs connected-
  12696. fnGetCTs()
  12697. {
  12698. static iCTs, id
  12699. iCTs = 0
  12700.  
  12701. for (id = 1; id <= g_maxplayers; id++)
  12702. {
  12703. if (g_isconnected[id])
  12704. {
  12705. if (fm_cs_get_user_team(id) == FM_CS_TEAM_CT)
  12706. iCTs++
  12707. }
  12708. }
  12709.  
  12710. return iCTs;
  12711. }
  12712.  
  12713. // Get Ts -returns number of Ts connected-
  12714. fnGetTs()
  12715. {
  12716. static iTs, id
  12717. iTs = 0
  12718.  
  12719. for (id = 1; id <= g_maxplayers; id++)
  12720. {
  12721. if (g_isconnected[id])
  12722. {
  12723. if (fm_cs_get_user_team(id) == FM_CS_TEAM_T)
  12724. iTs++
  12725. }
  12726. }
  12727.  
  12728. return iTs;
  12729. }
  12730.  
  12731. // Get Alive CTs -returns number of CTs alive-
  12732. fnGetAliveCTs()
  12733. {
  12734. static iCTs, id
  12735. iCTs = 0
  12736.  
  12737. for (id = 1; id <= g_maxplayers; id++)
  12738. {
  12739. if (g_isalive[id])
  12740. {
  12741. if (fm_cs_get_user_team(id) == FM_CS_TEAM_CT)
  12742. iCTs++
  12743. }
  12744. }
  12745.  
  12746. return iCTs;
  12747. }
  12748.  
  12749. // Get Alive Ts -returns number of Ts alive-
  12750. fnGetAliveTs()
  12751. {
  12752. static iTs, id
  12753. iTs = 0
  12754.  
  12755. for (id = 1; id <= g_maxplayers; id++)
  12756. {
  12757. if (g_isalive[id])
  12758. {
  12759. if (fm_cs_get_user_team(id) == FM_CS_TEAM_T)
  12760. iTs++
  12761. }
  12762. }
  12763.  
  12764. return iTs;
  12765. }
  12766.  
  12767. // Last Zombie Check -check for last zombie and set its flag-
  12768. fnCheckLastZombie()
  12769. {
  12770. static id
  12771. for (id = 1; id <= g_maxplayers; id++)
  12772. {
  12773. // Hattrick
  12774. //
  12775. // Last zombie
  12776. //if (g_isalive[id] && g_zombie[id] && !g_nemesis[id] && fnGetZombies() == 1)
  12777. if (g_isalive[id] && g_zombie[id] && !g_nemesis[id] && !g_assassin[id] && fnGetZombies() == 1)
  12778. {
  12779. if (!g_lastzombie[id])
  12780. {
  12781. // Last zombie forward
  12782. ExecuteForward(g_fwUserLastZombie, g_fwDummyResult, id);
  12783. }
  12784. g_lastzombie[id] = true
  12785. }
  12786. else
  12787. g_lastzombie[id] = false
  12788.  
  12789. // Hattrick
  12790. //
  12791. // Last human
  12792. //if (g_isalive[id] && !g_zombie[id] && !g_survivor[id] && fnGetHumans() == 1)
  12793. if (g_isalive[id] && !g_zombie[id] && !g_survivor[id] && !g_sniper[id] && fnGetHumans() == 1)
  12794. {
  12795. if (!g_lasthuman[id])
  12796. {
  12797. // Last human forward
  12798. ExecuteForward(g_fwUserLastHuman, g_fwDummyResult, id);
  12799.  
  12800. // Reward extra hp
  12801. fm_set_user_health(id, pev(id, pev_health) + get_pcvar_num(cvar_humanlasthp))
  12802. }
  12803. g_lasthuman[id] = true
  12804. }
  12805. else
  12806. g_lasthuman[id] = false
  12807. }
  12808. }
  12809.  
  12810. // Save player's stats to database
  12811. save_stats(id)
  12812. {
  12813. // Check whether there is another record already in that slot
  12814. if (db_name[id][0] && !equal(g_playername[id], db_name[id]))
  12815. {
  12816. // If DB size is exceeded, write over old records
  12817. if (db_slot_i >= sizeof db_name)
  12818. db_slot_i = g_maxplayers+1
  12819.  
  12820. // Move previous record onto an additional save slot
  12821. copy(db_name[db_slot_i], charsmax(db_name[]), db_name[id])
  12822. db_ammopacks[db_slot_i] = db_ammopacks[id]
  12823. db_zombieclass[db_slot_i] = db_zombieclass[id]
  12824. db_slot_i++
  12825. }
  12826.  
  12827. // Now save the current player stats
  12828. copy(db_name[id], charsmax(db_name[]), g_playername[id]) // name
  12829. db_ammopacks[id] = g_ammopacks[id] // ammo packs
  12830. db_zombieclass[id] = g_zombieclassnext[id] // zombie class
  12831. }
  12832.  
  12833. // Load player's stats from database (if a record is found)
  12834. load_stats(id)
  12835. {
  12836. // Look for a matching record
  12837. static i
  12838. for (i = 0; i < sizeof db_name; i++)
  12839. {
  12840. if (equal(g_playername[id], db_name[i]))
  12841. {
  12842. // Bingo!
  12843. g_ammopacks[id] = db_ammopacks[i]
  12844. g_zombieclass[id] = db_zombieclass[i]
  12845. g_zombieclassnext[id] = db_zombieclass[i]
  12846. return;
  12847. }
  12848. }
  12849. }
  12850.  
  12851. // Checks if a player is allowed to be zombie
  12852. allowed_zombie(id)
  12853. {
  12854. if ((g_zombie[id] && !g_nemesis[id]) || g_endround || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  12855. return false;
  12856.  
  12857. return true;
  12858. }
  12859.  
  12860. // Checks if a player is allowed to be human
  12861. allowed_human(id)
  12862. {
  12863. if ((!g_zombie[id] && !g_survivor[id]) || g_endround || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  12864. return false;
  12865.  
  12866. return true;
  12867. }
  12868.  
  12869. // Checks if a player is allowed to be survivor
  12870. allowed_survivor(id)
  12871. {
  12872. if (g_endround || g_survivor[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  12873. return false;
  12874.  
  12875. return true;
  12876. }
  12877.  
  12878. // Hattrick
  12879. //
  12880. // Checks if a player is allowed to be survivor
  12881. allowed_sniper(id)
  12882. {
  12883. if (g_endround || g_sniper[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && g_zombie[id] && fnGetZombies() == 1))
  12884. return false;
  12885.  
  12886. return true;
  12887. }
  12888.  
  12889. // Checks if a player is allowed to be nemesis
  12890. allowed_nemesis(id)
  12891. {
  12892. if (g_endround || g_nemesis[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  12893. return false;
  12894.  
  12895. return true;
  12896. }
  12897.  
  12898. // Hattrick
  12899. //
  12900. // Checks if a player is allowed to be nemesis
  12901. allowed_assassin(id)
  12902. {
  12903. if (g_endround || g_assassin[id] || !g_isalive[id] || task_exists(TASK_WELCOMEMSG) || (!g_newround && !g_zombie[id] && fnGetHumans() == 1))
  12904. return false;
  12905.  
  12906. return true;
  12907. }
  12908.  
  12909. // Checks if a player is allowed to respawn
  12910. allowed_respawn(id)
  12911. {
  12912. static team
  12913. team = fm_cs_get_user_team(id)
  12914.  
  12915. if (g_endround || team == FM_CS_TEAM_SPECTATOR || team == FM_CS_TEAM_UNASSIGNED || g_isalive[id])
  12916. return false;
  12917.  
  12918. return true;
  12919. }
  12920.  
  12921. // Checks if swarm mode is allowed
  12922. allowed_swarm()
  12923. {
  12924. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG))
  12925. return false;
  12926.  
  12927. return true;
  12928. }
  12929.  
  12930. // Checks if swarm mode is allowed
  12931. allowed_armageddon()
  12932. {
  12933. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG))
  12934. return false;
  12935.  
  12936. return true;
  12937. }
  12938.  
  12939. // Checks if swarm mode is allowed
  12940. allowed_avs()
  12941. {
  12942. if (g_endround || !g_newround || task_exists(TASK_WELCOMEMSG))
  12943. return false;
  12944.  
  12945. return true;
  12946. }
  12947.  
  12948. // Checks if multi infection mode is allowed
  12949. allowed_multi()
  12950. {
  12951. 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())
  12952. return false;
  12953.  
  12954. return true;
  12955. }
  12956.  
  12957. // Checks if plague mode is allowed
  12958. allowed_plague()
  12959. {
  12960. 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
  12961. || 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)
  12962. return false;
  12963.  
  12964. return true;
  12965. }
  12966.  
  12967. // Admin Command. zp_zombie
  12968. command_zombie(id, player)
  12969. {
  12970. // Show activity?
  12971. switch (get_pcvar_num(cvar_showactivity))
  12972. {
  12973. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_INFECT")
  12974. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_INFECT")
  12975. }
  12976.  
  12977. // Log to Zombie Plague log file?
  12978. if (get_pcvar_num(cvar_logcommands))
  12979. {
  12980. static logdata[100], authid[32], ip[16]
  12981. get_user_authid(id, authid, charsmax(authid))
  12982. get_user_ip(id, ip, charsmax(ip), 1)
  12983. 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)
  12984. log_to_file("zombieplague.log", logdata)
  12985. }
  12986.  
  12987. // New round?
  12988. if (g_newround)
  12989. {
  12990. // Set as first zombie
  12991. remove_task(TASK_MAKEZOMBIE)
  12992. make_a_zombie(MODE_INFECTION, player)
  12993. }
  12994. else
  12995. {
  12996. // Just infect
  12997. zombieme(player, 0, 0, 0, 0)
  12998. }
  12999. }
  13000.  
  13001. // Admin Command. zp_human
  13002. command_human(id, player)
  13003. {
  13004. // Show activity?
  13005. switch (get_pcvar_num(cvar_showactivity))
  13006. {
  13007. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
  13008. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
  13009. }
  13010.  
  13011. // Log to Zombie Plague log file?
  13012. if (get_pcvar_num(cvar_logcommands))
  13013. {
  13014. static logdata[100], authid[32], ip[16]
  13015. get_user_authid(id, authid, charsmax(authid))
  13016. get_user_ip(id, ip, charsmax(ip), 1)
  13017. 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)
  13018. log_to_file("zombieplague.log", logdata)
  13019. }
  13020.  
  13021. // Turn to human
  13022. humanme(player, 0, 0)
  13023. }
  13024.  
  13025. // Admin Command. zp_survivor
  13026. command_survivor(id, player)
  13027. {
  13028. // Show activity?
  13029. switch (get_pcvar_num(cvar_showactivity))
  13030. {
  13031. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_SURVIVAL")
  13032. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_SURVIVAL")
  13033. }
  13034.  
  13035. // Log to Zombie Plague log file?
  13036. if (get_pcvar_num(cvar_logcommands))
  13037. {
  13038. static logdata[100], authid[32], ip[16]
  13039. get_user_authid(id, authid, charsmax(authid))
  13040. get_user_ip(id, ip, charsmax(ip), 1)
  13041. 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)
  13042. log_to_file("zombieplague.log", logdata)
  13043. }
  13044.  
  13045. // New round?
  13046. if (g_newround)
  13047. {
  13048. // Set as first survivor
  13049. remove_task(TASK_MAKEZOMBIE)
  13050. make_a_zombie(MODE_SURVIVOR, player)
  13051. }
  13052. else
  13053. {
  13054. // Turn player into a Survivor
  13055. humanme(player, 1, 0)
  13056. }
  13057. }
  13058.  
  13059. // Hattrick
  13060. //
  13061. // Admin Command. zp_survivor
  13062. command_sniper(id, player)
  13063. {
  13064. // Show activity?
  13065. switch (get_pcvar_num(cvar_showactivity))
  13066. {
  13067. case 1: client_print(0, print_chat, "ADMIN - %s turned into a Sniper", g_playername[player])
  13068. case 2: client_print(0, print_chat, "ADMIN %s - %s turned into a Sniper", g_playername[id], g_playername[player])
  13069. }
  13070.  
  13071. // Log to Zombie Plague log file?
  13072. if (get_pcvar_num(cvar_logcommands))
  13073. {
  13074. static logdata[100], authid[32], ip[16]
  13075. get_user_authid(id, authid, charsmax(authid))
  13076. get_user_ip(id, ip, charsmax(ip), 1)
  13077. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s turned into a Sniper (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], fnGetPlaying(), g_maxplayers)
  13078. log_to_file("zombieplague.log", logdata)
  13079. }
  13080.  
  13081. // New round?
  13082. if (g_newround)
  13083. {
  13084. // Set as first survivor
  13085. remove_task(TASK_MAKEZOMBIE)
  13086. make_a_zombie(MODE_SNIPER, player)
  13087. }
  13088. else
  13089. {
  13090. // Turn player into a Survivor
  13091. humanme_sniper(player)
  13092. }
  13093. }
  13094.  
  13095. // Admin Command. zp_nemesis
  13096. command_nemesis(id, player)
  13097. {
  13098. // Show activity?
  13099. switch (get_pcvar_num(cvar_showactivity))
  13100. {
  13101. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_NEMESIS")
  13102. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_NEMESIS")
  13103. }
  13104.  
  13105. // Log to Zombie Plague log file?
  13106. if (get_pcvar_num(cvar_logcommands))
  13107. {
  13108. static logdata[100], authid[32], ip[16]
  13109. get_user_authid(id, authid, charsmax(authid))
  13110. get_user_ip(id, ip, charsmax(ip), 1)
  13111. 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)
  13112. log_to_file("zombieplague.log", logdata)
  13113. }
  13114.  
  13115. // New round?
  13116. if (g_newround)
  13117. {
  13118. // Set as first nemesis
  13119. remove_task(TASK_MAKEZOMBIE)
  13120. make_a_zombie(MODE_NEMESIS, player)
  13121. }
  13122. else
  13123. {
  13124. // Turn player into a Nemesis
  13125. zombieme(player, 0, 1, 0, 0)
  13126. }
  13127. }
  13128.  
  13129. // Hattrick
  13130. //
  13131. // Admin Command. zp_nemesis
  13132. command_assassin(id, player)
  13133. {
  13134. // Show activity?
  13135. switch (get_pcvar_num(cvar_showactivity))
  13136. {
  13137. case 1: client_print(0, print_chat, "ADMIN - %s turned into an Assassin", g_playername[player])
  13138. case 2: client_print(0, print_chat, "ADMIN %s - %s turned into an Assassin", g_playername[id], g_playername[player])
  13139. }
  13140.  
  13141. // Log to Zombie Plague log file?
  13142. if (get_pcvar_num(cvar_logcommands))
  13143. {
  13144. static logdata[100], authid[32], ip[16]
  13145. get_user_authid(id, authid, charsmax(authid))
  13146. get_user_ip(id, ip, charsmax(ip), 1)
  13147. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s turned into an Assassin (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], fnGetPlaying(), g_maxplayers)
  13148. log_to_file("zombieplague.log", logdata)
  13149. }
  13150.  
  13151. // New round?
  13152. if (g_newround)
  13153. {
  13154. // Set as first nemesis
  13155. remove_task(TASK_MAKEZOMBIE)
  13156. make_a_zombie(MODE_ASSASSIN, player)
  13157. }
  13158. else
  13159. {
  13160. // Turn player into a Nemesis
  13161. zombieme_assassin(player, 0, 0)
  13162. }
  13163. }
  13164.  
  13165. // Admin Command. zp_respawn
  13166. command_respawn(id, player)
  13167. {
  13168. // Show activity?
  13169. switch (get_pcvar_num(cvar_showactivity))
  13170. {
  13171. case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_RESPAWN")
  13172. case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_RESPAWN")
  13173. }
  13174.  
  13175. // Log to Zombie Plague log file?
  13176. if (get_pcvar_num(cvar_logcommands))
  13177. {
  13178. static logdata[100], authid[32], ip[16]
  13179. get_user_authid(id, authid, charsmax(authid))
  13180. get_user_ip(id, ip, charsmax(ip), 1)
  13181. 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)
  13182. log_to_file("zombieplague.log", logdata)
  13183. }
  13184.  
  13185. // Respawn as zombie?
  13186. 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))
  13187. g_respawn_as_zombie[player] = true
  13188.  
  13189. // Hattrick
  13190. //
  13191. // Override respawn as zombie setting on nemesis and survivor rounds
  13192. //if (g_survround) g_respawn_as_zombie[player] = true
  13193. //else if (g_nemround) g_respawn_as_zombie[player] = false
  13194. if (g_survround || g_sniperround) g_respawn_as_zombie[player] = true
  13195. else if (g_nemround || g_assassinround) g_respawn_as_zombie[player] = false
  13196.  
  13197. respawn_player_manually(player);
  13198. }
  13199.  
  13200. // Admin Command. zp_swarm
  13201. command_swarm(id)
  13202. {
  13203. // Show activity?
  13204. switch (get_pcvar_num(cvar_showactivity))
  13205. {
  13206. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_SWARM")
  13207. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_SWARM")
  13208. }
  13209.  
  13210. // Log to Zombie Plague log file?
  13211. if (get_pcvar_num(cvar_logcommands))
  13212. {
  13213. static logdata[100], authid[32], ip[16]
  13214. get_user_authid(id, authid, charsmax(authid))
  13215. get_user_ip(id, ip, charsmax(ip), 1)
  13216. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER, "CMD_SWARM", fnGetPlaying(), g_maxplayers)
  13217. log_to_file("zombieplague.log", logdata)
  13218. }
  13219.  
  13220. // Call Swarm Mode
  13221. remove_task(TASK_MAKEZOMBIE)
  13222. make_a_zombie(MODE_SWARM, 0)
  13223. }
  13224.  
  13225. // Admin Command. zp_swarm
  13226. command_avs(id)
  13227. {
  13228. // Show activity?
  13229. switch (get_pcvar_num(cvar_showactivity))
  13230. {
  13231. case 1: client_print(0, print_chat, "ADMIN - Started Assassins VS Snipers")
  13232. case 2: client_print(0, print_chat, "ADMIN %s - Started Assassins VS Snipers", g_playername[id])
  13233. }
  13234.  
  13235. // Log to Zombie Plague log file?
  13236. if (get_pcvar_num(cvar_logcommands))
  13237. {
  13238. static logdata[100], authid[32], ip[16]
  13239. get_user_authid(id, authid, charsmax(authid))
  13240. get_user_ip(id, ip, charsmax(ip), 1)
  13241. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - Started Assassins VS Snipers (Players: %d/%d)", g_playername[id], authid, ip, fnGetPlaying(), g_maxplayers)
  13242. log_to_file("zombieplague.log", logdata)
  13243. }
  13244.  
  13245. // Call Swarm Mode
  13246. remove_task(TASK_MAKEZOMBIE)
  13247. make_a_zombie(MODE_AVS, 0)
  13248. }
  13249.  
  13250. command_armageddon(id)
  13251. {
  13252. // Show activity?
  13253. switch (get_pcvar_num(cvar_showactivity))
  13254. {
  13255. case 1: client_print(0, print_chat, "ADMIN - Started Armageddon")
  13256. case 2: client_print(0, print_chat, "ADMIN %s - Started Armageddon", g_playername[id])
  13257. }
  13258.  
  13259. // Log to Zombie Plague log file?
  13260. if (get_pcvar_num(cvar_logcommands))
  13261. {
  13262. static logdata[100], authid[32], ip[16]
  13263. get_user_authid(id, authid, charsmax(authid))
  13264. get_user_ip(id, ip, charsmax(ip), 1)
  13265. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - Started Armageddon (Players: %d/%d)", g_playername[id], authid, ip, fnGetPlaying(), g_maxplayers)
  13266. log_to_file("zombieplague.log", logdata)
  13267. }
  13268.  
  13269. // Call Swarm Mode
  13270. remove_task(TASK_MAKEZOMBIE)
  13271. make_a_zombie(MODE_ARMAGEDDON, 0)
  13272. }
  13273.  
  13274. // Admin Command. zp_multi
  13275. command_multi(id)
  13276. {
  13277. // Show activity?
  13278. switch (get_pcvar_num(cvar_showactivity))
  13279. {
  13280. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_MULTI")
  13281. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_MULTI")
  13282. }
  13283.  
  13284. // Log to Zombie Plague log file?
  13285. if (get_pcvar_num(cvar_logcommands))
  13286. {
  13287. static logdata[100], authid[32], ip[16]
  13288. get_user_authid(id, authid, charsmax(authid))
  13289. get_user_ip(id, ip, charsmax(ip), 1)
  13290. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER,"CMD_MULTI", fnGetPlaying(), g_maxplayers)
  13291. log_to_file("zombieplague.log", logdata)
  13292. }
  13293.  
  13294. // Call Multi Infection
  13295. remove_task(TASK_MAKEZOMBIE)
  13296. make_a_zombie(MODE_MULTI, 0)
  13297. }
  13298.  
  13299. // Admin Command. zp_plague
  13300. command_plague(id)
  13301. {
  13302. // Show activity?
  13303. switch (get_pcvar_num(cvar_showactivity))
  13304. {
  13305. case 1: client_print(0, print_chat, "ADMIN - %L", LANG_PLAYER, "CMD_PLAGUE")
  13306. case 2: client_print(0, print_chat, "ADMIN %s - %L", g_playername[id], LANG_PLAYER, "CMD_PLAGUE")
  13307. }
  13308.  
  13309. // Log to Zombie Plague log file?
  13310. if (get_pcvar_num(cvar_logcommands))
  13311. {
  13312. static logdata[100], authid[32], ip[16]
  13313. get_user_authid(id, authid, charsmax(authid))
  13314. get_user_ip(id, ip, charsmax(ip), 1)
  13315. formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %L (Players: %d/%d)", g_playername[id], authid, ip, LANG_SERVER,"CMD_PLAGUE", fnGetPlaying(), g_maxplayers)
  13316. log_to_file("zombieplague.log", logdata)
  13317. }
  13318.  
  13319. // Call Plague Mode
  13320. remove_task(TASK_MAKEZOMBIE)
  13321. make_a_zombie(MODE_PLAGUE, 0)
  13322. }
  13323.  
  13324. // Set proper maxspeed for player
  13325. set_player_maxspeed(id)
  13326. {
  13327. // If frozen, prevent from moving
  13328. if (g_frozen[id])
  13329. {
  13330. set_pev(id, pev_maxspeed, 1.0)
  13331. }
  13332. // Otherwise, set maxspeed directly
  13333. else
  13334. {
  13335. if (g_zombie[id])
  13336. {
  13337. if (g_nemesis[id])
  13338. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_nemspd))
  13339. // Hattrick
  13340. //
  13341. else if (g_assassin[id])
  13342. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_assassinspd));
  13343. else
  13344. set_pev(id, pev_maxspeed, g_zombie_spd[id])
  13345. }
  13346. else
  13347. {
  13348. if (g_survivor[id])
  13349. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_survspd))
  13350. // Hattrick
  13351. //
  13352. else if (g_sniper[id])
  13353. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_sniperspd));
  13354. else if (get_pcvar_float(cvar_humanspd) > 0.0)
  13355. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_humanspd))
  13356. }
  13357. }
  13358. }
  13359.  
  13360. /*================================================================================
  13361. [Custom Natives]
  13362. =================================================================================*/
  13363.  
  13364. public zp_frozen(id)
  13365. {
  13366. if (!is_user_valid(id))
  13367. {
  13368. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13369. return -1;
  13370. }
  13371.  
  13372. return g_frozen[id];
  13373. }
  13374.  
  13375. public native_is_user_infector(id)
  13376. {
  13377. if (!is_user_valid(id))
  13378. {
  13379. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13380. return -1;
  13381. }
  13382.  
  13383. return g_infector[id];
  13384. }
  13385.  
  13386. // Native: zp_get_user_zombie
  13387. public native_get_user_zombie(id)
  13388. {
  13389. if (!is_user_valid(id))
  13390. {
  13391. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13392. return -1;
  13393. }
  13394.  
  13395. return g_zombie[id];
  13396. }
  13397.  
  13398. // Native: zp_get_user_nemesis
  13399. public native_get_user_nemesis(id)
  13400. {
  13401. if (!is_user_valid(id))
  13402. {
  13403. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13404. return -1;
  13405. }
  13406.  
  13407. return g_nemesis[id];
  13408. }
  13409.  
  13410. // Hattrick
  13411. //
  13412. public native_get_user_assassin(id)
  13413. {
  13414. if (!is_user_valid(id))
  13415. {
  13416. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13417. return -1;
  13418. }
  13419.  
  13420. return g_assassin[id];
  13421. }
  13422.  
  13423. // Native: zp_get_user_survivor
  13424. public native_get_user_survivor(id)
  13425. {
  13426. if (!is_user_valid(id))
  13427. {
  13428. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13429. return -1;
  13430. }
  13431.  
  13432. return g_survivor[id];
  13433. }
  13434.  
  13435. // Hattrick
  13436. //
  13437. // Native: zp_get_user_survivor
  13438. public native_get_user_sniper(id)
  13439. {
  13440. if (!is_user_valid(id))
  13441. {
  13442. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13443. return -1;
  13444. }
  13445.  
  13446. return g_sniper[id];
  13447. }
  13448.  
  13449. public native_get_user_first_zombie(id)
  13450. {
  13451. if (!is_user_valid(id))
  13452. {
  13453. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13454. return -1;
  13455. }
  13456.  
  13457. return g_firstzombie[id];
  13458. }
  13459.  
  13460. // Native: zp_get_user_last_zombie
  13461. public native_get_user_last_zombie(id)
  13462. {
  13463. if (!is_user_valid(id))
  13464. {
  13465. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13466. return -1;
  13467. }
  13468.  
  13469. return g_lastzombie[id];
  13470. }
  13471.  
  13472. // Native: zp_get_user_last_human
  13473. public native_get_user_last_human(id)
  13474. {
  13475. if (!is_user_valid(id))
  13476. {
  13477. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13478. return -1;
  13479. }
  13480.  
  13481. return g_lasthuman[id];
  13482. }
  13483.  
  13484. // Native: zp_get_user_zombie_class
  13485. public native_get_user_zombie_class(id)
  13486. {
  13487. if (!is_user_valid(id))
  13488. {
  13489. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13490. return -1;
  13491. }
  13492.  
  13493. return g_zombieclass[id];
  13494. }
  13495.  
  13496. // Native: zp_get_user_next_class
  13497. public native_get_user_next_class(id)
  13498. {
  13499. if (!is_user_valid(id))
  13500. {
  13501. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13502. return -1;
  13503. }
  13504.  
  13505. return g_zombieclassnext[id];
  13506. }
  13507.  
  13508. // Native: zp_set_user_zombie_class
  13509. public native_set_user_zombie_class(id, classid)
  13510. {
  13511. if (!is_user_valid(id))
  13512. {
  13513. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13514. return false;
  13515. }
  13516.  
  13517. if (classid < 0 || classid >= g_zclass_i)
  13518. {
  13519. log_error(AMX_ERR_NATIVE, "[ZP] Invalid zombie class id (%d)", classid)
  13520. return false;
  13521. }
  13522.  
  13523. g_zombieclassnext[id] = classid
  13524. return true;
  13525. }
  13526.  
  13527. // Native: zp_get_user_ammo_packs
  13528. public native_get_user_ammo_packs(id)
  13529. {
  13530. if (!is_user_valid(id))
  13531. {
  13532. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13533. return -1;
  13534. }
  13535.  
  13536. return g_ammopacks[id];
  13537. }
  13538.  
  13539. // Hattrick
  13540. //
  13541. public native_get_user_no_damage(id)
  13542. {
  13543. if (!is_user_valid(id))
  13544. {
  13545. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13546. return -1;
  13547. }
  13548.  
  13549. return g_nodamage[id];
  13550. }
  13551.  
  13552. // Hattrick
  13553. //
  13554. // Native: zp_get_user_ammo_packs
  13555. public native_get_user_zp_points(id)
  13556. {
  13557. if (!is_user_valid(id))
  13558. {
  13559. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13560. return -1;
  13561. }
  13562.  
  13563. return g_points[id];
  13564. }
  13565.  
  13566. // Native: zp_set_user_ammo_packs
  13567. public native_set_user_ammo_packs(id, amount)
  13568. {
  13569. if (!is_user_valid(id))
  13570. {
  13571. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13572. return false;
  13573. }
  13574.  
  13575. g_ammopacks[id] = amount;
  13576. return true;
  13577. }
  13578.  
  13579. // Hattrick
  13580. //
  13581. // Native: zp_set_user_ammo_packs
  13582. public native_set_user_zp_points(id, amount)
  13583. {
  13584. if (!is_user_valid(id))
  13585. {
  13586. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13587. return false;
  13588. }
  13589.  
  13590. g_points[id] = amount;
  13591. savePoints(id)
  13592. return true;
  13593. }
  13594.  
  13595. // Native: zp_get_zombie_maxhealth
  13596. public native_get_zombie_maxhealth(id)
  13597. {
  13598. // ZP disabled
  13599. if (!g_pluginenabled)
  13600. return -1;
  13601.  
  13602. if (!is_user_valid(id))
  13603. {
  13604. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13605. return -1;
  13606. }
  13607.  
  13608. if (!g_zombie[id] || g_nemesis[id])
  13609. {
  13610. log_error(AMX_ERR_NATIVE, "[ZP] Player not a normal zombie (%d)", id)
  13611. return -1;
  13612. }
  13613.  
  13614. if (g_firstzombie[id])
  13615. return floatround(float(ArrayGetCell(g_zclass_hp, g_zombieclass[id])) * get_pcvar_float(cvar_zombiefirsthp));
  13616.  
  13617. return ArrayGetCell(g_zclass_hp, g_zombieclass[id]);
  13618. }
  13619.  
  13620. // Native: zp_get_user_batteries
  13621. public native_get_user_batteries(id)
  13622. {
  13623. if (!is_user_valid(id))
  13624. {
  13625. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13626. return -1;
  13627. }
  13628.  
  13629. return g_flashbattery[id];
  13630. }
  13631.  
  13632. // Native: zp_set_user_batteries
  13633. public native_set_user_batteries(id, value)
  13634. {
  13635. // ZP disabled
  13636. if (!g_pluginenabled)
  13637. return false;
  13638.  
  13639. if (!is_user_valid_connected(id))
  13640. {
  13641. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13642. return false;
  13643. }
  13644.  
  13645. g_flashbattery[id] = clamp(value, 0, 100);
  13646.  
  13647. if (g_cached_customflash)
  13648. {
  13649. // Set the flashlight charge task to update battery status
  13650. remove_task(id+TASK_CHARGE)
  13651. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  13652. }
  13653. return true;
  13654. }
  13655.  
  13656. // Native: zp_get_user_nightvision
  13657. public native_get_user_nightvision(id)
  13658. {
  13659. if (!is_user_valid(id))
  13660. {
  13661. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13662. return -1;
  13663. }
  13664.  
  13665. return g_nvision[id];
  13666. }
  13667.  
  13668. // Native: zp_set_user_nightvision
  13669. public native_set_user_nightvision(id, set)
  13670. {
  13671. // ZP disabled
  13672. if (!g_pluginenabled)
  13673. return false;
  13674.  
  13675. if (!is_user_valid_connected(id))
  13676. {
  13677. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13678. return false;
  13679. }
  13680.  
  13681. if (set)
  13682. {
  13683. g_nvision[id] = true
  13684.  
  13685. if (!g_isbot[id])
  13686. {
  13687. g_nvisionenabled[id] = true
  13688.  
  13689. // Custom nvg?
  13690. if (get_pcvar_num(cvar_customnvg))
  13691. {
  13692. remove_task(id+TASK_NVISION)
  13693. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  13694. }
  13695. else
  13696. set_user_gnvision(id, 1)
  13697. }
  13698. else
  13699. cs_set_user_nvg(id, 1)
  13700. }
  13701. else
  13702. {
  13703. // Remove CS nightvision if player owns one (bugfix)
  13704. cs_set_user_nvg(id, 0)
  13705.  
  13706. if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
  13707. else if (g_nvisionenabled[id]) set_user_gnvision(id, 0)
  13708. g_nvision[id] = false
  13709. g_nvisionenabled[id] = false
  13710. }
  13711. return true;
  13712. }
  13713.  
  13714. // Native: zp_infect_user
  13715. public native_infect_user(id, infector, silent, rewards)
  13716. {
  13717. // ZP disabled
  13718. if (!g_pluginenabled)
  13719. return false;
  13720.  
  13721. if (!is_user_valid_alive(id))
  13722. {
  13723. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13724. return false;
  13725. }
  13726.  
  13727. // Not allowed to be zombie
  13728. if (!allowed_zombie(id))
  13729. return false;
  13730.  
  13731. // New round?
  13732. if (g_newround)
  13733. {
  13734. // Set as first zombie
  13735. remove_task(TASK_MAKEZOMBIE)
  13736. make_a_zombie(MODE_INFECTION, id)
  13737. }
  13738. else
  13739. {
  13740. // Just infect (plus some checks)
  13741. zombieme(id, is_user_valid_alive(infector) ? infector : 0, 0, (silent == 1) ? 1 : 0, (rewards == 1) ? 1 : 0)
  13742. }
  13743. return true;
  13744. }
  13745.  
  13746. // Native: zp_disinfect_user
  13747. public native_disinfect_user(id, silent)
  13748. {
  13749. // ZP disabled
  13750. if (!g_pluginenabled)
  13751. return false;
  13752.  
  13753. if (!is_user_valid_alive(id))
  13754. {
  13755. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13756. return false;
  13757. }
  13758.  
  13759. // Not allowed to be human
  13760. if (!allowed_human(id))
  13761. return false;
  13762.  
  13763. // Turn to human
  13764. humanme(id, 0, (silent == 1) ? 1 : 0)
  13765. return true;
  13766. }
  13767.  
  13768. // Native: zp_make_user_nemesis
  13769. public native_make_user_nemesis(id)
  13770. {
  13771. // ZP disabled
  13772. if (!g_pluginenabled)
  13773. return false;
  13774.  
  13775. if (!is_user_valid_alive(id))
  13776. {
  13777. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13778. return false;
  13779. }
  13780.  
  13781. // Not allowed to be nemesis
  13782. if (!allowed_nemesis(id))
  13783. return false;
  13784.  
  13785. // New round?
  13786. if (g_newround)
  13787. {
  13788. // Set as first nemesis
  13789. remove_task(TASK_MAKEZOMBIE)
  13790. make_a_zombie(MODE_NEMESIS, id)
  13791. }
  13792. else
  13793. {
  13794. // Turn player into a Nemesis
  13795. zombieme(id, 0, 1, 0, 0)
  13796. }
  13797. return true;
  13798. }
  13799.  
  13800. // Hattrick
  13801. //
  13802. // Native: zp_make_user_nemesis
  13803. public native_make_user_assassin(id)
  13804. {
  13805. // ZP disabled
  13806. if (!g_pluginenabled)
  13807. return false;
  13808.  
  13809. if (!is_user_valid_alive(id))
  13810. {
  13811. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13812. return false;
  13813. }
  13814.  
  13815. // Not allowed to be nemesis
  13816. if (!allowed_assassin(id))
  13817. return false;
  13818.  
  13819. // New round?
  13820. if (g_newround)
  13821. {
  13822. // Set as first nemesis
  13823. remove_task(TASK_MAKEZOMBIE)
  13824. make_a_zombie(MODE_ASSASSIN, id)
  13825. }
  13826. else
  13827. {
  13828. // Turn player into a Nemesis
  13829. zombieme_assassin(id, 0, 0)
  13830. }
  13831. return true;
  13832. }
  13833.  
  13834. // Native: zp_make_user_survivor
  13835. public native_make_user_survivor(id)
  13836. {
  13837. // ZP disabled
  13838. if (!g_pluginenabled)
  13839. return false;
  13840.  
  13841. if (!is_user_valid_alive(id))
  13842. {
  13843. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13844. return false;
  13845. }
  13846.  
  13847. // Not allowed to be survivor
  13848. if (!allowed_survivor(id))
  13849. return false;
  13850.  
  13851. // New round?
  13852. if (g_newround)
  13853. {
  13854. // Set as first survivor
  13855. remove_task(TASK_MAKEZOMBIE)
  13856. make_a_zombie(MODE_SURVIVOR, id)
  13857. }
  13858. else
  13859. {
  13860. // Turn player into a Survivor
  13861. humanme(id, 1, 0)
  13862. }
  13863.  
  13864. return true;
  13865. }
  13866.  
  13867. // Hattrick
  13868. //
  13869. // Native: zp_make_user_survivor
  13870. public native_make_user_sniper(id)
  13871. {
  13872. // ZP disabled
  13873. if (!g_pluginenabled)
  13874. return false;
  13875.  
  13876. if (!is_user_valid_alive(id))
  13877. {
  13878. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13879. return false;
  13880. }
  13881.  
  13882. // Not allowed to be survivor
  13883. if (!allowed_sniper(id))
  13884. return false;
  13885.  
  13886. // New round?
  13887. if (g_newround)
  13888. {
  13889. // Set as first survivor
  13890. remove_task(TASK_MAKEZOMBIE)
  13891. make_a_zombie(MODE_SNIPER, id)
  13892. }
  13893. else
  13894. {
  13895. // Turn player into a Survivor
  13896. humanme_sniper(id)
  13897. }
  13898.  
  13899. return true;
  13900. }
  13901.  
  13902. // Native: zp_respawn_user
  13903. public native_respawn_user(id, team)
  13904. {
  13905. // ZP disabled
  13906. if (!g_pluginenabled)
  13907. return false;
  13908.  
  13909. if (!is_user_valid_connected(id))
  13910. {
  13911. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13912. return false;
  13913. }
  13914.  
  13915. // Respawn not allowed
  13916. if (!allowed_respawn(id))
  13917. return false;
  13918.  
  13919. // Respawn as zombie?
  13920. g_respawn_as_zombie[id] = (team == ZP_TEAM_ZOMBIE) ? true : false
  13921.  
  13922. // Respawnish!
  13923. respawn_player_manually(id)
  13924. return true;
  13925. }
  13926.  
  13927. // Native: zp_force_buy_extra_item
  13928. public native_force_buy_extra_item(id, itemid, ignorecost)
  13929. {
  13930. // ZP disabled
  13931. if (!g_pluginenabled)
  13932. return false;
  13933.  
  13934. if (!is_user_valid_alive(id))
  13935. {
  13936. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13937. return false;
  13938. }
  13939.  
  13940. if (itemid < 0 || itemid >= g_extraitem_i)
  13941. {
  13942. log_error(AMX_ERR_NATIVE, "[ZP] Invalid extra item id (%d)", itemid)
  13943. return false;
  13944. }
  13945.  
  13946. buy_extra_item(id, itemid, ignorecost)
  13947. return true;
  13948. }
  13949.  
  13950. // Native: zp_override_user_model
  13951. public native_override_user_model(id, const newmodel[], modelindex)
  13952. {
  13953. // ZP disabled
  13954. if (!g_pluginenabled)
  13955. return false;
  13956.  
  13957. if (!is_user_valid_connected(id))
  13958. {
  13959. log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  13960. return false;
  13961. }
  13962.  
  13963. // Strings passed byref
  13964. param_convert(2)
  13965.  
  13966. // Remove previous tasks
  13967. remove_task(id+TASK_MODEL)
  13968.  
  13969. // Custom models stuff
  13970. static currentmodel[32]
  13971.  
  13972. if (g_handle_models_on_separate_ent)
  13973. {
  13974. // Set the right model
  13975. copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
  13976. if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
  13977.  
  13978. // Set model on player model entity
  13979. fm_set_playermodel_ent(id)
  13980. }
  13981. else
  13982. {
  13983. // Get current model for comparing it with the current one
  13984. fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
  13985.  
  13986. // Set the right model, after checking that we don't already have it
  13987. if (!equal(currentmodel, newmodel))
  13988. {
  13989. copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
  13990. if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
  13991.  
  13992. // An additional delay is offset at round start
  13993. // since SVC_BAD is more likely to be triggered there
  13994. if (g_newround)
  13995. set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
  13996. else
  13997. fm_user_model_update(id+TASK_MODEL)
  13998. }
  13999. }
  14000. return true;
  14001. }
  14002.  
  14003. // Native: zp_has_round_started
  14004. public native_has_round_started()
  14005. {
  14006. if (g_newround) return 0; // not started
  14007. if (g_modestarted) return 1; // started
  14008. return 2; // starting
  14009. }
  14010.  
  14011. // Native: zp_is_nemesis_round
  14012. public native_is_nemesis_round()
  14013. {
  14014. return g_nemround;
  14015. }
  14016.  
  14017. // Hattrick
  14018. //
  14019. // Native: zp_is_nemesis_round
  14020. public native_is_assassin_round()
  14021. {
  14022. return g_assassinround;
  14023. }
  14024.  
  14025. // Native: zp_is_survivor_round
  14026. public native_is_survivor_round()
  14027. {
  14028. return g_survround;
  14029. }
  14030.  
  14031. // Hattrick
  14032. //
  14033. // Native: zp_is_survivor_round
  14034. public native_is_sniper_round()
  14035. {
  14036. return g_sniperround;
  14037. }
  14038.  
  14039. // Native: zp_is_swarm_round
  14040. public native_is_swarm_round()
  14041. {
  14042. return g_swarmround;
  14043. }
  14044.  
  14045. // Native: zp_is_plague_round
  14046. public native_is_plague_round()
  14047. {
  14048. return g_plagueround;
  14049. }
  14050.  
  14051. // Native: zp_get_zombie_count
  14052. public native_get_zombie_count()
  14053. {
  14054. return fnGetZombies();
  14055. }
  14056.  
  14057. // Native: zp_get_human_count
  14058. public native_get_human_count()
  14059. {
  14060. return fnGetHumans();
  14061. }
  14062.  
  14063. // Native: zp_get_nemesis_count
  14064. public native_get_nemesis_count()
  14065. {
  14066. return fnGetNemesis();
  14067. }
  14068.  
  14069. // Native: zp_get_survivor_count
  14070. public native_get_survivor_count()
  14071. {
  14072. return fnGetSurvivors();
  14073. }
  14074.  
  14075. // Hattrick
  14076. //
  14077. public native_get_sniper_count()
  14078. {
  14079. return fnGetSnipers();
  14080. }
  14081.  
  14082. // Hattrick
  14083. //
  14084. public native_get_assassin_count()
  14085. {
  14086. return fnGetAssassins();
  14087. }
  14088.  
  14089. // Native: zp_register_extra_item
  14090. public native_register_extra_item(const name[], cost, team)
  14091. {
  14092. // ZP disabled
  14093. if (!g_pluginenabled)
  14094. return -1;
  14095.  
  14096. // Strings passed byref
  14097. param_convert(1)
  14098.  
  14099. // Arrays not yet initialized
  14100. if (!g_arrays_created)
  14101. {
  14102. log_error(AMX_ERR_NATIVE, "[ZP] Can't register extra item yet (%s)", name)
  14103. return -1;
  14104. }
  14105.  
  14106. if (strlen(name) < 1)
  14107. {
  14108. log_error(AMX_ERR_NATIVE, "[ZP] Can't register extra item with an empty name")
  14109. return -1;
  14110. }
  14111.  
  14112. new index, extraitem_name[32]
  14113. for (index = 0; index < g_extraitem_i; index++)
  14114. {
  14115. ArrayGetString(g_extraitem_name, index, extraitem_name, charsmax(extraitem_name))
  14116. if (equali(name, extraitem_name))
  14117. {
  14118. log_error(AMX_ERR_NATIVE, "[ZP] Extra item already registered (%s)", name)
  14119. return -1;
  14120. }
  14121. }
  14122.  
  14123. // For backwards compatibility
  14124. if (team == ZP_TEAM_ANY)
  14125. team = (ZP_TEAM_ZOMBIE|ZP_TEAM_HUMAN)
  14126.  
  14127. // Add the item
  14128. ArrayPushString(g_extraitem_name, name)
  14129. ArrayPushCell(g_extraitem_cost, cost)
  14130. ArrayPushCell(g_extraitem_team, team)
  14131.  
  14132. // Set temporary new item flag
  14133. ArrayPushCell(g_extraitem_new, 1)
  14134.  
  14135. // Override extra items data with our customizations
  14136. new i, buffer[32], size = ArraySize(g_extraitem2_realname)
  14137. for (i = 0; i < size; i++)
  14138. {
  14139. ArrayGetString(g_extraitem2_realname, i, buffer, charsmax(buffer))
  14140.  
  14141. // Check if this is the intended item to override
  14142. if (!equal(name, buffer))
  14143. continue;
  14144.  
  14145. // Remove new item flag
  14146. ArraySetCell(g_extraitem_new, g_extraitem_i, 0)
  14147.  
  14148. // Replace caption
  14149. ArrayGetString(g_extraitem2_name, i, buffer, charsmax(buffer))
  14150. ArraySetString(g_extraitem_name, g_extraitem_i, buffer)
  14151.  
  14152. // Replace cost
  14153. buffer[0] = ArrayGetCell(g_extraitem2_cost, i)
  14154. ArraySetCell(g_extraitem_cost, g_extraitem_i, buffer[0])
  14155.  
  14156. // Replace team
  14157. buffer[0] = ArrayGetCell(g_extraitem2_team, i)
  14158. ArraySetCell(g_extraitem_team, g_extraitem_i, buffer[0])
  14159. }
  14160.  
  14161. // Increase registered items counter
  14162. g_extraitem_i++
  14163.  
  14164. // Return id under which we registered the item
  14165. return g_extraitem_i-1;
  14166. }
  14167.  
  14168. // Function: zp_register_extra_item (to be used within this plugin only)
  14169. native_register_extra_item2(const name[], cost, team)
  14170. {
  14171. // Add the item
  14172. ArrayPushString(g_extraitem_name, name)
  14173. ArrayPushCell(g_extraitem_cost, cost)
  14174. ArrayPushCell(g_extraitem_team, team)
  14175.  
  14176. // Set temporary new item flag
  14177. ArrayPushCell(g_extraitem_new, 1)
  14178.  
  14179. // Increase registered items counter
  14180. g_extraitem_i++
  14181. }
  14182.  
  14183. // Native: zp_register_zombie_class
  14184. public native_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback)
  14185. {
  14186. // ZP disabled
  14187. if (!g_pluginenabled)
  14188. return -1;
  14189.  
  14190. // Strings passed byref
  14191. param_convert(1)
  14192. param_convert(2)
  14193. param_convert(3)
  14194. param_convert(4)
  14195.  
  14196. // Arrays not yet initialized
  14197. if (!g_arrays_created)
  14198. {
  14199. log_error(AMX_ERR_NATIVE, "[ZP] Can't register zombie class yet (%s)", name)
  14200. return -1;
  14201. }
  14202.  
  14203. if (strlen(name) < 1)
  14204. {
  14205. log_error(AMX_ERR_NATIVE, "[ZP] Can't register zombie class with an empty name")
  14206. return -1;
  14207. }
  14208.  
  14209. new index, zombieclass_name[32]
  14210. for (index = 0; index < g_zclass_i; index++)
  14211. {
  14212. ArrayGetString(g_zclass_name, index, zombieclass_name, charsmax(zombieclass_name))
  14213. if (equali(name, zombieclass_name))
  14214. {
  14215. log_error(AMX_ERR_NATIVE, "[ZP] Zombie class already registered (%s)", name)
  14216. return -1;
  14217. }
  14218. }
  14219.  
  14220. // Add the class
  14221. ArrayPushString(g_zclass_name, name)
  14222. ArrayPushString(g_zclass_info, info)
  14223.  
  14224. // Using same zombie models for all classes?
  14225. if (g_same_models_for_all)
  14226. {
  14227. ArrayPushCell(g_zclass_modelsstart, 0)
  14228. ArrayPushCell(g_zclass_modelsend, ArraySize(g_zclass_playermodel))
  14229. }
  14230. else
  14231. {
  14232. ArrayPushCell(g_zclass_modelsstart, ArraySize(g_zclass_playermodel))
  14233. ArrayPushString(g_zclass_playermodel, model)
  14234. ArrayPushCell(g_zclass_modelsend, ArraySize(g_zclass_playermodel))
  14235. ArrayPushCell(g_zclass_modelindex, -1)
  14236. }
  14237.  
  14238. ArrayPushString(g_zclass_clawmodel, clawmodel)
  14239. ArrayPushCell(g_zclass_hp, hp)
  14240. ArrayPushCell(g_zclass_spd, speed)
  14241. ArrayPushCell(g_zclass_grav, gravity)
  14242. ArrayPushCell(g_zclass_kb, knockback)
  14243.  
  14244. // Set temporary new class flag
  14245. ArrayPushCell(g_zclass_new, 1)
  14246.  
  14247. // Override zombie classes data with our customizations
  14248. new i, k, buffer[32], Float:buffer2, nummodels_custom, nummodels_default, prec_mdl[100], size = ArraySize(g_zclass2_realname)
  14249. for (i = 0; i < size; i++)
  14250. {
  14251. ArrayGetString(g_zclass2_realname, i, buffer, charsmax(buffer))
  14252.  
  14253. // Check if this is the intended class to override
  14254. if (!equal(name, buffer))
  14255. continue;
  14256.  
  14257. // Remove new class flag
  14258. ArraySetCell(g_zclass_new, g_zclass_i, 0)
  14259.  
  14260. // Replace caption
  14261. ArrayGetString(g_zclass2_name, i, buffer, charsmax(buffer))
  14262. ArraySetString(g_zclass_name, g_zclass_i, buffer)
  14263.  
  14264. // Replace info
  14265. ArrayGetString(g_zclass2_info, i, buffer, charsmax(buffer))
  14266. ArraySetString(g_zclass_info, g_zclass_i, buffer)
  14267.  
  14268. // Replace models, unless using same models for all classes
  14269. if (!g_same_models_for_all)
  14270. {
  14271. nummodels_custom = ArrayGetCell(g_zclass2_modelsend, i) - ArrayGetCell(g_zclass2_modelsstart, i)
  14272. nummodels_default = ArrayGetCell(g_zclass_modelsend, g_zclass_i) - ArrayGetCell(g_zclass_modelsstart, g_zclass_i)
  14273.  
  14274. // Replace each player model and model index
  14275. for (k = 0; k < min(nummodels_custom, nummodels_default); k++)
  14276. {
  14277. ArrayGetString(g_zclass2_playermodel, ArrayGetCell(g_zclass2_modelsstart, i) + k, buffer, charsmax(buffer))
  14278. ArraySetString(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k, buffer)
  14279.  
  14280. // Precache player model and replace its modelindex with the real one
  14281. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", buffer, buffer)
  14282. ArraySetCell(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k, engfunc(EngFunc_PrecacheModel, prec_mdl))
  14283. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  14284. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  14285. // Precache modelT.mdl files too
  14286. copy(prec_mdl[strlen(prec_mdl)-4], charsmax(prec_mdl) - (strlen(prec_mdl)-4), "T.mdl")
  14287. if (file_exists(prec_mdl)) engfunc(EngFunc_PrecacheModel, prec_mdl)
  14288. }
  14289.  
  14290. // We have more custom models than what we can accommodate,
  14291. // Let's make some space...
  14292. if (nummodels_custom > nummodels_default)
  14293. {
  14294. for (k = nummodels_default; k < nummodels_custom; k++)
  14295. {
  14296. ArrayGetString(g_zclass2_playermodel, ArrayGetCell(g_zclass2_modelsstart, i) + k, buffer, charsmax(buffer))
  14297. ArrayInsertStringAfter(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k - 1, buffer)
  14298.  
  14299. // Precache player model and retrieve its modelindex
  14300. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", buffer, buffer)
  14301. ArrayInsertCellAfter(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + k - 1, engfunc(EngFunc_PrecacheModel, prec_mdl))
  14302. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  14303. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  14304. // Precache modelT.mdl files too
  14305. copy(prec_mdl[strlen(prec_mdl)-4], charsmax(prec_mdl) - (strlen(prec_mdl)-4), "T.mdl")
  14306. if (file_exists(prec_mdl)) engfunc(EngFunc_PrecacheModel, prec_mdl)
  14307. }
  14308.  
  14309. // Fix models end index for this class
  14310. ArraySetCell(g_zclass_modelsend, g_zclass_i, ArrayGetCell(g_zclass_modelsend, g_zclass_i) + (nummodels_custom - nummodels_default))
  14311. }
  14312.  
  14313. /* --- Not needed since classes can't have more than 1 default model for now ---
  14314. // We have less custom models than what this class has by default,
  14315. // Get rid of those extra entries...
  14316. if (nummodels_custom < nummodels_default)
  14317. {
  14318. for (k = nummodels_custom; k < nummodels_default; k++)
  14319. {
  14320. ArrayDeleteItem(g_zclass_playermodel, ArrayGetCell(g_zclass_modelsstart, g_zclass_i) + nummodels_custom)
  14321. }
  14322.  
  14323. // Fix models end index for this class
  14324. ArraySetCell(g_zclass_modelsend, g_zclass_i, ArrayGetCell(g_zclass_modelsend, g_zclass_i) - (nummodels_default - nummodels_custom))
  14325. }
  14326. */
  14327. }
  14328.  
  14329. // Replace clawmodel
  14330. ArrayGetString(g_zclass2_clawmodel, i, buffer, charsmax(buffer))
  14331. ArraySetString(g_zclass_clawmodel, g_zclass_i, buffer)
  14332.  
  14333. // Precache clawmodel
  14334. formatex(prec_mdl, charsmax(prec_mdl), "models/zombie_plague/%s", buffer)
  14335. engfunc(EngFunc_PrecacheModel, prec_mdl)
  14336.  
  14337. // Replace health
  14338. buffer[0] = ArrayGetCell(g_zclass2_hp, i)
  14339. ArraySetCell(g_zclass_hp, g_zclass_i, buffer[0])
  14340.  
  14341. // Replace speed
  14342. buffer[0] = ArrayGetCell(g_zclass2_spd, i)
  14343. ArraySetCell(g_zclass_spd, g_zclass_i, buffer[0])
  14344.  
  14345. // Replace gravity
  14346. buffer2 = Float:ArrayGetCell(g_zclass2_grav, i)
  14347. ArraySetCell(g_zclass_grav, g_zclass_i, buffer2)
  14348.  
  14349. // Replace knockback
  14350. buffer2 = Float:ArrayGetCell(g_zclass2_kb, i)
  14351. ArraySetCell(g_zclass_kb, g_zclass_i, buffer2)
  14352. }
  14353.  
  14354. // If class was not overriden with customization data
  14355. if (ArrayGetCell(g_zclass_new, g_zclass_i))
  14356. {
  14357. // If not using same models for all classes
  14358. if (!g_same_models_for_all)
  14359. {
  14360. // Precache default class model and replace modelindex with the real one
  14361. formatex(prec_mdl, charsmax(prec_mdl), "models/player/%s/%s.mdl", model, model)
  14362. ArraySetCell(g_zclass_modelindex, ArrayGetCell(g_zclass_modelsstart, g_zclass_i), engfunc(EngFunc_PrecacheModel, prec_mdl))
  14363. if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, prec_mdl)
  14364. if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, prec_mdl)
  14365. // Precache modelT.mdl files too
  14366. copy(prec_mdl[strlen(prec_mdl)-4], charsmax(prec_mdl) - (strlen(prec_mdl)-4), "T.mdl")
  14367. if (file_exists(prec_mdl)) engfunc(EngFunc_PrecacheModel, prec_mdl)
  14368. }
  14369.  
  14370. // Precache default clawmodel
  14371. formatex(prec_mdl, charsmax(prec_mdl), "models/zombie_plague/%s", clawmodel)
  14372. engfunc(EngFunc_PrecacheModel, prec_mdl)
  14373. }
  14374.  
  14375. // Increase registered classes counter
  14376. g_zclass_i++
  14377.  
  14378. // Return id under which we registered the class
  14379. return g_zclass_i-1;
  14380. }
  14381.  
  14382. // Native: zp_get_extra_item_id
  14383. public native_get_extra_item_id(const name[])
  14384. {
  14385. // ZP disabled
  14386. if (!g_pluginenabled)
  14387. return -1;
  14388.  
  14389. // Strings passed byref
  14390. param_convert(1)
  14391.  
  14392. // Loop through every item (not using Tries since ZP should work on AMXX 1.8.0)
  14393. static i, item_name[32]
  14394. for (i = 0; i < g_extraitem_i; i++)
  14395. {
  14396. ArrayGetString(g_extraitem_name, i, item_name, charsmax(item_name))
  14397.  
  14398. // Check if this is the item to retrieve
  14399. if (equali(name, item_name))
  14400. return i;
  14401. }
  14402.  
  14403. return -1;
  14404. }
  14405.  
  14406. // Native: zp_get_zombie_class_id
  14407. public native_get_zombie_class_id(const name[])
  14408. {
  14409. // ZP disabled
  14410. if (!g_pluginenabled)
  14411. return -1;
  14412.  
  14413. // Strings passed byref
  14414. param_convert(1)
  14415.  
  14416. // Loop through every class (not using Tries since ZP should work on AMXX 1.8.0)
  14417. static i, class_name[32]
  14418. for (i = 0; i < g_zclass_i; i++)
  14419. {
  14420. ArrayGetString(g_zclass_name, i, class_name, charsmax(class_name))
  14421.  
  14422. // Check if this is the class to retrieve
  14423. if (equali(name, class_name))
  14424. return i;
  14425. }
  14426.  
  14427. return -1;
  14428. }
  14429.  
  14430. // Native: zp_get_zombie_class_info
  14431. public native_get_zombie_class_info(classid, info[], len)
  14432. {
  14433. // ZP disabled
  14434. if (!g_pluginenabled)
  14435. return false;
  14436.  
  14437. // Invalid class
  14438. if (classid < 0 || classid >= g_zclass_i)
  14439. {
  14440. log_error(AMX_ERR_NATIVE, "[ZP] Invalid zombie class id (%d)", classid)
  14441. return false;
  14442. }
  14443.  
  14444. // Strings passed byref
  14445. param_convert(2)
  14446.  
  14447. // Fetch zombie class info
  14448. ArrayGetString(g_zclass_info, classid, info, len)
  14449. return true;
  14450. }
  14451.  
  14452. /*================================================================================
  14453. [Custom Messages]
  14454. =================================================================================*/
  14455.  
  14456. // Custom Night Vision
  14457. public set_user_nvision(taskid)
  14458. {
  14459. // Get player's origin
  14460. static origin[3]
  14461. get_user_origin(ID_NVISION, origin)
  14462.  
  14463. // Nightvision message
  14464. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_NVISION)
  14465. write_byte(TE_DLIGHT) // TE id
  14466. write_coord(origin[0]) // x
  14467. write_coord(origin[1]) // y
  14468. write_coord(origin[2]) // z
  14469. write_byte(get_pcvar_num(cvar_nvgsize)) // radius
  14470.  
  14471. // Nemesis / Madness / Spectator in nemesis round
  14472. if (g_nemesis[ID_NVISION] || (g_zombie[ID_NVISION] && g_nodamage[ID_NVISION]) || (!g_isalive[ID_NVISION] && g_nemround))
  14473. {
  14474. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  14475. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  14476. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  14477. }
  14478. // Hattrick
  14479. //
  14480. else if (g_assassin[ID_NVISION] || (!g_isalive[ID_NVISION] && g_assassinround))
  14481. {
  14482. write_byte(get_pcvar_num(cvar_assassinnvgcolor[0])) // r
  14483. write_byte(get_pcvar_num(cvar_assassinnvgcolor[1])) // g
  14484. write_byte(get_pcvar_num(cvar_assassinnvgcolor[2])) // b
  14485. }
  14486. // Human / Spectator in normal round
  14487. else if (!g_zombie[ID_NVISION] || !g_isalive[ID_NVISION])
  14488. {
  14489. write_byte(get_pcvar_num(cvar_humnvgcolor[0])) // r
  14490. write_byte(get_pcvar_num(cvar_humnvgcolor[1])) // g
  14491. write_byte(get_pcvar_num(cvar_humnvgcolor[2])) // b
  14492. }
  14493. // Zombie
  14494. else
  14495. {
  14496. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  14497. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  14498. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  14499. }
  14500.  
  14501. write_byte(2) // life
  14502. write_byte(0) // decay rate
  14503. message_end()
  14504. }
  14505.  
  14506. // Game Nightvision
  14507. set_user_gnvision(id, toggle)
  14508. {
  14509. // Toggle NVG message
  14510. message_begin(MSG_ONE, g_msgNVGToggle, _, id)
  14511. write_byte(toggle) // toggle
  14512. message_end()
  14513. }
  14514.  
  14515. // Custom Flashlight
  14516. public set_user_flashlight(taskid)
  14517. {
  14518. // Get player and aiming origins
  14519. static Float:originF[3], Float:destoriginF[3]
  14520. pev(ID_FLASH, pev_origin, originF)
  14521. fm_get_aim_origin(ID_FLASH, destoriginF)
  14522.  
  14523. // Max distance check
  14524. if (get_distance_f(originF, destoriginF) > get_pcvar_float(cvar_flashdist))
  14525. return;
  14526.  
  14527. // Send to all players?
  14528. if (get_pcvar_num(cvar_flashshowall))
  14529. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, destoriginF, 0)
  14530. else
  14531. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_FLASH)
  14532.  
  14533. // Flashlight
  14534. write_byte(TE_DLIGHT) // TE id
  14535. engfunc(EngFunc_WriteCoord, destoriginF[0]) // x
  14536. engfunc(EngFunc_WriteCoord, destoriginF[1]) // y
  14537. engfunc(EngFunc_WriteCoord, destoriginF[2]) // z
  14538. write_byte(get_pcvar_num(cvar_flashsize)) // radius
  14539. write_byte(get_pcvar_num(cvar_flashcolor[0])) // r
  14540. write_byte(get_pcvar_num(cvar_flashcolor[1])) // g
  14541. write_byte(get_pcvar_num(cvar_flashcolor[2])) // b
  14542. write_byte(3) // life
  14543. write_byte(0) // decay rate
  14544. message_end()
  14545. }
  14546.  
  14547. // Infection special effects
  14548. infection_effects(id)
  14549. {
  14550. // Screen fade? (unless frozen)
  14551. if (!g_frozen[id] && get_pcvar_num(cvar_infectionscreenfade))
  14552. {
  14553. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
  14554. write_short(UNIT_SECOND) // duration
  14555. write_short(0) // hold time
  14556. write_short(FFADE_IN) // fade type
  14557. if (g_nemesis[id])
  14558. {
  14559. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  14560. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  14561. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  14562. }
  14563. else
  14564. {
  14565. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  14566. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  14567. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  14568. }
  14569. write_byte (255) // alpha
  14570. message_end()
  14571. }
  14572.  
  14573. // Screen shake?
  14574. if (get_pcvar_num(cvar_infectionscreenshake))
  14575. {
  14576. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
  14577. write_short(UNIT_SECOND*4) // amplitude
  14578. write_short(UNIT_SECOND*2) // duration
  14579. write_short(UNIT_SECOND*10) // frequency
  14580. message_end()
  14581. }
  14582.  
  14583. // Infection icon?
  14584. if (get_pcvar_num(cvar_hudicons))
  14585. {
  14586. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
  14587. write_byte(0) // damage save
  14588. write_byte(0) // damage take
  14589. write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
  14590. write_coord(0) // x
  14591. write_coord(0) // y
  14592. write_coord(0) // z
  14593. message_end()
  14594. }
  14595.  
  14596. // Get player's origin
  14597. static origin[3]
  14598. get_user_origin(id, origin)
  14599.  
  14600. // Tracers?
  14601. if (get_pcvar_num(cvar_infectiontracers))
  14602. {
  14603. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14604. write_byte(TE_IMPLOSION) // TE id
  14605. write_coord(origin[0]) // x
  14606. write_coord(origin[1]) // y
  14607. write_coord(origin[2]) // z
  14608. write_byte(128) // radius
  14609. write_byte(20) // count
  14610. write_byte(3) // duration
  14611. message_end()
  14612. }
  14613.  
  14614. // Particle burst?
  14615. if (get_pcvar_num(cvar_infectionparticles))
  14616. {
  14617. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14618. write_byte(TE_PARTICLEBURST) // TE id
  14619. write_coord(origin[0]) // x
  14620. write_coord(origin[1]) // y
  14621. write_coord(origin[2]) // z
  14622. write_short(50) // radius
  14623. write_byte(70) // color
  14624. write_byte(3) // duration (will be randomized a bit)
  14625. message_end()
  14626. }
  14627.  
  14628. // Light sparkle?
  14629. if (get_pcvar_num(cvar_infectionsparkle))
  14630. {
  14631. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14632. write_byte(TE_DLIGHT) // TE id
  14633. write_coord(origin[0]) // x
  14634. write_coord(origin[1]) // y
  14635. write_coord(origin[2]) // z
  14636. write_byte(20) // radius
  14637. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  14638. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  14639. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  14640. write_byte(2) // life
  14641. write_byte(0) // decay rate
  14642. message_end()
  14643. }
  14644. }
  14645.  
  14646. // Nemesis/madness aura task
  14647. public zombie_aura(taskid)
  14648. {
  14649. // Hattrick
  14650. //
  14651. // Not nemesis, not in zombie madness
  14652. //if (!g_nemesis[ID_AURA] && !g_nodamage[ID_AURA])
  14653. if (!g_nemesis[ID_AURA] && !g_assassin[ID_AURA] && !g_nodamage[ID_AURA])
  14654. {
  14655. // Task not needed anymore
  14656. remove_task(taskid);
  14657. return;
  14658. }
  14659.  
  14660. // Get player's origin
  14661. static origin[3]
  14662. get_user_origin(ID_AURA, origin)
  14663.  
  14664. // Colored Aura
  14665. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14666. write_byte(TE_DLIGHT) // TE id
  14667. write_coord(origin[0]) // x
  14668. write_coord(origin[1]) // y
  14669. write_coord(origin[2]) // z
  14670. write_byte(20) // radius
  14671. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  14672. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  14673. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  14674. write_byte(2) // life
  14675. write_byte(0) // decay rate
  14676. message_end()
  14677. }
  14678.  
  14679. // Make zombies leave footsteps and bloodstains on the floor
  14680. public make_blood(taskid)
  14681. {
  14682. // Only bleed when moving on ground
  14683. if (!(pev(ID_BLOOD, pev_flags) & FL_ONGROUND) || fm_get_speed(ID_BLOOD) < 80)
  14684. return;
  14685.  
  14686. // Get user origin
  14687. static Float:originF[3]
  14688. pev(ID_BLOOD, pev_origin, originF)
  14689.  
  14690. // If ducking set a little lower
  14691. if (pev(ID_BLOOD, pev_bInDuck))
  14692. originF[2] -= 18.0
  14693. else
  14694. originF[2] -= 36.0
  14695.  
  14696. // Send the decal message
  14697. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  14698. write_byte(TE_WORLDDECAL) // TE id
  14699. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14700. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14701. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14702. write_byte(ArrayGetCell(zombie_decals, random_num(0, ArraySize(zombie_decals) - 1)) + (g_czero * 12)) // random decal number (offsets +12 for CZ)
  14703. message_end()
  14704. }
  14705.  
  14706. // Hattrick
  14707. //
  14708. // Flare Lighting Effects
  14709. /*
  14710. flare_lighting(entity, duration)
  14711. {
  14712. // Get origin and color
  14713. static Float:originF[3], color[3]
  14714. pev(entity, pev_origin, originF)
  14715. pev(entity, PEV_FLARE_COLOR, color)
  14716.  
  14717. // Lighting
  14718. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  14719. write_byte(TE_DLIGHT) // TE id
  14720. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14721. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14722. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14723. write_byte(get_pcvar_num(cvar_flaresize)) // radius
  14724. write_byte(color[0]) // r
  14725. write_byte(color[1]) // g
  14726. write_byte(color[2]) // b
  14727. write_byte(21) //life
  14728. write_byte((duration < 2) ? 3 : 0) //decay rate
  14729. message_end()
  14730.  
  14731. // Sparks
  14732. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14733. write_byte(TE_SPARKS) // TE id
  14734. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14735. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14736. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14737. message_end()
  14738. }
  14739. */
  14740.  
  14741. // Burning Flames
  14742. public burning_flame(taskid)
  14743. {
  14744. // Get player origin and flags
  14745. static origin[3], flags
  14746. get_user_origin(ID_BURN, origin)
  14747. flags = pev(ID_BURN, pev_flags)
  14748.  
  14749. // Madness mode - in water - burning stopped
  14750. if (g_nodamage[ID_BURN] || get_user_godmode(ID_BURN) || (flags & FL_INWATER) || g_burning_duration[ID_BURN] < 1)
  14751. {
  14752. // Smoke sprite
  14753. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14754. write_byte(TE_SMOKE) // TE id
  14755. write_coord(origin[0]) // x
  14756. write_coord(origin[1]) // y
  14757. write_coord(origin[2]-50) // z
  14758. write_short(g_smokeSpr) // sprite
  14759. write_byte(random_num(15, 20)) // scale
  14760. write_byte(random_num(10, 20)) // framerate
  14761. message_end()
  14762.  
  14763. // Task not needed anymore
  14764. remove_task(taskid);
  14765. return;
  14766. }
  14767.  
  14768. // Hattrick
  14769. //
  14770. // Randomly play burning zombie scream sounds (not for nemesis)
  14771. // if (!g_nemesis[ID_BURN] && !random_num(0, 20))
  14772. if (!g_nemesis[ID_BURN] && !g_assassin[ID_BURN] && !random_num(0, 20))
  14773. {
  14774. static sound[64]
  14775. ArrayGetString(grenade_fire_player, random_num(0, ArraySize(grenade_fire_player) - 1), sound, charsmax(sound))
  14776. emit_sound(ID_BURN, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  14777. }
  14778.  
  14779. // Hattrick
  14780. //
  14781. // Fire slow down, unless nemesis
  14782. // if (!g_nemesis[ID_BURN] && (flags & FL_ONGROUND) && get_pcvar_float(cvar_fireslowdown) > 0.0)
  14783. if (!g_nemesis[ID_BURN] && !g_assassin[ID_BURN] && (flags & FL_ONGROUND) && get_pcvar_float(cvar_fireslowdown) > 0.0)
  14784. {
  14785. static Float:velocity[3]
  14786. pev(ID_BURN, pev_velocity, velocity)
  14787. xs_vec_mul_scalar(velocity, get_pcvar_float(cvar_fireslowdown), velocity)
  14788. set_pev(ID_BURN, pev_velocity, velocity)
  14789. }
  14790.  
  14791. // Get player's health
  14792. static health
  14793. health = pev(ID_BURN, pev_health)
  14794.  
  14795. // Take damage from the fire
  14796. if (health - floatround(get_pcvar_float(cvar_firedamage), floatround_ceil) > 0)
  14797. fm_set_user_health(ID_BURN, health - floatround(get_pcvar_float(cvar_firedamage), floatround_ceil))
  14798.  
  14799. // Flame sprite
  14800. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  14801. write_byte(TE_SPRITE) // TE id
  14802. write_coord(origin[0]+random_num(-5, 5)) // x
  14803. write_coord(origin[1]+random_num(-5, 5)) // y
  14804. write_coord(origin[2]+random_num(-10, 10)) // z
  14805. write_short(g_flameSpr) // sprite
  14806. write_byte(random_num(5, 10)) // scale
  14807. write_byte(200) // brightness
  14808. message_end()
  14809.  
  14810. // Decrease burning duration counter
  14811. g_burning_duration[ID_BURN]--
  14812. }
  14813.  
  14814. // Infection Bomb: Green Blast
  14815. create_blast(const Float:originF[3])
  14816. {
  14817. // Smallest ring
  14818. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14819. write_byte(TE_BEAMCYLINDER) // TE id
  14820. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14821. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14822. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14823. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14824. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14825. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  14826. write_short(g_exploSpr) // sprite
  14827. write_byte(0) // startframe
  14828. write_byte(0) // framerate
  14829. write_byte(4) // life
  14830. write_byte(60) // width
  14831. write_byte(0) // noise
  14832. write_byte(0) // red
  14833. write_byte(200) // green
  14834. write_byte(0) // blue
  14835. write_byte(200) // brightness
  14836. write_byte(0) // speed
  14837. message_end()
  14838.  
  14839. // Medium ring
  14840. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14841. write_byte(TE_BEAMCYLINDER) // TE id
  14842. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14843. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14844. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14845. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14846. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14847. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  14848. write_short(g_exploSpr) // sprite
  14849. write_byte(0) // startframe
  14850. write_byte(0) // framerate
  14851. write_byte(4) // life
  14852. write_byte(60) // width
  14853. write_byte(0) // noise
  14854. write_byte(0) // red
  14855. write_byte(200) // green
  14856. write_byte(0) // blue
  14857. write_byte(200) // brightness
  14858. write_byte(0) // speed
  14859. message_end()
  14860.  
  14861. // Largest ring
  14862. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14863. write_byte(TE_BEAMCYLINDER) // TE id
  14864. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14865. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14866. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14867. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14868. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14869. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  14870. write_short(g_exploSpr) // sprite
  14871. write_byte(0) // startframe
  14872. write_byte(0) // framerate
  14873. write_byte(4) // life
  14874. write_byte(60) // width
  14875. write_byte(0) // noise
  14876. write_byte(0) // red
  14877. write_byte(200) // green
  14878. write_byte(0) // blue
  14879. write_byte(200) // brightness
  14880. write_byte(0) // speed
  14881. message_end()
  14882. }
  14883.  
  14884. // Fire Grenade: Fire Blast
  14885. create_blast2(const Float:originF[3])
  14886. {
  14887. // Smallest ring
  14888. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14889. write_byte(TE_BEAMCYLINDER) // TE id
  14890. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14891. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14892. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14893. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14894. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14895. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  14896. write_short(g_exploSpr) // sprite
  14897. write_byte(0) // startframe
  14898. write_byte(0) // framerate
  14899. write_byte(4) // life
  14900. write_byte(60) // width
  14901. write_byte(0) // noise
  14902. write_byte(200) // red
  14903. write_byte(100) // green
  14904. write_byte(0) // blue
  14905. write_byte(200) // brightness
  14906. write_byte(0) // speed
  14907. message_end()
  14908.  
  14909. // Medium ring
  14910. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14911. write_byte(TE_BEAMCYLINDER) // TE id
  14912. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14913. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14914. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14915. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14916. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14917. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  14918. write_short(g_exploSpr) // sprite
  14919. write_byte(0) // startframe
  14920. write_byte(0) // framerate
  14921. write_byte(4) // life
  14922. write_byte(60) // width
  14923. write_byte(0) // noise
  14924. write_byte(200) // red
  14925. write_byte(50) // green
  14926. write_byte(0) // blue
  14927. write_byte(200) // brightness
  14928. write_byte(0) // speed
  14929. message_end()
  14930.  
  14931. // Largest ring
  14932. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14933. write_byte(TE_BEAMCYLINDER) // TE id
  14934. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14935. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14936. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14937. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14938. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14939. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  14940. write_short(g_exploSpr) // sprite
  14941. write_byte(0) // startframe
  14942. write_byte(0) // framerate
  14943. write_byte(4) // life
  14944. write_byte(60) // width
  14945. write_byte(0) // noise
  14946. write_byte(200) // red
  14947. write_byte(0) // green
  14948. write_byte(0) // blue
  14949. write_byte(200) // brightness
  14950. write_byte(0) // speed
  14951. message_end()
  14952. }
  14953.  
  14954. // Frost Grenade: Freeze Blast
  14955. create_blast3(const Float:originF[3])
  14956. {
  14957. // Smallest ring
  14958. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14959. write_byte(TE_BEAMCYLINDER) // TE id
  14960. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14961. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14962. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14963. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14964. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14965. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  14966. write_short(g_exploSpr) // sprite
  14967. write_byte(0) // startframe
  14968. write_byte(0) // framerate
  14969. write_byte(4) // life
  14970. write_byte(60) // width
  14971. write_byte(0) // noise
  14972. write_byte(0) // red
  14973. write_byte(100) // green
  14974. write_byte(200) // blue
  14975. write_byte(200) // brightness
  14976. write_byte(0) // speed
  14977. message_end()
  14978.  
  14979. // Medium ring
  14980. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  14981. write_byte(TE_BEAMCYLINDER) // TE id
  14982. engfunc(EngFunc_WriteCoord, originF[0]) // x
  14983. engfunc(EngFunc_WriteCoord, originF[1]) // y
  14984. engfunc(EngFunc_WriteCoord, originF[2]) // z
  14985. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  14986. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  14987. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  14988. write_short(g_exploSpr) // sprite
  14989. write_byte(0) // startframe
  14990. write_byte(0) // framerate
  14991. write_byte(4) // life
  14992. write_byte(60) // width
  14993. write_byte(0) // noise
  14994. write_byte(0) // red
  14995. write_byte(100) // green
  14996. write_byte(200) // blue
  14997. write_byte(200) // brightness
  14998. write_byte(0) // speed
  14999. message_end()
  15000.  
  15001. // Largest ring
  15002. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  15003. write_byte(TE_BEAMCYLINDER) // TE id
  15004. engfunc(EngFunc_WriteCoord, originF[0]) // x
  15005. engfunc(EngFunc_WriteCoord, originF[1]) // y
  15006. engfunc(EngFunc_WriteCoord, originF[2]) // z
  15007. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  15008. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  15009. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  15010. write_short(g_exploSpr) // sprite
  15011. write_byte(0) // startframe
  15012. write_byte(0) // framerate
  15013. write_byte(4) // life
  15014. write_byte(60) // width
  15015. write_byte(0) // noise
  15016. write_byte(0) // red
  15017. write_byte(100) // green
  15018. write_byte(200) // blue
  15019. write_byte(200) // brightness
  15020. write_byte(0) // speed
  15021. message_end()
  15022. }
  15023.  
  15024. // Hattrick
  15025. //
  15026. // Frost Grenade: Freeze Blast
  15027. create_blast4(const Float:originF[3])
  15028. {
  15029. // Smallest ring
  15030. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  15031. write_byte(TE_BEAMCYLINDER) // TE id
  15032. engfunc(EngFunc_WriteCoord, originF[0]) // x
  15033. engfunc(EngFunc_WriteCoord, originF[1]) // y
  15034. engfunc(EngFunc_WriteCoord, originF[2]) // z
  15035. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  15036. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  15037. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  15038. write_short(g_exploSpr) // sprite
  15039. write_byte(0) // startframe
  15040. write_byte(0) // framerate
  15041. write_byte(4) // life
  15042. write_byte(60) // width
  15043. write_byte(0) // noise
  15044. write_byte(255) // red
  15045. write_byte(0) // green
  15046. write_byte(0) // blue
  15047. write_byte(200) // brightness
  15048. write_byte(0) // speed
  15049. message_end()
  15050.  
  15051. // Medium ring
  15052. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  15053. write_byte(TE_BEAMCYLINDER) // TE id
  15054. engfunc(EngFunc_WriteCoord, originF[0]) // x
  15055. engfunc(EngFunc_WriteCoord, originF[1]) // y
  15056. engfunc(EngFunc_WriteCoord, originF[2]) // z
  15057. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  15058. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  15059. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  15060. write_short(g_exploSpr) // sprite
  15061. write_byte(0) // startframe
  15062. write_byte(0) // framerate
  15063. write_byte(4) // life
  15064. write_byte(60) // width
  15065. write_byte(0) // noise
  15066. write_byte(255) // red
  15067. write_byte(0) // green
  15068. write_byte(0) // blue
  15069. write_byte(200) // brightness
  15070. write_byte(0) // speed
  15071. message_end()
  15072.  
  15073. // Largest ring
  15074. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  15075. write_byte(TE_BEAMCYLINDER) // TE id
  15076. engfunc(EngFunc_WriteCoord, originF[0]) // x
  15077. engfunc(EngFunc_WriteCoord, originF[1]) // y
  15078. engfunc(EngFunc_WriteCoord, originF[2]) // z
  15079. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  15080. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  15081. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  15082. write_short(g_exploSpr) // sprite
  15083. write_byte(0) // startframe
  15084. write_byte(0) // framerate
  15085. write_byte(4) // life
  15086. write_byte(60) // width
  15087. write_byte(0) // noise
  15088. write_byte(255) // red
  15089. write_byte(0) // green
  15090. write_byte(0) // blue
  15091. write_byte(200) // brightness
  15092. write_byte(0) // speed
  15093. message_end()
  15094. }
  15095.  
  15096. // Fix Dead Attrib on scoreboard
  15097. FixDeadAttrib(id)
  15098. {
  15099. message_begin(MSG_BROADCAST, g_msgScoreAttrib)
  15100. write_byte(id) // id
  15101. write_byte(0) // attrib
  15102. message_end()
  15103. }
  15104.  
  15105. // Send Death Message for infections
  15106. SendDeathMsg(attacker, victim)
  15107. {
  15108. message_begin(MSG_BROADCAST, g_msgDeathMsg)
  15109. write_byte(attacker) // killer
  15110. write_byte(victim) // victim
  15111. write_byte(1) // headshot flag
  15112. write_string("infection") // killer's weapon
  15113. message_end()
  15114. }
  15115.  
  15116. // Update Player Frags and Deaths
  15117. UpdateFrags(attacker, victim, frags, deaths, scoreboard)
  15118. {
  15119. // Set attacker frags
  15120. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  15121.  
  15122. // Set victim deaths
  15123. fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) + deaths)
  15124.  
  15125. // Update scoreboard with attacker and victim info
  15126. if (scoreboard)
  15127. {
  15128. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  15129. write_byte(attacker) // id
  15130. write_short(pev(attacker, pev_frags)) // frags
  15131. write_short(cs_get_user_deaths(attacker)) // deaths
  15132. write_short(0) // class?
  15133. write_short(fm_cs_get_user_team(attacker)) // team
  15134. message_end()
  15135.  
  15136. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  15137. write_byte(victim) // id
  15138. write_short(pev(victim, pev_frags)) // frags
  15139. write_short(cs_get_user_deaths(victim)) // deaths
  15140. write_short(0) // class?
  15141. write_short(fm_cs_get_user_team(victim)) // team
  15142. message_end()
  15143. }
  15144. }
  15145.  
  15146. // Remove Player Frags (when Nemesis/Survivor ignore_frags cvar is enabled)
  15147. RemoveFrags(attacker, victim)
  15148. {
  15149. // Remove attacker frags
  15150. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) - 1))
  15151.  
  15152. // Remove victim deaths
  15153. fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) - 1)
  15154. }
  15155.  
  15156. // Plays a sound on clients
  15157. PlaySound(const sound[])
  15158. {
  15159. if (equal(sound[strlen(sound)-4], ".mp3"))
  15160. client_cmd(0, "mp3 play ^"sound/%s^"", sound)
  15161. else
  15162. client_cmd(0, "spk ^"%s^"", sound)
  15163. }
  15164.  
  15165. // Prints a colored message to target (use 0 for everyone), supports ML formatting.
  15166. // Note: I still need to make something like gungame's LANG_PLAYER_C to avoid unintended
  15167. // argument replacement when a function passes -1 (it will be considered a LANG_PLAYER)
  15168. zp_colored_print(target, const message[], any:...)
  15169. {
  15170. static buffer[512], i, argscount
  15171. argscount = numargs()
  15172.  
  15173. // Send to everyone
  15174. if (!target)
  15175. {
  15176. static player
  15177. for (player = 1; player <= g_maxplayers; player++)
  15178. {
  15179. // Not connected
  15180. if (!g_isconnected[player])
  15181. continue;
  15182.  
  15183. // Remember changed arguments
  15184. static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
  15185. changedcount = 0
  15186.  
  15187. // Replace LANG_PLAYER with player id
  15188. for (i = 2; i < argscount; i++)
  15189. {
  15190. if (getarg(i) == LANG_PLAYER)
  15191. {
  15192. setarg(i, 0, player)
  15193. changed[changedcount] = i
  15194. changedcount++
  15195. }
  15196. }
  15197.  
  15198. // Format message for player
  15199. vformat(buffer, charsmax(buffer), message, 3)
  15200.  
  15201. // Send it
  15202. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
  15203. write_byte(player)
  15204. write_string(buffer)
  15205. message_end()
  15206.  
  15207. // Replace back player id's with LANG_PLAYER
  15208. for (i = 0; i < changedcount; i++)
  15209. setarg(changed[i], 0, LANG_PLAYER)
  15210. }
  15211. }
  15212. // Send to specific target
  15213. else
  15214. {
  15215. /*
  15216. // Not needed since you should set the ML argument
  15217. // to the player's id for a targeted print message
  15218.  
  15219. // Replace LANG_PLAYER with player id
  15220. for (i = 2; i < argscount; i++)
  15221. {
  15222. if (getarg(i) == LANG_PLAYER)
  15223. setarg(i, 0, target)
  15224. }
  15225. */
  15226.  
  15227. // Format message for player
  15228. vformat(buffer, charsmax(buffer), message, 3)
  15229.  
  15230. // Send it
  15231. message_begin(MSG_ONE, g_msgSayText, _, target)
  15232. write_byte(target)
  15233. write_string(buffer)
  15234. message_end()
  15235. }
  15236. }
  15237.  
  15238. /*================================================================================
  15239. [Stocks]
  15240. =================================================================================*/
  15241.  
  15242. // Set an entity's key value (from fakemeta_util)
  15243. stock fm_set_kvd(entity, const key[], const value[], const classname[])
  15244. {
  15245. set_kvd(0, KV_ClassName, classname)
  15246. set_kvd(0, KV_KeyName, key)
  15247. set_kvd(0, KV_Value, value)
  15248. set_kvd(0, KV_fHandled, 0)
  15249.  
  15250. dllfunc(DLLFunc_KeyValue, entity, 0)
  15251. }
  15252.  
  15253. // Set entity's rendering type (from fakemeta_util)
  15254. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  15255. {
  15256. static Float:color[3]
  15257. color[0] = float(r)
  15258. color[1] = float(g)
  15259. color[2] = float(b)
  15260.  
  15261. set_pev(entity, pev_renderfx, fx)
  15262. set_pev(entity, pev_rendercolor, color)
  15263. set_pev(entity, pev_rendermode, render)
  15264. set_pev(entity, pev_renderamt, float(amount))
  15265. }
  15266.  
  15267. // Get entity's speed (from fakemeta_util)
  15268. stock fm_get_speed(entity)
  15269. {
  15270. static Float:velocity[3]
  15271. pev(entity, pev_velocity, velocity)
  15272.  
  15273. return floatround(vector_length(velocity));
  15274. }
  15275.  
  15276. // Get entity's aim origins (from fakemeta_util)
  15277. stock fm_get_aim_origin(id, Float:origin[3])
  15278. {
  15279. static Float:origin1F[3], Float:origin2F[3]
  15280. pev(id, pev_origin, origin1F)
  15281. pev(id, pev_view_ofs, origin2F)
  15282. xs_vec_add(origin1F, origin2F, origin1F)
  15283.  
  15284. pev(id, pev_v_angle, origin2F);
  15285. engfunc(EngFunc_MakeVectors, origin2F)
  15286. global_get(glb_v_forward, origin2F)
  15287. xs_vec_mul_scalar(origin2F, 9999.0, origin2F)
  15288. xs_vec_add(origin1F, origin2F, origin2F)
  15289.  
  15290. engfunc(EngFunc_TraceLine, origin1F, origin2F, 0, id, 0)
  15291. get_tr2(0, TR_vecEndPos, origin)
  15292. }
  15293.  
  15294. // Find entity by its owner (from fakemeta_util)
  15295. stock fm_find_ent_by_owner(entity, const classname[], owner)
  15296. {
  15297. while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  15298. return entity;
  15299. }
  15300.  
  15301. // Set player's health (from fakemeta_util)
  15302. stock fm_set_user_health(id, health)
  15303. {
  15304. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  15305. }
  15306.  
  15307. // Give an item to a player (from fakemeta_util)
  15308. stock fm_give_item(id, const item[])
  15309. {
  15310. static ent
  15311. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  15312. if (!pev_valid(ent)) return;
  15313.  
  15314. static Float:originF[3]
  15315. pev(id, pev_origin, originF)
  15316. set_pev(ent, pev_origin, originF)
  15317. set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  15318. dllfunc(DLLFunc_Spawn, ent)
  15319.  
  15320. static save
  15321. save = pev(ent, pev_solid)
  15322. dllfunc(DLLFunc_Touch, ent, id)
  15323. if (pev(ent, pev_solid) != save)
  15324. return;
  15325.  
  15326. engfunc(EngFunc_RemoveEntity, ent)
  15327. }
  15328.  
  15329. // Strip user weapons (from fakemeta_util)
  15330. stock fm_strip_user_weapons(id)
  15331. {
  15332. static ent
  15333. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  15334. if (!pev_valid(ent)) return;
  15335.  
  15336. dllfunc(DLLFunc_Spawn, ent)
  15337. dllfunc(DLLFunc_Use, ent, id)
  15338. engfunc(EngFunc_RemoveEntity, ent)
  15339. }
  15340.  
  15341. // Collect random spawn points
  15342. stock load_spawns()
  15343. {
  15344. // Check for CSDM spawns of the current map
  15345. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  15346. get_configsdir(cfgdir, charsmax(cfgdir))
  15347. get_mapname(mapname, charsmax(mapname))
  15348. formatex(filepath, charsmax(filepath), "%s/csdm/%s.spawns.cfg", cfgdir, mapname)
  15349.  
  15350. // Load CSDM spawns if present
  15351. if (file_exists(filepath))
  15352. {
  15353. new csdmdata[10][6], file = fopen(filepath,"rt")
  15354.  
  15355. while (file && !feof(file))
  15356. {
  15357. fgets(file, linedata, charsmax(linedata))
  15358.  
  15359. // invalid spawn
  15360. if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  15361.  
  15362. // get spawn point data
  15363. 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)
  15364.  
  15365. // origin
  15366. g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
  15367. g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
  15368. g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
  15369.  
  15370. // increase spawn count
  15371. g_spawnCount++
  15372. if (g_spawnCount >= sizeof g_spawns) break;
  15373. }
  15374. if (file) fclose(file)
  15375. }
  15376. else
  15377. {
  15378. // Collect regular spawns
  15379. collect_spawns_ent("info_player_start")
  15380. collect_spawns_ent("info_player_deathmatch")
  15381. }
  15382.  
  15383. // Collect regular spawns for non-random spawning unstuck
  15384. collect_spawns_ent2("info_player_start")
  15385. collect_spawns_ent2("info_player_deathmatch")
  15386. }
  15387.  
  15388. // Collect spawn points from entity origins
  15389. stock collect_spawns_ent(const classname[])
  15390. {
  15391. new ent = -1
  15392. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) != 0)
  15393. {
  15394. // get origin
  15395. new Float:originF[3]
  15396. pev(ent, pev_origin, originF)
  15397. g_spawns[g_spawnCount][0] = originF[0]
  15398. g_spawns[g_spawnCount][1] = originF[1]
  15399. g_spawns[g_spawnCount][2] = originF[2]
  15400.  
  15401. // increase spawn count
  15402. g_spawnCount++
  15403. if (g_spawnCount >= sizeof g_spawns) break;
  15404. }
  15405. }
  15406.  
  15407. // Collect spawn points from entity origins
  15408. stock collect_spawns_ent2(const classname[])
  15409. {
  15410. new ent = -1
  15411. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) != 0)
  15412. {
  15413. // get origin
  15414. new Float:originF[3]
  15415. pev(ent, pev_origin, originF)
  15416. g_spawns2[g_spawnCount2][0] = originF[0]
  15417. g_spawns2[g_spawnCount2][1] = originF[1]
  15418. g_spawns2[g_spawnCount2][2] = originF[2]
  15419.  
  15420. // increase spawn count
  15421. g_spawnCount2++
  15422. if (g_spawnCount2 >= sizeof g_spawns2) break;
  15423. }
  15424. }
  15425.  
  15426. // Drop primary/secondary weapons
  15427. stock drop_weapons(id, dropwhat)
  15428. {
  15429. // Get user weapons
  15430. static weapons[32], num, i, weaponid
  15431. num = 0 // reset passed weapons count (bugfix)
  15432. get_user_weapons(id, weapons, num)
  15433.  
  15434. // Loop through them and drop primaries or secondaries
  15435. for (i = 0; i < num; i++)
  15436. {
  15437. // Prevent re-indexing the array
  15438. weaponid = weapons[i]
  15439.  
  15440. if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  15441. {
  15442. // Get weapon entity
  15443. static wname[32], weapon_ent
  15444. get_weaponname(weaponid, wname, charsmax(wname))
  15445. weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  15446.  
  15447. // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  15448. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
  15449.  
  15450. // Player drops the weapon and looses his bpammo
  15451. engclient_cmd(id, "drop", wname)
  15452. cs_set_user_bpammo(id, weaponid, 0)
  15453. }
  15454. }
  15455. }
  15456.  
  15457. // Stock by (probably) Twilight Suzuka -counts number of chars in a string
  15458. stock str_count(const str[], searchchar)
  15459. {
  15460. new count, i, len = strlen(str)
  15461.  
  15462. for (i = 0; i <= len; i++)
  15463. {
  15464. if(str[i] == searchchar)
  15465. count++
  15466. }
  15467.  
  15468. return count;
  15469. }
  15470.  
  15471. // Checks if a space is vacant (credits to VEN)
  15472. stock is_hull_vacant(Float:origin[3], hull)
  15473. {
  15474. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
  15475.  
  15476. if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
  15477. return true;
  15478.  
  15479. return false;
  15480. }
  15481.  
  15482. // Check if a player is stuck (credits to VEN)
  15483. stock is_player_stuck(id)
  15484. {
  15485. static Float:originF[3]
  15486. pev(id, pev_origin, originF)
  15487.  
  15488. engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  15489.  
  15490. if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  15491. return true;
  15492.  
  15493. return false;
  15494. }
  15495.  
  15496. // Simplified get_weaponid (CS only)
  15497. stock cs_weapon_name_to_id(const weapon[])
  15498. {
  15499. static i
  15500. for (i = 0; i < sizeof WEAPONENTNAMES; i++)
  15501. {
  15502. if (equal(weapon, WEAPONENTNAMES[i]))
  15503. return i;
  15504. }
  15505.  
  15506. return 0;
  15507. }
  15508.  
  15509. // Get User Current Weapon Entity
  15510. stock fm_cs_get_current_weapon_ent(id)
  15511. {
  15512. // Prevent server crash if entity's private data not initalized
  15513. if (pev_valid(id) != PDATA_SAFE)
  15514. return -1;
  15515.  
  15516. return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX);
  15517. }
  15518.  
  15519. // Get Weapon Entity's Owner
  15520. stock fm_cs_get_weapon_ent_owner(ent)
  15521. {
  15522. // Prevent server crash if entity's private data not initalized
  15523. if (pev_valid(ent) != PDATA_SAFE)
  15524. return -1;
  15525.  
  15526. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  15527. }
  15528.  
  15529. // Set User Deaths
  15530. stock fm_cs_set_user_deaths(id, value)
  15531. {
  15532. // Prevent server crash if entity's private data not initalized
  15533. if (pev_valid(id) != PDATA_SAFE)
  15534. return;
  15535.  
  15536. set_pdata_int(id, OFFSET_CSDEATHS, value, OFFSET_LINUX)
  15537. }
  15538.  
  15539. // Get User Team
  15540. stock fm_cs_get_user_team(id)
  15541. {
  15542. // Prevent server crash if entity's private data not initalized
  15543. if (pev_valid(id) != PDATA_SAFE)
  15544. return FM_CS_TEAM_UNASSIGNED;
  15545.  
  15546. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  15547. }
  15548.  
  15549. // Set a Player's Team
  15550. stock fm_cs_set_user_team(id, team)
  15551. {
  15552. // Prevent server crash if entity's private data not initalized
  15553. if (pev_valid(id) != PDATA_SAFE)
  15554. return;
  15555.  
  15556. set_pdata_int(id, OFFSET_CSTEAMS, team, OFFSET_LINUX)
  15557. }
  15558.  
  15559. // Set User Money
  15560. stock fm_cs_set_user_money(id, value)
  15561. {
  15562. // Prevent server crash if entity's private data not initalized
  15563. if (pev_valid(id) != PDATA_SAFE)
  15564. return;
  15565.  
  15566. set_pdata_int(id, OFFSET_CSMONEY, value, OFFSET_LINUX)
  15567. }
  15568.  
  15569. // Set User Flashlight Batteries
  15570. stock fm_cs_set_user_batteries(id, value)
  15571. {
  15572. // Prevent server crash if entity's private data not initalized
  15573. if (pev_valid(id) != PDATA_SAFE)
  15574. return;
  15575.  
  15576. set_pdata_int(id, OFFSET_FLASHLIGHT_BATTERY, value, OFFSET_LINUX)
  15577. }
  15578.  
  15579. // Update Player's Team on all clients (adding needed delays)
  15580. stock fm_user_team_update(id)
  15581. {
  15582. static Float:current_time
  15583. current_time = get_gametime()
  15584.  
  15585. if (current_time - g_teams_targettime >= 0.1)
  15586. {
  15587. set_task(0.1, "fm_cs_set_user_team_msg", id+TASK_TEAM)
  15588. g_teams_targettime = current_time + 0.1
  15589. }
  15590. else
  15591. {
  15592. set_task((g_teams_targettime + 0.1) - current_time, "fm_cs_set_user_team_msg", id+TASK_TEAM)
  15593. g_teams_targettime = g_teams_targettime + 0.1
  15594. }
  15595. }
  15596.  
  15597. // Send User Team Message
  15598. public fm_cs_set_user_team_msg(taskid)
  15599. {
  15600. // Note to self: this next message can now be received by other plugins
  15601.  
  15602. // Set the switching team flag
  15603. g_switchingteam = true
  15604.  
  15605. if(is_user_alive(ID_TEAM) && g_vip[ID_TEAM] && containi(g_vip_flags[ID_TEAM], "S") != -1)
  15606. {
  15607. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  15608. write_byte(ID_TEAM)
  15609. write_byte(4)
  15610. message_end()
  15611. }
  15612.  
  15613. // Tell everyone my new team
  15614. emessage_begin(MSG_ALL, g_msgTeamInfo)
  15615. ewrite_byte(ID_TEAM) // player
  15616. ewrite_string(CS_TEAM_NAMES[fm_cs_get_user_team(ID_TEAM)]) // team
  15617. emessage_end()
  15618.  
  15619. if(is_user_alive(ID_TEAM) && g_vip[ID_TEAM] && containi(g_vip_flags[ID_TEAM], "S") != -1)
  15620. {
  15621. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  15622. write_byte(ID_TEAM)
  15623. write_byte(4)
  15624. message_end()
  15625. }
  15626.  
  15627. // Done switching team
  15628. g_switchingteam = false
  15629. }
  15630.  
  15631. // Set the precached model index (updates hitboxes server side)
  15632. stock fm_cs_set_user_model_index(id, value)
  15633. {
  15634. // Prevent server crash if entity's private data not initalized
  15635. if (pev_valid(id) != PDATA_SAFE)
  15636. return;
  15637.  
  15638. set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
  15639. }
  15640.  
  15641. // Set Player Model on Entity
  15642. stock fm_set_playermodel_ent(id)
  15643. {
  15644. // Make original player entity invisible without hiding shadows or firing effects
  15645. fm_set_rendering(id, kRenderFxNone, 255, 255, 255, kRenderTransTexture, 1)
  15646.  
  15647. // Format model string
  15648. static model[100]
  15649. formatex(model, charsmax(model), "models/player/%s/%s.mdl", g_playermodel[id], g_playermodel[id])
  15650.  
  15651. // Set model on entity or make a new one if unexistant
  15652. if (!pev_valid(g_ent_playermodel[id]))
  15653. {
  15654. g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  15655. if (!pev_valid(g_ent_playermodel[id])) return;
  15656.  
  15657. set_pev(g_ent_playermodel[id], pev_classname, MODEL_ENT_CLASSNAME)
  15658. set_pev(g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW)
  15659. set_pev(g_ent_playermodel[id], pev_aiment, id)
  15660. set_pev(g_ent_playermodel[id], pev_owner, id)
  15661. }
  15662.  
  15663. engfunc(EngFunc_SetModel, g_ent_playermodel[id], model)
  15664. }
  15665.  
  15666. // Set Weapon Model on Entity
  15667. stock fm_set_weaponmodel_ent(id)
  15668. {
  15669. // Get player's p_ weapon model
  15670. static model[100]
  15671. pev(id, pev_weaponmodel2, model, charsmax(model))
  15672.  
  15673. // Set model on entity or make a new one if unexistant
  15674. if (!pev_valid(g_ent_weaponmodel[id]))
  15675. {
  15676. g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  15677. if (!pev_valid(g_ent_weaponmodel[id])) return;
  15678.  
  15679. set_pev(g_ent_weaponmodel[id], pev_classname, WEAPON_ENT_CLASSNAME)
  15680. set_pev(g_ent_weaponmodel[id], pev_movetype, MOVETYPE_FOLLOW)
  15681. set_pev(g_ent_weaponmodel[id], pev_aiment, id)
  15682. set_pev(g_ent_weaponmodel[id], pev_owner, id)
  15683. }
  15684.  
  15685. engfunc(EngFunc_SetModel, g_ent_weaponmodel[id], model)
  15686. }
  15687.  
  15688. // Remove Custom Model Entities
  15689. stock fm_remove_model_ents(id)
  15690. {
  15691. // Remove "playermodel" ent if present
  15692. if (pev_valid(g_ent_playermodel[id]))
  15693. {
  15694. engfunc(EngFunc_RemoveEntity, g_ent_playermodel[id])
  15695. g_ent_playermodel[id] = 0
  15696. }
  15697. // Remove "weaponmodel" ent if present
  15698. if (pev_valid(g_ent_weaponmodel[id]))
  15699. {
  15700. engfunc(EngFunc_RemoveEntity, g_ent_weaponmodel[id])
  15701. g_ent_weaponmodel[id] = 0
  15702. }
  15703. }
  15704.  
  15705. // Set User Model
  15706. public fm_cs_set_user_model(taskid)
  15707. {
  15708. set_user_info(ID_MODEL, "model", g_playermodel[ID_MODEL])
  15709. }
  15710.  
  15711. // Get User Model -model passed byref-
  15712. stock fm_cs_get_user_model(player, model[], len)
  15713. {
  15714. get_user_info(player, "model", model, len)
  15715. }
  15716.  
  15717. // Update Player's Model on all clients (adding needed delays)
  15718. public fm_user_model_update(taskid)
  15719. {
  15720. static Float:current_time
  15721. current_time = get_gametime()
  15722.  
  15723. if (current_time - g_models_targettime >= g_modelchange_delay)
  15724. {
  15725. fm_cs_set_user_model(taskid)
  15726. g_models_targettime = current_time
  15727. }
  15728. else
  15729. {
  15730. set_task((g_models_targettime + g_modelchange_delay) - current_time, "fm_cs_set_user_model", taskid)
  15731. g_models_targettime = g_models_targettime + g_modelchange_delay
  15732. }
  15733. }
  15734.  
  15735. // Hattrick
  15736. //
  15737. public AddCommas( iNum , szOutput[] , iLen )
  15738. {
  15739. new szTmp[ 15 ] , iOutputPos , iNumPos , iNumLen;
  15740.  
  15741. if ( iNum < 0 )
  15742. {
  15743. szOutput[ iOutputPos++ ] = '-';
  15744. iNum = abs( iNum );
  15745. }
  15746.  
  15747. iNumLen = num_to_str( iNum , szTmp , charsmax( szTmp ) );
  15748.  
  15749. if ( iNumLen <= 3 )
  15750. {
  15751. iOutputPos += copy( szOutput[ iOutputPos ] , iLen , szTmp );
  15752. }
  15753. else
  15754. {
  15755. while ( ( iNumPos < iNumLen ) && ( iOutputPos < iLen ) )
  15756. {
  15757. szOutput[ iOutputPos++ ] = szTmp[ iNumPos++ ];
  15758.  
  15759. if( ( iNumLen - iNumPos ) && !( ( iNumLen - iNumPos ) % 3 ) )
  15760. szOutput[ iOutputPos++ ] = ',';
  15761. }
  15762.  
  15763. szOutput[ iOutputPos ] = EOS;
  15764. }
  15765.  
  15766. return iOutputPos;
  15767. }
Add Comment
Please, Sign In to add comment