Guest User

Untitled

a guest
Feb 1st, 2012
1,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 390.27 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <xs>
  6. #include <engine>
  7. #include <fun>
  8. #include <sqlx>
  9.  
  10. /*================================================================================
  11. [Plugin Customization]
  12. =================================================================================*/
  13. new const Levels[640] =
  14. { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000, 2500, 3000, 3500,
  15. 4000, 4500, 5000, 5500, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000,
  16. 18000, 20000, 22000, 24000, 26000, 28000, 30000, 32000, 34000, 36000, 39000, 42000, 45000, 48000, 51000,
  17. 54000, 57000, 60000, 63000, 66000, 70000, 74000, 78000, 82000, 86000, 90000, 94000, 98000, 102000, 106000,
  18. 111000, 116000, 121000, 126000, 131000, 136000, 141000, 146000, 151000, 156000, 162000, 168000, 174000, 180000, 186000, 192000, 198000,
  19. 206000, 212000, 218000, 225000, 232000, 235000, 242000, 249000, 256000, 273000, 280000, 287000, 294000, 302000, 310000, 318000,
  20. 326000, 334000, 342000, 350000, 358000, 366000, 374000, 383000, 392000, 401000, 410000, 419000, 428000, 437000, 446000, 455000, 464000,
  21. 474000, 484000, 494000, 504000, 514000, 524000, 534000, 544000, 554000, 564000, 575000, 586000, 597000, 608000, 619000, 630000,
  22. 641000, 652000, 663000, 674000, 684000, 694000, 704000, 714000, 724000, 734000, 744000, 754000, 764000, 774000, 784000,
  23. 794000, 804000, 814000, 824000, 834000, 844000, 854000, 864000, 874000, 885000, 900000, 915000, 930000, 945000, 960000, 975000,
  24. 990000, 1005000, 1020000, 1040000, 1060000, 1080000, 1100000, 1120000, 1140000, 1160000, 1180000, 1200000, 1220000, 1260000, 1300000,
  25. 1340000, 1380000, 1420000, 1460000, 1500000, 1540000, 1580000, 1620000, 1700000, 1780000, 1860000, 1940000, 2020000, 2100000, 2180000, 2260000,
  26. 2340000, 2420000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000, 3300000, 3400000,
  27. 3500000, 3600000, 3700000, 3800000, 3900000, 4000000, 4100000, 4200000, 4300000, 4400000, 4500000, 4700000, 4900000, 5100000, 5300000, 5500000, 5700000,
  28. 5900000, 6100000, 6300000, 6500000, 6700000, 6900000, 7100000, 7300000, 7500000, 7700000, 7900000, 8100000, 8300000,
  29. 8500000, 8700000, 8900000, 9100000, 9300000, 9500000, 9700000, 9900000, 10100000, 10300000, 10600000, 10900000, 11200000, 11500000,
  30. 11800000, 12100000, 12400000, 12700000 , 13000000, 13500000, 14000000, 14500000, 15000000, 15500000 ,15800000, 16100000,
  31. 16400000, 16700000, 17000000, 17400000, 17800000, 18000000, 18400000, 18600000, 18900000, 19300000, 19700000, 20000000,
  32. 20300000, 20700000, 20900000, 21200000, 21500000, 21800000, 22100000, 22400000, 22700000, 23000000, 23200000, 23600000, 23800000, 24000000,
  33. 24400000, 24800000, 25100000, 25600000, 25900000, 26200000, 26500000, 26800000, 27200000, 27600000, 27900000, 28200000, 28400000, 28700000,
  34. 28900000, 29200000, 29500000, 29700000, 29900000, 31000000, 31400000, 31600000, 31900000, 32100000, 32400000, 32600000, 32800000, 33100000,
  35. 33500000, 33800000, 34000000, 34300000, 34700000, 35000000, 35300000, 35700000, 36000000, 36400000, 36800000, 37000000, 37300000, 37600000,
  36. 37900000, 38300000, 38600000, 38900000, 39000000, 39200000, 39500000, 39700000, 40000000, 40200000, 40500000, 40700000, 40900000, 41000000,
  37. 41300000, 41600000, 41900000, 42100000, 42400000, 42700000, 43000000, 43300000, 43600000, 43900000, 44100000, 44300000, 44500000, 44700000,
  38. 44900000, 45100000, 45300000, 45500000, 45700000, 46000000, 46200000, 46500000, 46700000, 46900000, 47200000, 47500000, 47800000, 48000000,
  39. 48200000, 48400000, 48600000, 48800000, 49000000, 49200000, 49400000, 49600000, 49800000, 50000000, 50200000, 50400000, 50600000, 50800000,
  40. 51000000, 51200000, 51400000, 51600000, 51800000, 52000000, 52200000, 52400000, 52600000, 52800000, 53000000, 53200000, 53400000, 53600000,
  41. 53800000, 54000000, 54200000, 54400000, 54600000, 54800000, 55000000, 55200000, 55400000, 55600000, 55800000, 56000000, 56200000, 56400000,
  42. 56600000, 56800000, 57000000, 57200000, 57400000, 57600000, 57800000, 58000000, 58200000, 58400000, 58600000, 58800000, 59000000, 59200000,
  43. 59400000, 59600000, 59800000, 60000000, 60200000, 60400000, 60600000, 60800000, 61000000, 61200000, 61400000, 61600000, 61800000, 62000000,
  44. 62200000, 62400000, 62600000, 62800000, 63000000, 63200000, 63400000, 63600000, 63800000, 64000000, 64200000, 64400000, 64600000, 64800000,
  45. 65000000, 65200000, 65400000, 65600000, 65800000, 66000000, 66200000, 66400000, 66600000, 66800000, 67000000, 67200000, 67400000, 67600000,
  46. 67800000, 68000000, 68200000, 68400000, 68600000, 68800000, 69000000, 69200000, 69400000, 69600000, 69800000, 70000000, 70200000, 70400000,
  47. 70600000, 70800000, 71000000, 71200000, 71400000, 71600000, 71800000, 72000000, 72200000, 72400000, 72600000, 72800000, 73000000, 73200000,
  48. 73400000, 73600000, 73800000, 74000000, 74200000, 74400000, 74600000, 74800000, 75000000, 75200000, 75400000, 75600000, 75800000, 76000000,
  49. 76200000, 76400000, 76600000, 76800000, 77000000, 77200000, 77400000, 77600000, 77800000, 78000000, 78200000, 78400000, 78600000, 78800000,
  50. 79000000, 79200000, 79400000, 79600000, 79800000, 80000000, 80200000, 80400000, 80600000, 80800000, 81000000, 81200000, 81400000, 81600000,
  51. 81800000, 82000000, 82200000, 82400000, 82600000, 82800000, 83000000, 83200000, 83400000, 83600000, 83800000, 84000000, 84200000, 84400000,
  52. 84600000, 84800000, 85000000, 85200000, 85400000, 85600000, 85800000, 86000000, 86200000, 86400000, 86600000, 86800000, 87000000, 87200000,
  53. 87400000, 87600000, 87800000, 88000000, 88200000, 88400000, 88600000, 88800000, 89000000, 89200000, 89400000, 89600000, 89800000, 90000000,
  54. 90200000, 90400000, 90600000, 90800000, 91000000, 91200000, 91400000, 91600000, 91800000, 92000000, 92200000, 92400000, 92600000, 92800000,
  55. 93000000, 93200000, 93400000, 93600000, 93800000, 94000000, 94200000, 94400000, 94600000, 94800000, 95000000, 95200000, 95400000, 95600000,
  56. 95800000, 96000000, 96200000, 96400000, 96600000, 96800000, 97000000, 97200000, 97400000, 97600000, 97800000, 98000000, 98200000, 98400000,
  57. 98500000, 98600000, 98700000, 98800000, 98900000, 99000000, 99100000, 99200000, 99300000, 99400000, 99500000, 99600000, 99700000, 99800000,
  58. 99900000, 100000000, 100200000, 100400000, 100500000, 100800000, 100900000 }
  59.  
  60. // MYSQL
  61. #define MYSQL_HOST "localhost"
  62. #define MYSQL_USER "root"
  63. #define MYSQL_PASS "kill125"
  64. #define MYSQL_DB "zp_database"
  65.  
  66. // Access Flags Required (check CMDACCESS.INI for console commands)
  67. const ACCESS_FLAG = ADMIN_BAN // to access the admin menu
  68. const ACCESS_FLAG2 = ADMIN_RCON // to turn the mod on/off
  69. const ACCESS_FLAG3 = ADMIN_BAN // to get admin models
  70.  
  71. new const espacio[][][] =
  72. {
  73. {
  74. "",
  75. "",
  76. "",
  77. "",
  78. "",
  79. "^n"
  80. },
  81. {
  82. "",
  83. "",
  84. "",
  85. "^n",
  86. "",
  87. ""
  88. }
  89. }
  90. new const g_levelprimary[] =
  91. {
  92. 1,
  93. 5,
  94. 11,
  95. 16,
  96. 30,
  97. 38,
  98. 47,
  99. 56,
  100. 68,
  101. 74,
  102. 89,
  103. 97,
  104. 108,
  105. 115,
  106. 128,
  107. 137,
  108. 149,
  109. 157,
  110. 168,
  111. 186,
  112. 198,
  113. 206,
  114. 216,
  115. 227,
  116. 239,
  117. 256,
  118. 269,
  119. 287,
  120. 298,
  121. 314,
  122. 336,
  123. 349,
  124. 368,
  125. 376,
  126. 389,
  127. 403,
  128. 413,
  129. 435,
  130. 450,
  131. 465,
  132. 476,
  133. 489,
  134. 496,
  135. 508,
  136. 512,
  137. 528,
  138. 539,
  139. 543,
  140. 554,
  141. 576,
  142. 587,
  143. 593,
  144. 603,
  145. 612,
  146. 616,
  147. 621,
  148. 630
  149. }
  150. new const g_levelsecondary[] = {
  151.  
  152. 1,
  153. 12,
  154. 30,
  155. 42,
  156. 53,
  157. 64
  158. }
  159. new const g_primary_names[][] = {
  160.  
  161. "Mac 10",
  162. "Tmp",
  163. "Ump 45",
  164. "P90",
  165. "Mp5 Navy",
  166. "M3",
  167. "XM1014",
  168. "Galil",
  169. "Famas",
  170. "Ak-47",
  171. "M4A1 Carbine",
  172. "SG-552 Commando",
  173. "AUG 131",
  174. "Awp Magnum Sniper",
  175. "M249 Para Machine Gun",
  176. "SG-550 Auto Sniper",
  177. "G3SG1 Auto Sniper",
  178. "Mp5 Tac 131",
  179. "P90 41",
  180. "Famas 131",
  181. "IMI Galil .36",
  182. "Shotgun M3 .390",
  183. "Serbu Super",
  184. "Kar 32",
  185. "Delta F11",
  186. "Dual Navy",
  187. "Minigin",
  188. "Tactical Mp5 A4",
  189. "Br-47",
  190. "Fire Awp",
  191. "Frost Awp",
  192. "Colt 221",
  193. "Galil vBlack",
  194. "Famas F11",
  195. "HCO ScoutGuardSG550-V",
  196. "HK G3A4",
  197. "FERO-Z51",
  198. "Awp 131",
  199. "Thompson",
  200. "H5 Hugit",
  201. "Demon Serbu x980",
  202. ".45 Winchester Magnum",
  203. "Ak-74 QTDN",
  204. "JT-910",
  205. "Ocillator .98",
  206. "L9A1",
  207. "Ump Vtac",
  208. "Remington .35",
  209. "Fire Daemon",
  210. "Frozen Daemon",
  211. "Mossberg 500",
  212. "Scar H",
  213. "SG-550 Zeus",
  214. "M16A4",
  215. "Intervention",
  216. "RPD",
  217. "Spas - 12"
  218. }
  219.  
  220. // Armas
  221. new bool: mp5_tac[33], bool: p90_41[33], bool: famas_131[33], bool: galil_36[33], bool: m3_390[33], bool: xm1014_serbu[33]
  222. new bool: sg552_kar32[33], bool: aug_delta[33], bool: mp5_dual[33], bool: m249_minigun[33], bool: mp5_tacticala4[33]
  223. new bool: ak47_br47[33], bool: awp_fire[33], bool: awp_frost[33], bool: m4a1_colt[33], bool: galil_black[33]
  224. new bool: famas_f11[33], bool: sg550_scoutguard[33], bool: sg552_hk[33], bool: g3sg1_fero[33], bool: awp_131[33]
  225. new bool: ak47_thompson[33], bool: m4a1_hugit[33], bool: xm1014_demon[33], bool: m3_winchester[33], bool: ak47_ak74[33]
  226. new bool: m4a1_jt[33], bool: aug_ocillator[33], bool: sg552_l9a1[33], bool: ump45_tac[33], bool: m3_remington[33]
  227. new bool: g3sg1_fire[33], bool: g3sg1_frost[33], bool: mp5_mossberg[33], bool: sg552_scar[33]
  228. new bool: sg550_zeus[33], bool: m4a1_m16[33], bool: awp_intervention[33], bool: m249_rpd[33], bool: m3_spas12[33]
  229.  
  230. new const g_secondary_names[][] = {
  231.  
  232. "Glock 18.C",
  233. "USP .45 ACP Tactical",
  234. "P228 Compact",
  235. "Desert Eagle",
  236. "FiveSeven",
  237. "Dual Elites"
  238. }
  239. new const g_primary_items[][] = {
  240.  
  241. "weapon_mac10",
  242. "weapon_tmp",
  243. "weapon_ump45",
  244. "weapon_p90",
  245. "weapon_mp5navy",
  246. "weapon_m3",
  247. "weapon_xm1014",
  248. "weapon_galil",
  249. "weapon_famas",
  250. "weapon_ak47",
  251. "weapon_m4a1",
  252. "weapon_sg552",
  253. "weapon_aug",
  254. "weapon_awp",
  255. "weapon_m249" ,
  256. "weapon_sg550",
  257. "weapon_g3sg1",
  258. "weapon_mp5navy",
  259. "weapon_p90",
  260. "weapon_famas",
  261. "weapon_galil",
  262. "weapon_m3",
  263. "weapon_xm1014",
  264. "weapon_sg552",
  265. "weapon_aug",
  266. "weapon_mp5navy",
  267. "weapon_m249" ,
  268. "weapon_mp5navy",
  269. "weapon_ak47",
  270. "weapon_awp",
  271. "weapon_awp",
  272. "weapon_m4a1",
  273. "weapon_galil",
  274. "weapon_famas",
  275. "weapon_sg550",
  276. "weapon_galil",
  277. "weapon_g3sg1",
  278. "weapon_awp",
  279. "weapon_ak47",
  280. "weapon_m4a1",
  281. "weapon_xm1014",
  282. "weapon_m3",
  283. "weapon_ak47",
  284. "weapon_m4a1",
  285. "weapon_aug",
  286. "weapon_sg552",
  287. "weapon_ump45",
  288. "weapon_m3",
  289. "weapon_g3sg1",
  290. "weapon_g3sg1",
  291. "weapon_mp5navy",
  292. "weapon_sg552",
  293. "weapon_sg550",
  294. "weapon_m4a1",
  295. "weapon_awp",
  296. "weapon_m249" ,
  297. "weapon_m3"
  298. }
  299.  
  300. new const g_secondary_items[][] = {
  301.  
  302. "weapon_glock18",
  303. "weapon_usp",
  304. "weapon_p228",
  305. "weapon_deagle",
  306. "weapon_fiveseven",
  307. "weapon_elite"
  308. }
  309.  
  310. new const COLOR_NAMES[10][9] = {
  311.  
  312. "Rojo",
  313. "Verde",
  314. "Azul",
  315. "Amarillo",
  316. "Celeste",
  317. "Blanco",
  318. "Indigo",
  319. "Naranja",
  320. "Magenta",
  321. "Violeta"
  322. }
  323.  
  324. new const COLOR_RGB[10][3] = {
  325.  
  326. { 255, 0, 0 },
  327. { 0, 255, 0 },
  328. { 0, 0, 255 },
  329. { 255, 255, 0 },
  330. { 135, 206, 255 },
  331. { 255, 255, 255 },
  332. { 75, 0, 130 },
  333. { 255, 112, 40 },
  334. { 255, 0, 255 },
  335. { 100, 0, 255 }
  336. }
  337.  
  338. new const BOMBNAMES[4][3][] =
  339. {
  340.  
  341. {
  342. "Fire",
  343. "Frost",
  344. "Force"
  345. },
  346. {
  347. "Molotov",
  348. "Frost",
  349. "Force"
  350. },
  351. {
  352. "Molotov",
  353. "Frost",
  354. "Force"
  355. },
  356. {
  357. "Molotov",
  358. "Frost",
  359. "Force"
  360. }
  361. }
  362.  
  363. new const g_mejoras_names[2][6][] =
  364. {
  365. {
  366. "Daño",
  367. "Vitalidad",
  368. "Velocidad",
  369. "Chaleco",
  370. "Gravedad",
  371. "Defensa"
  372. },
  373. {
  374. "Daño",
  375. "Vitalidad",
  376. "Velocidad",
  377. "Gravedad",
  378. "",
  379. ""
  380. }
  381. }
  382.  
  383. new const g_mejoras_names_max[][] =
  384. {
  385. {
  386. 40,
  387. 30,
  388. 20,
  389. 30,
  390. 12,
  391. 5
  392. },
  393. {
  394. 10,
  395. 40,
  396. 30,
  397. 14
  398. }
  399. }
  400.  
  401. new const g_terciary_items[3][] = {
  402.  
  403. "weapon_hegrenade",
  404. "weapon_flashbang",
  405. "weapon_smokegrenade"
  406. }
  407.  
  408. new const BOMBWEAPONNAMMO[3] = {
  409.  
  410. CSW_HEGRENADE,
  411. CSW_FLASHBANG,
  412. CSW_SMOKEGRENADE
  413. }
  414.  
  415. new const BOMBAMMOUNT[4][3] =
  416. {
  417.  
  418. {
  419. 1,
  420. 1,
  421. 1
  422. },
  423. {
  424. 2,
  425. 1,
  426. 2
  427. },
  428. {
  429. 2,
  430. 2,
  431. 2
  432. },
  433. {
  434. 3,
  435. 3,
  436. 3
  437. }
  438. }
  439.  
  440. new g_bomb_level[4] = {
  441.  
  442. 1,
  443. 25,
  444. 75,
  445. 100
  446. }
  447.  
  448. new email_valido[][] =
  449. {
  450. "@hotmail.com",
  451. "@gmail.com",
  452. "@live.com",
  453. "@yahoo.com.ar"
  454. }
  455.  
  456. // Player Models (randomly chosen if more than one)
  457. new const model_nemesis[][] = { "nemesisgd" } // Nemesis
  458. new const model_survivor[][] = { "jillsg2" } // Survivor
  459. new const model_admin[][] = { "vip" } // Admin (human)
  460. new const model_admin_zombie[][] = { "zombie_source" } // Admin (zombie)
  461. new const model_wesker[][] = { "Wesker_l4d" } // Wesker
  462. new const model_terminator[][] = { "terminator" } // terminator
  463. new const model_depredador[][] = { "depredador" } // depredador
  464. new const model_assassin[][] = { "assesianasd" } // Assassin
  465.  
  466. // Weapon Models
  467. new const model_vknife_nemesis[] = { "models/zombie_plague/v_knife_blood.mdl" }
  468. new const model_vm249_survivor[] = { "models/v_m249.mdl" }
  469. new const model_vknife_human[] = { "models/v_knifeb.mdl" }
  470. new const model_grenade_infect[] = { "models/zombie_plague/v_grenade_infect.mdl" }
  471. new const model_grenade_fire[] = { "models/zombie_plague/v_grenade_fire.mdl" }
  472. new const model_grenade_frost[] = { "models/zombie_plague/v_grenade_frost.mdl" }
  473. new const model_grenade_flare[] = { "models/zombie_plague/v_grenade_flare.mdl" }
  474. new const v_campo[] = { "models/zombie_world/v_force.mdl" }
  475. new const w_campo[] = { "models/zombie_world/w_force.mdl" }
  476. new const entclas[] = { "campo_grenade_forze" }
  477. new const v_ump45[] = { "models/zombie_world/v_umpvtac.mdl" }
  478. new const p_ump45[] = { "models/zombie_world/p_umpvtac.mdl" }
  479. new const v_spas12[] = { "models/zombie_world/v_m3_released.mdl" }
  480. new const v_deagle_fire[] = { "models/zombie_world/v_deagle_fire.mdl" }
  481. new const p_deagle_fire[] = { "models/zombie_world/p_deagle_fire.mdl" }
  482. new const v_m3_terminator[] = { "models/zombie_world/v_m3_1.mdl" }
  483. new const p_m3_terminator[] = { "models/zombie_world/p_m3_1.mdl" }
  484. new const v_colt[] = { "models/zombie_world/v_m4a1_1.mdl" }
  485. new const p_colt[] = { "models/zombie_world/p_m4a1_1.mdl" }
  486. new const v_knife_assassin[] = { "models/zombie_world/v_knife_human.mdl" }
  487. new const v_knife_depredador[] = { "models/zombie_world/v_knife_nemesis_A.mdl" }
  488. new const p_knife_nemesis[] = { "models/zombie_world/p_knifenem.mdl" }
  489. new const pirate2[] = { "models/hats/pirate2.mdl" }
  490. new const scream[] = { "models/hats/scream.mdl" }
  491. new const viking[] = { "models/hats/viking.mdl" }
  492. new const jason[] = { "models/hats/jason.mdl" }
  493.  
  494. // Grenade Sprites
  495. new const sprite_grenade_trail[] = { "sprites/laserbeam.spr" }
  496. new const sprite_grenade_ring[] = { "sprites/shockwave.spr" }
  497. new const sprite_grenade_fire[] = { "sprites/flame.spr" }
  498. new const sprite_grenade_smoke[] = { "sprites/black_smoke3.spr" }
  499. new const sprite_grenade_glass[] = { "models/glassgibs.mdl" }
  500.  
  501. // Sounds (randomly chosen if more than one)
  502. new const sound_win_zombies[][] = { "ambience/the_horror1.wav", "ambience/the_horror3.wav", "ambience/the_horror4.wav" }
  503. new const sound_win_humans[][] = { "zombie_plague/win_humans1.wav", "zombie_plague/win_humans2.wav" }
  504. new const sound_win_no_one[][] = { "ambience/3dmstart.wav" }
  505. new const zombie_infect[][] = { "zombie_plague/zombie_infec1.wav", "zombie_plague/zombie_infec2.wav", "zombie_plague/zombie_infec3.wav", "scientist/c1a0_sci_catscream.wav", "scientist/scream01.wav" }
  506. new const zombie_pain[][] = { "zombie_plague/zombie_pain1.wav", "zombie_plague/zombie_pain2.wav", "zombie_plague/zombie_pain3.wav", "zombie_plague/zombie_pain4.wav", "zombie_plague/zombie_pain5.wav" }
  507. new const nemesis_pain[][] = { "zombie_plague/nemesis_pain1.wav", "zombie_plague/nemesis_pain2.wav", "zombie_plague/nemesis_pain3.wav" }
  508. new const zombie_die[][] = { "zombie_plague/zombie_die1.wav", "zombie_plague/zombie_die2.wav", "zombie_plague/zombie_die3.wav", "zombie_plague/zombie_die4.wav", "zombie_plague/zombie_die5.wav" }
  509. new const zombie_fall[][] = { "zombie_plague/zombie_fall1.wav" }
  510. new const zombie_miss_slash[][] = { "weapons/knife_slash1.wav", "weapons/knife_slash2.wav" }
  511. new const zombie_miss_wall[][] = { "weapons/knife_hitwall1.wav" }
  512. new const zombie_hit_normal[][] = { "weapons/knife_hit1.wav", "weapons/knife_hit2.wav", "weapons/knife_hit3.wav", "weapons/knife_hit4.wav" }
  513. new const zombie_hit_stab[][] = { "weapons/knife_stab.wav" }
  514. new const zombie_idle[][] = { "nihilanth/nil_now_die.wav", "nihilanth/nil_slaves.wav", "nihilanth/nil_alone.wav", "zombie_plague/zombie_brains1.wav", "zombie_plague/zombie_brains2.wav" }
  515. new const zombie_idle_last[][] = { "nihilanth/nil_thelast.wav" }
  516. new const zombie_madness[][] = { "zombie_plague/zombie_madness1.wav" }
  517. new const sound_nemesis[][] = { "zombie_plague/nemesis1.wav", "zombie_plague/nemesis2.wav" }
  518. new const sound_survivor[][] = { "zombie_plague/survivor1.wav", "zombie_plague/survivor2.wav" }
  519. new const sound_swarm[][] = { "ambience/the_horror2.wav" }
  520. new const sound_multi[][] = { "ambience/the_horror2.wav" }
  521. new const sound_plague[][] = { "zombie_plague/nemesis1.wav", "zombie_plague/survivor1.wav" }
  522. new const grenade_infect[][] = { "zombie_plague/grenade_infect.wav" }
  523. new const grenade_infect_player[][] = { "scientist/scream20.wav", "scientist/scream22.wav", "scientist/scream05.wav" }
  524. new const grenade_fire[] = { "zombie_plague/molotov_explosion.wav" }
  525. new const grenade_fire_player[][] = { "zombie_plague/zombie_burn3.wav","zombie_plague/zombie_burn4.wav","zombie_plague/zombie_burn5.wav","zombie_plague/zombie_burn6.wav","zombie_plague/zombie_burn7.wav" }
  526. new const grenade_frost[][] = { "warcraft3/frostnova.wav" }
  527. new const grenade_frost_player[][] = { "warcraft3/impalehit.wav" }
  528. new const grenade_frost_break[][] = { "warcraft3/impalelaunch1.wav" }
  529. new const grenade_flare[][] = { "items/nvg_on.wav" }
  530. new const sound_antidote[][] = { "items/smallmedkit1.wav" }
  531. new const sound_thunder[][] = { "zombie_plague/thunder1.wav", "zombie_plague/thunder2.wav" }
  532. new const Level_up[] = { "zombie_plague/lowlevelup.wav" }
  533. new const sound_armageddon[][] = { "zombie_plague/armaggedon2.wav" }
  534. new const sound_apocalypsis[][] = { "zombie_plague/sound_apocalypsis.wav" }
  535.  
  536. // Uncomment the following line to enable ambience sounds
  537. #define AMBIENCE_SOUNDS
  538.  
  539. #if defined AMBIENCE_SOUNDS // Ambience Sounds List (only .wav and .mp3 formats supported)
  540. // Infection Rounds
  541. new const sound_ambience1[][] = { "zombie_plague/ambience.wav" } // sounds (played randomly)
  542. new const Float:sound_ambience1_duration[] = { 17.0 } // duration in seconds of each sound
  543. // Nemesis Rounds
  544. new const sound_ambience2[][] = { "zombie_plague/ambience.wav" }
  545. new const Float:sound_ambience2_duration[] = { 17.0 }
  546. // Survivor Rounds
  547. new const sound_ambience3[][] = { "zombie_plague/ambience.wav" }
  548. new const Float:sound_ambience3_duration[] = { 17.0 }
  549. // Swarm Rounds
  550. new const sound_ambience4[][] = { "zombie_plague/ambience.wav" }
  551. new const Float:sound_ambience4_duration[] = { 17.0 }
  552. // Plague Rounds
  553. new const sound_ambience5[][] = { "zombie_plague/ambience.wav" }
  554. new const Float:sound_ambience5_duration[] = { 17.0 }
  555. #endif
  556.  
  557. // Additional Items to give after buying all weapons (e.g. grenades)
  558. //new const g_additional_items[][] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
  559.  
  560. // Extra Items: Weapons and their costs
  561. new const g_extra_names[][] = { "Napalm Nade", "Frost Nade", "Force Bomb" }
  562. new const g_extra_items[][] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
  563. new const g_extra_costs[] = { 6, 6, 6 }
  564.  
  565. // Extra Items: costs for Night Vision, Antidote, Zombie Madness, and Infection Bomb
  566. new const g_extra_costs2[] = { 15, 15, 17, 20 }
  567.  
  568. // Hud stuff
  569. new const hud_stuff[][] = { "Mover a la Izquierda", "Mover a la derecha", "Mover Arriba", "Mover Abajo^n", "Centrar", "Esquinar a la Izquierda", "Esquinar a la Derecha" }
  570.  
  571. // Weather Effects: uncomment a line to have the desired effect
  572. #define AMBIENCE_RAIN // Rain
  573. #define AMBIENCE_SNOW // Snow
  574. //#define AMBIENCE_FOG // Fog
  575.  
  576. #if defined AMBIENCE_FOG // Fog Customization (if enabled)
  577. new const FOG_DENSITY[] = "0.0018" // Density
  578. new const FOG_COLOR[] = "128 128 128" // Color: Red Green Blue
  579. #endif
  580.  
  581. // Sky Names (randomly chosen if more than one)
  582. new const skynames[][] = { "space" }
  583.  
  584. // Uncomment if you don't want the sky to be changed
  585. //#define DONT_CHANGE_SKY
  586.  
  587. // Lightning Lights Cycle
  588. new const lights_thunder1[][] = { "i" ,"j", "k", "l", "m", "n", "o", "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a"}
  589. new const lights_thunder2[][] = { "k", "l", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a", "a", "b", "c", "d", "e", "d", "c", "b", "a"}
  590. new const lights_thunder3[][] = { "b", "c", "d", "e", "f", "e", "d", "c", "i" ,"j", "k", "l", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a"}
  591.  
  592. // Decal List for Zombie Bloodstains/Footsteps
  593. new const zombie_decals[] = { 99, 107, 108, 184, 185, 186, 187, 188, 189 }
  594.  
  595. // Knockback Power values for weapons
  596. // Note: negative values will disable knockback power for the weapon
  597. new const Float:kb_weapon_power[] =
  598. {
  599. -1.0, // ---
  600. 2.4, // P228
  601. -1.0, // ---
  602. 6.5, // SCOUT
  603. -1.0, // ---
  604. 8.0, // XM1014
  605. -1.0, // ---
  606. 2.3, // MAC10
  607. 5.0, // AUG
  608. -1.0, // ---
  609. 2.4, // ELITE
  610. 2.0, // FIVESEVEN
  611. 2.4, // UMP45
  612. 5.3, // SG550
  613. 5.5, // GALIL
  614. 5.5, // FAMAS
  615. 2.2, // USP
  616. 2.0, // GLOCK18
  617. 10.0, // AWP
  618. 2.5, // MP5NAVY
  619. 5.2, // M249
  620. 8.0, // M3
  621. 5.0, // M4A1
  622. 2.4, // TMP
  623. 6.5, // G3SG1
  624. -1.0, // ---
  625. 5.3, // DEAGLE
  626. 5.0, // SG552
  627. 6.0, // AK47
  628. -1.0, // ---
  629. 2.0 // P90
  630. }
  631.  
  632. // Dynamic Stuff Limiters (increase if needed)
  633. const MAX_EXTRA_ITEMS = 30
  634. const MAX_ZOMBIE_CLASSSES = 20
  635. const MAX_HUMAN_CLASSSES = 20
  636. const MAX_CSDM_SPAWNS = 128
  637. const MAX_STATS_SAVED = 64
  638. const MAX_MODELS_NEMESIS = 10
  639. const MAX_MODELS_SURVIVOR = 10
  640. const MAX_MODELS_HUMAN = 20
  641. const MAX_MODELS_ADM_HUMAN = 10
  642. const MAX_MODELS_ADM_ZOMBIE = 10
  643. const MAX_MODELS_WESKER = 5
  644. const MAX_MODELS_TERMINATOR = 5
  645. const MAX_MODELS_DEPREDADOR = 5
  646. const MAX_MODELS_ASSASSIN = 5
  647.  
  648. // Objective entites and anything that would affect plugin gameplay
  649. new const g_objective_ents[][] = { "func_bomb_target", "info_bomb_target", "info_vip_start", "func_vip_safetyzone", "func_escapezone", "hostage_entity",
  650. "monster_scientist", "func_hostage_rescue", "info_hostage_rescue", "env_fog", "env_rain", "env_snow", "item_longjump", "func_vehicle" }
  651.  
  652. // ***************************************************************
  653. // *** If you experience many SVC_BAD kicks, try the following ***
  654. // ***************************************************************
  655. // 1. Increase the delay between model changes here: (e.g. set it to 0.5)
  656. const Float:MODELCHANGE_DELAY = 0.2
  657. // 2. If the above doesn't help, uncomment the following line: (experimental!)
  658. //#define HANDLE_MODELS_ON_SEPARATE_ENT
  659.  
  660. // Alternate: This makes the plugin set the model index serverside offset
  661. // for accurate hitboxes and might also help with svc_bad (untested)
  662. // Note: Make sure your models don't have messed up hitboxes, otherwise
  663. // this setting may cause your server insane cpu usage and LAG!
  664. //#define SET_MODELINDEX_OFFSET
  665.  
  666. // ---------------------------------------------------------------
  667. // ------------------ Customization ends here!! ------------------
  668. // ---------------------------------------------------------------
  669.  
  670. /*================================================================================
  671. [Offsets and Constants]
  672. =================================================================================*/
  673.  
  674. // Plugin Version
  675. new const PLUGIN_VERSION[] = "4.2"
  676.  
  677. // Task offsets
  678. enum (+= 100)
  679. {
  680. TASK_MODEL = 2000,
  681. TASK_TEAM,
  682. TASK_SPAWN,
  683. TASK_BLOOD,
  684. TASK_NVISION,
  685. TASK_FLASH,
  686. TASK_CHARGE,
  687. TASK_SHOWHUD,
  688. TASK_NADES,
  689. TASK_MAKEZOMBIE,
  690. TASK_WELCOMEMSG,
  691. TASK_THUNDER_PRE,
  692. TASK_THUNDER,
  693. TASK_AMBIENCESOUNDS,
  694. TASK_LIGHTING
  695. }
  696.  
  697. // IDs inside tasks
  698. #define ID_MODEL (taskid - TASK_MODEL)
  699. #define ID_TEAM (taskid - TASK_TEAM)
  700. #define ID_SPAWN (taskid - TASK_SPAWN)
  701. #define ID_BLOOD (taskid - TASK_BLOOD)
  702. #define ID_NVISION (taskid - TASK_NVISION)
  703. #define ID_FLASH (taskid - TASK_FLASH)
  704. #define ID_CHARGE (taskid - TASK_CHARGE)
  705. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  706. #define LOGIN_FULL 3
  707.  
  708. // Force defines
  709. #define ONE_COLOR // bubble color
  710. #define CAMPO_TASK // force task
  711.  
  712. //#define RANDOM_COLOR // define if want default color
  713.  
  714. #if defined ONE_COLOR
  715. new Float:colour_force_shield[3] = { 255.0 , 255.0 , 255.0 } // bubble color
  716. #endif
  717.  
  718. // Mejoras
  719. #define costo(%1) (%1 * 3) + 1 // costo de mejoras
  720. #define reset_damage(%1) 1.1 * (%1 + 1) / 1.7 // reset damage
  721. #define ammount_damage(%1) (%1 + 3) * 0.3 // upgrade damage
  722. #define ammount_speed(%1) (%1 * 10) // upgrade speed
  723. #define ammount_health(%1) (%1 * 30) // upgrade health
  724. #define ammount_armor(%1) (%1 * 20) // upgrade armor
  725. #define ammount_gravity(%1) ((%1 * 0.01) * 4) // upgrade gravity
  726. #define ammount_zgravity(%1) ((%1 * 0.01) * 2) // upgrade gravity
  727. #define ammount_zhealth(%1) (%1 * 10000) // upgrade zombie health
  728. #define ammount_zspeed(%1) (%1 * 5) // upgrade zombie speed
  729. #define ammount_resistence(%1) (%1 / 1.1) // resistence upgrade
  730. #define ammount_zdamage(%1) (%1 * 2) // zombie damage upgrade
  731. #define TASK_ID 1603
  732.  
  733.  
  734. // Flare and flame tasks
  735. #define FLARE_ENTITY args[0]
  736. #define FLARE_DURATION args[1]
  737. #define FLARE_R args[2]
  738. #define FLARE_G args[3]
  739. #define FLARE_B args[4]
  740. #define FLAME_DURATION args[0]
  741.  
  742. // For player list menu handlers
  743. #define PL_STARTID g_menu_data[id][0]
  744. #define PL_ACTION g_menu_data[id][1]
  745. #define PL_SELECTION (g_menu_data[id][0]+key+1)
  746.  
  747. // For weapon buy menu handlers
  748. #define WPN_STARTID g_menu_data[id][2]
  749. #define WPN_MAXIDS (sizeof g_primary_items)
  750. #define WPN_MAXIDS2 (sizeof g_secondary_items)
  751. #define WPN_SELECTION (g_menu_data[id][2]+key)
  752. #define WPN_AUTO_ON g_menu_data[id][3]
  753. #define WPN_AUTO_PRI g_menu_data[id][4]
  754. #define WPN_AUTO_SEC g_menu_data[id][5]
  755. #define WPN_AUTO_TER g_menu_data[id][6]
  756.  
  757. // For extra items menu handlers
  758. #define EXTRAS_STARTID g_menu_data[id][7]
  759. #define EXTRAS_SELECTION (g_menu_data[id][7]+key)
  760. #define EXTRAS_CUSTOM_STARTID (4+sizeof g_extra_names)
  761.  
  762. // For zombie class menu handlers
  763. #define ZCLASSES_STARTID g_menu_data[id][8]
  764. #define ZCLASSES_SELECTION (g_menu_data[id][8]+key)
  765.  
  766. // For human class menu handlers
  767. #define HCLASSES_STARTID g_menu_data[id][9]
  768. #define HCLASSES_SELECTION (g_menu_data[id][9]+key)
  769.  
  770. // Menu selections
  771. const MENU_KEY_AUTOSELECT = 7
  772. const MENU_KEY_BACK = 7
  773. const MENU_KEY_NEXT = 8
  774. const MENU_KEY_EXIT = 9
  775.  
  776. // Hard coded extra items
  777. enum
  778. {
  779. EXTRA_NVISION = 0,
  780. EXTRA_ANTIDOTE,
  781. EXTRA_MADNESS,
  782. EXTRA_INFBOMB,
  783. EXTRA_WEAPONS_STARTID
  784. }
  785.  
  786. // Game modes
  787. enum
  788. {
  789. MODE_NONE = 0,
  790. MODE_INFECTION,
  791. MODE_NEMESIS,
  792. MODE_SURVIVOR,
  793. MODE_SWARM,
  794. MODE_MULTI,
  795. MODE_PLAGUE,
  796. MODE_SYNAPSIS,
  797. MODE_ARMAGEDDON,
  798. MODE_WESKER,
  799. MODE_TERMINATOR,
  800. MODE_DEPREDADOR,
  801. MODE_ASSASSIN,
  802. MODE_APOCALYPSIS,
  803. MODE_INVASION,
  804. MODE_REVELACION
  805. }
  806.  
  807. // ZP Teams
  808. enum
  809. {
  810. ZP_TEAM_ANY = 0,
  811. ZP_TEAM_ZOMBIE,
  812. ZP_TEAM_HUMAN
  813. }
  814.  
  815. // Zombie classes
  816. const ZCLASS_NONE = -1
  817.  
  818. // Human classes
  819. const HCLASS_NONE = -1
  820.  
  821. // HUD messages
  822. const Float:HUD_EVENT_X = -1.0
  823. const Float:HUD_EVENT_Y = 0.17
  824. const Float:HUD_INFECT_X = 0.05
  825. const Float:HUD_INFECT_Y = 0.45
  826. const Float:HUD_SPECT_X = 0.6
  827. const Float:HUD_SPECT_Y = 0.8
  828. const Float:HUD_STATS_X = 0.02
  829. const Float:HUD_STATS_Y = 0.9
  830.  
  831. // CS Offsets (win32)
  832. const OFFSET_CSTEAMS = 114
  833. const OFFSET_CSMONEY = 115
  834. const OFFSET_NVGOGGLES = 129
  835. const OFFSET_ZOOMTYPE = 363
  836. const OFFSET_CSDEATHS = 444
  837. const OFFSET_AWM_AMMO = 377
  838. const OFFSET_SCOUT_AMMO = 378
  839. const OFFSET_PARA_AMMO = 379
  840. const OFFSET_FAMAS_AMMO = 380
  841. const OFFSET_M3_AMMO = 381
  842. const OFFSET_USP_AMMO = 382
  843. const OFFSET_FIVESEVEN_AMMO = 383
  844. const OFFSET_DEAGLE_AMMO = 384
  845. const OFFSET_P228_AMMO = 385
  846. const OFFSET_GLOCK_AMMO = 386
  847. const OFFSET_FLASH_AMMO = 387
  848. const OFFSET_HE_AMMO = 388
  849. const OFFSET_SMOKE_AMMO = 389
  850. const OFFSET_C4_AMMO = 390
  851. const OFFSET_CLIPAMMO = 51
  852. const OFFSET_MODELINDEX = 491 // by Orangutanz
  853.  
  854. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  855. const OFFSET_LINUX_WEAPONS = 4 // weapon offsets are only 4 steps higher on Linux
  856.  
  857. // CS Teams
  858. enum
  859. {
  860. CS_TEAM_UNASSIGNED = 0,
  861. CS_TEAM_T,
  862. CS_TEAM_CT,
  863. CS_TEAM_SPECTATOR
  864. }
  865. new const TEAMNAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
  866.  
  867. // Some constants
  868. const HIDE_MONEY = (1<<5)|(1<<3)
  869. const ATTRIB_BOMB = (1<<1)
  870. const UNIT_SECOND = (1<<12)
  871. const DMG_HEGRENADE = (1<<24)
  872. const CS_NO_ZOOM = 0x5A
  873. const HAS_NVGOGGLES = (1<<0)
  874. const IMPULSE_FLASHLIGHT = 100
  875. const USE_USING = 2
  876. const USE_STOPPED = 0
  877. const STEPTIME_SILENT = 999
  878. const BREAK_GLASS = 0x01
  879. const FFADE_IN = 0x0000
  880. const PEV_SPEC_TARGET = pev_iuser2
  881.  
  882. // Max BP ammo for weapons
  883. new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
  884. 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }
  885.  
  886. // Max Clip for weapons
  887. new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
  888. 10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 }
  889.  
  890. // Amount of ammo to give when buying additional clips for weapons
  891. new const BUYAMMO[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
  892. 10, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }
  893.  
  894. // Ammo IDs for weapons
  895. new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
  896. 1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }
  897.  
  898. // Weapon IDs for ammo types
  899. new const AMMOWEAPON[] = { 0, CSW_AWP, CSW_SCOUT, CSW_M249, CSW_AUG, CSW_XM1014, CSW_MAC10, CSW_FIVESEVEN, CSW_DEAGLE,
  900. CSW_P228, CSW_ELITE, CSW_FLASHBANG, CSW_HEGRENADE, CSW_SMOKEGRENADE, CSW_C4 }
  901.  
  902. // Ammo Offsets for weapons
  903. new const AMMOOFFSET[] = { -1, OFFSET_P228_AMMO, -1, OFFSET_SCOUT_AMMO, OFFSET_HE_AMMO, OFFSET_M3_AMMO, OFFSET_C4_AMMO,
  904. OFFSET_USP_AMMO, OFFSET_FAMAS_AMMO, OFFSET_SMOKE_AMMO, OFFSET_GLOCK_AMMO, OFFSET_FIVESEVEN_AMMO,
  905. OFFSET_USP_AMMO, OFFSET_FAMAS_AMMO, OFFSET_FAMAS_AMMO, OFFSET_FAMAS_AMMO, OFFSET_USP_AMMO,
  906. OFFSET_GLOCK_AMMO, OFFSET_AWM_AMMO, OFFSET_GLOCK_AMMO, OFFSET_PARA_AMMO, OFFSET_M3_AMMO,
  907. OFFSET_FAMAS_AMMO, OFFSET_GLOCK_AMMO, OFFSET_SCOUT_AMMO, OFFSET_FLASH_AMMO, OFFSET_DEAGLE_AMMO,
  908. OFFSET_FAMAS_AMMO, OFFSET_SCOUT_AMMO, -1, OFFSET_FIVESEVEN_AMMO }
  909.  
  910.  
  911.  
  912. // Primary and Secondary Weapon Names
  913. /*new const WEAPONNAMES[][] = { "", "P228 Compact", "", "XM1014", "", "XM1014", "", "Mac-10", "AUG 131",
  914. "", "Dual Elite Berettas", "FiveseveN", "Ump 45", "SG-550 Auto-Sniper", "Galil", "Famas",
  915. "USP .45 ACP Tactical", "Glock 18C", "AWP Magnum Sniper", "Mp5 Navy", "M249 Para Machinegun",
  916. "M3 Super 90", "M4A1 Carbine", "Tmp", "G3SG1 Auto-Sniper", "", "Desert Eagle .50 AE",
  917. "SG552 Commando", "Ak-47", "", "P90", "M249 Machnine Gun" }*/
  918.  
  919. // CS sounds
  920. new const sound_flashlight[] = "items/flashlight1.wav"
  921. new const sound_buyammo[] = "items/9mmclip1.wav"
  922. new const sound_armorhit[] = "player/bhit_helmet-1.wav"
  923.  
  924. // Explosion radius for custom grenades
  925. const Float:NADE_EXPLOSION_RADIUS = 240.0
  926.  
  927. // pev_ field used to store additional ammo on weapons
  928. const PEV_ADDITIONAL_AMMO = pev_iuser1
  929.  
  930. // pev_ field used to store custom nade types and their values
  931. const PEV_NADE_TYPE = pev_flTimeStepSound
  932. const NADE_TYPE_INFECTION = 1111
  933. const NADE_TYPE_NAPALM = 2222
  934. const NADE_TYPE_FROST = 3333
  935. const NADE_TYPE_FLARE = 4444
  936. const NADE_TYPE_CAMPO = 5555
  937. const PEV_FLARE_COLOR = pev_punchangle
  938.  
  939. // Weapon bitsums
  940. 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)
  941. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  942.  
  943. // Allowed weapons for zombies (added grenades/bomb for sub-plugin support, since they shouldn't be getting them aynway)
  944. const ZOMBIE_ALLOWED_WEAPONS_BITSUM = (1<<CSW_KNIFE)|(1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_C4)
  945.  
  946. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  947. // Classnames for separate model entities
  948. new const MODEL_ENT_CLASSNAME[] = "player_model"
  949. new const WEAPON_ENT_CLASSNAME[] = "weapon_model"
  950. #endif
  951.  
  952. // Menu keys
  953. const KEYSMENU = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
  954.  
  955. /*================================================================================
  956. [Global Variables]
  957. =================================================================================*/
  958.  
  959. // Stupid compiler
  960. #pragma unused g_models_targettime
  961.  
  962. // Player vars
  963. new iSec
  964. new g_HatEnt[33]
  965. new bool:Valido[33]
  966. new password_v[33][33]
  967. new g_playername[33][32]
  968. new g_MsgSync
  969. new g_login[33]
  970. new g_personaje_nombre[33][6][33]
  971. new g_personaje[33]
  972. new cuenta[33][33]
  973. new password[33][33]
  974. new g_date[33][33]
  975. new Handle:g_hTuple
  976. new ErrorCode
  977. new g_Error[514]
  978. new Efecto
  979. new g_assassin[33] // is assassin
  980. new g_depredador[33] // is depredador
  981. new g_tiempo[33][3]
  982. new g_kills[33]
  983. new g_sp_skill_points[33] // especial skill points
  984. new g_gastados[33][2] // puntos zombie/humanos gastados
  985. new g_skill_points[33][2][6] // mejoras
  986. new g_skill_points_type[33][2] // puntos h z
  987. new bool: g_colt[33] // colt
  988. new g_flash_color[33][3] // flash color
  989. new g_bubble_bomb[33] // variable del campo
  990. new g_nvg[33][3] // night vision colors
  991. new red[33], green[33], blue[33] // hud colors
  992. new Float:g_hud_pos[33][2] // hud position
  993. new efecto[33] // hud effect
  994. new g_level[33] // level
  995. new g_reset[33] // reset
  996. new g_flare_color[33][3] // flare color
  997. new g_terminator[33] // is terminator
  998. new g_wesker[33] // is wesker
  999. new g_zombie[33] // is zombie
  1000. new g_nemesis[33] // is nemesis
  1001. new g_survivor[33] // is surivor
  1002. new g_firstzombie[33] // is the first zombie
  1003. new g_lastzombie[33] // is last zombie
  1004. new g_lasthuman[33] // is last human
  1005. new g_frozen[33] // is frozen (can't move)
  1006. new g_nodamage[33] // has spawn protection/zombie madness
  1007. new g_respawn_as_zombie[33] // should respawn as zombie
  1008. new g_nvision[33] // has night vision
  1009. new g_nvisionenabled[33] // has night vision turned on
  1010. new g_zombieclass[33] // zombie class
  1011. new g_zombieclassnext[33] // zombie class for next infection
  1012. new g_humanclass[33]
  1013. new g_humanclassnext[33]
  1014. new g_flashlight[33] // has custom flashlight turned on
  1015. new g_flashbattery[33] = { 100, ... } // custom flashlight battery
  1016. new g_currentweapon[33] // current weapon the player is holding
  1017. new g_canbuy[33] // is allowed to buy a new weapon through the menu
  1018. new g_ammopacks[33] // ammo pack count
  1019. new g_damagedealt[33] // damage dealt to zombies (used to calculate ammo packs reward)
  1020. new g_restorevel[33], Float:g_velocity[33][3] // Pain Shock Free vars
  1021. new Float:g_lastleaptime[33] // time leap was last used
  1022. new Float:g_lastflashtime[33] // time flashlight was last turned on/off
  1023. new g_switchingteam[33] // is switching team
  1024. new g_playermodel[33][32] // current model's short name [player][model]
  1025. new g_menu_data[33][10] // data for various menus
  1026. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  1027. new g_ent_playermodel[33] // player model entity
  1028. new g_ent_weaponmodel[33] // weapon model entity
  1029. #endif
  1030.  
  1031. // Game vars
  1032. new g_invasionround // invasion round
  1033. new g_apocalypsisround // apocalypsis round
  1034. new g_assassinround // assassin round
  1035. new g_depredadorround // depredador round
  1036. new count // admin count
  1037. new g_terminatorround // terminator round
  1038. new g_weskerround // wesker round
  1039. new g_armageddonround // armagedon round
  1040. new g_synapsisround // synapsis round
  1041. new Float:g_teams_i // delay between Team Change messages
  1042. new g_pluginenabled // ZP plugin enabled
  1043. new g_newround // new round starting
  1044. new g_revelacionround // revelacion round
  1045. new g_endround // round ended
  1046. new g_nemround // nemesis round
  1047. new g_survround // survivor round
  1048. new g_swarmround // swarm round
  1049. new g_plagueround // plague round
  1050. new g_lastmode // last played mode
  1051. new g_scorezombies, g_scorehumans // team scores
  1052. new g_spawnCount // available spawn points counter
  1053. new Float:g_spawns[MAX_CSDM_SPAWNS][3] // spawn points data
  1054. new g_lights_i // lightning current lights counter
  1055. new Float:g_models_targettime // for adding delays between Model Change messages
  1056. new Float:g_teams_targettime // for adding delays between Team Change messages
  1057. new g_MsgSync2 // message sync objects
  1058. new g_trailSpr, g_exploSpr, g_flameSpr, g_smokeSpr, g_glassSpr // grenade sprites
  1059. new g_modname[32] // for formating the mod name
  1060. new g_freezetime // whether it's freeze time
  1061. new g_maxplayers // max players counter
  1062. new g_czero // whether we are running on a CZ server
  1063. new g_hamczbots // whether ham forwards are registered for CZ bots
  1064. new g_fwSpawn // spawn forward handle
  1065. new g_infbombcounter // to limit buying infection bombs
  1066.  
  1067. // Precached model indexes
  1068. new g_modelindex_nemesis[MAX_MODELS_NEMESIS]
  1069. new g_modelindex_survivor[MAX_MODELS_SURVIVOR]
  1070. new g_modelindex_admin[MAX_MODELS_ADM_HUMAN]
  1071. new g_modelindex_admin_zombie[MAX_MODELS_ADM_ZOMBIE]
  1072. new g_modelindex_wesker[MAX_MODELS_WESKER]
  1073. new g_modelindex_depredador[MAX_MODELS_DEPREDADOR]
  1074. new g_modelindex_terminator[MAX_MODELS_TERMINATOR]
  1075. new g_modelindex_assassin[MAX_MODELS_ASSASSIN]
  1076.  
  1077. // Some forward handlers
  1078. new g_fwRoundStart, g_fwRoundEnd, g_fwUserInfected_pre, g_fwUserInfected_post,
  1079. g_fwUserHumanized_pre, g_fwUserHumanized_post, g_fwExtraItemSelected, g_fwDummyResult
  1080.  
  1081. // Temporary Database vars (used to restore players stats in case they get disconnected)
  1082. new db_name[MAX_STATS_SAVED][32] // player name
  1083. new db_ammopacks[MAX_STATS_SAVED] // ammo pack count
  1084. new db_zombieclass[MAX_STATS_SAVED] // zombie class
  1085. new db_slot_i // additional saved slots counter (should start on maxplayers+1)
  1086.  
  1087. // Extra Items vars
  1088. new g_extraitem_name[MAX_EXTRA_ITEMS][32] // caption
  1089. new g_extraitem_cost[MAX_EXTRA_ITEMS] // cost
  1090. new g_extraitem_team[MAX_EXTRA_ITEMS] // team
  1091. new g_extraitem_i // loaded extra items counter
  1092.  
  1093. // Zombie Classes vars
  1094. new g_zclass_name[MAX_ZOMBIE_CLASSSES][32] // name
  1095. new g_zclass_info[MAX_ZOMBIE_CLASSSES][32] // description
  1096. new g_zclass_model[MAX_ZOMBIE_CLASSSES][32] // player model
  1097. new g_zclass_modelindex[MAX_ZOMBIE_CLASSSES] // model index
  1098. new g_zclass_clawmodel[MAX_ZOMBIE_CLASSSES][32] // claw model
  1099. new g_zclass_hp[MAX_ZOMBIE_CLASSSES] // health
  1100. new g_zclass_spd[MAX_ZOMBIE_CLASSSES] // speed
  1101. new Float:g_zclass_grav[MAX_ZOMBIE_CLASSSES] // gravity
  1102. new Float:g_zclass_kb[MAX_ZOMBIE_CLASSSES] // knockback
  1103. new g_zclass_i // loaded zombie classes counter
  1104.  
  1105. // Human Classes vars
  1106. new g_hclass_name[MAX_HUMAN_CLASSSES][32] // name
  1107. new g_hclass_info[MAX_HUMAN_CLASSSES][32] // description
  1108. new g_hclass_model[MAX_HUMAN_CLASSSES][32] // player model
  1109. new g_hclass_modelindex[MAX_HUMAN_CLASSSES] // model index
  1110. new g_hclass_clawmodel[MAX_HUMAN_CLASSSES][32] // claw model
  1111. new g_hclass_hp[MAX_HUMAN_CLASSSES] // health
  1112. new g_hclass_spd[MAX_HUMAN_CLASSSES] // speed
  1113. new g_hclass_armor[MAX_HUMAN_CLASSSES] // armor
  1114. new Float:g_hclass_dmg[MAX_HUMAN_CLASSSES] // damage
  1115. new g_hclass_lvl[MAX_HUMAN_CLASSSES] // level
  1116. new Float:g_hclass_grav[MAX_HUMAN_CLASSSES] // gravity
  1117. new g_hclass_i // loaded human classes counter
  1118.  
  1119. // Message IDs vars
  1120. new g_msgScoreInfo, g_msgNVGToggle, g_msgScoreAttrib, g_msgAmmoPickup, g_msgScreenFade,
  1121. g_msgDeathMsg, g_msgSetFOV, g_msgFlashlight, g_msgFlashBat, g_msgTeamInfo, g_msgDamage,
  1122. g_msgHideWeapon, g_msgCrosshair, g_msgSayText, g_msgScreenShake, g_msgCurWeapon
  1123.  
  1124. // CVAR pointers
  1125. new cvar_lighting, cvar_zombiefov, cvar_plague, cvar_plaguechance, cvar_zombiefirsthp,
  1126. cvar_removemoney, cvar_thunder, cvar_zombiebonushp, cvar_nemhp, cvar_nem, cvar_surv,
  1127. cvar_nemchance, cvar_deathmatch, cvar_nemglow, cvar_cnvg, cvar_hitzones, cvar_humanhp,
  1128. cvar_nemgravity, cvar_flashsize, cvar_ammodamage, cvar_zombiearmor, cvar_survpainfree,
  1129. cvar_nempainfree, cvar_nemspd, cvar_survchance, cvar_survhp, cvar_survspd, cvar_humanspd,
  1130. cvar_swarmchance, cvar_flashdrain, cvar_zombiebleeding, cvar_removedoors,
  1131. cvar_randspawn, cvar_multi, cvar_multichance, cvar_infammo, cvar_swarm, cvar_ammoinfect,
  1132. cvar_toggle, cvar_knockbackpower, cvar_freezeduration, cvar_triggered, cvar_flashcharge,
  1133. cvar_firegrenades, cvar_frostgrenades, cvar_survgravity, cvar_logcommands, cvar_survglow,
  1134. cvar_humangravity, cvar_spawnprotection, cvar_nvgsize, cvar_flareduration, cvar_zclasses, cvar_hclasses,
  1135. cvar_extraitems, cvar_showactivity, cvar_humanlasthp, cvar_warmup,
  1136. cvar_flashdist, cvar_fireduration, cvar_firedamage,
  1137. cvar_flaregrenades, cvar_knockbackducking, cvar_knockbackdamage, cvar_knockbackzvel,
  1138. cvar_multiratio, cvar_flaresize, cvar_spawndelay, cvar_extraantidote, cvar_extramadness,
  1139. cvar_extraweapons, cvar_extranvision, cvar_nvggive, cvar_preventconsecutive, cvar_botquota,
  1140. cvar_buycustom, cvar_zombiepainfree, cvar_fireslowdown, cvar_survbasehp, cvar_survaura,
  1141. cvar_nemaura, cvar_extrainfbomb, cvar_knockback,
  1142. cvar_fragsinfect, cvar_fragskill, cvar_humanarmor, cvar_zombiesilent,
  1143. cvar_plagueratio, cvar_blocksuicide, cvar_knockbackdist, cvar_leapzombies,
  1144. cvar_leapzombiesforce, cvar_leapzombiesheight, cvar_leapzombiescooldown, cvar_leapnemesis,
  1145. cvar_leapnemesisforce, cvar_leapnemesisheight, cvar_leapnemesiscooldown, cvar_leapsurvivor,
  1146. cvar_leapsurvivorforce, cvar_leapsurvivorheight, cvar_nemminplayers, cvar_survminplayers,
  1147. cvar_respawnonsuicide, cvar_respawnafterlast, cvar_leapsurvivorcooldown, cvar_statssave,
  1148. cvar_swarmminplayers, cvar_multiminplayers, cvar_plagueminplayers, cvar_adminmodelshuman,
  1149. cvar_adminmodelszombie, cvar_nembasehp, cvar_blockpushables, cvar_respawnworldspawnkill,
  1150. cvar_madnessduration, cvar_plaguenemnum, cvar_plaguenemhpmulti, cvar_plaguesurvhpmulti,
  1151. cvar_survweapon, cvar_plaguesurvnum, cvar_infectionscreenfade, cvar_infectionscreenshake,
  1152. cvar_infectionsparkle, cvar_infectiontracers, cvar_infectionparticles, cvar_infbomblimit,
  1153. cvar_hudicons, cvar_flashshowall, cvar_synapsis, cvar_synapsischance, cvar_synapsisminplayers,
  1154. cvar_synapsisratio, cvar_armagedonratio, cvar_armagedon, cvar_armagedonchance, cvar_armagedonminplayers,
  1155. cvar_nvgcolor[3], cvar_nemnvgcolor[3], cvar_humnvgcolor[3], cvar_flashcolor[3],
  1156. cvar_bubblepush, cvar_wesker, cvar_weskerchance, cvar_weskerminplayers, cvar_weskergravity,
  1157. cvar_weskerhp, cvar_weskerspd, cvar_weskerdmg, cvar_terminator, cvar_terminatorchance,
  1158. cvar_terminatorminplayers, cvar_terminatorgravity, cvar_terminator_basehp, cvar_terminatorspd,
  1159. cvar_terminatordmg, cvar_survivordmg, cvar_depredador, cvar_depredadorchance,
  1160. cvar_depredadorminplayers, cvar_depredadorgravity, cvar_depredadorspd,
  1161. cvar_depredadorbasehp, cvar_assassin, cvar_assassinchance,
  1162. cvar_assassinminplayers, cvar_assassingravity, cvar_assassinspd,
  1163. cvar_assassinbasehp, cvar_apocalypsis, cvar_apocalypsischance, cvar_apocalypsisminplayers,
  1164. cvar_invasion, cvar_invasionchance, cvar_invasionminplayers,
  1165. cvar_revelacion, cvar_revelacionchance, cvar_revelacionminplayers
  1166.  
  1167. /*================================================================================
  1168. [Natives, Precache and Init]
  1169. =================================================================================*/
  1170. public plugin_natives()
  1171. {
  1172. // Player specific natives
  1173. register_native("zp_get_user_zombie", "native_get_user_zombie", 1)
  1174. register_native("zp_get_user_nemesis", "native_get_user_nemesis", 1)
  1175. register_native("zp_get_user_terminator", "native_get_user_terminator", 1)
  1176. register_native("zp_get_user_survivor", "native_get_user_survivor", 1)
  1177. register_native("zp_get_user_first_zombie", "native_get_user_first_zombie", 1)
  1178. register_native("zp_get_user_last_zombie", "native_get_user_last_zombie", 1)
  1179. register_native("zp_get_user_last_human", "native_get_user_last_human", 1)
  1180. register_native("zp_get_user_zombie_class", "native_get_user_zombie_class", 1)
  1181. register_native("zp_set_user_zombie_class", "native_set_user_zombie_class", 1)
  1182. register_native("zp_get_user_human_class", "native_get_user_human_class", 1)
  1183. register_native("zp_set_user_human_class", "native_set_user_human_class", 1)
  1184. register_native("zp_get_user_ammo_packs", "native_get_user_ammo_packs", 1)
  1185. register_native("zp_set_user_ammo_packs", "native_set_user_ammo_packs", 1)
  1186. register_native("zp_get_user_reset", "native_get_user_reset", 1)
  1187. register_native("zp_set_user_reset", "native_set_user_reset", 1)
  1188. register_native("zp_get_user_level", "native_get_user_level", 1)
  1189. register_native("zp_set_user_level", "native_set_user_level", 1)
  1190. register_native("zp_get_zombie_maxhealth", "native_get_zombie_maxhealth", 1)
  1191. register_native("zp_get_user_batteries", "native_get_user_batteries", 1)
  1192. register_native("zp_set_user_batteries", "native_set_user_batteries", 1)
  1193. register_native("zp_infect_user", "native_infect_user", 1)
  1194. register_native("zp_disinfect_user", "native_disinfect_user", 1)
  1195. register_native("zp_respawn_user", "native_respawn_user", 1)
  1196.  
  1197. // Round natives
  1198. register_native("zp_has_round_started", "native_has_round_started", 1)
  1199. register_native("zp_is_nemesis_round", "native_is_nemesis_round", 1)
  1200. register_native("zp_is_survivor_round", "native_is_survivor_round", 1)
  1201. register_native("zp_is_swarm_round", "native_is_swarm_round", 1)
  1202. register_native("zp_is_plague_round", "native_is_plague_round", 1)
  1203. register_native("zp_is_wesker_round", "native_is_wesker_round", 1)
  1204.  
  1205. // External additions natives
  1206. register_native("zp_register_extra_item", "native_register_extra_item", 1)
  1207. register_native("zp_register_zombie_class", "native_register_zombie_class", 1)
  1208. register_native("zp_register_human_class", "native_register_human_class", 1)
  1209.  
  1210. // Load up the hard coded extra items
  1211. native_register_extra_item2("nvision", g_extra_costs2[0], ZP_TEAM_HUMAN)
  1212. native_register_extra_item2("antidote", g_extra_costs2[1], ZP_TEAM_ZOMBIE)
  1213. native_register_extra_item2("madness", g_extra_costs2[2], ZP_TEAM_ZOMBIE)
  1214. native_register_extra_item2("infbomb", g_extra_costs2[3], ZP_TEAM_ZOMBIE)
  1215. for (new i = 0; i < sizeof g_extra_names; i++) // weapons
  1216. native_register_extra_item2(g_extra_names[i], g_extra_costs[i], ZP_TEAM_HUMAN)
  1217. }
  1218.  
  1219. public plugin_precache()
  1220. {
  1221. Efecto = precache_model("sprites/blueflare1.spr")
  1222.  
  1223. // To switch plugin on/off
  1224. register_concmd("zp_toggle", "cmd_toggle", ACCESS_FLAG2, "<1/0> - Enable/Disable Zombie Plague (will restart the current map)")
  1225. cvar_toggle = register_cvar("zp_on", "1")
  1226.  
  1227. // Plugin disabled?
  1228. if (!get_pcvar_num(cvar_toggle)) return;
  1229. g_pluginenabled = true
  1230.  
  1231. new i, playermodel[100]
  1232.  
  1233. // Custom player models
  1234. for (i = 0; i < sizeof model_assassin; i++)
  1235. {
  1236. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_assassin[i], model_assassin[i])
  1237. g_modelindex_assassin[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1238. }
  1239. for (i = 0; i < sizeof model_depredador; i++)
  1240. {
  1241. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_depredador[i], model_depredador[i])
  1242. g_modelindex_depredador[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1243. }
  1244. for (i = 0; i < sizeof model_wesker; i++)
  1245. {
  1246. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_wesker[i], model_wesker[i])
  1247. g_modelindex_wesker[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1248. }
  1249. for (i = 0; i < sizeof model_terminator; i++)
  1250. {
  1251. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_terminator[i], model_terminator[i])
  1252. g_modelindex_terminator[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1253. }
  1254. for (i = 0; i < sizeof model_nemesis; i++)
  1255. {
  1256. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_nemesis[i], model_nemesis[i])
  1257. g_modelindex_nemesis[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1258. }
  1259. for (i = 0; i < sizeof model_survivor; i++)
  1260. {
  1261. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_survivor[i], model_survivor[i])
  1262. g_modelindex_survivor[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1263. }
  1264. for (i = 0; i < sizeof model_admin; i++)
  1265. {
  1266. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_admin[i], model_admin[i])
  1267. g_modelindex_admin[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1268. }
  1269. for (i = 0; i < sizeof model_admin_zombie; i++)
  1270. {
  1271. formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", model_admin_zombie[i], model_admin_zombie[i])
  1272. g_modelindex_admin_zombie[i] = engfunc(EngFunc_PrecacheModel, playermodel)
  1273. }
  1274.  
  1275. // Custom weapon models
  1276. //engfunc(EngFunc_PrecacheModel, model_vknife_human)
  1277. engfunc(EngFunc_PrecacheModel, model_vknife_nemesis)
  1278. engfunc(EngFunc_PrecacheModel, model_vm249_survivor)
  1279. engfunc(EngFunc_PrecacheModel, model_grenade_infect)
  1280. engfunc(EngFunc_PrecacheModel, model_grenade_fire)
  1281. engfunc(EngFunc_PrecacheModel, model_grenade_frost)
  1282. engfunc(EngFunc_PrecacheModel, model_grenade_flare)
  1283. engfunc(EngFunc_PrecacheModel, v_campo)
  1284. engfunc(EngFunc_PrecacheModel, w_campo)
  1285. engfunc(EngFunc_PrecacheModel, v_ump45)
  1286. engfunc(EngFunc_PrecacheModel, p_ump45)
  1287. engfunc(EngFunc_PrecacheModel, v_spas12)
  1288. engfunc(EngFunc_PrecacheModel, v_deagle_fire)
  1289. engfunc(EngFunc_PrecacheModel, p_deagle_fire)
  1290. engfunc(EngFunc_PrecacheModel, v_m3_terminator)
  1291. engfunc(EngFunc_PrecacheModel, p_m3_terminator)
  1292. engfunc(EngFunc_PrecacheModel, v_colt)
  1293. engfunc(EngFunc_PrecacheModel, p_colt)
  1294. engfunc(EngFunc_PrecacheModel, model_vknife_human)
  1295. engfunc(EngFunc_PrecacheModel, v_knife_assassin)
  1296. engfunc(EngFunc_PrecacheModel, v_knife_depredador)
  1297. engfunc(EngFunc_PrecacheModel, p_knife_nemesis)
  1298. engfunc(EngFunc_PrecacheModel, scream)
  1299. engfunc(EngFunc_PrecacheModel, viking)
  1300. engfunc(EngFunc_PrecacheModel, pirate2)
  1301. engfunc(EngFunc_PrecacheModel, jason)
  1302.  
  1303. // Custom sounds
  1304. for (i = 0; i < sizeof sound_apocalypsis; i++)
  1305. engfunc(EngFunc_PrecacheSound, sound_apocalypsis[i])
  1306. for (i = 0; i < sizeof sound_armageddon; i++)
  1307. engfunc(EngFunc_PrecacheSound, sound_armageddon[i])
  1308. for (i = 0; i < sizeof Level_up; i++)
  1309. engfunc(EngFunc_PrecacheSound, Level_up[i])
  1310. for (i = 0; i < sizeof sound_win_zombies; i++)
  1311. engfunc(EngFunc_PrecacheSound, sound_win_zombies[i])
  1312. for (i = 0; i < sizeof sound_win_humans; i++)
  1313. engfunc(EngFunc_PrecacheSound, sound_win_humans[i])
  1314. for (i = 0; i < sizeof sound_win_no_one; i++)
  1315. engfunc(EngFunc_PrecacheSound, sound_win_no_one[i])
  1316. for (i = 0; i < sizeof zombie_infect; i++)
  1317. engfunc(EngFunc_PrecacheSound, zombie_infect[i])
  1318. for (i = 0; i < sizeof zombie_pain; i++)
  1319. engfunc(EngFunc_PrecacheSound, zombie_pain[i])
  1320. for (i = 0; i < sizeof nemesis_pain; i++)
  1321. engfunc(EngFunc_PrecacheSound, nemesis_pain[i])
  1322. for (i = 0; i < sizeof zombie_die; i++)
  1323. engfunc(EngFunc_PrecacheSound, zombie_die[i])
  1324. for (i = 0; i < sizeof zombie_fall; i++)
  1325. engfunc(EngFunc_PrecacheSound, zombie_fall[i])
  1326. for (i = 0; i < sizeof zombie_miss_slash; i++)
  1327. engfunc(EngFunc_PrecacheSound, zombie_miss_slash[i])
  1328. for (i = 0; i < sizeof zombie_miss_wall; i++)
  1329. engfunc(EngFunc_PrecacheSound, zombie_miss_wall[i])
  1330. for (i = 0; i < sizeof zombie_hit_normal; i++)
  1331. engfunc(EngFunc_PrecacheSound, zombie_hit_normal[i])
  1332. for (i = 0; i < sizeof zombie_hit_stab; i++)
  1333. engfunc(EngFunc_PrecacheSound, zombie_hit_stab[i])
  1334. for (i = 0; i < sizeof zombie_idle; i++)
  1335. engfunc(EngFunc_PrecacheSound, zombie_idle[i])
  1336. for (i = 0; i < sizeof zombie_idle_last; i++)
  1337. engfunc(EngFunc_PrecacheSound, zombie_idle_last[i])
  1338. for (i = 0; i < sizeof zombie_madness; i++)
  1339. engfunc(EngFunc_PrecacheSound, zombie_madness[i])
  1340. for (i = 0; i < sizeof sound_nemesis; i++)
  1341. engfunc(EngFunc_PrecacheSound, sound_nemesis[i])
  1342. for (i = 0; i < sizeof sound_survivor; i++)
  1343. engfunc(EngFunc_PrecacheSound, sound_survivor[i])
  1344. for (i = 0; i < sizeof sound_swarm; i++)
  1345. engfunc(EngFunc_PrecacheSound, sound_swarm[i])
  1346. for (i = 0; i < sizeof sound_multi; i++)
  1347. engfunc(EngFunc_PrecacheSound, sound_multi[i])
  1348. for (i = 0; i < sizeof sound_plague; i++)
  1349. engfunc(EngFunc_PrecacheSound, sound_plague[i])
  1350. for (i = 0; i < sizeof grenade_infect; i++)
  1351. engfunc(EngFunc_PrecacheSound, grenade_infect[i])
  1352. for (i = 0; i < sizeof grenade_infect_player; i++)
  1353. engfunc(EngFunc_PrecacheSound, grenade_infect_player[i])
  1354.  
  1355. engfunc(EngFunc_PrecacheSound, grenade_fire)
  1356.  
  1357. for (i = 0; i < sizeof grenade_fire_player; i++)
  1358. engfunc(EngFunc_PrecacheSound, grenade_fire_player[i])
  1359. for (i = 0; i < sizeof grenade_frost; i++)
  1360. engfunc(EngFunc_PrecacheSound, grenade_frost[i])
  1361. for (i = 0; i < sizeof grenade_frost_player; i++)
  1362. engfunc(EngFunc_PrecacheSound, grenade_frost_player[i])
  1363. for (i = 0; i < sizeof grenade_frost_break; i++)
  1364. engfunc(EngFunc_PrecacheSound, grenade_frost_break[i])
  1365. for (i = 0; i < sizeof grenade_flare; i++)
  1366. engfunc(EngFunc_PrecacheSound, grenade_flare[i])
  1367. for (i = 0; i < sizeof sound_antidote; i++)
  1368. engfunc(EngFunc_PrecacheSound, sound_antidote[i])
  1369. for (i = 0; i < sizeof sound_thunder; i++)
  1370. engfunc(EngFunc_PrecacheSound, sound_thunder[i])
  1371. #if defined AMBIENCE_SOUNDS
  1372. for (i = 0; i < sizeof sound_ambience1; i++)
  1373. {
  1374. if (equal(sound_ambience1[i][strlen(sound_ambience1[i])-4], ".mp3"))
  1375. {
  1376. formatex(playermodel, sizeof playermodel - 1, "sound/%s", sound_ambience1[i])
  1377. engfunc(EngFunc_PrecacheGeneric, playermodel)
  1378. }
  1379. else
  1380. {
  1381. engfunc(EngFunc_PrecacheSound, sound_ambience1[i])
  1382. }
  1383. }
  1384. for (i = 0; i < sizeof sound_ambience2; i++)
  1385. {
  1386. if (equal(sound_ambience2[i][strlen(sound_ambience2[i])-4], ".mp3"))
  1387. {
  1388. formatex(playermodel, sizeof playermodel - 1, "sound/%s", sound_ambience2[i])
  1389. engfunc(EngFunc_PrecacheGeneric, playermodel)
  1390. }
  1391. else
  1392. {
  1393. engfunc(EngFunc_PrecacheSound, sound_ambience2[i])
  1394. }
  1395. }
  1396. for (i = 0; i < sizeof sound_ambience3; i++)
  1397. {
  1398. if (equal(sound_ambience3[i][strlen(sound_ambience3[i])-4], ".mp3"))
  1399. {
  1400. formatex(playermodel, sizeof playermodel - 1, "sound/%s", sound_ambience3[i])
  1401. engfunc(EngFunc_PrecacheGeneric, playermodel)
  1402. }
  1403. else
  1404. {
  1405. engfunc(EngFunc_PrecacheSound, sound_ambience3[i])
  1406. }
  1407. }
  1408. for (i = 0; i < sizeof sound_ambience4; i++)
  1409. {
  1410. if (equal(sound_ambience4[i][strlen(sound_ambience4[i])-4], ".mp3"))
  1411. {
  1412. formatex(playermodel, sizeof playermodel - 1, "sound/%s", sound_ambience4[i])
  1413. engfunc(EngFunc_PrecacheGeneric, playermodel)
  1414. }
  1415. else
  1416. {
  1417. engfunc(EngFunc_PrecacheSound, sound_ambience4[i])
  1418. }
  1419. }
  1420. for (i = 0; i < sizeof sound_ambience5; i++)
  1421. {
  1422. if (equal(sound_ambience5[i][strlen(sound_ambience5[i])-4], ".mp3"))
  1423. {
  1424. formatex(playermodel, sizeof playermodel - 1, "sound/%s", sound_ambience5[i])
  1425. engfunc(EngFunc_PrecacheGeneric, playermodel)
  1426. }
  1427. else
  1428. {
  1429. engfunc(EngFunc_PrecacheSound, sound_ambience5[i])
  1430. }
  1431. }
  1432. #endif
  1433.  
  1434. // CS sounds (just in case)
  1435. engfunc(EngFunc_PrecacheSound, sound_flashlight)
  1436. engfunc(EngFunc_PrecacheSound, sound_buyammo)
  1437. engfunc(EngFunc_PrecacheSound, sound_armorhit)
  1438.  
  1439. // Custom models/sprites for grenades
  1440. g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
  1441. g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
  1442. g_flameSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_fire)
  1443. g_smokeSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_smoke)
  1444. g_glassSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_glass)
  1445.  
  1446. new ent
  1447.  
  1448. // Fake Hostage (to force round ending)
  1449. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"))
  1450. if (pev_valid(ent))
  1451. {
  1452. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  1453. dllfunc(DLLFunc_Spawn, ent)
  1454. }
  1455.  
  1456. #if defined AMBIENCE_FOG
  1457. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  1458. if (pev_valid(ent))
  1459. {
  1460. fm_set_kvd(ent, "density", FOG_DENSITY, "env_fog")
  1461. fm_set_kvd(ent, "rendercolor", FOG_COLOR, "env_fog")
  1462. }
  1463. #endif
  1464.  
  1465. #if defined AMBIENCE_RAIN
  1466. engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain"))
  1467. #endif
  1468.  
  1469. #if defined AMBIENCE_SNOW
  1470. engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_snow"))
  1471. #endif
  1472.  
  1473. // Prevent some entities from spawning
  1474. g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  1475. }
  1476.  
  1477. public plugin_init()
  1478. {
  1479. iSec = 30
  1480.  
  1481. for (new i = 0; i <= 32; i++)
  1482. warm_up(i)
  1483.  
  1484. // Create the HUD Sync Objects
  1485. g_MsgSync = CreateHudSyncObj()
  1486.  
  1487. // Iniciar MYSQL
  1488. mysql_init()
  1489.  
  1490. // Register plugin call
  1491. register_plugin("Zombie Plague", PLUGIN_VERSION, "MeRcyLeZZ")
  1492.  
  1493. // Plugin disabled?
  1494. if (!g_pluginenabled) return;
  1495.  
  1496. // No zombie classes?
  1497. if (!g_zclass_i) set_fail_state("No zombie classes loaded!")
  1498.  
  1499. // No human classes?
  1500. if (!g_hclass_i) set_fail_state("No human classes loaded!")
  1501.  
  1502. // Language files
  1503. register_dictionary("zombie_plague.txt")
  1504.  
  1505. // Events
  1506. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  1507. register_logevent("logevent_round_start",2, "1=Round_Start")
  1508. register_logevent("logevent_round_end", 2, "1=Round_End")
  1509. #if defined AMBIENCE_SOUNDS
  1510. register_event("30", "event_intermission", "a")
  1511. #endif
  1512. register_event("CurWeapon", "event_cur_weapon", "b", "1=1")
  1513. register_event("35", "event_weapon_anim", "b")
  1514. register_event("Damage", "damage_msg", "b", "2!0", "3=0", "4!0")
  1515. register_event("CurWeapon", "hook_curwpn", "be", "1=1", "2!29");
  1516.  
  1517. // Forwards
  1518. register_touch(entclas, "player", "entity_touch")
  1519. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  1520. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  1521. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  1522. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  1523. RegisterHam(Ham_Use, "func_tank", "fw_UseStationary")
  1524. RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary")
  1525. RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary")
  1526. RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary")
  1527. RegisterHam(Ham_Use, "func_pushable", "fw_UsePushable")
  1528. RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  1529. RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  1530. RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  1531. RegisterHam(Ham_AddPlayerItem, "player", "fw_AddPlayerItem")
  1532. RegisterHam(Ham_IsMoving, "player", "fw_IsMoving")
  1533. register_forward(FM_ClientKill, "fw_ClientKill")
  1534. register_forward(FM_EmitSound, "fw_EmitSound")
  1535. #if !defined HANDLE_MODELS_ON_SEPARATE_ENT
  1536. register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
  1537. register_forward(FM_ClientUserInfoChanged, "fw_ClientUserInfoChanged")
  1538. #endif
  1539. register_forward(FM_GetGameDescription, "fw_GetGameDescription")
  1540. register_forward(FM_CmdStart, "fw_CmdStart")
  1541. register_forward(FM_SetModel, "fw_SetModel")
  1542. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  1543. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  1544. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink_Post", 1)
  1545. unregister_forward(FM_Spawn, g_fwSpawn)
  1546. remove_entity_name("armoury_entity")
  1547. register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged")
  1548.  
  1549. // Client commands
  1550. register_clcmd("say zpmenu", "clcmd_saymenu")
  1551. register_clcmd("say /zpmenu", "clcmd_saymenu")
  1552. register_clcmd("say unstuck", "clcmd_sayunstuck")
  1553. register_clcmd("say /unstuck", "clcmd_sayunstuck")
  1554. register_clcmd("nightvision", "clcmd_nightvision")
  1555. register_clcmd("drop", "clcmd_drop")
  1556. register_clcmd("buyammo1", "clcmd_buyammo")
  1557. register_clcmd("buyammo2", "clcmd_buyammo")
  1558. register_clcmd("chooseteam", "clcmd_changeteam")
  1559. register_clcmd("_Resetear_", "clcmd_reset")
  1560. register_clcmd("say /admin", "clcmd_admins")
  1561. register_clcmd("Contrasenia_Actual", "ingresar_actual")
  1562. register_clcmd("Crear_Cuenta", "filtro_crear_cuenta")
  1563. register_clcmd("Crear_Contrasenia", "filtro_crear_contrasenia")
  1564. register_clcmd("Verificar_Contrasenia", "filtro_crear_contrasenia_v")
  1565. register_clcmd("Verifica_Contrasenia", "filtro_cambiar_contrasenia_v2")
  1566. register_clcmd("Cuenta", "filtro_login_cuenta")
  1567. register_clcmd("Contrasenia", "filtro_login_contrasenia")
  1568. register_clcmd("Cambiar_Contrasenia", "filtro_cambiar_contrasenia")
  1569. register_clcmd("Crear_Email", "filtro_crear_email")
  1570.  
  1571. // Menus
  1572. register_menu("Buy Menu 1", KEYSMENU, "menu_buy1")
  1573. register_menu("Buy Menu 2", KEYSMENU, "menu_buy2")
  1574. register_menu("Buy Menu 3", KEYSMENU, "menu_buy3")
  1575. register_menu("Zombie Class Menu", KEYSMENU, "menu_zclass")
  1576. register_menu("Human Class Menu", KEYSMENU, "menu_hclass")
  1577. register_menu("Game Menu", KEYSMENU, "menu_game")
  1578. register_menu("Extra Items", KEYSMENU, "menu_extras")
  1579. register_menu("Mod Info", KEYSMENU, "menu_info")
  1580. register_menu("Admin Menu", KEYSMENU, "menu_admin")
  1581. register_menu("Player List Menu", KEYSMENU, "menu_player_list")
  1582. register_menu("Menu De Reseteo", KEYSMENU, "reset_handler")
  1583. register_menu("Config Menu", KEYSMENU, "menu_player")
  1584. register_menu("Mejoras Especiales", KEYSMENU, "menu_mejoras_sp_handler")
  1585. register_menu("Estadisticas", KEYSMENU, "menu_estadisticas_handler")
  1586. register_menu("Cuenta Menu", KEYSMENU, "menu_cuenta")
  1587. register_menu("Personajes Menu", KEYSMENU, "menu_personajes")
  1588. register_menu("Personaje Crear Menu", KEYSMENU, "menu_personaje_crear")
  1589.  
  1590. // Admin commands
  1591. register_concmd("zp_zombie", "cmd_zombie", ACCESS_FLAG, "<target> - Turn someone into a Zombie")
  1592. register_concmd("zp_human", "cmd_human", ACCESS_FLAG, "<target> - Turn someone back to Human")
  1593. register_concmd("zp_nemesis", "cmd_nemesis", ACCESS_FLAG, "<target> - Turn someone into a Nemesis")
  1594. register_concmd("zp_survivor", "cmd_survivor", ACCESS_FLAG, "Start Mode Survivor")
  1595. register_concmd("zp_terminator", "cmd_terminator", ACCESS_FLAG, "Start Mode Terminator")
  1596. register_concmd("zp_respawn", "cmd_respawn", ACCESS_FLAG, "<target> - Respawn someone")
  1597. register_concmd("zp_swarm", "cmd_swarm", ACCESS_FLAG, " - Start Swarm Mode")
  1598. register_concmd("zp_multi", "cmd_multi", ACCESS_FLAG, " - Start Multi Infection")
  1599. register_concmd("zp_plague", "cmd_plague", ACCESS_FLAG, " - Start Plague Mode")
  1600. register_concmd("zp_synapsis", "cmd_synapsis", ACCESS_FLAG, " - Start Synapsis Mode")
  1601. register_concmd("zp_wesker", "cmd_wesker", ACCESS_FLAG, "<target> - Turn someone into a Wesker")
  1602. register_concmd("zp_assassin", "cmd_assassin", ACCESS_FLAG, "<target> - Turn someone into an Assassin")
  1603. register_concmd("zp_depredador", "cmd_depredador", ACCESS_FLAG, "Start Depredator Mode")
  1604. register_concmd("zp_apocalypsis", "cmd_apocalypsis", ACCESS_FLAG, "Start Apocalypsis Mode")
  1605. register_concmd("zp_armageddon", "cmd_armageddon", ACCESS_FLAG, " - Start Armageddon Mode")
  1606. register_concmd("zp_invasion", "cmd_invasion", ACCESS_FLAG, " - Start Invasion Mode")
  1607. register_concmd("zp_levels", "cmd_levels", ACCESS_FLAG, " <Nick> <Amount>")
  1608. register_concmd("zp_resets", "cmd_resets", ACCESS_FLAG, " <Nick> <Amount>")
  1609.  
  1610.  
  1611. // Message IDs
  1612. g_msgScoreInfo = get_user_msgid("ScoreInfo")
  1613. g_msgTeamInfo = get_user_msgid("TeamInfo")
  1614. g_msgDeathMsg = get_user_msgid("DeathMsg")
  1615. g_msgScoreAttrib = get_user_msgid("ScoreAttrib")
  1616. g_msgSetFOV = get_user_msgid("SetFOV")
  1617. g_msgScreenFade = get_user_msgid("ScreenFade")
  1618. g_msgScreenShake = get_user_msgid("ScreenShake")
  1619. g_msgNVGToggle = get_user_msgid("NVGToggle")
  1620. g_msgFlashlight = get_user_msgid("Flashlight")
  1621. g_msgFlashBat = get_user_msgid("FlashBat")
  1622. g_msgAmmoPickup = get_user_msgid("AmmoPickup")
  1623. g_msgDamage = get_user_msgid("Damage")
  1624. g_msgHideWeapon = get_user_msgid("HideWeapon")
  1625. g_msgCrosshair = get_user_msgid("Crosshair")
  1626. g_msgSayText = get_user_msgid("SayText")
  1627. g_msgCurWeapon = get_user_msgid("CurWeapon")
  1628.  
  1629. // Message hooks
  1630. register_message(g_msgCurWeapon, "message_cur_weapon")
  1631. register_message(get_user_msgid("AmmoX"), "message_ammo_x")
  1632. register_message(get_user_msgid("Money"), "message_money")
  1633. register_message(get_user_msgid("Health"), "message_health")
  1634. register_message(g_msgFlashBat, "message_flashbat")
  1635. register_message(g_msgScreenFade, "message_screenfade")
  1636. register_message(g_msgNVGToggle, "message_nvgtoggle")
  1637. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  1638. register_message(get_user_msgid("ClCorpse"), "message_clcorpse")
  1639. #endif
  1640. register_message(get_user_msgid("WeapPickup"), "message_weappickup")
  1641. register_message(g_msgAmmoPickup, "message_ammopickup")
  1642. register_message(get_user_msgid("Scenario"), "message_scenario")
  1643. register_message(get_user_msgid("HostagePos"), "message_hostagepos")
  1644. register_message(get_user_msgid("TextMsg"), "message_textmsg")
  1645. register_message(get_user_msgid("SendAudio"), "message_sendaudio")
  1646. register_message(get_user_msgid("TeamScore"), "message_teamscore")
  1647. register_message(g_msgTeamInfo, "message_teaminfo")
  1648. register_message(get_user_msgid("VGUIMenu"), "Menu_Hook")
  1649. register_message(get_user_msgid("ShowMenu"), "Menu_Hook")
  1650.  
  1651. //cvarss
  1652.  
  1653. // CVARS - General Purpose
  1654. cvar_warmup = register_cvar("zp_delay", "10")
  1655. cvar_lighting = register_cvar("zp_lighting", "a")
  1656. cvar_thunder = register_cvar("zp_thunderclap", "90")
  1657. cvar_triggered = register_cvar("zp_triggered_lights", "1")
  1658. cvar_removedoors = register_cvar("zp_remove_doors", "0")
  1659. cvar_blockpushables = register_cvar("zp_blockuse_pushables", "1")
  1660. cvar_blocksuicide = register_cvar("zp_block_suicide", "1")
  1661. cvar_deathmatch = register_cvar("zp_deathmatch", "0")
  1662. cvar_spawndelay = register_cvar("zp_spawn_delay", "5")
  1663. cvar_spawnprotection = register_cvar("zp_spawn_protection", "5")
  1664. cvar_respawnonsuicide = register_cvar("zp_respawn_on_suicide", "0")
  1665. cvar_respawnafterlast = register_cvar("zp_respawn_after_last_human", "1")
  1666. cvar_respawnworldspawnkill = register_cvar("zp_respawn_on_worldspawn_kill", "1")
  1667. cvar_randspawn = register_cvar("zp_random_spawn", "1")
  1668. cvar_removemoney = register_cvar("zp_remove_money", "1")
  1669. cvar_buycustom = register_cvar("zp_buy_custom", "1")
  1670. cvar_adminmodelshuman = register_cvar("zp_admin_models_human", "1")
  1671. cvar_adminmodelszombie = register_cvar("zp_admin_models_zombie", "1")
  1672. cvar_zclasses = register_cvar("zp_zombie_classes", "1")
  1673. cvar_hclasses = register_cvar("zp_human_classes", "1")
  1674. cvar_statssave = register_cvar("zp_stats_save", "1")
  1675. cvar_preventconsecutive = register_cvar("zp_prevent_consecutive_modes", "1")
  1676.  
  1677. // CVARS - Terminator
  1678. cvar_terminator = register_cvar("zp_terminator_enabled", "1")
  1679. cvar_terminatorchance = register_cvar("zp_terminator_chance", "20")
  1680. cvar_terminatorminplayers = register_cvar("zp_terminator_min_players", "5")
  1681. cvar_terminator_basehp = register_cvar("zp_terminator_basehp", "150")
  1682. cvar_terminatorspd = register_cvar("zp_terminator_speed", "420")
  1683. cvar_terminatorgravity = register_cvar("zp_terminator_gravity", "0.4")
  1684. cvar_terminatordmg = register_cvar("zp_terminator_damage", "81.9")
  1685.  
  1686. // CVARS - Depredador
  1687. cvar_depredador = register_cvar("zp_depredador_enabled", "1")
  1688. cvar_depredadorchance = register_cvar("zp_depredador_chance", "20")
  1689. cvar_depredadorminplayers = register_cvar("zp_depredador_min_players", "5")
  1690. cvar_depredadorspd = register_cvar("zp_depredador_speed", "500")
  1691. cvar_depredadorgravity = register_cvar("zp_depredador_gravity", "0.4")
  1692. cvar_depredadorbasehp = register_cvar("zp_depredador_basehp", "1500")
  1693.  
  1694. // CVARS - Assassin
  1695. cvar_assassin = register_cvar("zp_assassin_enabled", "1")
  1696. cvar_assassinchance = register_cvar("zp_assassin_chance", "20")
  1697. cvar_assassinminplayers = register_cvar("zp_assassin_min_players", "5")
  1698. cvar_assassinspd = register_cvar("zp_assassin_speed", "700")
  1699. cvar_assassingravity = register_cvar("zp_assassin_gravity", "0.4")
  1700. cvar_assassinbasehp = register_cvar("zp_assassin_basehp", "1000")
  1701.  
  1702. // CVARS - Wesker
  1703. cvar_wesker = register_cvar("zp_wesker_enabled", "1")
  1704. cvar_weskerchance = register_cvar("zp_wesker_chance", "20")
  1705. cvar_weskerminplayers = register_cvar("zp_wesker_min_players", "0")
  1706. cvar_weskerhp = register_cvar("zp_wesker_basehp", "140")
  1707. cvar_weskerspd = register_cvar("zp_wesker_speed", "300")
  1708. cvar_weskergravity = register_cvar("zp_wesker_gravity", "0.50")
  1709. cvar_weskerdmg = register_cvar("zp_wesker_damage", "2.8")
  1710.  
  1711. // CVARS - Extra Items
  1712. cvar_extraitems = register_cvar("zp_extra_items", "1")
  1713. cvar_extraweapons = register_cvar("zp_extra_weapons", "1")
  1714. cvar_extranvision = register_cvar("zp_extra_nvision", "1")
  1715. cvar_extraantidote = register_cvar("zp_extra_antidote", "1")
  1716. cvar_extramadness = register_cvar("zp_extra_madness", "1")
  1717. cvar_madnessduration = register_cvar("zp_extra_madness_duration", "5.0")
  1718. cvar_extrainfbomb = register_cvar("zp_extra_infbomb", "1")
  1719. cvar_infbomblimit = register_cvar("zp_extra_infbomb_limit", "10")
  1720.  
  1721. // CVARS - Flashlight and Nightvision
  1722. cvar_nvggive = register_cvar("zp_nvg_give", "1")
  1723. cvar_cnvg = register_cvar("zp_nvg_custom", "1")
  1724. cvar_nvgsize = register_cvar("zp_nvg_size", "80")
  1725. cvar_nvgcolor[0] = register_cvar("zp_nvg_color_R", "0")
  1726. cvar_nvgcolor[1] = register_cvar("zp_nvg_color_G", "150")
  1727. cvar_nvgcolor[2] = register_cvar("zp_nvg_color_B", "0")
  1728. cvar_humnvgcolor[0] = register_cvar("zp_nvg_hum_color_R", "0")
  1729. cvar_humnvgcolor[1] = register_cvar("zp_nvg_hum_color_G", "150")
  1730. cvar_humnvgcolor[2] = register_cvar("zp_nvg_hum_color_B", "0")
  1731. cvar_nemnvgcolor[0] = register_cvar("zp_nvg_nem_color_R", "150")
  1732. cvar_nemnvgcolor[1] = register_cvar("zp_nvg_nem_color_G", "0")
  1733. cvar_nemnvgcolor[2] = register_cvar("zp_nvg_nem_color_B", "0")
  1734. cvar_flashsize = register_cvar("zp_flash_size", "10")
  1735. cvar_flashdrain = register_cvar("zp_flash_drain", "1")
  1736. cvar_flashcharge = register_cvar("zp_flash_charge", "5")
  1737. cvar_flashdist = register_cvar("zp_flash_distance", "1000")
  1738. cvar_flashcolor[0] = register_cvar("zp_flash_color_R", "100")
  1739. cvar_flashcolor[1] = register_cvar("zp_flash_color_G", "100")
  1740. cvar_flashcolor[2] = register_cvar("zp_flash_color_B", "100")
  1741. cvar_flashshowall = register_cvar("zp_flash_show_all", "1")
  1742.  
  1743. // CVARS - Synapsis Mode
  1744. cvar_synapsis = register_cvar("zp_synapsis_enabled", "1")
  1745. cvar_synapsischance = register_cvar("zp_synapsis_chance", "20")
  1746. cvar_synapsisminplayers = register_cvar("zp_synapsis_min_players", "9")
  1747. cvar_synapsisratio = register_cvar("zp_synapsis_ratio", "0.5")
  1748.  
  1749. // CVARS - Knockback
  1750. cvar_knockback = register_cvar("zp_knockback", "0")
  1751. cvar_knockbackdamage = register_cvar("zp_knockback_damage", "1")
  1752. cvar_knockbackpower = register_cvar("zp_knockback_power", "1")
  1753. cvar_knockbackzvel = register_cvar("zp_knockback_zvel", "0")
  1754. cvar_knockbackducking = register_cvar("zp_knockback_ducking", "0.25")
  1755. cvar_knockbackdist = register_cvar("zp_knockback_distance", "500")
  1756.  
  1757. // CVARS - Leap
  1758. cvar_leapzombies = register_cvar("zp_leap_zombies", "0")
  1759. cvar_leapzombiesforce = register_cvar("zp_leap_zombies_force", "500")
  1760. cvar_leapzombiesheight = register_cvar("zp_leap_zombies_height", "300")
  1761. cvar_leapzombiescooldown = register_cvar("zp_leap_zombies_cooldown", "5.0")
  1762. cvar_leapnemesis = register_cvar("zp_leap_nemesis", "0")
  1763. cvar_leapnemesisforce = register_cvar("zp_leap_nemesis_force", "500")
  1764. cvar_leapnemesisheight = register_cvar("zp_leap_nemesis_height", "300")
  1765. cvar_leapnemesiscooldown = register_cvar("zp_leap_nemesis_cooldown", "5.0")
  1766. cvar_leapsurvivor = register_cvar("zp_leap_survivor", "0")
  1767. cvar_leapsurvivorforce = register_cvar("zp_leap_survivor_force", "500")
  1768. cvar_leapsurvivorheight = register_cvar("zp_leap_survivor_height", "300")
  1769. cvar_leapsurvivorcooldown = register_cvar("zp_leap_survivor_cooldown", "5.0")
  1770.  
  1771. // CVARS - Humans
  1772. cvar_humanhp = register_cvar("zp_human_health", "100")
  1773. cvar_humanlasthp = register_cvar("zp_human_last_extrahp", "0")
  1774. cvar_humanspd = register_cvar("zp_human_speed", "240")
  1775. cvar_humangravity = register_cvar("zp_human_gravity", "1.0")
  1776. cvar_humanarmor = register_cvar("zp_human_armor_protect", "1")
  1777. cvar_infammo = register_cvar("zp_human_unlimited_ammo", "0")
  1778. cvar_ammodamage = register_cvar("zp_human_damage_reward", "500")
  1779. cvar_fragskill = register_cvar("zp_human_frags_for_kill", "1")
  1780.  
  1781. // CVARS - Custom Grenades
  1782. cvar_firegrenades = register_cvar("zp_fire_grenades", "1")
  1783. cvar_fireduration = register_cvar("zp_fire_duration", "10")
  1784. cvar_firedamage = register_cvar("zp_fire_damage", "5")
  1785. cvar_fireslowdown = register_cvar("zp_fire_slowdown", "0.5")
  1786. cvar_frostgrenades = register_cvar("zp_frost_grenades", "1")
  1787. cvar_freezeduration = register_cvar("zp_frost_duration", "3")
  1788. cvar_flaregrenades = register_cvar("zp_flare_grenades","1")
  1789. cvar_flareduration = register_cvar("zp_flare_duration", "60")
  1790. cvar_flaresize = register_cvar("zp_flare_size", "25")
  1791.  
  1792. // CVARS - Armagedon Mode
  1793. cvar_armagedon = register_cvar("zp_armagedon_enabled", "1")
  1794. cvar_armagedonchance = register_cvar("zp_armagedon_chance", "30")
  1795. cvar_armagedonminplayers = register_cvar("zp_armagedon_min_players", "0")
  1796. cvar_armagedonratio = register_cvar("zp_armagedon_ratio", "1.2")
  1797.  
  1798. // CVARS - Apocalypsis Mode
  1799. cvar_apocalypsis = register_cvar("zp_apocalypsis_enabled", "1")
  1800. cvar_apocalypsischance = register_cvar("zp_apocalypsis_chance", "30")
  1801. cvar_apocalypsisminplayers = register_cvar("zp_apocalypsis_min_players", "10")
  1802.  
  1803. // CVARS - Invasion Mode
  1804. cvar_invasion = register_cvar("zp_invasion_enabled", "1")
  1805. cvar_invasionchance = register_cvar("zp_invasion_chance", "30")
  1806. cvar_invasionminplayers = register_cvar("zp_invasion_min_players", "10")
  1807.  
  1808. // CVARS - Revelacion Mode
  1809. cvar_revelacion = register_cvar("zp_revelacion_enabled", "1")
  1810. cvar_revelacionchance = register_cvar("zp_revelacion_chance", "30")
  1811. cvar_revelacionminplayers = register_cvar("zp_revelacion_min_players", "10")
  1812.  
  1813. // CVARS - Zombies
  1814. cvar_zombiefirsthp = register_cvar("zp_zombie_first_hp", "2.0")
  1815. cvar_zombiearmor = register_cvar("zp_zombie_armor", "0.75")
  1816. cvar_hitzones = register_cvar("zp_zombie_hitzones", "0")
  1817. cvar_zombiebonushp = register_cvar("zp_zombie_infect_health", "100")
  1818. cvar_zombiefov = register_cvar("zp_zombie_fov", "110")
  1819. cvar_zombiesilent = register_cvar("zp_zombie_silent", "1")
  1820. cvar_zombiepainfree = register_cvar("zp_zombie_painfree", "2")
  1821. cvar_zombiebleeding = register_cvar("zp_zombie_bleeding", "1")
  1822. cvar_ammoinfect = register_cvar("zp_zombie_infect_reward", "1")
  1823. cvar_fragsinfect = register_cvar("zp_zombie_frags_for_infect", "1")
  1824.  
  1825. // CVARS - Special Effects
  1826. cvar_infectionscreenfade = register_cvar("zp_infection_screenfade", "1")
  1827. cvar_infectionscreenshake = register_cvar("zp_infection_screenshake", "1")
  1828. cvar_infectionsparkle = register_cvar("zp_infection_sparkle", "1")
  1829. cvar_infectiontracers = register_cvar("zp_infection_tracers", "1")
  1830. cvar_infectionparticles = register_cvar("zp_infection_particles", "1")
  1831. cvar_hudicons = register_cvar("zp_hud_icons", "1")
  1832.  
  1833. // CVARS - Nemesis
  1834. cvar_nem = register_cvar("zp_nem_enabled", "1")
  1835. cvar_nemchance = register_cvar("zp_nem_chance", "20")
  1836. cvar_nemminplayers = register_cvar("zp_nem_min_players", "0")
  1837. cvar_nembasehp = register_cvar("zp_nem_base_health", "0")
  1838. cvar_nemspd = register_cvar("zp_nem_speed", "250")
  1839. cvar_nemgravity = register_cvar("zp_nem_gravity", "0.5")
  1840. cvar_nemglow = register_cvar("zp_nem_glow", "1")
  1841. cvar_nemaura = register_cvar("zp_nem_aura", "1")
  1842. cvar_nempainfree = register_cvar("zp_nem_painfree", "0")
  1843.  
  1844. // CVARS - Survivor
  1845. cvar_surv = register_cvar("zp_surv_enabled", "1")
  1846. cvar_survchance = register_cvar("zp_surv_chance", "20")
  1847. cvar_survminplayers = register_cvar("zp_surv_min_players", "5")
  1848. cvar_survhp = register_cvar("zp_surv_health", "0")
  1849. cvar_survbasehp = register_cvar("zp_surv_base_health", "110")
  1850. cvar_survspd = register_cvar("zp_surv_speed", "230")
  1851. cvar_survgravity = register_cvar("zp_surv_gravity", "1.25")
  1852. cvar_survglow = register_cvar("zp_surv_glow", "1")
  1853. cvar_survaura = register_cvar("zp_surv_aura", "1")
  1854. cvar_survpainfree = register_cvar("zp_surv_painfree", "1")
  1855. cvar_survweapon = register_cvar("zp_surv_weapon", "weapon_m249")
  1856. cvar_survivordmg = register_cvar("zp_surv_damage", "2.0")
  1857.  
  1858. // CVARS - Swarm Mode
  1859. cvar_swarm = register_cvar("zp_swarm_enabled", "1")
  1860. cvar_swarmchance = register_cvar("zp_swarm_chance", "20")
  1861. cvar_swarmminplayers = register_cvar("zp_swarm_min_players", "0")
  1862.  
  1863. // CVARS - Multi Infection
  1864. cvar_multi = register_cvar("zp_multi_enabled", "1")
  1865. cvar_multichance = register_cvar("zp_multi_chance", "20")
  1866. cvar_multiminplayers = register_cvar("zp_multi_min_players", "0")
  1867. cvar_multiratio = register_cvar("zp_multi_ratio", "0.15")
  1868.  
  1869. // CVARS - Plague Mode
  1870. cvar_plague = register_cvar("zp_plague_enabled", "1")
  1871. cvar_plaguechance = register_cvar("zp_plague_chance", "30")
  1872. cvar_plagueminplayers = register_cvar("zp_plague_min_players", "0")
  1873. cvar_plagueratio = register_cvar("zp_plague_ratio", "0.5")
  1874. cvar_plaguenemnum = register_cvar("zp_plague_nem_number", "1")
  1875. cvar_plaguenemhpmulti = register_cvar("zp_plague_nem_hp_multi", "0.5")
  1876. cvar_plaguesurvnum = register_cvar("zp_plague_surv_number", "1")
  1877. cvar_plaguesurvhpmulti = register_cvar("zp_plague_surv_hp_multi", "0.5")
  1878.  
  1879. // CVARS - Others
  1880. cvar_logcommands = register_cvar("zp_logcommands", "1")
  1881. cvar_showactivity = get_cvar_pointer("amx_show_activity")
  1882. cvar_botquota = get_cvar_pointer("bot_quota")
  1883. register_cvar("zp_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  1884. set_cvar_string("zp_version", PLUGIN_VERSION)
  1885. cvar_bubblepush = register_cvar("zp_bubble_push", "1.2")
  1886.  
  1887. // Custom Forwards
  1888. g_fwRoundStart = CreateMultiForward("zp_round_started", ET_IGNORE, FP_CELL, FP_CELL)
  1889. g_fwRoundEnd = CreateMultiForward("zp_round_ended", ET_IGNORE, FP_CELL)
  1890. g_fwUserInfected_pre = CreateMultiForward("zp_user_infected_pre", ET_IGNORE, FP_CELL, FP_CELL)
  1891. g_fwUserInfected_post = CreateMultiForward("zp_user_infected_post", ET_IGNORE, FP_CELL, FP_CELL)
  1892. g_fwUserHumanized_pre = CreateMultiForward("zp_user_humanized_pre", ET_IGNORE, FP_CELL)
  1893. g_fwUserHumanized_post = CreateMultiForward("zp_user_humanized_post", ET_IGNORE, FP_CELL)
  1894. g_fwExtraItemSelected = CreateMultiForward("zp_extra_item_selected", ET_IGNORE, FP_CELL, FP_CELL)
  1895.  
  1896. // Collect random spawn points
  1897. load_spawns()
  1898.  
  1899. #if !defined DONT_CHANGE_SKY
  1900. // Set a random skybox
  1901. set_cvar_string("sv_skyname", skynames[random_num(0, sizeof skynames - 1)])
  1902. #endif
  1903.  
  1904. // Disable sky lighting so it doesn't mess up our custom lighting
  1905. set_cvar_num("sv_skycolor_r", 0)
  1906. set_cvar_num("sv_skycolor_g", 0)
  1907. set_cvar_num("sv_skycolor_b", 0)
  1908.  
  1909. // Create the HUD Sync Objects
  1910. g_MsgSync = CreateHudSyncObj()
  1911. g_MsgSync2 = CreateHudSyncObj()
  1912.  
  1913. // Format mod name
  1914. formatex(g_modname, sizeof g_modname - 1, "Zombie Plague %s", PLUGIN_VERSION)
  1915.  
  1916. // Get Max Players
  1917. g_maxplayers = get_maxplayers()
  1918.  
  1919. // Reserved saving slots starts on maxplayers+1
  1920. db_slot_i = g_maxplayers+1
  1921.  
  1922. // Check if it's a CZ server
  1923. new mymod[6]
  1924. get_modname(mymod, sizeof mymod - 1)
  1925. if (equal(mymod, "czero")) g_czero = 1
  1926.  
  1927. // Lighting task
  1928. set_task(5.0, "lighting_effects", TASK_LIGHTING, _, _, "b")
  1929.  
  1930. // Call Round Start
  1931. set_task(1.0, "event_round_start")
  1932. }
  1933.  
  1934. public mysql_init()
  1935. g_hTuple = SQL_MakeDbTuple(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
  1936.  
  1937. public plugin_cfg()
  1938. {
  1939. // Get configs dir
  1940. new cfgdir[32]
  1941. get_configsdir(cfgdir, sizeof cfgdir - 1);
  1942.  
  1943. // Execute config file (zombieplague.cfg)
  1944. server_cmd("exec %s/zombieplague.cfg", cfgdir)
  1945. }
  1946.  
  1947. /*================================================================================
  1948. [Main Events]
  1949. =================================================================================*/
  1950.  
  1951. // Event Round Start
  1952. public event_round_start()
  1953. {
  1954. remove_entity_name("info_target")
  1955.  
  1956. // Remove any tasks bound to custom nades (since they're removed at roundstart)
  1957. remove_task(TASK_NADES)
  1958.  
  1959. // Remove doors/lights?
  1960. set_task(0.2, "remove_stuff")
  1961.  
  1962. // New round starting
  1963. g_newround = true
  1964. g_endround = false
  1965. g_survround = false
  1966. g_nemround = false
  1967. g_swarmround = false
  1968. g_plagueround = false
  1969. g_synapsisround = false
  1970. g_armageddonround = false
  1971. g_weskerround = false
  1972. g_terminatorround = false
  1973. g_depredadorround = false
  1974. g_assassinround = false
  1975. g_apocalypsisround = false
  1976. g_invasionround = false
  1977. g_revelacionround = false
  1978.  
  1979. // Reset bought infection bombs counter
  1980. g_infbombcounter = 0
  1981.  
  1982. // Freezetime begins
  1983. g_freezetime = true
  1984.  
  1985. // Show welcome message and T-Virus notice
  1986. remove_task(TASK_WELCOMEMSG)
  1987. set_task(2.0, "welcome_msg", TASK_WELCOMEMSG)
  1988.  
  1989. // Set a new "Make Zombie Task"
  1990. remove_task(TASK_MAKEZOMBIE)
  1991. set_task(2.0+random_float(get_pcvar_float(cvar_warmup), get_pcvar_float(cvar_warmup)+3.0), "make_zombie_task", TASK_MAKEZOMBIE)
  1992. }
  1993.  
  1994. // Log Event Round Start
  1995. public logevent_round_start()
  1996. {
  1997. // Freezetime ends
  1998. g_freezetime = false
  1999. }
  2000.  
  2001. // Log Event Round End
  2002. public logevent_round_end()
  2003. {
  2004. // Prevent this from getting called twice when restarting (bugfix)
  2005. static Float:lastendtime
  2006. if (get_gametime() - lastendtime < 0.5) return;
  2007. lastendtime = get_gametime()
  2008.  
  2009. // Temporarily save player stats?
  2010. if (get_pcvar_num(cvar_statssave))
  2011. {
  2012. static id, team
  2013. for (id = 1; id <= g_maxplayers; id++)
  2014. {
  2015. // Not connected
  2016. if (!is_user_connected(id))
  2017. continue;
  2018.  
  2019. team = fm_get_user_team(id)
  2020.  
  2021. // Not playing
  2022. if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
  2023. continue;
  2024.  
  2025. save_stats(id)
  2026. }
  2027. }
  2028.  
  2029. // Round ended
  2030. g_endround = true
  2031.  
  2032. // Stop old tasks (if any)
  2033. remove_task(TASK_WELCOMEMSG)
  2034. remove_task(TASK_MAKEZOMBIE)
  2035.  
  2036. #if defined AMBIENCE_SOUNDS
  2037. // Stop ambience sounds
  2038. remove_task(TASK_AMBIENCESOUNDS)
  2039. ambience_sound_stop()
  2040. #endif
  2041.  
  2042. // Balance the teams
  2043. set_task(0.1, "balance_teams")
  2044.  
  2045. // Show HUD notice, play win sound, update team scores...
  2046. if (!fnGetZombies())
  2047. {
  2048. // Human team wins
  2049. set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2050. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_HUMAN")
  2051.  
  2052. // Play win sound and increase score
  2053. PlaySound(sound_win_humans[random_num(0, sizeof sound_win_humans -1)])
  2054. g_scorehumans++
  2055.  
  2056. // Round end forward
  2057. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, 2);
  2058. }
  2059. else if (!fnGetHumans())
  2060. {
  2061. // Zombie team wins
  2062. set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2063. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_ZOMBIE")
  2064.  
  2065. // Play win sound and increase score
  2066. PlaySound(sound_win_zombies[random_num(0, sizeof sound_win_zombies -1)])
  2067. g_scorezombies++
  2068.  
  2069. // Round end forward
  2070. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, 1);
  2071. }
  2072. else
  2073. {
  2074. // No one wins
  2075. set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  2076. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "WIN_NO_ONE")
  2077. PlaySound(sound_win_no_one[random_num(0, sizeof sound_win_no_one -1)])
  2078.  
  2079. // Round end forward
  2080. ExecuteForward(g_fwRoundEnd, g_fwDummyResult, 0);
  2081. }
  2082. }
  2083.  
  2084. #if defined AMBIENCE_SOUNDS
  2085. // Event Map Ended
  2086. public event_intermission()
  2087. {
  2088. // Remove ambience sounds task
  2089. remove_task(TASK_AMBIENCESOUNDS)
  2090. }
  2091. #endif
  2092.  
  2093. // Current Weapon Event
  2094. public event_cur_weapon(id)
  2095. {
  2096. // Not alive
  2097. if (!is_user_alive(id))
  2098. return;
  2099.  
  2100. // Zombie not holding an allowed weapon for some reason
  2101. if (g_zombie[id] && !((1<<read_data(2)) & ZOMBIE_ALLOWED_WEAPONS_BITSUM))
  2102. {
  2103. // Switch to knife
  2104. engclient_cmd(id, "weapon_knife")
  2105.  
  2106. // Update the HUD and let other plugins know
  2107. emessage_begin(MSG_ONE, g_msgCurWeapon, _, id)
  2108. ewrite_byte(1) // active
  2109. ewrite_byte(CSW_KNIFE) // weapon
  2110. ewrite_byte(MAXCLIP[CSW_KNIFE]) // clip
  2111. emessage_end()
  2112. }
  2113. }
  2114.  
  2115. // Weapon Animation Event
  2116. public event_weapon_anim()
  2117. {
  2118. // Because of a weird bug within the AMXX event system, we need to
  2119. // hook this message to prevent some weird behavior when calling
  2120. // engclient_cmd(id, "weapon_knife") in the CurWeapon Event forward.
  2121. // http://forums.alliedmods.net/showthread.php?t=85161&page=2
  2122. }
  2123.  
  2124. /*================================================================================
  2125. [Main Forwards]
  2126. =================================================================================*/
  2127.  
  2128. // Client joins the game
  2129. public client_putinserver(id)
  2130. {
  2131. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  2132. replace_all(g_playername[id], charsmax(g_playername), "'", "")
  2133.  
  2134. // Plugin disabled?
  2135. if (!g_pluginenabled) return;
  2136.  
  2137. // Initialize player vars
  2138. reset_vars(id, 1)
  2139.  
  2140. // Load player stats?
  2141. if (get_pcvar_num(cvar_statssave)) load_stats(id)
  2142.  
  2143. // Set some tasks for humans only
  2144. if (!is_user_bot(id))
  2145. {
  2146. // Set the custom HUD display task
  2147. set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
  2148.  
  2149. // Disable minmodels for clients to see zombies properly
  2150. set_task(5.0, "disable_minmodels", id)
  2151. }
  2152. else
  2153. {
  2154. // CZ bots seem to use a different "classtype" for player entities
  2155. // (or something like that) which needs to be hooked separately
  2156. if (!g_hamczbots && cvar_botquota)
  2157. {
  2158. // Set a task to let the private data initialize
  2159. set_task(0.1, "register_ham_czbots", id)
  2160. }
  2161. }
  2162.  
  2163. if (is_user_admin(id))
  2164. {
  2165. count++
  2166. new name[33]
  2167. get_user_name(id, name, 32)
  2168. }
  2169.  
  2170. armar_variables(id)
  2171.  
  2172. set_task(1.0, "chequear_hora", id+TASK_SHOWHUD, _, _, "b")
  2173. }
  2174.  
  2175. public armar_variables(id)
  2176. {
  2177. g_nvg[id] = { 255, 0, 255 }
  2178. g_hud_pos[id][0] = 0.00
  2179. g_hud_pos[id][1] = 0.00
  2180. red[id] = 255
  2181. g_level[id] = 1
  2182. }
  2183.  
  2184. // Client disconnect
  2185. public client_disconnect(id)
  2186. {
  2187. if (is_user_admin(id))
  2188. {
  2189. count--
  2190. }
  2191. // Plugin disabled?
  2192. if (!g_pluginenabled) return;
  2193.  
  2194. // Check that we still have both humans and zombies to keep the round going
  2195. if (is_user_alive(id)) check_round(id)
  2196.  
  2197. // Temporarily save player stats?
  2198. if (get_pcvar_num(cvar_statssave)) save_stats(id)
  2199.  
  2200. // Remove previous tasks
  2201. remove_task(id+TASK_TEAM)
  2202. remove_task(id+TASK_MODEL)
  2203. remove_task(id+TASK_FLASH)
  2204. remove_task(id+TASK_CHARGE)
  2205. remove_task(id+TASK_SPAWN)
  2206. remove_task(id+TASK_BLOOD)
  2207. remove_task(id+TASK_NVISION)
  2208. remove_task(id+TASK_SHOWHUD)
  2209.  
  2210. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  2211. // Remove custom model entities
  2212. fm_remove_model_ents(id)
  2213. #endif
  2214.  
  2215. // Last Zombie Check
  2216. set_task(0.1, "fnCheckLastZombie")
  2217.  
  2218. Save(id)
  2219. }
  2220.  
  2221. // Entity Spawn Forward
  2222. public fw_Spawn(entity)
  2223. {
  2224. // Invalid entity
  2225. if (!pev_valid(entity)) return FMRES_IGNORED;
  2226.  
  2227. // Get classname
  2228. new classname[32]
  2229. pev(entity, pev_classname, classname, sizeof classname - 1)
  2230.  
  2231. // Check whether it needs to be removed
  2232. for (new i = 0; i < sizeof g_objective_ents; i++)
  2233. {
  2234. if (equal(classname, g_objective_ents[i]))
  2235. {
  2236. engfunc(EngFunc_RemoveEntity, entity)
  2237. return FMRES_SUPERCEDE;
  2238. }
  2239. }
  2240.  
  2241. return FMRES_IGNORED;
  2242. }
  2243.  
  2244. // Ham Player Spawn Post Forward
  2245. public fw_PlayerSpawn_Post(id)
  2246. {
  2247. if (g_reset[id] >= 4)
  2248. {
  2249. Set_Hat(id, pirate2)
  2250. }
  2251. else
  2252. {
  2253. switch (g_reset[id])
  2254. {
  2255. case 1: Set_Hat(id, scream)
  2256. case 2: Set_Hat(id, jason)
  2257. case 3: Set_Hat(id, viking)
  2258. }
  2259. }
  2260.  
  2261. Save(id)
  2262.  
  2263. // Not alive or didn't join a team yet
  2264. if (!is_user_alive(id) || !fm_get_user_team(id))
  2265. return;
  2266.  
  2267. // Remove previous tasks
  2268. remove_task(id+TASK_SPAWN)
  2269. remove_task(id+TASK_TEAM)
  2270. remove_task(id+TASK_MODEL)
  2271. remove_task(id+TASK_BLOOD)
  2272.  
  2273. // Spawn randomly?
  2274. if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
  2275.  
  2276. // Hide money?
  2277. if (get_pcvar_num(cvar_removemoney))
  2278. set_task(0.2, "task_hide_money", id+TASK_SPAWN)
  2279.  
  2280. // Respawn player if he dies because of a worldspawn kill?
  2281. if (get_pcvar_num(cvar_respawnworldspawnkill))
  2282. set_task(2.0, "respawn_player", id+TASK_SPAWN)
  2283.  
  2284. // Spawn as zombie?
  2285. if (g_respawn_as_zombie[id] && !g_newround)
  2286. {
  2287. reset_vars(id, 0)
  2288. zombieme(id, 0, 0, 0) // make him zombie right away
  2289. return;
  2290. }
  2291.  
  2292. // Reset player vars
  2293. reset_vars(id, 0)
  2294.  
  2295. // Show human class menu if they haven't chosen any (e.g. just connected)
  2296. if (g_humanclassnext[id] == HCLASS_NONE && get_pcvar_num(cvar_hclasses))
  2297. set_task(0.2, "show_menu_hclass", id)
  2298. else if (get_pcvar_num(cvar_buycustom))
  2299. set_task(0.2, "show_menu_buy1", id+TASK_SPAWN)
  2300.  
  2301. // Set selected human class
  2302. g_humanclass[id] = g_humanclassnext[id]
  2303.  
  2304. // If no class selected yet, use the first (default) one
  2305. if (g_humanclass[id] == HCLASS_NONE) g_humanclass[id] = 0
  2306.  
  2307. // Set health and gravity
  2308. fm_set_user_health(id, g_hclass_hp[g_humanclass[id]] + ammount_health(g_skill_points[id][0][1]))
  2309. set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] - ammount_gravity(g_skill_points[id][0][4]))
  2310. set_user_armor(id, g_hclass_armor[g_humanclass[id]] + ammount_armor(g_skill_points[id][0][3]))
  2311.  
  2312. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  2313.  
  2314. // Set the right model
  2315. if (get_pcvar_num(cvar_adminmodelshuman) && get_user_flags(id) & ACCESS_FLAG3)
  2316. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin[random_num(0, sizeof model_admin -1)])
  2317. else
  2318. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_hclass_model[g_humanclass[id]])
  2319.  
  2320. // Set model on player model entity
  2321. fm_set_playermodel_ent(id)
  2322.  
  2323. // Remove glow on player model entity
  2324. fm_set_rendering(g_ent_playermodel[id])
  2325.  
  2326. #else
  2327.  
  2328. // Set the right model, after checking that we don't already have it
  2329. static currentmodel[32], already_has_model, i, iRand
  2330. already_has_model = false
  2331.  
  2332. // Get current model and compare it with current one
  2333. fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
  2334.  
  2335. if (get_pcvar_num(cvar_adminmodelshuman) && get_user_flags(id) & ACCESS_FLAG3)
  2336. {
  2337. for (i = 0; i < sizeof model_admin; i++)
  2338. if (equal(model_admin[i], currentmodel)) already_has_model = true
  2339.  
  2340. if (!already_has_model)
  2341. {
  2342. iRand = random_num(0, sizeof model_admin -1)
  2343. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin[iRand])
  2344. #if defined SET_MODELINDEX_OFFSET
  2345. fm_set_user_model_index(id, g_modelindex_admin[iRand])
  2346. #endif
  2347. }
  2348. }
  2349. else
  2350. {
  2351. if (equal(g_hclass_model[g_humanclass[id]], currentmodel)) already_has_model = true;
  2352.  
  2353. if (!already_has_model)
  2354. {
  2355. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_hclass_model[g_humanclass[id]])
  2356. #if defined SET_MODELINDEX_OFFSET
  2357. fm_set_user_model_index(id, g_hclass_modelindex[g_humanclass[id]])
  2358. #endif
  2359. }
  2360. }
  2361.  
  2362. // Need to change the model?
  2363. if (!already_has_model)
  2364. {
  2365. // An additional delay is offset at round start
  2366. // since SVC_BAD is more likely to be triggered there
  2367. if (g_newround)
  2368. set_task(5.0*MODELCHANGE_DELAY, "fm_user_model_update", id+TASK_MODEL)
  2369. else
  2370. fm_user_model_update(id+TASK_MODEL)
  2371. }
  2372.  
  2373. // Remove glow
  2374. fm_set_rendering(id)
  2375.  
  2376. #endif
  2377.  
  2378. // Bots stuff
  2379. if (is_user_bot(id))
  2380. {
  2381. // Turn off NVG for bots
  2382. fm_set_bot_nvg(id, 0)
  2383.  
  2384. // Automatically buy extra items/weapons after first zombie is chosen
  2385. if (get_pcvar_num(cvar_extraitems))
  2386. {
  2387. if (g_newround) set_task(10.0+get_pcvar_float(cvar_warmup), "bot_buy_extras", id+TASK_SPAWN)
  2388. else set_task(10.0, "bot_buy_extras", id+TASK_SPAWN)
  2389. }
  2390. }
  2391.  
  2392. // Show custom buy menu?
  2393. if (get_pcvar_num(cvar_buycustom))
  2394. set_task(0.4, "show_menu_buy1", id+TASK_SPAWN)
  2395.  
  2396. // Get spawn protection time
  2397. static Float:sptime
  2398. sptime = get_pcvar_float(cvar_spawnprotection)
  2399.  
  2400. // Enable spawn protection for humans spawning mid-round
  2401. if (!g_newround && sptime > 0.0)
  2402. {
  2403. // Dont take any damage
  2404. g_nodamage[id] = true
  2405.  
  2406. // Make temporarily invisible
  2407. set_pev(id, pev_effects, pev(id, pev_effects) | EF_NODRAW)
  2408.  
  2409. // Set task to remove it
  2410. set_task(sptime, "remove_spawn_protection", id+TASK_SPAWN)
  2411. }
  2412.  
  2413. // Last Zombie Check
  2414. set_task(0.1, "fnCheckLastZombie")
  2415. }
  2416.  
  2417. // Ham Player Killed Forward
  2418. public fw_PlayerKilled(victim, attacker, shouldgib)
  2419. {
  2420. // Last Zombie Check
  2421. set_task(0.1, "fnCheckLastZombie")
  2422.  
  2423. // Enable dead players nightvision
  2424. set_task(0.2, "spec_nvision", victim)
  2425.  
  2426. // Get nightvision give setting
  2427. static nvggive
  2428. nvggive = get_pcvar_num(cvar_nvggive)
  2429.  
  2430. // Disable nightvision when killed (bugfix)
  2431. if (nvggive == 0 && g_nvision[victim])
  2432. {
  2433. if (g_nvisionenabled[victim] && !get_pcvar_num(cvar_cnvg)) set_user_gnvision(victim, 0)
  2434. g_nvision[victim] = false
  2435. g_nvisionenabled[victim] = false
  2436. }
  2437.  
  2438. // Turn off nightvision when killed (bugfix)
  2439. if (nvggive == 2 && g_nvision[victim] && g_nvisionenabled[victim])
  2440. {
  2441. if (!get_pcvar_num(cvar_cnvg)) set_user_gnvision(victim, 0)
  2442. g_nvisionenabled[victim] = false
  2443. }
  2444.  
  2445. // Stop bleeding/burning when killed
  2446. if (g_zombie[victim])
  2447. {
  2448. g_kills[attacker]++
  2449. remove_task(victim+TASK_BLOOD)
  2450. }
  2451. if (g_nemesis[victim] || g_survivor[victim])
  2452. SetHamParamInteger(3, 2)
  2453.  
  2454. // Get deathmatch mode status and whether the player killed himself
  2455. static deathmatch, selfkill
  2456. deathmatch = get_pcvar_num(cvar_deathmatch)
  2457. selfkill = (victim == attacker || !is_user_connected(attacker)) ? true : false
  2458.  
  2459. // Respawn if deathmatch is enabled
  2460. if (deathmatch)
  2461. {
  2462. // Respawn on suicide?
  2463. if (selfkill && !get_pcvar_num(cvar_respawnonsuicide))
  2464. return;
  2465.  
  2466. // Respawn if only the last human is left?
  2467. if (!get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() == 1)
  2468. return;
  2469.  
  2470. // Respawn as zombie?
  2471. if (deathmatch == 2 || (deathmatch == 3 && random_num(0, 1)) || (deathmatch == 4 && fnGetZombies() < fnGetAlive()/2))
  2472. g_respawn_as_zombie[victim] = true
  2473.  
  2474. // Set the respawn task
  2475. set_task(get_pcvar_float(cvar_spawndelay), "respawn_player", victim+TASK_SPAWN)
  2476. }
  2477.  
  2478. if (g_nemesis[victim] && !g_assassin[victim] && !g_depredador[victim])
  2479. {
  2480. if (is_user_admin(attacker))
  2481. {
  2482. g_skill_points_type[attacker][0] += 5
  2483. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 5 puntos humanos")
  2484. }
  2485. else
  2486. {
  2487. g_skill_points_type[attacker][0] += 2
  2488. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 2 puntos humanos")
  2489. }
  2490. }
  2491. else if (g_nemesis[victim] && g_depredador[victim] && !g_assassin[victim])
  2492. {
  2493. if (is_user_admin(attacker))
  2494. {
  2495. g_skill_points_type[attacker][0] += 10
  2496. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 10 puntos humanos")
  2497. }
  2498. else
  2499. {
  2500. g_skill_points_type[attacker][0] += 5
  2501. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 5 puntos humanos")
  2502. }
  2503. }
  2504. else if (g_nemesis[victim] && !g_depredador[victim] && g_assassin[victim])
  2505. {
  2506. if (is_user_admin(attacker))
  2507. {
  2508. g_skill_points_type[attacker][0] += 8
  2509. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 8 puntos humanos")
  2510. }
  2511. else
  2512. {
  2513. g_skill_points_type[attacker][0] += 4
  2514. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 4 puntos humanos")
  2515. }
  2516. }
  2517.  
  2518. if (g_survivor[victim] && !g_terminator[victim] && !g_wesker[victim])
  2519. {
  2520. if (is_user_admin(attacker))
  2521. {
  2522. g_skill_points_type[attacker][1] += 5
  2523. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 5 puntos zombies")
  2524. }
  2525. else
  2526. {
  2527. g_skill_points_type[attacker][1] += 2
  2528. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 2 puntos zombies")
  2529. }
  2530. }
  2531. else if (g_terminator[victim] && g_survivor[victim])
  2532. {
  2533. if (is_user_admin(attacker))
  2534. {
  2535. g_skill_points_type[attacker][1] += 10
  2536. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 10 puntos zombies")
  2537. }
  2538. else
  2539. {
  2540. g_skill_points_type[attacker][1] += 5
  2541. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 5 puntos zombies")
  2542. }
  2543. }
  2544. else if (g_survivor[victim] && g_wesker[victim])
  2545. {
  2546. if (is_user_admin(attacker))
  2547. {
  2548. g_skill_points_type[attacker][1] += 8
  2549. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 8 puntos zombies")
  2550. }
  2551. else
  2552. {
  2553. g_skill_points_type[attacker][1] += 4
  2554. zp_colored_print(attacker, "^x04[ZP]^x01 Ganaste 4 puntos zombies")
  2555. }
  2556. }
  2557.  
  2558. // Killed by a non-player entity or self killed
  2559. if (selfkill) return;
  2560.  
  2561.  
  2562. // Zombie/nemesis killed human, reward ammo packs
  2563. update_ap(attacker, get_pcvar_num(cvar_ammoinfect))
  2564.  
  2565. // Get frag rewards for humans and zombies
  2566. static fragskill, fragsinfect
  2567. fragskill = get_pcvar_num(cvar_fragskill)
  2568. fragsinfect = get_pcvar_num(cvar_fragsinfect)
  2569.  
  2570. // Human killed zombie, add up the extra frags for kill
  2571. if (!g_zombie[attacker] && fragskill > 1)
  2572. UpdateFrags(attacker, victim, fragskill-1, 0, 0)
  2573.  
  2574. // Zombie killed human, add up the extra frags for kill
  2575. if (g_zombie[attacker] && fragsinfect > 1)
  2576. UpdateFrags(attacker, victim, fragsinfect-1, 0, 0)
  2577. }
  2578.  
  2579. public fw_IsMoving(id)
  2580. {
  2581. client_print(id, print_center ,"Te estas moviendo")
  2582. }
  2583.  
  2584.  
  2585. // Ham Take Damage Forward (inflictor = weapon)
  2586. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  2587. {
  2588. // Non-player damage or self damage
  2589. if (victim == attacker || !is_user_connected(attacker))
  2590. return HAM_IGNORED;
  2591.  
  2592. // New round starting or round ended
  2593. if (g_newround || g_endround)
  2594. return HAM_SUPERCEDE;
  2595.  
  2596. // Victim shouldn't take damage or victim is frozen
  2597. if (g_nodamage[victim])
  2598. return HAM_SUPERCEDE;
  2599.  
  2600. // Prevent friendly fire
  2601. if (g_zombie[attacker] == g_zombie[victim])
  2602. return HAM_SUPERCEDE;
  2603.  
  2604. // Attacker is human...
  2605. if (!g_zombie[attacker])
  2606. {
  2607. if (!g_survivor[attacker])
  2608. {
  2609. damage *= g_hclass_dmg[g_humanclass[attacker]] * reset_damage(g_reset[attacker]) * ammount_damage(g_skill_points[attacker][0][0] )
  2610. SetHamParamFloat(4, damage)
  2611. }
  2612.  
  2613. // Armor multiplier for the final damage on normal zombies
  2614. if (!g_nemesis[victim])
  2615. {
  2616. damage *= get_pcvar_float(cvar_zombiearmor)
  2617. SetHamParamFloat(4, damage)
  2618. }
  2619.  
  2620. if (g_wesker[attacker] && g_survivor[attacker] && !g_terminator[attacker])
  2621. {
  2622. damage *= get_pcvar_float(cvar_weskerdmg)
  2623. SetHamParamFloat(4, damage * get_pcvar_float(cvar_weskerdmg))
  2624. }
  2625.  
  2626. if (g_terminator[attacker] && g_survivor[attacker] && !g_wesker[attacker])
  2627. {
  2628. damage *= get_pcvar_float(cvar_terminatordmg)
  2629. SetHamParamFloat(4, damage * get_pcvar_float(cvar_terminatordmg))
  2630. }
  2631.  
  2632. if (g_survivor[attacker] && !g_wesker[attacker] && !g_terminator[attacker])
  2633. {
  2634. damage *= get_pcvar_float(cvar_survivordmg)
  2635. SetHamParamFloat(4, damage)
  2636. }
  2637. if (get_user_weapon(attacker) == CSW_M4A1)
  2638. {
  2639. if (g_colt[attacker])
  2640. {
  2641. damage *= 7
  2642. }
  2643. else
  2644. {
  2645. damage *= 1
  2646. }
  2647. SetHamParamFloat(4, damage)
  2648. }
  2649.  
  2650. // Store damage dealt
  2651. g_damagedealt[attacker] += floatround(damage)
  2652.  
  2653. // Get damage required to get an ammo pack
  2654. static ammodamage
  2655. ammodamage = get_pcvar_num(cvar_ammodamage)
  2656.  
  2657. // Reward ammo packs for every [ammo damage] dealt
  2658. while (g_damagedealt[attacker] >= ammodamage)
  2659. {
  2660. if (is_user_admin(attacker))
  2661. {
  2662. update_ap(attacker, 1500)
  2663. g_damagedealt[attacker] -= ammodamage
  2664. }
  2665. else
  2666. {
  2667. update_ap(attacker, 1)
  2668. g_damagedealt[attacker] -= ammodamage
  2669. }
  2670. }
  2671.  
  2672. return HAM_IGNORED;
  2673. }
  2674.  
  2675. // Attacker is zombie...
  2676.  
  2677. // Prevent infection by HE grenade (bugfix)
  2678. if (damage_type & DMG_HEGRENADE)
  2679. return HAM_SUPERCEDE;
  2680.  
  2681. // Nemesis?
  2682. if (g_nemesis[attacker])
  2683. {
  2684. if (g_depredador[attacker])
  2685. {
  2686. // Set depredador damage
  2687. SetHamParamFloat(4, damage * 12)
  2688. return HAM_IGNORED;
  2689. }
  2690. else if (g_assassin[attacker])
  2691. {
  2692. if (g_assassinround)
  2693. {
  2694. SetHamParamFloat(4, damage * 90)
  2695. return HAM_IGNORED;
  2696. }
  2697. else
  2698. {
  2699. SetHamParamFloat(4, damage * 13)
  2700. return HAM_IGNORED;
  2701. }
  2702. }
  2703. else
  2704. {
  2705. // Set nemesis damage
  2706. SetHamParamFloat(4, damage * 9)
  2707. return HAM_IGNORED;
  2708. }
  2709. }
  2710.  
  2711. // Last human or swarm round or plague round
  2712. if (g_swarmround || g_plagueround || fnGetHumans() == 1 || g_survround)
  2713. return HAM_IGNORED; // human is killed
  2714.  
  2715. // Does human armor need to be reduced before infecting?
  2716. if (get_pcvar_num(cvar_humanarmor))
  2717. {
  2718. // Get victim armor
  2719. static Float:armor
  2720. pev(victim, pev_armorvalue, armor)
  2721.  
  2722. // Block the attack if he has some
  2723. if (armor > 0.0)
  2724. {
  2725. engfunc(EngFunc_EmitSound, victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
  2726.  
  2727. if (!g_zombie[attacker])
  2728. {
  2729. set_pev(victim, pev_armorvalue, - floatmax(0.0, armor - damage/ammount_resistence(g_skill_points[attacker][0][5])))
  2730. return HAM_SUPERCEDE;
  2731.  
  2732. }
  2733. else
  2734. {
  2735. set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage+ammount_zdamage(g_skill_points[attacker][1][0])))
  2736. return HAM_SUPERCEDE;
  2737. }
  2738.  
  2739. }
  2740. }
  2741.  
  2742. // Infection allowed
  2743. SendDeathMsg(attacker, victim) // send death notice
  2744. FixDeadAttrib(victim) // fix the "dead" attrib on scoreboard
  2745. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect), 1, 1) // add corresponding frags and deaths
  2746.  
  2747. zombieme(victim, attacker, 0, 0) // turn into zombie
  2748.  
  2749. g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect) // ammo packs given to zombie for infection
  2750. fm_set_user_health(attacker, pev(attacker, pev_health)+get_pcvar_num(cvar_zombiebonushp)) // attacker gets bonus HP for the infection
  2751.  
  2752. return HAM_SUPERCEDE;
  2753. }
  2754.  
  2755. // Ham Trace Attack Forward
  2756. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  2757. {
  2758. // Non-player damage or self damage
  2759. if (victim == attacker || !is_user_connected(attacker))
  2760. return HAM_IGNORED;
  2761.  
  2762. // New round starting or round ended
  2763. if (g_newround || g_endround)
  2764. return HAM_SUPERCEDE;
  2765.  
  2766. // Victim shouldn't take damage or victim is frozen
  2767. if (g_nodamage[victim])
  2768. return HAM_SUPERCEDE;
  2769.  
  2770. // Prevent friendly fire
  2771. if (g_zombie[attacker] == g_zombie[victim])
  2772. return HAM_SUPERCEDE;
  2773.  
  2774. // Victim isn't a normal zombie
  2775. if (!g_zombie[victim] || g_nemesis[victim])
  2776. return HAM_IGNORED;
  2777.  
  2778. // Get custom hitzones setting
  2779. static hitzones
  2780. hitzones = get_pcvar_num(cvar_hitzones)
  2781.  
  2782. // Check if we hit an allowed one
  2783. if (hitzones && !(hitzones & (1<<get_tr2(tracehandle, TR_iHitgroup))))
  2784. return HAM_SUPERCEDE;
  2785.  
  2786. // Knockback disabled or not bullet damage
  2787. if (!(damage_type & DMG_BULLET) || !get_pcvar_num(cvar_knockback))
  2788. return HAM_IGNORED;
  2789.  
  2790. // Get victim flags and knockback while ducking setting
  2791. static victimflags, Float:knockduck
  2792. victimflags = pev(victim, pev_flags)
  2793. knockduck = get_pcvar_float(cvar_knockbackducking)
  2794.  
  2795. // Zombie is ducking on ground
  2796. if (knockduck == 0.0 && (victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
  2797. return HAM_IGNORED;
  2798.  
  2799. // Get distance between players
  2800. static Float:origin1F[3], Float:origin2F[3]
  2801. pev(victim, pev_origin, origin1F)
  2802. pev(attacker, pev_origin, origin2F)
  2803.  
  2804. // Max distance exceeded
  2805. if (get_distance_f(origin1F, origin2F) > get_pcvar_float(cvar_knockbackdist))
  2806. return HAM_IGNORED;
  2807.  
  2808. // Get victim's velocity
  2809. static Float:velocity[3]
  2810. pev(victim, pev_velocity, velocity)
  2811.  
  2812. // Use damage on knockback calculation
  2813. if (get_pcvar_num(cvar_knockbackdamage))
  2814. xs_vec_mul_scalar(direction, damage, direction)
  2815.  
  2816. // Use weapon power on knockback calculation
  2817. if (kb_weapon_power[g_currentweapon[attacker]] > 0.0 && get_pcvar_num(cvar_knockbackpower))
  2818. xs_vec_mul_scalar(direction, kb_weapon_power[g_currentweapon[attacker]], direction)
  2819.  
  2820. // Apply ducking knockback multiplier
  2821. if ((victimflags & FL_DUCKING) && (victimflags & FL_ONGROUND))
  2822. xs_vec_mul_scalar(direction, knockduck, direction)
  2823.  
  2824. // Apply zombie class knockback multiplier
  2825. xs_vec_mul_scalar(direction, g_zclass_kb[g_zombieclass[victim]], direction)
  2826.  
  2827. // Add up the new vector
  2828. xs_vec_add(velocity, direction, direction)
  2829.  
  2830. // Should knockback also affect vertical velocity?
  2831. if (!get_pcvar_num(cvar_knockbackzvel))
  2832. direction[2] = velocity[2]
  2833.  
  2834. // Set the knockback'd victim's velocity
  2835. set_pev(victim, pev_velocity, direction)
  2836.  
  2837. return HAM_IGNORED;
  2838. }
  2839.  
  2840. // Ham Use Stationary Gun Forward
  2841. public fw_UseStationary(entity, caller, activator, use_type)
  2842. {
  2843. // Not a player
  2844. if (!is_user_connected(caller))
  2845. return HAM_IGNORED;
  2846.  
  2847. // Prevent zombies from using stationary guns
  2848. if (use_type == USE_USING && g_zombie[caller])
  2849. return HAM_SUPERCEDE;
  2850.  
  2851. // Someone stopped using a stationary gun
  2852. if (use_type == USE_STOPPED)
  2853. set_task(0.1, "replace_models", caller) // replace weapon models (bugfix)
  2854.  
  2855. return HAM_IGNORED;
  2856. }
  2857.  
  2858. // Ham Use Pushable Forward
  2859. public fw_UsePushable()
  2860. {
  2861. // Prevent speed bug with pushables?
  2862. if (get_pcvar_num(cvar_blockpushables))
  2863. return HAM_SUPERCEDE;
  2864.  
  2865. return HAM_IGNORED;
  2866. }
  2867.  
  2868. // Ham Weapon Touch Forward
  2869. public fw_TouchWeapon(weapon, id)
  2870. {
  2871. // Not a player
  2872. if (!is_user_connected(id))
  2873. return HAM_IGNORED;
  2874.  
  2875. // Dont pickup weapons if zombie or survivor (+PODBot MM fix)
  2876. if (g_zombie[id] || (g_survivor[id] && !is_user_bot(id)))
  2877. return HAM_SUPERCEDE;
  2878.  
  2879. return HAM_IGNORED;
  2880. }
  2881.  
  2882. // Ham Weapon Pickup Forward
  2883. public fw_AddPlayerItem(id, weapon_ent)
  2884. {
  2885. // Retrieve our custom extra ammo from the weapon
  2886. static extra_ammo
  2887. extra_ammo = pev(weapon_ent, PEV_ADDITIONAL_AMMO)
  2888.  
  2889. // If present, add to player's bpammo (dont exceed max capacity though)
  2890. if (extra_ammo)
  2891. {
  2892. static wname[32], weapon
  2893. pev(weapon_ent, pev_classname, wname, sizeof wname - 1)
  2894. weapon = get_weaponid(wname)
  2895.  
  2896. fm_set_user_bpammo(id, weapon, min(fm_get_user_bpammo(id, weapon)+extra_ammo, MAXBPAMMO[weapon]))
  2897. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, 0)
  2898. }
  2899. }
  2900.  
  2901. // Client Kill Forward
  2902. public fw_ClientKill()
  2903. {
  2904. // Prevent players from killing themselves?
  2905. if (get_pcvar_num(cvar_blocksuicide))
  2906. return FMRES_SUPERCEDE;
  2907.  
  2908. return FMRES_IGNORED;
  2909. }
  2910.  
  2911. // Emit Sound Forward
  2912. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  2913. {
  2914. // Replace these sounds for zombies only
  2915. if (!is_user_connected(id) || !g_zombie[id])
  2916. return FMRES_IGNORED;
  2917.  
  2918. // Zombie being hit
  2919. if (equal(sample[7], "bhit", 4))
  2920. {
  2921. if (g_nemesis[id])
  2922. engfunc(EngFunc_EmitSound, id, channel, nemesis_pain[random_num(0, sizeof nemesis_pain - 1)], volume, attn, flags, pitch)
  2923. else
  2924. engfunc(EngFunc_EmitSound, id, channel, zombie_pain[random_num(0, sizeof zombie_pain - 1)], volume, attn, flags, pitch)
  2925. return FMRES_SUPERCEDE;
  2926. }
  2927.  
  2928. // Zombie attacks with knife
  2929. if (equal(sample[8], "kni", 3))
  2930. {
  2931. if (equal(sample[14], "sla", 3)) // slash
  2932. {
  2933. engfunc(EngFunc_EmitSound, id, channel, zombie_miss_slash[random_num(0, sizeof zombie_miss_slash - 1)], volume, attn, flags, pitch)
  2934. return FMRES_SUPERCEDE;
  2935. }
  2936. if (equal(sample[14], "hit", 3))
  2937. {
  2938. if (sample[17] == 'w') // wall
  2939. {
  2940. engfunc(EngFunc_EmitSound, id, channel, zombie_miss_wall[random_num(0, sizeof zombie_miss_wall - 1)], volume, attn, flags, pitch)
  2941. return FMRES_SUPERCEDE;
  2942. }
  2943. else // hit
  2944. {
  2945. engfunc(EngFunc_EmitSound, id, channel, zombie_hit_normal[random_num(0, sizeof zombie_hit_normal - 1)], volume, attn, flags, pitch)
  2946. return FMRES_SUPERCEDE;
  2947. }
  2948. }
  2949. if (equal(sample[14], "sta", 3)) // stab
  2950. {
  2951. engfunc(EngFunc_EmitSound, id, channel, zombie_hit_stab[random_num(0, sizeof zombie_hit_stab - 1)], volume, attn, flags, pitch)
  2952. return FMRES_SUPERCEDE;
  2953. }
  2954. }
  2955.  
  2956. // Zombie dies
  2957. if (equal(sample[7], "die", 3) || equal(sample[7], "dea", 3))
  2958. {
  2959. engfunc(EngFunc_EmitSound, id, channel, zombie_die[random_num(0, sizeof zombie_die - 1)], volume, attn, flags, pitch)
  2960. return FMRES_SUPERCEDE;
  2961. }
  2962.  
  2963. // Zombie falls off
  2964. if (equal(sample[10], "fall", 4))
  2965. {
  2966. engfunc(EngFunc_EmitSound, id, channel, zombie_fall[random_num(0, sizeof zombie_fall - 1)], volume, attn, flags, pitch)
  2967. return FMRES_SUPERCEDE;
  2968. }
  2969.  
  2970. return FMRES_IGNORED;
  2971. }
  2972.  
  2973. #if !defined HANDLE_MODELS_ON_SEPARATE_ENT
  2974. // Forward Set ClientKey Value -prevent CS from changing player models-
  2975. public fw_SetClientKeyValue(id, const infobuffer[], const key[])
  2976. {
  2977. // Block CS model changes
  2978. if (equal(key, "model"))
  2979. return FMRES_SUPERCEDE;
  2980.  
  2981. return FMRES_IGNORED;
  2982. }
  2983.  
  2984. // Forward Client User Info Changed -prevent players from changing models-
  2985. public fw_ClientUserInfoChanged(id)
  2986. {
  2987. // Get current model
  2988. static currentmodel[32]
  2989. fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
  2990.  
  2991. // If they're different, set model again
  2992. if (!equal(currentmodel, g_playermodel[id]) && !task_exists(id+TASK_MODEL))
  2993. fm_set_user_model(id+TASK_MODEL)
  2994.  
  2995. new OldName[33], NewName[33]
  2996.  
  2997. pev(id, pev_netname, OldName, charsmax(OldName))
  2998.  
  2999. if (OldName[0])
  3000. {
  3001. get_user_info(id, "name", NewName, charsmax(NewName))
  3002.  
  3003. if (!equal(OldName, NewName))
  3004. {
  3005. if(!g_login[id])
  3006. {
  3007. SetUserName(id, NewName)
  3008. return FMRES_IGNORED;
  3009. }
  3010. else
  3011. {
  3012. return FMRES_IGNORED;
  3013. }
  3014. }
  3015. }
  3016.  
  3017. return FMRES_HANDLED;
  3018. }
  3019. #endif
  3020.  
  3021. // Forward Get Game Description
  3022. public fw_GetGameDescription()
  3023. {
  3024. // Return the mod name so it can be easily identified
  3025. forward_return(FMV_STRING, g_modname)
  3026.  
  3027. return FMRES_SUPERCEDE;
  3028. }
  3029.  
  3030. // Forward CmdStart
  3031. public fw_CmdStart(id, handle)
  3032. {
  3033. // Check if it's a flashlight impulse
  3034. if (get_uc(handle, UC_Impulse) != IMPULSE_FLASHLIGHT)
  3035. return;
  3036.  
  3037. // Not alive
  3038. if (!is_user_alive(id))
  3039. return;
  3040.  
  3041. // Block it for zombies, survivor (and override it for humans when custom flashlight is on)
  3042. if (g_zombie[id] || g_survivor[id])
  3043. {
  3044. // Human's custom flashlight should be turned on instead
  3045. if (!g_zombie[id] && !g_survivor[id] && get_gametime() - g_lastflashtime[id] > 1.1)
  3046. {
  3047. // Prevent turning the flashlight on/off too quickly (bugfix)
  3048. g_lastflashtime[id] = get_gametime()
  3049.  
  3050. // Turn custom flashlight on/off
  3051. g_flashlight[id] = !(g_flashlight[id])
  3052.  
  3053. // Set the flashlight charge task
  3054. remove_task(id+TASK_CHARGE)
  3055. set_task(1.0, "flashlight_charge", id+TASK_CHARGE, _, _, "b")
  3056.  
  3057. // Update flashlight status on the HUD
  3058. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  3059. write_byte(g_flashlight[id]) // toggle
  3060. write_byte(g_flashbattery[id]) // battery
  3061. message_end()
  3062.  
  3063. // Turn off original flashlight if active
  3064. set_pev(id, pev_effects, pev(id, pev_effects) & ~EF_DIMLIGHT)
  3065.  
  3066. // Play flashlight toggle sound
  3067. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_flashlight, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3068.  
  3069. // Finally call our custom flashlight task
  3070. remove_task(id+TASK_FLASH)
  3071. set_task(0.1, "set_user_flashlight", id+TASK_FLASH, _, _, "b")
  3072. }
  3073.  
  3074. // Block the impulse
  3075. set_uc(handle, UC_Impulse, 0)
  3076. }
  3077. }
  3078.  
  3079. // Forward Set Model
  3080. public fw_SetModel(entity, const model[])
  3081. {
  3082. // Get entity's classname
  3083. static class[10]
  3084. pev(entity, pev_classname, class, sizeof class - 1)
  3085.  
  3086. // Check if it's a weapon box
  3087. if (equal(class, "weaponbox"))
  3088. {
  3089. // They get automatically removed when thinking
  3090. set_pev(entity, pev_nextthink, get_gametime() + 3)
  3091. return;
  3092. }
  3093.  
  3094. // Get damage time of grenade
  3095. static Float:dmgtime
  3096. pev(entity, pev_dmgtime, dmgtime)
  3097.  
  3098. // Grenade not yet thrown
  3099. if (dmgtime == 0.0)
  3100. return;
  3101.  
  3102. if (equal(model[7], "w_he", 4))
  3103. {
  3104. if (g_zombie[pev(entity, pev_owner)]) // [ZOMBIE] - Infection Grenade
  3105. {
  3106. // Give it a glow
  3107. fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  3108.  
  3109. // And a colored trail
  3110. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3111. write_byte(TE_BEAMFOLLOW) // TE id
  3112. write_short(entity) // entity
  3113. write_short(g_trailSpr) // sprite
  3114. write_byte(10) // life
  3115. write_byte(10) // width
  3116. write_byte(0) // r
  3117. write_byte(200) // g
  3118. write_byte(0) // b
  3119. write_byte(200) // brightness
  3120. message_end()
  3121.  
  3122. // Set grenade type on the thrown grenade entity
  3123. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  3124. }
  3125. else if (get_pcvar_num(cvar_firegrenades)) // [HUMAN] - Fire Grenade
  3126. {
  3127. // Give it a glow
  3128. fm_set_rendering(entity, kRenderFxGlowShell, 200, 0, 0, kRenderNormal, 16);
  3129.  
  3130. // And a colored trail
  3131. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3132. write_byte(TE_BEAMFOLLOW) // TE id
  3133. write_short(entity) // entity
  3134. write_short(g_trailSpr) // sprite
  3135. write_byte(10) // life
  3136. write_byte(10) // width
  3137. write_byte(200) // r
  3138. write_byte(0) // g
  3139. write_byte(0) // b
  3140. write_byte(200) // brightness
  3141. message_end()
  3142.  
  3143. // Set grenade type on the thrown grenade entity
  3144. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
  3145. }
  3146. else
  3147. {
  3148. // Give it a glow
  3149. fm_set_rendering(entity, kRenderFxGlowShell, 200, 0, 0, kRenderNormal, 16);
  3150.  
  3151. // And a colored trail
  3152. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3153. write_byte(TE_BEAMFOLLOW) // TE id
  3154. write_short(entity) // entity
  3155. write_short(g_trailSpr) // sprite
  3156. write_byte(10) // life
  3157. write_byte(10) // width
  3158. write_byte(200) // r
  3159. write_byte(0) // g
  3160. write_byte(0) // b
  3161. write_byte(200) // brightness
  3162. message_end()
  3163.  
  3164. // Set grenade type on the thrown grenade entity
  3165. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_NAPALM)
  3166. }
  3167. }
  3168. else if (equal(model[7], "w_fl", 4) && get_pcvar_num(cvar_frostgrenades)) // Frost Grenade
  3169. {
  3170. // Give it a glow
  3171. fm_set_rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
  3172.  
  3173. // And a colored trail
  3174. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3175. write_byte(TE_BEAMFOLLOW) // TE id
  3176. write_short(entity) // entity
  3177. write_short(g_trailSpr) // sprite
  3178. write_byte(10) // life
  3179. write_byte(10) // width
  3180. write_byte(0) // r
  3181. write_byte(100) // g
  3182. write_byte(200) // b
  3183. write_byte(200) // brightness
  3184. message_end()
  3185.  
  3186. // Set grenade type on the thrown grenade entity
  3187. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FROST)
  3188. }
  3189. else if (equal(model[7], "w_sm", 4) && get_pcvar_num(cvar_flaregrenades)) // Flare
  3190. {
  3191. static id; id = pev( entity, pev_owner )
  3192.  
  3193. // Give it a glow
  3194. fm_set_rendering(entity, kRenderFxGlowShell, g_flare_color[id][0], g_flare_color[id][1], g_flare_color[id][2], kRenderNormal, 1);
  3195.  
  3196. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3197. write_byte(TE_BEAMFOLLOW) // TE id
  3198. write_short(entity) // entity
  3199. write_short(g_trailSpr) // sprite
  3200. write_byte(10) // life
  3201. write_byte(10) // width
  3202. write_byte(g_flare_color[id][0]) // r
  3203. write_byte(g_flare_color[id][1]) // g
  3204. write_byte(g_flare_color[id][2]) // b
  3205. write_byte(200) // brightness
  3206. message_end()
  3207.  
  3208. // Set grenade type on the thrown grenade entity
  3209. set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE)
  3210.  
  3211. // Set flare color on the thrown grenade entity
  3212. for (new i = 0; i < 3; i++)
  3213. set_pev(entity, PEV_FLARE_COLOR, g_flare_color[id][i])
  3214. }
  3215. }
  3216.  
  3217. // Ham Grenade Think Forward
  3218. public fw_ThinkGrenade(entity)
  3219. {
  3220. // Invalid entity
  3221. if (!pev_valid(entity)) return FMRES_IGNORED;
  3222.  
  3223. // Get damage time of grenade
  3224. static Float:dmgtime
  3225. pev(entity, pev_dmgtime, dmgtime)
  3226.  
  3227. // Check if it's time to go off
  3228. if (dmgtime > get_gametime())
  3229. return HAM_IGNORED;
  3230.  
  3231. // Check if it's one of our custom nades
  3232. switch (pev(entity, PEV_NADE_TYPE))
  3233. {
  3234. case NADE_TYPE_INFECTION: // Infection Bomb
  3235. {
  3236. infection_explode(entity)
  3237. }
  3238. case NADE_TYPE_NAPALM: // Napalm Grenade
  3239. {
  3240. fire_explode(entity)
  3241. }
  3242. case NADE_TYPE_FROST: // Frost Grenade
  3243. {
  3244. frost_explode(entity)
  3245. }
  3246. case NADE_TYPE_FLARE: // Flare
  3247. {
  3248. // Light up when it's stopped on ground
  3249. if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10)
  3250. {
  3251. // Flare sound
  3252. engfunc(EngFunc_EmitSound, entity, CHAN_WEAPON, grenade_flare[random_num(0, sizeof grenade_flare - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  3253.  
  3254. // Our task params
  3255. static params[5]
  3256. params[0] = entity // entity id
  3257. params[1] = get_pcvar_num(cvar_flareduration)/5 // duration
  3258.  
  3259. // Retrieve flare color from entity
  3260. pev(entity, PEV_FLARE_COLOR, params[2]) // params[2] r - params[3] g - params[4] b
  3261.  
  3262. // Call our lighting task
  3263. set_task(0.1, "flare_lighting", TASK_NADES, params, sizeof params)
  3264.  
  3265. bubble_explode(entity)
  3266. }
  3267. else
  3268. {
  3269. // Delay the explosion until we hit ground
  3270. set_pev(entity, pev_dmgtime, get_gametime() + 0.5)
  3271. return HAM_IGNORED;
  3272. }
  3273. }
  3274. default: return HAM_IGNORED;
  3275. }
  3276.  
  3277. return HAM_SUPERCEDE;
  3278. }
  3279.  
  3280. // Forward Player PreThink
  3281. public fw_PlayerPreThink(id)
  3282. {
  3283. // Not alive
  3284. if (!is_user_alive(id))
  3285. return;
  3286.  
  3287. // Silent footsteps for zombies?
  3288. if (g_zombie[id] && !g_nemesis[id] && get_pcvar_num(cvar_zombiesilent))
  3289. set_pev(id, pev_flTimeStepSound, STEPTIME_SILENT)
  3290.  
  3291. if (g_nemesis[id] && g_assassin[id])
  3292. set_pev(id, pev_flTimeStepSound, STEPTIME_SILENT)
  3293.  
  3294. // Set Player MaxSpeed
  3295. if (g_frozen[id])
  3296. {
  3297. set_pev(id, pev_velocity, Float:{0.0,0.0,0.0}) // stop motion
  3298. set_pev(id, pev_maxspeed, 1.0) // prevent from moving
  3299. }
  3300. else if (!g_freezetime)
  3301. {
  3302. if (g_zombie[id])
  3303. {
  3304. if (g_nemesis[id] && !g_depredador[id] && !g_assassin[id])
  3305. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_nemspd))
  3306. else if (g_depredador[id] && g_nemesis[id])
  3307. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_depredadorspd))
  3308. else if (g_assassin[id] && g_nemesis[id])
  3309. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_assassinspd))
  3310. else
  3311. set_pev(id, pev_maxspeed, float(g_zclass_spd[g_zombieclass[id]]) + ammount_zspeed(g_skill_points[id][1][2]))
  3312. }
  3313. else
  3314. {
  3315. if (g_survivor[id] && !g_wesker[id])
  3316. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_survspd))
  3317. else if (g_wesker[id] && g_survivor[id])
  3318. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_weskerspd))
  3319. else if (g_terminator[id] && g_survivor[id])
  3320. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_terminatorspd))
  3321. else
  3322. set_pev(id, pev_maxspeed, float(g_hclass_spd[g_humanclass[id]]) + ammount_speed(g_skill_points[id][0][2]))
  3323. }
  3324. }
  3325.  
  3326.  
  3327. // Should Leap?
  3328. if (allowed_leap(id))
  3329. {
  3330. // Get force and height cvars
  3331. static force, height, Float:velocity[3]
  3332. force = g_survivor[id] ? get_pcvar_num(cvar_leapsurvivorforce) : g_nemesis[id] ? get_pcvar_num(cvar_leapnemesisforce) : get_pcvar_num(cvar_leapzombiesforce)
  3333. height = g_survivor[id] ? get_pcvar_num(cvar_leapsurvivorheight) : g_nemesis[id] ? get_pcvar_num(cvar_leapnemesisheight) : get_pcvar_num(cvar_leapzombiesheight)
  3334.  
  3335. // Make velocity vector
  3336. velocity_by_aim(id, force, velocity)
  3337.  
  3338. // Set custom height
  3339. velocity[2] = float(height)
  3340.  
  3341. // Apply the new velocity
  3342. set_pev(id, pev_velocity, velocity)
  3343.  
  3344. // Set the current leap time
  3345. g_lastleaptime[id] = get_gametime()
  3346. }
  3347.  
  3348. // Should be Pain Shock Free?
  3349. if (allowed_painshockfree(id))
  3350. {
  3351. // Remember his velocity
  3352. pev(id, pev_velocity, g_velocity[id])
  3353. g_restorevel[id] = true
  3354. }
  3355. }
  3356.  
  3357. // Forward Player PreThink Post
  3358. public fw_PlayerPreThink_Post(id)
  3359. {
  3360. // Pain Shock Free: need to restore velocity?
  3361. if (!g_restorevel[id])
  3362. return FMRES_IGNORED;
  3363.  
  3364. g_restorevel[id] = false
  3365.  
  3366. // Not alive
  3367. if (!is_user_alive(id))
  3368. return FMRES_IGNORED;
  3369.  
  3370. // Driving a vehicle
  3371. if (pev(id, pev_flags) & FL_ONTRAIN)
  3372. return FMRES_IGNORED;
  3373.  
  3374. // NOTE: within DLL PlayerPreThink Jump() function is called;
  3375. // there is a conveyor velocity addiction we should care of
  3376. static groundent
  3377. groundent = pev(id, pev_groundentity)
  3378.  
  3379. if (pev_valid(groundent) && (pev(groundent, pev_flags) & FL_CONVEYOR))
  3380. {
  3381. // Add pev_basevelocity to our stored velocity
  3382. static Float:tempvel[3]
  3383. pev(id, pev_basevelocity, tempvel)
  3384. xs_vec_add(g_velocity[id], tempvel, g_velocity[id])
  3385. }
  3386.  
  3387. // Restore previous velocity
  3388. set_pev(id, pev_velocity, g_velocity[id])
  3389. return FMRES_HANDLED;
  3390. }
  3391.  
  3392. /*================================================================================
  3393. [Client Commands]
  3394. =================================================================================*/
  3395. public clcmd_admins(id)
  3396. {
  3397. if (is_user_admin(id))
  3398. {
  3399. new name[33]
  3400. get_user_name(id, name, 32)
  3401.  
  3402. if (count > 0)
  3403. {
  3404. zp_colored_print(id, "^x04 ADMINS ONLINE: %s ^x01", name)
  3405. }
  3406. else if (count == 0)
  3407. {
  3408. zp_colored_print(id, "^x04 NO ADMINS ONLINE ^x01")
  3409. }
  3410. }
  3411. }
  3412.  
  3413. // Say "/zpmenu"
  3414. public clcmd_saymenu(id)
  3415. {
  3416. show_menu_game(id) // show game menu
  3417. }
  3418.  
  3419. // Say "/unstuck"
  3420. public clcmd_sayunstuck(id)
  3421. {
  3422. menu_game(id, 3) // try to get unstuck
  3423. }
  3424.  
  3425. // Nightvision toggle
  3426. public clcmd_nightvision(id)
  3427. {
  3428. if (g_nvision[id])
  3429. {
  3430. // Enable-disable
  3431. g_nvisionenabled[id] = !(g_nvisionenabled[id])
  3432.  
  3433. // Custom nvg?
  3434. if (get_pcvar_num(cvar_cnvg))
  3435. {
  3436. remove_task(id+TASK_NVISION);
  3437. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  3438. }
  3439. else
  3440. set_user_gnvision(id, g_nvisionenabled[id])
  3441. }
  3442.  
  3443. return PLUGIN_HANDLED;
  3444. }
  3445.  
  3446. // Weapon Drop
  3447. public clcmd_drop(id)
  3448. {
  3449. // Survivor should stick with M249
  3450. if (g_survivor[id])
  3451. return PLUGIN_HANDLED;
  3452.  
  3453. return PLUGIN_CONTINUE;
  3454. }
  3455.  
  3456. // Buy BP Ammo
  3457. public clcmd_buyammo(id)
  3458. {
  3459. // Not alive or infinite ammo setting enabled
  3460. if (get_pcvar_num(cvar_infammo) || !is_user_alive(id))
  3461. return PLUGIN_HANDLED;
  3462.  
  3463. // Not human
  3464. if (g_zombie[id])
  3465. {
  3466. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_HUMAN_ONLY")
  3467. return PLUGIN_HANDLED;
  3468. }
  3469.  
  3470. // Not enough ammo packs
  3471. if (g_ammopacks[id] < 1)
  3472. {
  3473. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  3474. return PLUGIN_HANDLED;
  3475. }
  3476.  
  3477. // Get user weapons
  3478. static weapons[32], num, i, currentammo, weaponid, refilled
  3479. num = 0 // reset passed weapons count (bugfix)
  3480. refilled = false
  3481. get_user_weapons(id, weapons, num)
  3482.  
  3483. // Loop through them and give the right ammo type
  3484. for (i = 0; i < num; i++)
  3485. {
  3486. // Prevents re-indexing the array
  3487. weaponid = weapons[i]
  3488.  
  3489. // Primary and secondary only
  3490. if (MAXBPAMMO[weaponid] > 2)
  3491. {
  3492. // Get current ammo of the weapon
  3493. currentammo = fm_get_user_bpammo(id, weaponid)
  3494.  
  3495. // Check if we are close to the BP ammo limit
  3496. if (currentammo < MAXBPAMMO[weaponid]-BUYAMMO[weaponid])
  3497. {
  3498. // Flash ammo in hud
  3499. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  3500. write_byte(AMMOID[weaponid]) // ammo id
  3501. write_byte(BUYAMMO[weaponid]) // ammo amount
  3502. message_end()
  3503.  
  3504. // Increase BP ammo
  3505. fm_set_user_bpammo(id, weaponid, currentammo + BUYAMMO[weaponid])
  3506.  
  3507. refilled = true
  3508. }
  3509. else if (currentammo < MAXBPAMMO[weaponid])
  3510. {
  3511. // Flash ammo in hud
  3512. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  3513. write_byte(AMMOID[weaponid]) // ammo id
  3514. write_byte(MAXBPAMMO[weaponid]-currentammo) // ammo amount
  3515. message_end()
  3516.  
  3517. // Reached the limit
  3518. fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
  3519.  
  3520. refilled = true
  3521. }
  3522. }
  3523. }
  3524.  
  3525. // Weapons already have full ammo
  3526. if (!refilled) return PLUGIN_HANDLED;
  3527.  
  3528. // Deduce ammo packs, play clip purchase sound, and notify the player
  3529. update_ap(id, -1)
  3530. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3531. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "AMMO_BOUGHT")
  3532.  
  3533. return PLUGIN_HANDLED;
  3534. }
  3535.  
  3536.  
  3537. // Block Team Change
  3538. public clcmd_changeteam(id)
  3539. {
  3540. static team
  3541. team = fm_get_user_team(id)
  3542.  
  3543. // Unless it's a spectator joining the game
  3544. if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
  3545. return PLUGIN_CONTINUE;
  3546.  
  3547. // Pressing 'M' (chooseteam) ingame should show the main menu instead
  3548. show_menu_game(id)
  3549. return PLUGIN_HANDLED;
  3550. }
  3551.  
  3552. /*================================================================================
  3553. [Menus]
  3554. =================================================================================*/
  3555.  
  3556. // Game Menu
  3557. show_menu_game(id)
  3558. {
  3559. static menu[250], len
  3560. len = 0
  3561.  
  3562. // Title
  3563. len += formatex(menu[len], sizeof menu - 1 - len, "\y%s^n^n", g_modname)
  3564.  
  3565. // 1. Buy weapons
  3566. if (get_pcvar_num(cvar_buycustom))
  3567. len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\w %L^n", id, "MENU_BUY")
  3568. else
  3569. len += formatex(menu[len], sizeof menu - 1 - len, "\d1. %L^n", id, "MENU_BUY")
  3570.  
  3571. // 2. Extra items
  3572. if (!g_survivor[id] && !g_nemesis[id] && get_pcvar_num(cvar_extraitems) && is_user_alive(id))
  3573. len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\w %L^n", id, "MENU_EXTRABUY")
  3574. else
  3575. len += formatex(menu[len], sizeof menu - 1 - len, "\d2. %L^n", id, "MENU_EXTRABUY")
  3576.  
  3577. // 3. Zombie class || Human class
  3578. if (g_zombie[id])
  3579. len += formatex(menu[len], sizeof menu - 1 - len, "\r3.\w %L^n", id,"MENU_ZCLASS")
  3580. else
  3581. len += formatex(menu[len], sizeof menu - 1 - len, "\r3. %L^n", id,"MENU_HCLASS")
  3582.  
  3583. // 4. Upgrade Menu
  3584. len += formatex(menu[len], sizeof menu - 1 - len, "\r4. %L^n", id,"MENU_MEJORAS")
  3585.  
  3586. // 5. Unstuck
  3587. if (is_user_alive(id))
  3588. len += formatex(menu[len], sizeof menu - 1 - len, "\r5.\w %L^n", id, "MENU_UNSTUCK")
  3589. else
  3590. len += formatex(menu[len], sizeof menu - 1 - len, "\d5. %L^n", id, "MENU_UNSTUCK")
  3591.  
  3592. // 6. Config Menu
  3593. len += formatex(menu[len], sizeof menu - 1 - len, "\r6. %L^n^n", id,"MENU_CONFIG")
  3594.  
  3595. // 7. Estadistics Menu
  3596. len += formatex(menu[len], sizeof menu - 1 - len, "\r7. %L^n^n", id,"MENU_ESTADISTICS")
  3597.  
  3598. // 9. Admin menu
  3599. if (get_user_flags(id) & ACCESS_FLAG)
  3600. len += formatex(menu[len], sizeof menu - 1 - len, "\r9.\w %L", id, "MENU_ADMIN")
  3601. else
  3602. len += formatex(menu[len], sizeof menu - 1 - len, "\d9. %L", id, "MENU_ADMIN")
  3603.  
  3604. // 0. Exit
  3605. len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  3606.  
  3607. show_menu(id, KEYSMENU, menu, -1, "Game Menu")
  3608. }
  3609.  
  3610. // Buy Menu 1
  3611. public show_menu_buy1(taskid)
  3612. {
  3613. // Get player id
  3614. static id
  3615. (taskid > g_maxplayers) ? (id = ID_SPAWN) : (id = taskid);
  3616.  
  3617. // Zombies or survivors get no guns
  3618. if (g_zombie[id] || g_survivor[id] || !is_user_alive(id))
  3619. return;
  3620.  
  3621. // Bots pick their weapons randomly
  3622. if (is_user_bot(id))
  3623. {
  3624. buy_primary_weapon(id, random_num(0, sizeof g_primary_items - 1))
  3625. menu_buy2(id, random_num(0, sizeof g_secondary_items - 1))
  3626. menu_buy3(id, random_num(0, sizeof g_terciary_items - 1))
  3627. return;
  3628. }
  3629.  
  3630. // Automatic selection enabled for player and menu called on spawn event
  3631. if (WPN_AUTO_ON && taskid > g_maxplayers)
  3632. {
  3633. buy_primary_weapon(id, WPN_AUTO_PRI)
  3634. menu_buy2(id, WPN_AUTO_SEC)
  3635. menu_buy3(id, WPN_AUTO_TER)
  3636.  
  3637. return ;
  3638. }
  3639.  
  3640. static menu[400], len, weap
  3641. len = 0
  3642.  
  3643. // Title
  3644. len += formatex(menu[len], sizeof menu - 1 - len, "\y%L \r[%d-%d]^n^n", id, "MENU_BUY1_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
  3645.  
  3646. // 1-7. Weapon List
  3647. for (weap = WPN_STARTID; weap < min(WPN_STARTID+7, WPN_MAXIDS); weap++)
  3648. {
  3649. if(g_level[id] >= g_levelprimary[weap])
  3650. {
  3651. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", weap-WPN_STARTID+1, g_primary_names[weap], g_levelprimary[weap])
  3652. }
  3653. else
  3654. {
  3655. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s (\rMin Level \w%d\d)^n", weap-WPN_STARTID+1, g_primary_names[weap], g_levelprimary[weap])
  3656. }
  3657. }
  3658.  
  3659. // 8. Auto Select
  3660. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  3661.  
  3662. // 9. Next/Back - 0. Exit
  3663. len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r9.\w %L/%L^n^n\r0.\w %L", id, "MENU_NEXT", id, "MENU_BACK", id, "MENU_EXIT")
  3664.  
  3665. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 1")
  3666. }
  3667.  
  3668. // Buy Menu 2
  3669. show_menu_buy2(id)
  3670. {
  3671. static menu[350], len, weap
  3672. len = 0
  3673.  
  3674. // Title
  3675. len += formatex(menu[len], sizeof menu - 1 - len, "\y%L^n", id, "MENU_BUY2_TITLE")
  3676.  
  3677. // 1-6. Weapon List
  3678. for (weap = 0; weap < sizeof g_secondary_items; weap++)
  3679. {
  3680. if(g_level[id] >= g_levelsecondary[weap])
  3681. {
  3682. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r%d.\w %s", weap+1, g_secondary_names[weap], g_levelsecondary[weap])
  3683. }
  3684. else
  3685. {
  3686. len += formatex(menu[len], sizeof menu - 1 - len, "^n\d%d. %s (\rMin Level \w%d\d)", weap+1, g_secondary_names[weap], g_levelsecondary[weap])
  3687. }
  3688. }
  3689.  
  3690. // 8. Auto Select
  3691. len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  3692.  
  3693. // 0. Exit
  3694. len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  3695.  
  3696. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 2")
  3697. }
  3698. // Buy Menu 3
  3699. show_menu_buy3(id)
  3700. {
  3701. if(WPN_AUTO_TER > 0 && WPN_AUTO_ON == 1)
  3702. return;
  3703.  
  3704. static menu[512], len, i, j, bomb_level
  3705. len = 0
  3706.  
  3707. // Title
  3708. len += formatex(menu[len], charsmax(menu) - len, "\yMenu de Granadas^n^n", id)
  3709.  
  3710. // 1-4. Bombs List
  3711. for (j = 0; j < 4; j++)
  3712. {
  3713. bomb_level = g_bomb_level[j]
  3714.  
  3715. if(g_level[id] < bomb_level)
  3716. {
  3717. for(i = 0; i < 3; i++)
  3718. {
  3719. if (i != 1)
  3720. {
  3721. len += formatex(menu[len], charsmax(menu) - len, " \y|\d %d %s^n", BOMBAMMOUNT[j][i], BOMBNAMES[j][i])
  3722. }
  3723. else
  3724. {
  3725. len += formatex(menu[len], charsmax(menu) - len, "\r%d.\y|\d %d %s (\rMin Lvl \w%d\d)^n", j+1, BOMBAMMOUNT[j][i], BOMBNAMES[j][i], bomb_level)
  3726. }
  3727. }
  3728. }
  3729. else
  3730. {
  3731. for(i = 0; i < 3; i++)
  3732. {
  3733. if (i != 1)
  3734. {
  3735. len += formatex(menu[len], charsmax(menu) - len, " \y|\w %d %s^n", BOMBAMMOUNT[j][i], BOMBNAMES[j][i])
  3736. }
  3737. else
  3738. {
  3739. len += formatex(menu[len], charsmax(menu) - len, "\r%d.\r|\w %d %s \d(\yMin Lvl \w%d\d)^n",j+1, BOMBAMMOUNT[j][i], BOMBNAMES[j][i], bomb_level)
  3740. }
  3741. }
  3742. }
  3743.  
  3744. len += formatex(menu[len], charsmax(menu) - len, "^n")
  3745. }
  3746.  
  3747. // 8. Auto Select
  3748. 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")
  3749.  
  3750. // 0. Exit
  3751. len += formatex(menu[len], charsmax(menu) - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
  3752.  
  3753. show_menu(id, KEYSMENU, menu, -1, "Buy Menu 3")
  3754. }
  3755.  
  3756. // Extra Items Menu
  3757. show_menu_extras(id)
  3758. {
  3759. static menu[400], len, item
  3760. len = 0
  3761.  
  3762. // Title
  3763. len += formatex(menu[len], sizeof menu - 1 - len, "\y%L [%L] \r[%d-%d]^n^n", id, "MENU_EXTRA_TITLE", id, (g_zombie[id]) ? "CLASS_ZOMBIE" : "CLASS_HUMAN", EXTRAS_STARTID+1, min(EXTRAS_STARTID+7, g_extraitem_i))
  3764.  
  3765. // 1-7. Item List
  3766. for (item = EXTRAS_STARTID; item < min(EXTRAS_STARTID+7, g_extraitem_i); item++)
  3767. {
  3768. // Unavailable item
  3769. if ((g_zombie[id] && g_extraitem_team[item] == ZP_TEAM_HUMAN) || (!g_zombie[id] && g_extraitem_team[item] == ZP_TEAM_ZOMBIE) || (item == EXTRA_NVISION && !get_pcvar_num(cvar_extranvision)) || (item == EXTRA_ANTIDOTE && !get_pcvar_num(cvar_extraantidote)) || (item == EXTRA_MADNESS && !get_pcvar_num(cvar_extramadness))
  3770. || (item == EXTRA_INFBOMB && (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit))) || (item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)) || g_assassinround)
  3771. {
  3772. // Check if it's one of the hardcoded items and set the correct caption
  3773. switch (item)
  3774. {
  3775. case EXTRA_NVISION: len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA1")
  3776. case EXTRA_ANTIDOTE: len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA2")
  3777. case EXTRA_MADNESS: len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA3")
  3778. case EXTRA_INFBOMB: len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA4")
  3779. default: len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s", item-EXTRAS_STARTID+1, g_extraitem_name[item])
  3780. }
  3781. // Item Cost
  3782. len += formatex(menu[len], sizeof menu - 1 - len, " %d %L^n", g_extraitem_cost[item], id, "AMMO_PACKS2")
  3783. }
  3784. else
  3785. {
  3786. // Check if it's one of the hardcoded items and set the correct caption
  3787. switch (item)
  3788. {
  3789. case EXTRA_NVISION: len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA1")
  3790. case EXTRA_ANTIDOTE: len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA2")
  3791. case EXTRA_MADNESS: len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA3")
  3792. case EXTRA_INFBOMB: len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %L", item-EXTRAS_STARTID+1, id, "MENU_EXTRA4")
  3793. default: len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s", item-EXTRAS_STARTID+1, g_extraitem_name[item])
  3794. }
  3795. // Item Cost
  3796. len += formatex(menu[len], sizeof menu - 1 - len, " \y%d %L^n", g_extraitem_cost[item], id, "AMMO_PACKS2")
  3797. }
  3798. }
  3799.  
  3800. // 8. Back - 9. Next - 0. Exit
  3801. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L", id, "MENU_BACK", id, "MENU_NEXT", id, "MENU_EXIT")
  3802.  
  3803. show_menu(id, KEYSMENU, menu, -1, "Extra Items")
  3804. }
  3805.  
  3806. // Zombie Class Menu
  3807. public show_menu_zclass(id)
  3808. {
  3809. // Player disconnected
  3810. if (!is_user_connected(id))
  3811. return;
  3812.  
  3813. // Bots pick their zombie class randomly
  3814. if (is_user_bot(id))
  3815. {
  3816. g_zombieclassnext[id] = random_num(0, g_zclass_i - 1)
  3817. return;
  3818. }
  3819.  
  3820. static menu[400], len, class
  3821. len = 0
  3822.  
  3823. // Title
  3824. len += formatex(menu[len], sizeof menu - 1 - len, "\y%L \r[%d-%d]^n^n", id, "MENU_ZCLASS_TITLE", ZCLASSES_STARTID+1, min(ZCLASSES_STARTID+7, g_zclass_i))
  3825.  
  3826. // 1-7. Class List
  3827. for (class = ZCLASSES_STARTID; class < min(ZCLASSES_STARTID+7, g_zclass_i); class++)
  3828. {
  3829. if (class == g_zombieclassnext[id])
  3830. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s ^n", class-ZCLASSES_STARTID+1, g_zclass_name[class], g_zclass_info[class])
  3831. else
  3832. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s\y ^n", class-ZCLASSES_STARTID+1, g_zclass_name[class], g_zclass_info[class])
  3833. }
  3834.  
  3835. // 8. Back - 9. Next - 0. Exit
  3836. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L", id, "MENU_BACK", id, "MENU_NEXT", id, "MENU_EXIT")
  3837.  
  3838. show_menu(id, KEYSMENU, menu, -1, "Zombie Class Menu")
  3839. }
  3840.  
  3841. // Human Class Menu
  3842. public show_menu_hclass(id)
  3843. {
  3844. // Player disconnected
  3845. if (!is_user_connected(id))
  3846. return;
  3847.  
  3848. // Bots pick their human class randomly
  3849. if (is_user_bot(id))
  3850. {
  3851. g_humanclassnext[id] = random_num(0, g_hclass_i - 1)
  3852. return;
  3853. }
  3854.  
  3855. static menu[400], len, class
  3856. len = 0
  3857.  
  3858. // Title
  3859. len += formatex(menu[len], sizeof menu - 1 - len, "\y%L \r[%d-%d]^n^n", id, "MENU_HCLASS_TITLE", HCLASSES_STARTID+1, min(HCLASSES_STARTID+7, g_hclass_i))
  3860.  
  3861. // 1-7. Class List
  3862. for (class = HCLASSES_STARTID; class < min(HCLASSES_STARTID+7, g_hclass_i); class++)
  3863. {
  3864. if (g_level[id] >= g_hclass_lvl[class])
  3865. {
  3866. if (class == g_humanclassnext[id])
  3867. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s %s^n", class-HCLASSES_STARTID+1, g_hclass_name[class], g_hclass_info[class])
  3868. else
  3869. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s\y %s^n", class-HCLASSES_STARTID+1, g_hclass_name[class], g_hclass_info[class])
  3870. }
  3871. else
  3872. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s %s(\rMin Level \w%d\d)^n", class-HCLASSES_STARTID+1, g_hclass_name[class], g_hclass_info[class], g_hclass_lvl[class])
  3873. }
  3874.  
  3875. // 8. Back - 9. Next - 0. Exit
  3876. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L", id, "MENU_BACK", id, "MENU_NEXT", id, "MENU_EXIT")
  3877.  
  3878. show_menu(id, KEYSMENU, menu, -1, "Human Class Menu")
  3879. }
  3880.  
  3881. // Help Menu
  3882. public show_menu_info(id)
  3883. {
  3884. // Player disconnected
  3885. if (!is_user_connected(id))
  3886. return;
  3887.  
  3888. static menu[150]
  3889.  
  3890. formatex(menu, sizeof menu - 1, "\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")
  3891. show_menu(id, KEYSMENU, menu, -1, "Mod Info")
  3892. }
  3893.  
  3894. // Admin Menu
  3895. show_menu_admin(id)
  3896. {
  3897. static admin3[50]
  3898.  
  3899. if (get_user_flags(id) & ADMIN_LEVEL_A)
  3900. {
  3901. formatex(admin3, charsmax(admin3), "x5", id)
  3902. }
  3903. else if (get_user_flags(id) & ADMIN_LEVEL_B)
  3904. {
  3905. formatex(admin3, charsmax(admin3), "x4", id)
  3906. }
  3907. else if (get_user_flags(id) & ADMIN_LEVEL_C)
  3908. {
  3909. formatex(admin3, charsmax(admin3), "x3", id)
  3910. }
  3911. else if (get_user_flags(id) & ADMIN_LEVEL_D)
  3912. {
  3913. formatex(admin3, charsmax(admin3), "x2", id)
  3914. }
  3915.  
  3916. static menu, menu1[150]
  3917. formatex(menu1, 149, "\yAdmin Menu^n^n\wAdmin \y%s^n\wIniciar Modo:^n^n", admin3)
  3918. menu = menu_create(menu1, "menu_admin")
  3919.  
  3920. // 1. Zombiefy/Humanize command
  3921. if (!g_endround && !g_swarmround && !g_nemround && !g_survround && !g_plagueround && !task_exists(TASK_WELCOMEMSG) && !g_synapsisround && !g_armageddonround)
  3922. menu_additem(menu, "\yHacer Zombie o Humano a alguien", "1")
  3923. else
  3924. menu_additem(menu, "\dHacer Zombie o Humano a alguien","1")
  3925.  
  3926. // 2. Nemesis command
  3927. if (g_newround && !g_endround && get_pcvar_num(cvar_nem) && !task_exists(TASK_WELCOMEMSG))
  3928. menu_additem(menu, "\yNemesis", "2")
  3929. else
  3930. {
  3931. if (g_nemround && !g_depredadorround && !g_assassinround)
  3932. menu_additem(menu, "\yNemesis \w[\rCurrent Mod\w]", "2")
  3933. else
  3934. menu_additem(menu, "\dNemesis", "2")
  3935. }
  3936.  
  3937. // 3. Survivor command
  3938. if (g_newround && !g_endround && get_pcvar_num(cvar_surv) && !task_exists(TASK_WELCOMEMSG))
  3939. menu_additem(menu, "\ySurvivor", "3")
  3940. else
  3941. {
  3942. if (g_survround && !g_terminatorround && !g_weskerround)
  3943. menu_additem(menu, "\ySurvivor \w[\rCurrent Mod\w]", "3")
  3944. else
  3945. menu_additem(menu, "\dSurvivor", "3")
  3946. }
  3947.  
  3948. // 4. Respawn command
  3949. if (!g_endround && !g_survround && !g_swarmround && !g_nemround && !g_plagueround && !g_synapsisround)
  3950. menu_additem(menu, "\yRevivir a alguien", "4")
  3951. else
  3952. menu_additem(menu, "\dRevivir a alguien", "4")
  3953.  
  3954. // 5. Wesker command
  3955. if (g_newround && !g_endround && get_pcvar_num(cvar_wesker) && !task_exists(TASK_WELCOMEMSG))
  3956. menu_additem(menu, "\yWesker", "5")
  3957. else
  3958. {
  3959. if (g_weskerround)
  3960. menu_additem(menu, "\yWesker \w[\rCurrent Mod\w]", "5")
  3961. else
  3962. menu_additem(menu, "\dWesker", "5")
  3963. }
  3964.  
  3965. // 6. Terminator command
  3966. if (g_newround && !g_endround && get_pcvar_num(cvar_wesker) && !task_exists(TASK_WELCOMEMSG))
  3967. menu_additem(menu, "\yTerminator", "6")
  3968. else
  3969. {
  3970. if (g_terminatorround)
  3971. menu_additem(menu, "\yTerminator \w[\rCurrent Mod\w]", "6")
  3972. else
  3973. menu_additem(menu, "\dTerminator", "6")
  3974. }
  3975.  
  3976. // 7. Assassin Command command
  3977. if (g_newround && !g_endround && get_pcvar_num(cvar_assassin) && !task_exists(TASK_WELCOMEMSG))
  3978. menu_additem(menu, "\yAssassin", "7")
  3979. else
  3980. {
  3981. if (g_assassinround)
  3982. menu_additem(menu, "\yAssassin \w[\rCurrent Mod\w]", "7")
  3983. else
  3984. menu_additem(menu, "\dAssassin", "7")
  3985. }
  3986.  
  3987. // 8. Swarm mode command
  3988. if (allowed_swarm())
  3989. menu_additem(menu, "\ySwarm", "8")
  3990. else
  3991. {
  3992. if (g_swarmround)
  3993. menu_additem(menu, "\ySwarm \w[\rCurrent Mod\w]", "8")
  3994. else
  3995. menu_additem(menu, "\dSwarm", "8")
  3996. }
  3997.  
  3998. // 9. Multi infection command
  3999. if (allowed_multi())
  4000. menu_additem(menu, "\yMultiple Infeccion", "9")
  4001. else
  4002. {
  4003. if (g_lastmode == MODE_MULTI)
  4004. menu_additem(menu, "\yMultiple Infeccion \w[\rCurrent Mod\w]", "9")
  4005. else
  4006. menu_additem(menu, "\dMultiple Infeccion", "9")
  4007. }
  4008.  
  4009. // 10. Plague mode command
  4010. if (allowed_plague())
  4011. menu_additem(menu, "\yPlague", "10")
  4012. else
  4013. {
  4014. if (!g_synapsisround && g_plagueround && !g_armageddonround && !g_invasionround)
  4015. menu_additem(menu, "\yPlague \w[\rCurrent Mod\w]", "10")
  4016. else
  4017. menu_additem(menu, "\dPlague", "10")
  4018. }
  4019.  
  4020. // 11. Synapsis
  4021. if (allowed_swarm())
  4022. menu_additem(menu, "\ySynapsis", "11")
  4023. else
  4024. {
  4025. if (g_synapsisround && g_plagueround)
  4026. menu_additem(menu, "\ySynapsis \w[\rCurrent Mod\w]", "11")
  4027. else
  4028. menu_additem(menu, "\dSynapsis", "11")
  4029. }
  4030. // 12. Armageddon
  4031. if (allowed_swarm())
  4032. menu_additem(menu, "\yArmageddon", "12")
  4033. else
  4034. {
  4035. if (g_armageddonround && g_plagueround)
  4036. menu_additem(menu, "\yArmageddon \w[\rCurrent Mod\w]", "12")
  4037. else
  4038. menu_additem(menu, "\dArmageddon", "12")
  4039. }
  4040. // 13. Depredador
  4041. if (allowed_nemesis(id))
  4042. menu_additem(menu, "\yDepredador", "13")
  4043. else
  4044. {
  4045. if (g_depredadorround)
  4046. menu_additem(menu, "\yDepredador \w[\rCurrent Mod\w]", "13")
  4047. else
  4048. menu_additem(menu, "\dDepredador", "13")
  4049. }
  4050. // 14. Apocalypsis
  4051. if (allowed_nemesis(id))
  4052. menu_additem(menu, "\yApocalypsis", "14")
  4053. else
  4054. {
  4055. if (g_apocalypsisround && g_plagueround)
  4056. menu_additem(menu, "\yApocalypsis \w[\rCurrent Mod\w]", "14")
  4057. else
  4058. menu_additem(menu, "\dApocalypsis", "14")
  4059. }
  4060. // 15. Invasion
  4061. if (allowed_nemesis(id))
  4062. menu_additem(menu, "\yInvasion", "15")
  4063. else
  4064. {
  4065. if (g_invasionround && g_plagueround)
  4066. menu_additem(menu, "\yInvasion \w[\rCurrent Mod\w]", "15")
  4067. else
  4068. menu_additem(menu, "\dInvasion", "15")
  4069. }
  4070.  
  4071. menu_setprop(menu,MPROP_EXITNAME,"\y Salir")
  4072. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  4073. menu_display(id, menu, 0)
  4074. return PLUGIN_HANDLED
  4075. }
  4076.  
  4077. // Player List Menu
  4078. show_menu_player_list(id)
  4079. {
  4080. static menu[400], len, player, name[32]
  4081. len = 0
  4082.  
  4083. // Title
  4084. switch (PL_ACTION)
  4085. {
  4086. case 0: len += formatex(menu[len], sizeof menu - 1 - len, "\yHacer Zombie/Humano")
  4087. case 1: len += formatex(menu[len], sizeof menu - 1 - len, "\yHacer Nemesis ")
  4088. case 2: len += formatex(menu[len], sizeof menu - 1 - len, "\yHacer Survivor ")
  4089. case 3: len += formatex(menu[len], sizeof menu - 1 - len, "\yRevivir a Alguien")
  4090. case 4: len += formatex(menu[len], sizeof menu - 1 - len, "\yHacer Wesker ")
  4091. case 6: len += formatex(menu[len], sizeof menu - 1 - len, "\yHacer Assassin ")
  4092. }
  4093. len += formatex(menu[len], sizeof menu - 1 - len, "\r[%d-%d]^n^n", PL_STARTID+1, min(PL_STARTID+7, g_maxplayers))
  4094.  
  4095. // 1-7. player list
  4096. for (player = PL_STARTID+1; player <= min(PL_STARTID+7, g_maxplayers); player++)
  4097. {
  4098. if (is_user_connected(player)) // check if it's connected
  4099. {
  4100. // Get player's name
  4101. get_user_name(player, name, sizeof name - 1)
  4102.  
  4103. // Format text depending on the action to take
  4104. switch (PL_ACTION)
  4105. {
  4106. case 0:
  4107. {
  4108. if (g_zombie[player])
  4109. {
  4110. if (allowed_human(player))
  4111. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s \r[%L]^n", player-PL_STARTID, name, id, "CLASS_ZOMBIE")
  4112. else
  4113. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s [%L]^n", player-PL_STARTID, name, id, "CLASS_ZOMBIE")
  4114. }
  4115. else
  4116. {
  4117. if (allowed_zombie(player))
  4118. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s \y[%L]^n", player-PL_STARTID, name, id, "CLASS_HUMAN")
  4119. else
  4120. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s [%L]^n", player-PL_STARTID, name, id, "CLASS_HUMAN")
  4121. }
  4122. }
  4123. case 1:
  4124. {
  4125. if (allowed_nemesis(player))
  4126. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", player-PL_STARTID, name)
  4127. else
  4128. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", player-PL_STARTID, name)
  4129. }
  4130. case 2:
  4131. {
  4132. if (allowed_survivor(player))
  4133. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", player-PL_STARTID, name)
  4134. else
  4135. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", player-PL_STARTID, name)
  4136. }
  4137. case 3:
  4138. {
  4139. if (allowed_respawn(player))
  4140. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", player-PL_STARTID, name)
  4141. else
  4142. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", player-PL_STARTID, name)
  4143. }
  4144. case 4:
  4145. {
  4146. if (allowed_survivor(player))
  4147. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", player-PL_STARTID, name)
  4148. else
  4149. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", player-PL_STARTID, name)
  4150. }
  4151. case 6:
  4152. {
  4153. if (allowed_nemesis(player))
  4154. len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", player-PL_STARTID, name)
  4155. else
  4156. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", player-PL_STARTID, name)
  4157. }
  4158.  
  4159. }
  4160. }
  4161. else
  4162. {
  4163. len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. -----^n", player-PL_STARTID)
  4164. }
  4165. }
  4166.  
  4167. // 8. Back - 9. Next - 0. Exit
  4168. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L", id, "MENU_BACK", id, "MENU_NEXT", id, "MENU_EXIT")
  4169.  
  4170. show_menu(id, KEYSMENU, menu, -1, "Player List Menu")
  4171. }
  4172.  
  4173. /*================================================================================
  4174. [Menu Handlers]
  4175. =================================================================================*/
  4176.  
  4177. // Game Menu
  4178. public menu_game(id, key)
  4179. {
  4180. switch (key)
  4181. {
  4182. case 0: // Buy Weapons
  4183. {
  4184. // Custom buy menus enabled?
  4185. if (get_pcvar_num(cvar_buycustom))
  4186. {
  4187. // Disable the remember selection setting
  4188. WPN_AUTO_ON = 0
  4189. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"BUY_ENABLED")
  4190.  
  4191. // Show menu if player hasn't yet bought anything
  4192. if (g_canbuy[id]) show_menu_buy1(id)
  4193. }
  4194. else
  4195. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4196. }
  4197. case 1: // Extra Items
  4198. {
  4199. // Extra items enabled?
  4200. if (get_pcvar_num(cvar_extraitems))
  4201. {
  4202. // Check whether the player is able to buy anything
  4203. if (is_user_alive(id) && !g_survivor[id] && !g_nemesis[id])
  4204. show_menu_extras(id)
  4205. else
  4206. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"CMD_NOT")
  4207. }
  4208. else
  4209. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"CMD_NOT_EXTRAS")
  4210. }
  4211. case 2: // Zombie Classes || Human Classes
  4212. {
  4213. // Zombie classes enabled?
  4214. if (g_zombie[id])
  4215. show_menu_zclass(id)
  4216. else
  4217. show_menu_hclass(id)
  4218. }
  4219. case 3: menu_mejoras(id)
  4220. case 4: // Unstuck
  4221. {
  4222. // Check if player is stuck
  4223. if (is_user_alive(id) && is_player_stuck(id))
  4224. {
  4225. // Spawn randomly / get back to base
  4226. if (get_pcvar_num(cvar_randspawn))
  4227. do_random_spawn(id)
  4228. else
  4229. dllfunc(DLLFunc_Spawn, id)
  4230. }
  4231. else
  4232. zp_colored_print(id, "^x04[ZP]^x01 %L", id ,"CMD_NOT_STUCK")
  4233. }
  4234. case 5: show_menu_player(id)
  4235. case 6: show_menu_estadisticas(id)
  4236. case 8: // Admin Menu
  4237. {
  4238. // Check if player has the required access
  4239. if (get_user_flags(id) & ACCESS_FLAG)
  4240. show_menu_admin(id)
  4241. else
  4242. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_ACCESS")
  4243. }
  4244. }
  4245.  
  4246. return PLUGIN_HANDLED;
  4247. }
  4248.  
  4249. // Buy Menu 1
  4250. public menu_buy1(id, key)
  4251. {
  4252. // Zombies or survivors get no guns
  4253. if (g_zombie[id] || g_survivor[id] || !is_user_alive(id))
  4254. return PLUGIN_HANDLED;
  4255.  
  4256. // Special keys / weapon list exceeded
  4257. if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
  4258. {
  4259. switch (key)
  4260. {
  4261. case MENU_KEY_AUTOSELECT: // toggle auto select
  4262. {
  4263. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  4264. }
  4265. case MENU_KEY_NEXT: // next/back
  4266. {
  4267. if (WPN_STARTID+7 < WPN_MAXIDS)
  4268. WPN_STARTID += 7
  4269. else
  4270. WPN_STARTID = 0
  4271. }
  4272. case MENU_KEY_EXIT: // exit
  4273. {
  4274. return PLUGIN_HANDLED;
  4275. }
  4276. }
  4277.  
  4278. // Show buy menu again
  4279. show_menu_buy1(id)
  4280. return PLUGIN_HANDLED;
  4281. }
  4282.  
  4283. if(g_level[id] < g_levelprimary[WPN_SELECTION])
  4284. {
  4285. show_menu_buy1(id)
  4286. return PLUGIN_HANDLED;
  4287. }
  4288.  
  4289. // Store selected weapon id
  4290. WPN_AUTO_PRI = WPN_SELECTION
  4291.  
  4292. // Buy primary weapon
  4293. buy_primary_weapon(id, WPN_AUTO_PRI)
  4294.  
  4295. // Show pistols menu
  4296. show_menu_buy2(id)
  4297.  
  4298. return PLUGIN_HANDLED;
  4299. }
  4300.  
  4301. // Buy Primary Weapon
  4302. buy_primary_weapon(id, selection)
  4303. {
  4304. // Drop previous weapons
  4305. drop_weapons(id, 1)
  4306. drop_weapons(id, 2)
  4307.  
  4308. // Strip off from weapons
  4309. fm_strip_user_weapons(id)
  4310. fm_give_item(id, "weapon_knife")
  4311.  
  4312. // Get weapon index
  4313. static weaponid
  4314. weaponid = get_weaponid(g_primary_items[selection])
  4315.  
  4316. // Give the new weapon
  4317. fm_give_item(id, g_primary_items[selection])
  4318. fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
  4319.  
  4320. // Weapons bought
  4321. g_canbuy[id] = false
  4322.  
  4323. switch (selection)
  4324. {
  4325. case 7:
  4326. {
  4327. g_colt[id] = false
  4328. }
  4329. case 17:
  4330. {
  4331. g_colt[id] = true
  4332. }
  4333. }
  4334. }
  4335.  
  4336. // Buy Menu 2
  4337. public menu_buy2(id, key)
  4338. {
  4339. // Zombies or survivors get no guns
  4340. if (g_zombie[id] || g_survivor[id] || !is_user_alive(id))
  4341. return PLUGIN_HANDLED;
  4342.  
  4343. // Special keys / weapon list exceeded
  4344. if (key >= sizeof g_secondary_items)
  4345. {
  4346. // Toggle autoselect
  4347. if (key == MENU_KEY_AUTOSELECT)
  4348. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  4349.  
  4350. // Reshow menu unless user exited
  4351. if (key != MENU_KEY_EXIT)
  4352. show_menu_buy2(id)
  4353.  
  4354. return PLUGIN_HANDLED;
  4355. }
  4356.  
  4357. if(g_level[id] < g_levelsecondary[key])
  4358. {
  4359. show_menu_buy2(id)
  4360. return PLUGIN_HANDLED;
  4361. }
  4362.  
  4363. // Store selected weapon
  4364. WPN_AUTO_SEC = key
  4365.  
  4366. // Drop secondary gun again, in case we picked another (bugfix)
  4367. drop_weapons(id, 2)
  4368.  
  4369. // Get weapon index
  4370. static weaponid
  4371. weaponid = get_weaponid(g_secondary_items[key])
  4372.  
  4373. // Give the new weapon with full ammo
  4374. fm_give_item(id, g_secondary_items[key])
  4375. fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
  4376.  
  4377. show_menu_buy3(id)
  4378.  
  4379. return PLUGIN_HANDLED;
  4380. }
  4381.  
  4382. //Buy Menu 3
  4383. public menu_buy3(id, key)
  4384. {
  4385. static i
  4386.  
  4387. // Zombies or survivors get no guns
  4388. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  4389. return PLUGIN_HANDLED;
  4390.  
  4391. // Special keys / weapon list exceeded
  4392. if (key > 4)
  4393. {
  4394. // Toggle autoselect
  4395. if (key == MENU_KEY_AUTOSELECT)
  4396. WPN_AUTO_ON = 1 - WPN_AUTO_ON
  4397.  
  4398. // Reshow menu unless user exited
  4399. if (key != MENU_KEY_EXIT)
  4400. show_menu_buy3(id)
  4401.  
  4402. return PLUGIN_HANDLED;
  4403. }
  4404.  
  4405. new bomb_level = g_bomb_level[key]
  4406.  
  4407. if(g_level[id] >= bomb_level)
  4408. {
  4409. for(i = 0; i < 3; i++)
  4410. {
  4411. fm_give_item(id, g_terciary_items[i])
  4412. fm_set_user_bpammo(id, BOMBWEAPONNAMMO[i], BOMBAMMOUNT[key][i])
  4413.  
  4414. // Flash ammo in hud
  4415. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  4416. write_byte(AMMOID[BOMBWEAPONNAMMO[i]]) // ammo id
  4417. write_byte(BOMBAMMOUNT[key][i]) // ammo amount
  4418. message_end()
  4419. }
  4420. }
  4421. else
  4422. {
  4423. show_menu_buy3(id)
  4424. return PLUGIN_HANDLED;
  4425. }
  4426.  
  4427. // Store selected weapon
  4428. WPN_AUTO_TER = key
  4429.  
  4430. return PLUGIN_HANDLED;
  4431. }
  4432.  
  4433. // Extra Items Menu
  4434. public menu_extras(id, key)
  4435. {
  4436. // Nemesis or Survivor shouldnt get extra items
  4437. if (g_survivor[id] || g_nemesis[id] || !is_user_alive(id))
  4438. {
  4439. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4440. return PLUGIN_HANDLED;
  4441. }
  4442.  
  4443. // Special keys / items list exceeded
  4444. if (key >= MENU_KEY_BACK || EXTRAS_SELECTION >= g_extraitem_i)
  4445. {
  4446. switch (key)
  4447. {
  4448. case MENU_KEY_BACK: // back
  4449. {
  4450. if (EXTRAS_STARTID-7 >= 0) EXTRAS_STARTID -= 7
  4451. }
  4452. case MENU_KEY_NEXT: // next
  4453. {
  4454. if (EXTRAS_STARTID+7 < g_extraitem_i) EXTRAS_STARTID += 7
  4455. }
  4456. case MENU_KEY_EXIT: // exit
  4457. {
  4458. return PLUGIN_HANDLED;
  4459. }
  4460. }
  4461.  
  4462. // Show extra items menu again
  4463. show_menu_extras(id)
  4464. return PLUGIN_HANDLED;
  4465. }
  4466.  
  4467. // Try to buy the item
  4468. buy_extra_item(id, EXTRAS_SELECTION);
  4469. show_menu_extras(id)
  4470.  
  4471. return PLUGIN_HANDLED;
  4472. }
  4473.  
  4474. // Buy Extra Item
  4475. buy_extra_item(id, itemid)
  4476. {
  4477. // Check for human only items
  4478. if (g_zombie[id] && g_extraitem_team[itemid] == ZP_TEAM_HUMAN)
  4479. {
  4480. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_HUMAN_ONLY")
  4481. return;
  4482. }
  4483.  
  4484. // Check for zombie only items
  4485. if (!g_zombie[id] && g_extraitem_team[itemid] == ZP_TEAM_ZOMBIE)
  4486. {
  4487. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_ZOMBIE_ONLY")
  4488. return;
  4489. }
  4490.  
  4491. // Check for unavailable items
  4492. if ((itemid == EXTRA_NVISION && !get_pcvar_num(cvar_extranvision) || g_assassinround) || (itemid == EXTRA_ANTIDOTE && !get_pcvar_num(cvar_extraantidote)) || (itemid == EXTRA_MADNESS && !get_pcvar_num(cvar_extramadness)) || (itemid == EXTRA_INFBOMB && (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit))) || (itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1 && !get_pcvar_num(cvar_extraweapons)))
  4493. {
  4494. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4495. return;
  4496. }
  4497.  
  4498. // Check for hard coded items with special conditions
  4499. 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))) || (itemid == EXTRA_MADNESS && g_nodamage[id]) || (itemid == EXTRA_INFBOMB && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround)))
  4500. {
  4501. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT_CANTUSE")
  4502. return;
  4503. }
  4504.  
  4505. // Check that we have enough ammo packs
  4506. if (g_ammopacks[id] < g_extraitem_cost[itemid])
  4507. {
  4508. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "NOT_ENOUGH_AMMO")
  4509. return;
  4510. }
  4511.  
  4512. // Deduce item cost
  4513. update_ap(id, 0 - g_extraitem_cost[itemid])
  4514.  
  4515. // Check which kind of item we're buying
  4516. switch (itemid)
  4517. {
  4518. case EXTRA_NVISION: // Night Vision
  4519. {
  4520. if (!is_user_bot(id))
  4521. {
  4522. g_nvision[id] = true
  4523. g_nvisionenabled[id] = true
  4524.  
  4525. // Custom nvg?
  4526. if (get_pcvar_num(cvar_cnvg))
  4527. {
  4528. remove_task(id+TASK_NVISION)
  4529. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  4530. }
  4531. else
  4532. set_user_gnvision(id, 1)
  4533. }
  4534. else
  4535. fm_set_bot_nvg(id, 1)
  4536. }
  4537. case EXTRA_ANTIDOTE: // Antidote
  4538. {
  4539. humanme(id, 0)
  4540. }
  4541. case EXTRA_MADNESS: // Zombie Madness
  4542. {
  4543. g_nodamage[id] = true
  4544. zombie_aura(id+TASK_BLOOD)
  4545. engfunc(EngFunc_EmitSound, id, CHAN_VOICE, zombie_madness[random_num(0, sizeof zombie_madness - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  4546. set_task(get_pcvar_float(cvar_madnessduration), "madness_over", id+TASK_BLOOD)
  4547. }
  4548. case EXTRA_INFBOMB: // Infection Bomb
  4549. {
  4550. // Increase infection bomb purchase count for this round
  4551. g_infbombcounter++
  4552.  
  4553. // Already own one
  4554. if (user_has_weapon(id, CSW_HEGRENADE))
  4555. {
  4556. // Increase BP ammo on it instead
  4557. fm_set_user_bpammo(id, CSW_HEGRENADE, fm_get_user_bpammo(id, CSW_HEGRENADE) + 1)
  4558.  
  4559. // Flash ammo in hud
  4560. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  4561. write_byte(AMMOID[CSW_HEGRENADE]) // ammo id
  4562. write_byte(1) // ammo amount
  4563. message_end()
  4564.  
  4565. // Play clip purchase sound
  4566. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4567.  
  4568. return; // stop here
  4569. }
  4570.  
  4571. // Give weapon to the player
  4572. fm_give_item(id, "weapon_hegrenade")
  4573. }
  4574. case EXTRA_WEAPONS_STARTID .. EXTRAS_CUSTOM_STARTID-1: // Weapons
  4575. {
  4576. // Get weapon index
  4577. static weaponid
  4578. weaponid = get_weaponid(g_extra_items[itemid-4])
  4579.  
  4580. // If we are giving a primary/secondary weapon
  4581. if (MAXBPAMMO[weaponid] > 2)
  4582. {
  4583. // Make user drop the previous one
  4584. if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
  4585. drop_weapons(id, 1)
  4586. else
  4587. drop_weapons(id, 2)
  4588.  
  4589. // Give full BP ammo for the new one
  4590. fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
  4591. }
  4592. // If we are giving a grenade which the user already owns
  4593. else if (user_has_weapon(id, weaponid))
  4594. {
  4595. // Increase BP ammo on it instead
  4596. fm_set_user_bpammo(id, weaponid, fm_get_user_bpammo(id, weaponid) + 1)
  4597.  
  4598. // Flash ammo in hud
  4599. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  4600. write_byte(AMMOID[weaponid]) // ammo id
  4601. write_byte(1) // ammo amount
  4602. message_end()
  4603.  
  4604. // Play clip purchase sound
  4605. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_buyammo, 1.0, ATTN_NORM, 0, PITCH_NORM)
  4606.  
  4607. return; // stop here
  4608. }
  4609.  
  4610. // Give weapon to the player
  4611. fm_give_item(id, g_extra_items[itemid-4])
  4612. }
  4613. default: // Custom additions
  4614. {
  4615. // Item selected forward
  4616. ExecuteForward(g_fwExtraItemSelected, g_fwDummyResult, id, itemid);
  4617. }
  4618. }
  4619. }
  4620.  
  4621. // Zombie Class Menu
  4622. public menu_zclass(id, key)
  4623. {
  4624. // Special keys / items list exceeded
  4625. if (key >= MENU_KEY_BACK || ZCLASSES_SELECTION >= g_zclass_i)
  4626. {
  4627. switch (key)
  4628. {
  4629. case MENU_KEY_BACK: // back
  4630. {
  4631. if (ZCLASSES_STARTID-7 >= 0) ZCLASSES_STARTID -= 7
  4632. }
  4633. case MENU_KEY_NEXT: // next
  4634. {
  4635. if (ZCLASSES_STARTID+7 < g_zclass_i) ZCLASSES_STARTID += 7
  4636. }
  4637. case MENU_KEY_EXIT: // exit
  4638. {
  4639. return PLUGIN_HANDLED;
  4640. }
  4641. }
  4642.  
  4643. // Show extra items menu again
  4644. show_menu_zclass(id)
  4645. return PLUGIN_HANDLED;
  4646. }
  4647.  
  4648. // Store selection for the next infection
  4649. g_zombieclassnext[id] = ZCLASSES_SELECTION;
  4650. show_menu_zclass(id)
  4651.  
  4652. return PLUGIN_HANDLED;
  4653. }
  4654.  
  4655. // Human Class Menu
  4656. public menu_hclass(id, key)
  4657. {
  4658. // Special keys / items list exceeded
  4659. if (key >= MENU_KEY_BACK || HCLASSES_SELECTION >= g_hclass_i)
  4660. {
  4661. switch (key)
  4662. {
  4663. case MENU_KEY_BACK: // back
  4664. {
  4665. if (HCLASSES_STARTID-7 >= 0) HCLASSES_STARTID -= 7
  4666. }
  4667. case MENU_KEY_NEXT: // next
  4668. {
  4669. if (HCLASSES_STARTID+7 < g_hclass_i) HCLASSES_STARTID += 7
  4670. }
  4671. case MENU_KEY_EXIT: // exit
  4672. {
  4673. return PLUGIN_HANDLED;
  4674. }
  4675. }
  4676.  
  4677. // Show extra items menu again
  4678. show_menu_hclass(id)
  4679. return PLUGIN_HANDLED;
  4680. }
  4681.  
  4682. if (g_level[id] >= g_hclass_lvl[HCLASSES_SELECTION])
  4683. {
  4684. g_humanclassnext[id] = HCLASSES_SELECTION;
  4685. show_menu_hclass(id)
  4686. }
  4687.  
  4688. return PLUGIN_HANDLED;
  4689. }
  4690.  
  4691. // Info Menu
  4692. public menu_info(id, key)
  4693. {
  4694. static motd[1000], len
  4695. len = 0
  4696.  
  4697. switch (key)
  4698. {
  4699. case 0: // General
  4700. {
  4701. static weather, lights[2]
  4702. weather = 0
  4703.  
  4704. // Get light style
  4705. get_pcvar_string(cvar_lighting, lights, sizeof lights - 1)
  4706. strtolower(lights)
  4707.  
  4708. len += formatex(motd[len], sizeof motd - 1 - len, "%L ", id, "MOTD_INFO11", "Zombie Plague", PLUGIN_VERSION, "MeRcyLeZZ")
  4709. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO12")
  4710. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_A")
  4711.  
  4712. #if defined AMBIENCE_FOG
  4713. len += formatex(motd[len], sizeof motd - 1 - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_FOG")
  4714. weather++
  4715. #endif
  4716. #if defined AMBIENCE_RAIN
  4717. len += formatex(motd[len], sizeof motd - 1 - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_RAIN")
  4718. weather++
  4719. #endif
  4720. #if defined AMBIENCE_SNOW
  4721. len += formatex(motd[len], sizeof motd - 1 - len, (weather < 1) ? " %L" : ". %L", id, "MOTD_SNOW")
  4722. weather++
  4723. #endif
  4724. if (weather < 1) len += formatex(motd[len], sizeof motd - 1 - len, " %L", id, "MOTD_DISABLED")
  4725.  
  4726. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_B", lights)
  4727. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_C", id, get_pcvar_num(cvar_triggered) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4728. if (lights[0] == 'a' && get_pcvar_num(cvar_thunder)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_D", get_pcvar_num(cvar_thunder))
  4729. len += formatex(motd[len], sizeof motd - 1 - 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")
  4730. len += formatex(motd[len], sizeof motd - 1 - 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")
  4731. if (get_pcvar_num(cvar_deathmatch)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_G", get_pcvar_num(cvar_spawnprotection))
  4732. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_H", id, get_pcvar_num(cvar_randspawn) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4733. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_I", id, get_pcvar_num(cvar_extraitems) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4734. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_J", id, get_pcvar_num(cvar_zclasses) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4735. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO1_K", id, get_pcvar_num(cvar_cnvg) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4736.  
  4737. show_motd(id, motd)
  4738. }
  4739. case 1: // Humans
  4740. {
  4741. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2")
  4742. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_A", get_pcvar_num(cvar_humanhp))
  4743. if (get_pcvar_num(cvar_humanlasthp) > 0) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_B", get_pcvar_num(cvar_humanlasthp))
  4744. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_C", get_pcvar_num(cvar_humanspd))
  4745. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_D", floatround(get_pcvar_float(cvar_humangravity)*800))
  4746. len += formatex(motd[len], sizeof motd - 1 - 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")
  4747. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_F", get_pcvar_num(cvar_ammodamage))
  4748. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_G", id, get_pcvar_num(cvar_firegrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4749. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_H", id, get_pcvar_num(cvar_frostgrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4750. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_I", id, get_pcvar_num(cvar_flaregrenades) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4751. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO2_J", id, get_pcvar_num(cvar_knockback) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4752.  
  4753. show_motd(id, motd)
  4754. }
  4755. case 2: // Zombies
  4756. {
  4757. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3")
  4758. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_A", g_zclass_hp[0])
  4759. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_B", floatround(g_zclass_hp[0]*get_pcvar_float(cvar_zombiefirsthp)))
  4760. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_C", floatround(get_pcvar_float(cvar_zombiearmor)*100))
  4761. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_D", g_zclass_spd[0])
  4762. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_E", floatround(g_zclass_grav[0]*800))
  4763. if (get_pcvar_num(cvar_zombiebonushp)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_F", get_pcvar_num(cvar_zombiebonushp))
  4764. len += formatex(motd[len], sizeof motd - 1 - 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")
  4765. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_H", id, get_pcvar_num(cvar_zombiebleeding) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4766. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO3_I", get_pcvar_num(cvar_ammoinfect))
  4767.  
  4768. show_motd(id, motd)
  4769. }
  4770. case 3: // Gameplay Modes
  4771. {
  4772. static nemhp[5], survhp[5]
  4773.  
  4774. // Get nemesis and survivor health
  4775. num_to_str(get_pcvar_num(cvar_nemhp), nemhp, sizeof nemhp - 1)
  4776. num_to_str(get_pcvar_num(cvar_survhp), survhp, sizeof survhp - 1)
  4777.  
  4778. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4")
  4779. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_A", id, get_pcvar_num(cvar_nem) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4780. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_B", get_pcvar_num(cvar_nemchance))
  4781. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_C", get_pcvar_num(cvar_nemhp) > 0 ? nemhp : "[Auto]")
  4782. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_D", get_pcvar_num(cvar_nemspd))
  4783. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_E", floatround(get_pcvar_float(cvar_nemgravity)*800))
  4784. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_F", id, get_pcvar_num(cvar_leapnemesis) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4785. if (get_pcvar_num(cvar_nem)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_G", id, get_pcvar_num(cvar_nempainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4786. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_H", id, get_pcvar_num(cvar_surv) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4787. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_I", get_pcvar_num(cvar_survchance))
  4788. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_J", get_pcvar_num(cvar_survhp) > 0 ? survhp : "[Auto]")
  4789. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_K", get_pcvar_num(cvar_survspd))
  4790. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_L", floatround(get_pcvar_float(cvar_survgravity)*800))
  4791. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_M", id, get_pcvar_num(cvar_leapsurvivor) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4792. if (get_pcvar_num(cvar_surv)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_N", id, get_pcvar_num(cvar_survpainfree) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4793. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_O", id, get_pcvar_num(cvar_swarm) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4794. if (get_pcvar_num(cvar_swarm)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_P", get_pcvar_num(cvar_swarmchance))
  4795. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_Q", id, get_pcvar_num(cvar_multi) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4796. if (get_pcvar_num(cvar_multi)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_R", get_pcvar_num(cvar_multichance))
  4797. if (get_pcvar_num(cvar_multi)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_S", floatround(get_pcvar_float(cvar_multiratio)*100))
  4798. len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_T", id, get_pcvar_num(cvar_plague) ? "MOTD_ENABLED" : "MOTD_DISABLED")
  4799. if (get_pcvar_num(cvar_plague)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_U", get_pcvar_num(cvar_plaguechance))
  4800. if (get_pcvar_num(cvar_plague)) len += formatex(motd[len], sizeof motd - 1 - len, "%L", id, "MOTD_INFO4_V", floatround(get_pcvar_float(cvar_plagueratio)*100))
  4801.  
  4802. show_motd(id, motd)
  4803. }
  4804. default: return PLUGIN_HANDLED;
  4805. }
  4806.  
  4807. // Show help menu again if user wishes to read another topic
  4808. set_task(0.2, "show_menu_info", id);
  4809.  
  4810. return PLUGIN_HANDLED;
  4811. }
  4812.  
  4813.  
  4814. // Admin Menu
  4815. public menu_admin(id, menu6, item)
  4816. {
  4817. if (item == MENU_EXIT)
  4818. {
  4819. menu_destroy(menu6)
  4820. return PLUGIN_HANDLED
  4821. }
  4822.  
  4823. new Data[6], Name[64]
  4824. new Access, Callback
  4825. menu_item_getinfo(menu6, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  4826.  
  4827. new Key = str_to_num(Data)
  4828.  
  4829. switch (Key)
  4830. {
  4831. case 1: // Zombiefy/Humanize command
  4832. {
  4833. if (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround || task_exists(TASK_WELCOMEMSG))
  4834. {
  4835. // Not available
  4836. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4837. show_menu_admin(id)
  4838. }
  4839. else
  4840. {
  4841. // Show player list for admin to pick a target
  4842. PL_ACTION = item
  4843. show_menu_player_list(id)
  4844. }
  4845. }
  4846. case 2: // Nemesis command
  4847. {
  4848. if (g_endround || !g_newround || !get_pcvar_num(cvar_nem) || task_exists(TASK_WELCOMEMSG))
  4849. {
  4850. // Not available
  4851. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4852. show_menu_admin(id)
  4853. }
  4854. else
  4855. {
  4856. // Show player list for admin to pick a target
  4857. PL_ACTION = item
  4858. show_menu_player_list(id)
  4859. }
  4860. }
  4861. case 3: // Survivor command
  4862. {
  4863. if (allowed_swarm())
  4864. command_survivor(id)
  4865. else
  4866. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4867.  
  4868. show_menu_admin(id)
  4869. }
  4870. case 4: // Respawn command
  4871. {
  4872. if (g_endround || g_survround || g_swarmround || g_nemround || g_plagueround)
  4873. {
  4874. // Not available
  4875. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4876. show_menu_admin(id)
  4877. }
  4878. else
  4879. {
  4880. // Show player list for admin to pick a target
  4881. PL_ACTION = item
  4882. show_menu_player_list(id)
  4883. }
  4884. }
  4885. case 5: // wesker command
  4886. {
  4887. if (g_endround || !g_newround || !get_pcvar_num(cvar_wesker) || task_exists(TASK_WELCOMEMSG))
  4888. {
  4889. // Not available
  4890. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4891. show_menu_admin(id)
  4892. }
  4893. else
  4894. {
  4895. // Show player list for admin to pick a target
  4896. PL_ACTION = item
  4897. show_menu_player_list(id)
  4898. }
  4899. }
  4900. case 6: // terminator command
  4901. {
  4902. if (allowed_swarm())
  4903. command_terminator(id)
  4904. else
  4905. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4906.  
  4907. show_menu_admin(id)
  4908. }
  4909. case 7: // assassin command
  4910. {
  4911. if (g_endround || !g_newround || !get_pcvar_num(cvar_assassin) || task_exists(TASK_WELCOMEMSG))
  4912. {
  4913. // Not available
  4914. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4915. show_menu_admin(id)
  4916. }
  4917. else
  4918. {
  4919. // Show player list for admin to pick a target
  4920. PL_ACTION = item
  4921. show_menu_player_list(id)
  4922. }
  4923. }
  4924. case 8: // Swarm Mode command
  4925. {
  4926. if (allowed_swarm())
  4927. command_swarm(id)
  4928. else
  4929. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4930.  
  4931. show_menu_admin(id)
  4932. }
  4933. case 9: // Multiple Infection command
  4934. {
  4935. if (allowed_multi())
  4936. command_multi(id)
  4937. else
  4938. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4939.  
  4940. show_menu_admin(id)
  4941. }
  4942. case 10: // Plague Mode command
  4943. {
  4944. if (allowed_plague())
  4945. command_plague(id)
  4946. else
  4947. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4948.  
  4949. show_menu_admin(id)
  4950. }
  4951. case 11: // Synapsis Mode command
  4952. {
  4953. if (allowed_plague())
  4954. command_synapsis(id)
  4955. else
  4956. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4957.  
  4958. show_menu_admin(id)
  4959. }
  4960. case 12: // Armageddon Mode command
  4961. {
  4962. if (allowed_plague())
  4963. command_armageddon(id)
  4964. else
  4965. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4966.  
  4967. show_menu_admin(id)
  4968. }
  4969. case 13: // Depredador Mode command
  4970. {
  4971. if (allowed_nemesis(id))
  4972. command_depredador(id)
  4973. else
  4974. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4975.  
  4976. show_menu_admin(id)
  4977. }
  4978. case 14: // Apocalypsis Mode command
  4979. {
  4980. if (allowed_nemesis(id))
  4981. command_apocalypsis(id)
  4982. else
  4983. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4984.  
  4985. show_menu_admin(id)
  4986. }
  4987. case 15: // Invasion Mode command
  4988. {
  4989. if (allowed_nemesis(id))
  4990. command_invasion(id)
  4991. else
  4992. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  4993.  
  4994. show_menu_admin(id)
  4995. }
  4996. }
  4997.  
  4998. return PLUGIN_HANDLED;
  4999. }
  5000.  
  5001. // Player List Menu
  5002. public menu_player_list(id, key)
  5003. {
  5004. switch (key)
  5005. {
  5006. case MENU_KEY_BACK: // back
  5007. {
  5008. if (PL_STARTID-7 >= 0) PL_STARTID -= 7
  5009. }
  5010. case MENU_KEY_NEXT: // next
  5011. {
  5012. if (PL_STARTID+7 < g_maxplayers) PL_STARTID += 7
  5013. }
  5014. case MENU_KEY_EXIT: // go back to admin menu
  5015. {
  5016. show_menu_admin(id);
  5017. return PLUGIN_HANDLED
  5018. }
  5019. default: // perform action on player
  5020. {
  5021. // Make sure it's connected
  5022. if (is_user_connected(PL_SELECTION))
  5023. {
  5024. // Perform the right action if allowed
  5025. switch (PL_ACTION)
  5026. {
  5027. case 0:
  5028. {
  5029. if (g_zombie[PL_SELECTION])
  5030. {
  5031. if (allowed_human(PL_SELECTION))
  5032. command_human(id, PL_SELECTION)
  5033. else
  5034. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5035. }
  5036. else
  5037. {
  5038. if (allowed_zombie(PL_SELECTION))
  5039. command_zombie(id, PL_SELECTION)
  5040. else
  5041. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5042. }
  5043. }
  5044. case 1:
  5045. {
  5046. if (allowed_nemesis(PL_SELECTION))
  5047. command_nemesis(id, PL_SELECTION)
  5048. else
  5049. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5050. }
  5051. case 2:
  5052. {
  5053. if (allowed_respawn(PL_SELECTION))
  5054. command_respawn(id, PL_SELECTION)
  5055. else
  5056. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5057. }
  5058. case 4:
  5059. {
  5060. if (allowed_survivor(PL_SELECTION))
  5061. command_wesker(id, PL_SELECTION)
  5062. else
  5063. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5064. }
  5065. case 6:
  5066. {
  5067. if (allowed_survivor(PL_SELECTION))
  5068. command_assassin(id, PL_SELECTION)
  5069. else
  5070. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5071. }
  5072. }
  5073. }
  5074. else
  5075. {
  5076. zp_colored_print(id, "^x04[ZP]^x01 %L", id, "CMD_NOT")
  5077. }
  5078. }
  5079. }
  5080.  
  5081. show_menu_player_list(id)
  5082. return PLUGIN_HANDLED;
  5083. }
  5084.  
  5085. /*================================================================================
  5086. [Admin Commands]
  5087. =================================================================================*/
  5088.  
  5089. // zp_toggle [1/0]
  5090. public cmd_toggle(id, level, cid)
  5091. {
  5092. // Check for access flag
  5093. if (!cmd_access(id, level, cid, 2))
  5094. return PLUGIN_HANDLED;
  5095.  
  5096. // Retrieve arguments
  5097. new arg[2]
  5098. read_argv(1, arg, sizeof arg - 1)
  5099.  
  5100. // Mod already enabled/disabled
  5101. if (str_to_num(arg) == g_pluginenabled)
  5102. return PLUGIN_HANDLED;
  5103.  
  5104. // Set the toggle cvar
  5105. set_pcvar_num(cvar_toggle, str_to_num(arg))
  5106.  
  5107. // Retrieve map name
  5108. new mapname[32]
  5109. get_mapname(mapname, sizeof mapname - 1)
  5110.  
  5111. // Restart current map
  5112. server_cmd("changelevel %s", mapname)
  5113.  
  5114. return PLUGIN_HANDLED;
  5115. }
  5116.  
  5117. // zp_zombie [target]
  5118. public cmd_zombie(id, level, cid)
  5119. {
  5120. // Check for access flag
  5121. if (!cmd_access(id, level, cid, 2))
  5122. return PLUGIN_HANDLED;
  5123.  
  5124. // Retrieve arguments
  5125. static arg[32], player
  5126. read_argv(1, arg, sizeof arg - 1)
  5127. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5128.  
  5129. // Invalid target
  5130. if (!player) return PLUGIN_HANDLED;
  5131.  
  5132. // Target not allowed to be zombie
  5133. if (!allowed_zombie(player))
  5134. {
  5135. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5136. return PLUGIN_HANDLED
  5137. }
  5138.  
  5139. command_zombie(id, player)
  5140.  
  5141. return PLUGIN_HANDLED;
  5142. }
  5143.  
  5144. // zp_terminator [target]
  5145. public cmd_terminator(id, level, cid)
  5146. {
  5147. // Check for access flag
  5148. if (!cmd_access(id, level, cid, 2))
  5149. return PLUGIN_HANDLED;
  5150.  
  5151. // Retrieve arguments
  5152. static arg[32], player
  5153. read_argv(1, arg, sizeof arg - 1)
  5154. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5155.  
  5156. // Invalid target
  5157. if (!player) return PLUGIN_HANDLED;
  5158.  
  5159. // Target not allowed to be human
  5160. if (!allowed_survivor(player))
  5161. {
  5162. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5163. return PLUGIN_HANDLED;
  5164. }
  5165.  
  5166. command_terminator(id)
  5167.  
  5168. return PLUGIN_HANDLED;
  5169. }
  5170.  
  5171. // zp_human [target]
  5172. public cmd_human(id, level, cid)
  5173. {
  5174. // Check for access flag
  5175. if (!cmd_access(id, level, cid, 2))
  5176. return PLUGIN_HANDLED;
  5177.  
  5178. // Retrieve arguments
  5179. static arg[32], player
  5180. read_argv(1, arg, sizeof arg - 1)
  5181. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5182.  
  5183. // Invalid target
  5184. if (!player) return PLUGIN_HANDLED;
  5185.  
  5186. // Target not allowed to be human
  5187. if (!allowed_human(player))
  5188. {
  5189. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5190. return PLUGIN_HANDLED;
  5191. }
  5192.  
  5193. command_human(id, player)
  5194.  
  5195. return PLUGIN_HANDLED;
  5196. }
  5197. public cmd_resets(id, level, cid)
  5198. {
  5199. if (!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED;
  5200.  
  5201. new arg1[33], arg2[6], player
  5202.  
  5203. read_argv(1, arg1, 32)
  5204. read_argv(2, arg2, 5)
  5205.  
  5206. player = cmd_target(id, arg1, CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
  5207.  
  5208. if (!player) return PLUGIN_HANDLED
  5209.  
  5210. g_reset[player] = str_to_num(arg2)
  5211.  
  5212. return PLUGIN_HANDLED;
  5213. }
  5214. // zp_assassin [target]
  5215. public cmd_assassin(id, level, cid)
  5216. {
  5217. if (!cmd_access(id, level, cid, 2))
  5218. return PLUGIN_HANDLED
  5219.  
  5220. // Retrieve arguments
  5221. static arg[32], player
  5222. read_argv(1, arg, sizeof arg - 1)
  5223. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5224.  
  5225. if (!allowed_nemesis(player))
  5226. {
  5227. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5228. return PLUGIN_HANDLED;
  5229. }
  5230.  
  5231. command_assassin(id, player)
  5232.  
  5233. return PLUGIN_HANDLED;
  5234. }
  5235. // zp_depredador
  5236. public cmd_depredador(id, level, cid)
  5237. {
  5238. if (!cmd_access(id, level, cid, 2))
  5239. return PLUGIN_HANDLED
  5240.  
  5241. // Retrieve arguments
  5242. static arg[32], player
  5243. read_argv(1, arg, sizeof arg - 1)
  5244. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5245.  
  5246. if (!allowed_nemesis(player))
  5247. {
  5248. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5249. return PLUGIN_HANDLED;
  5250. }
  5251.  
  5252. command_depredador(id)
  5253.  
  5254. return PLUGIN_HANDLED;
  5255. }
  5256. // zp_invasion
  5257. public cmd_invasion(id, level, cid)
  5258. {
  5259. if (!cmd_access(id, level, cid, 2))
  5260. return PLUGIN_HANDLED;
  5261.  
  5262. if (!allowed_plague())
  5263. {
  5264. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5265. return PLUGIN_HANDLED;
  5266. }
  5267.  
  5268. command_invasion(id)
  5269.  
  5270. return PLUGIN_HANDLED;
  5271. }
  5272.  
  5273. // zp_apocalypsis
  5274. public cmd_apocalypsis(id, level, cid)
  5275. {
  5276. if (!cmd_access(id, level, cid, 2))
  5277. return PLUGIN_HANDLED;
  5278.  
  5279. if (!allowed_plague())
  5280. {
  5281. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5282. return PLUGIN_HANDLED;
  5283. }
  5284.  
  5285. command_apocalypsis(id)
  5286.  
  5287. return PLUGIN_HANDLED;
  5288. }
  5289.  
  5290. // zp_revelacion
  5291. public cmd_revelacion(id, level, cid)
  5292. {
  5293. if (!cmd_access(id, level, cid, 2))
  5294. return PLUGIN_HANDLED;
  5295.  
  5296. if (!allowed_plague())
  5297. {
  5298. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5299. return PLUGIN_HANDLED;
  5300. }
  5301.  
  5302. command_revelacion(id)
  5303.  
  5304. return PLUGIN_HANDLED;
  5305. }
  5306.  
  5307. // zp_armageddon
  5308. public cmd_armageddon(id, level, cid)
  5309. {
  5310. if (!cmd_access(id, level, cid, 2))
  5311. return PLUGIN_HANDLED;
  5312.  
  5313. if (!allowed_plague())
  5314. {
  5315. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5316. return PLUGIN_HANDLED;
  5317. }
  5318.  
  5319. command_armageddon(id)
  5320.  
  5321. return PLUGIN_HANDLED;
  5322. }
  5323. // zp_levels [target][amount]
  5324. public cmd_levels(id, level, cid)
  5325. {
  5326. // Check for access flag
  5327. if (!cmd_access(id, level, cid, 2))
  5328. return PLUGIN_HANDLED;
  5329.  
  5330. // Retrieve arguments
  5331. static arg[32], arg2[6], player, iLevels
  5332. read_argv(1, arg, sizeof arg - 1)
  5333. read_argv(2, arg2, sizeof arg2 - 1)
  5334. player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
  5335.  
  5336. // Invalid target
  5337. if (!player) return PLUGIN_HANDLED;
  5338.  
  5339. // Increase levels
  5340. iLevels = (str_to_num(arg2))
  5341. g_level[player] += iLevels
  5342.  
  5343. return PLUGIN_HANDLED;
  5344. }
  5345.  
  5346. // zp_wesker [target]
  5347. public cmd_wesker(id, level, cid)
  5348. {
  5349. // Check for access flag
  5350. if (!cmd_access(id, level, cid, 2))
  5351. return PLUGIN_HANDLED;
  5352.  
  5353. // Retrieve arguments
  5354. static arg[32], player
  5355. read_argv(1, arg, sizeof arg - 1)
  5356. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5357.  
  5358. // Invalid target
  5359. if (!player) return PLUGIN_HANDLED;
  5360.  
  5361. // Target not allowed to be survivor
  5362. if (!allowed_survivor(player))
  5363. {
  5364. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5365. return PLUGIN_HANDLED;
  5366. }
  5367.  
  5368. command_wesker(id, player)
  5369.  
  5370. return PLUGIN_HANDLED;
  5371. }
  5372. // zp_survivor [target]
  5373. public cmd_survivor(id, level, cid)
  5374. {
  5375. // Check for access flag
  5376. if (!cmd_access(id, level, cid, 2))
  5377. return PLUGIN_HANDLED;
  5378.  
  5379. // Target not allowed to be survivor
  5380. if (!allowed_survivor(id))
  5381. {
  5382. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5383. return PLUGIN_HANDLED;
  5384. }
  5385.  
  5386. command_survivor(id)
  5387.  
  5388. return PLUGIN_HANDLED;
  5389. }
  5390.  
  5391. // zp_synapsis
  5392. public cmd_synapsis(id, level, cid)
  5393. {
  5394. if (!cmd_access(id, level, cid, 2))
  5395. return PLUGIN_HANDLED;
  5396.  
  5397. // swarm not allowed?
  5398. if (!allowed_swarm())
  5399. {
  5400. zp_colored_print(id, "^x04[ZP]^x01 Comando no disponible")
  5401. return PLUGIN_HANDLED;
  5402. }
  5403.  
  5404. command_synapsis(id)
  5405.  
  5406. return PLUGIN_HANDLED;
  5407. }
  5408.  
  5409.  
  5410. // zp_nemesis [target]
  5411. public cmd_nemesis(id, level, cid)
  5412. {
  5413. // Check for access flag
  5414. if (!cmd_access(id, level, cid, 2))
  5415. return PLUGIN_HANDLED;
  5416.  
  5417. // Retrieve arguments
  5418. static arg[32], player
  5419. read_argv(1, arg, sizeof arg - 1)
  5420. player = cmd_target(id, arg, CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF)
  5421.  
  5422. // Invalid target
  5423. if (!player) return PLUGIN_HANDLED;
  5424.  
  5425. // Target not allowed to be nemesis
  5426. if (!allowed_nemesis(player))
  5427. {
  5428. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5429. return PLUGIN_HANDLED;
  5430. }
  5431.  
  5432. command_nemesis(id, player)
  5433.  
  5434. return PLUGIN_HANDLED;
  5435. }
  5436.  
  5437. // zp_respawn [target]
  5438. public cmd_respawn(id, level, cid)
  5439. {
  5440. // Check for access flag
  5441. if (!cmd_access(id, level, cid, 2))
  5442. return PLUGIN_HANDLED;
  5443.  
  5444. // Retrieve arguments
  5445. static arg[32], player
  5446. read_argv(1, arg, sizeof arg - 1)
  5447. player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  5448.  
  5449. // Invalid target
  5450. if (!player) return PLUGIN_HANDLED;
  5451.  
  5452. // Target not allowed to be respawned
  5453. if (!allowed_respawn(player))
  5454. {
  5455. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5456. return PLUGIN_HANDLED;
  5457. }
  5458.  
  5459. command_respawn(id, player)
  5460.  
  5461. return PLUGIN_HANDLED;
  5462. }
  5463.  
  5464. // zp_swarm
  5465. public cmd_swarm(id, level, cid)
  5466. {
  5467. // Check for access flag
  5468. if (!cmd_access(id, level, cid, 1))
  5469. return PLUGIN_HANDLED;
  5470.  
  5471. // Swarm mode not allowed
  5472. if (!allowed_swarm())
  5473. {
  5474. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5475. return PLUGIN_HANDLED;
  5476. }
  5477.  
  5478. command_swarm(id)
  5479.  
  5480. return PLUGIN_HANDLED;
  5481. }
  5482.  
  5483. // zp_multi
  5484. public cmd_multi(id, level, cid)
  5485. {
  5486. // Check for access flag
  5487. if (!cmd_access(id, level, cid, 1))
  5488. return PLUGIN_HANDLED;
  5489.  
  5490. // Multi infection mode not allowed
  5491. if (!allowed_multi())
  5492. {
  5493. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5494. return PLUGIN_HANDLED;
  5495. }
  5496.  
  5497. command_multi(id)
  5498.  
  5499. return PLUGIN_HANDLED;
  5500. }
  5501.  
  5502. // zp_plague
  5503. public cmd_plague(id, level, cid)
  5504. {
  5505. // Check for access flag
  5506. if (!cmd_access(id, level, cid, 1))
  5507. return PLUGIN_HANDLED;
  5508.  
  5509. // Plague mode not allowed
  5510. if (!allowed_plague())
  5511. {
  5512. client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
  5513. return PLUGIN_HANDLED;
  5514. }
  5515.  
  5516. command_plague(id)
  5517.  
  5518. return PLUGIN_HANDLED;
  5519. }
  5520.  
  5521. /*================================================================================
  5522. [Message Hooks]
  5523. =================================================================================*/
  5524.  
  5525. // Current Weapon info
  5526. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  5527. {
  5528. // Player not alive or not an active weapon
  5529. if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
  5530. return;
  5531.  
  5532. // Get weapon id
  5533. static weapon
  5534. weapon = get_msg_arg_int(2)
  5535.  
  5536. // Store weapon id for reference
  5537. g_currentweapon[msg_entity] = weapon
  5538.  
  5539. // Replace weapon models with custom ones
  5540. replace_models(msg_entity)
  5541.  
  5542. // Unlimited Clip Ammo?
  5543. if (MAXBPAMMO[weapon] > 2 && (g_survivor[msg_entity] || get_pcvar_num(cvar_infammo) > 1))
  5544. {
  5545. // Refill when it's running out
  5546. if (get_msg_arg_int(3) < 7)
  5547. {
  5548. // Get weapon entity
  5549. static wname[32], weapon_ent
  5550. get_weaponname(weapon, wname, sizeof wname - 1)
  5551. weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
  5552.  
  5553. // Max out clip ammo
  5554. fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
  5555. }
  5556.  
  5557. // HUD should show full clip all the time
  5558. set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
  5559. }
  5560. }
  5561.  
  5562. // BP Ammo update
  5563. public message_ammo_x(msg_id, msg_dest, msg_entity)
  5564. {
  5565. // Get ammo type
  5566. static type
  5567. type = get_msg_arg_int(1)
  5568.  
  5569. // Unknown ammo type
  5570. if (type >= sizeof AMMOWEAPON) return;
  5571.  
  5572. // Get weapon id
  5573. static weapon
  5574. weapon = AMMOWEAPON[type]
  5575.  
  5576. // Primary and secondary only
  5577. if (MAXBPAMMO[weapon] > 2)
  5578. {
  5579. // Get ammo amount
  5580. static amount
  5581. amount = get_msg_arg_int(2)
  5582.  
  5583. // Unlimited BP Ammo?
  5584. if (g_survivor[msg_entity] || get_pcvar_num(cvar_infammo))
  5585. {
  5586. if (amount < MAXBPAMMO[weapon])
  5587. {
  5588. fm_set_user_bpammo(msg_entity, weapon, MAXBPAMMO[weapon])
  5589. set_msg_arg_int(2, get_msg_argtype(2), MAXBPAMMO[weapon])
  5590. }
  5591. }
  5592. // Bots automatically buy ammo when needed
  5593. else if (!g_zombie[msg_entity] && !g_survivor[msg_entity] && g_ammopacks[msg_entity] > 0 && amount <= BUYAMMO[weapon] && is_user_bot(msg_entity))
  5594. clcmd_buyammo(msg_entity);
  5595. }
  5596. }
  5597.  
  5598. // Take off player's money
  5599. public message_money(msg_id, msg_dest, msg_entity)
  5600. {
  5601. // Remove money setting enabled?
  5602. if (!get_pcvar_num(cvar_removemoney))
  5603. return PLUGIN_CONTINUE;
  5604.  
  5605. set_pdata_int(msg_entity, OFFSET_CSMONEY, 0, OFFSET_LINUX)
  5606. return PLUGIN_HANDLED;
  5607. }
  5608.  
  5609. // Fix for the HL engine bug when HP is multiples of 256
  5610. public message_health(msg_id, msg_dest, msg_entity)
  5611. {
  5612. // Get player's health
  5613. static health
  5614. health = get_msg_arg_int(1)
  5615.  
  5616. // Don't bother
  5617. if (health < 256) return;
  5618.  
  5619. // Check if we need to fix it
  5620. if (health % 256 == 0)
  5621. fm_set_user_health(msg_entity, pev(msg_entity, pev_health)+1)
  5622.  
  5623. // HUD can only show as much as 255 hp
  5624. set_msg_arg_int(1, get_msg_argtype(1), 255)
  5625. }
  5626.  
  5627. // Block flashlight battery messages when it's not available, or if custom flashlight is enabled instead
  5628. public message_flashbat(msg_id, msg_dest, msg_entity)
  5629. {
  5630. if (g_zombie[msg_entity] || g_survivor[msg_entity] || !is_user_alive(msg_entity))
  5631. return PLUGIN_HANDLED;
  5632.  
  5633. return PLUGIN_CONTINUE;
  5634. }
  5635.  
  5636. // Flashbangs should only affect zombies
  5637. public message_screenfade(msg_id, msg_dest, msg_entity)
  5638. {
  5639. 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)
  5640. return PLUGIN_CONTINUE;
  5641.  
  5642. // Nemesis shouldn't be FBed
  5643. if (g_zombie[msg_entity] && !g_nemesis[msg_entity])
  5644. {
  5645. // Set flash color to nighvision's
  5646. set_msg_arg_int(4, get_msg_argtype(4), get_pcvar_num(cvar_nvgcolor[0]))
  5647. set_msg_arg_int(5, get_msg_argtype(5), get_pcvar_num(cvar_nvgcolor[1]))
  5648. set_msg_arg_int(6, get_msg_argtype(6), get_pcvar_num(cvar_nvgcolor[2]))
  5649. return PLUGIN_CONTINUE;
  5650. }
  5651.  
  5652. return PLUGIN_HANDLED;
  5653. }
  5654.  
  5655. // Prevent spectators' nightvision from being turned off when switching targets, etc.
  5656. public message_nvgtoggle(msg_id, msg_dest, msg_entity)
  5657. {
  5658. return PLUGIN_HANDLED;
  5659. }
  5660.  
  5661. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  5662. // Set correct model on player corpses
  5663. public message_clcorpse()
  5664. {
  5665. set_msg_arg_string(1, g_playermodel[get_msg_arg_int(12)])
  5666. }
  5667. #endif
  5668.  
  5669. // Prevent zombies from seeing any weapon pickup icon
  5670. public message_weappickup(msg_id, msg_dest, msg_entity)
  5671. {
  5672. if (g_zombie[msg_entity])
  5673. return PLUGIN_HANDLED;
  5674.  
  5675. return PLUGIN_CONTINUE;
  5676. }
  5677.  
  5678. // Prevent zombies from seeing any ammo pickup icon
  5679. public message_ammopickup(msg_id, msg_dest, msg_entity)
  5680. {
  5681. if (g_zombie[msg_entity])
  5682. return PLUGIN_HANDLED;
  5683.  
  5684. return PLUGIN_CONTINUE;
  5685. }
  5686.  
  5687. // Block hostage HUD display
  5688. public message_scenario()
  5689. {
  5690. if (get_msg_args() > 1)
  5691. {
  5692. static sprite[8]
  5693. get_msg_arg_string(2, sprite, sizeof sprite - 1)
  5694.  
  5695. if (equal(sprite, "hostage"))
  5696. return PLUGIN_HANDLED;
  5697. }
  5698.  
  5699. return PLUGIN_CONTINUE;
  5700. }
  5701.  
  5702. // Block hostages from appearing on radar
  5703. public message_hostagepos()
  5704. {
  5705. return PLUGIN_HANDLED;
  5706. }
  5707.  
  5708. // Block some text messages
  5709. public message_textmsg()
  5710. {
  5711. static textmsg[22]
  5712. get_msg_arg_string(2, textmsg, sizeof textmsg - 1);
  5713.  
  5714. // Game restarting, reset scores and call round end to balance the teams
  5715. if (equal(textmsg, "#Game_will_restart_in"))
  5716. {
  5717. g_scorehumans = 0
  5718. g_scorezombies = 0
  5719. logevent_round_end()
  5720. }
  5721. // Block round end related messages
  5722. else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
  5723. {
  5724. return PLUGIN_HANDLED;
  5725. }
  5726.  
  5727. return PLUGIN_CONTINUE;
  5728. }
  5729.  
  5730. // Block CS round win audio messages, since we're playing our own instead
  5731. public message_sendaudio()
  5732. {
  5733. static audio[17]
  5734. get_msg_arg_string(2, audio, sizeof audio - 1)
  5735.  
  5736. if(equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
  5737. return PLUGIN_HANDLED;
  5738.  
  5739. return PLUGIN_CONTINUE;
  5740. }
  5741.  
  5742. // Send actual team scores (T = zombies // CT = humans)
  5743. public message_teamscore()
  5744. {
  5745. static team[2]
  5746. get_msg_arg_string(1, team, sizeof team - 1)
  5747.  
  5748. switch (team[0])
  5749. {
  5750. // CT
  5751. case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_scorehumans)
  5752. // Terrorist
  5753. case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_scorezombies)
  5754. }
  5755. }
  5756.  
  5757. // Team Switch (or player joining a team for first time)
  5758. public message_teaminfo(msg_id, msg_dest)
  5759. {
  5760. // Only hook global messages
  5761. if (msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
  5762.  
  5763. // Get player id
  5764. static id
  5765. id = get_msg_arg_int(1)
  5766.  
  5767. // Don't pick up our own TeamInfo messages for this player (bugfix)
  5768. if (g_switchingteam[id]) return;
  5769.  
  5770. // Enable spectators' nightvision if not spawning right away
  5771. set_task(0.2, "spec_nvision", id)
  5772.  
  5773. // Round didn't start yet, nothing to worry about
  5774. if (g_newround) return;
  5775.  
  5776. // Get his new team
  5777. static team[2]
  5778. get_msg_arg_string(2, team, sizeof team - 1)
  5779.  
  5780. switch (team[0])
  5781. {
  5782. case 'C': // CT
  5783. {
  5784. if (g_survround && fnGetHumans()) // survivor alive --> switch to T and spawn as zombie
  5785. {
  5786. g_respawn_as_zombie[id] = true;
  5787. remove_task(id+TASK_TEAM)
  5788. fm_set_user_team(id, CS_TEAM_T)
  5789. set_msg_arg_string(2, "TERRORIST")
  5790. }
  5791. else if (!fnGetZombies()) // no zombies alive --> switch to T and spawn as zombie
  5792. {
  5793. g_respawn_as_zombie[id] = true;
  5794. remove_task(id+TASK_TEAM)
  5795. fm_set_user_team(id, CS_TEAM_T)
  5796. set_msg_arg_string(2, "TERRORIST")
  5797. }
  5798. }
  5799. case 'T': // Terrorist
  5800. {
  5801. if ((g_swarmround || g_survround) && fnGetHumans()) // survivor alive or swarm round w/ humans --> spawn as zombie
  5802. {
  5803. g_respawn_as_zombie[id] = true;
  5804. }
  5805. else if (fnGetZombies()) // zombies alive --> switch to CT
  5806. {
  5807. remove_task(id+TASK_TEAM)
  5808. fm_set_user_team(id, CS_TEAM_CT)
  5809. set_msg_arg_string(2, "CT")
  5810. }
  5811. }
  5812. }
  5813. }
  5814.  
  5815. /*================================================================================
  5816. [Main Functions]
  5817. =================================================================================*/
  5818.  
  5819. // Make Zombie Task
  5820. public make_zombie_task()
  5821. {
  5822. // Call make a zombie with no specific mode
  5823. make_a_zombie(MODE_NONE, 0)
  5824. }
  5825.  
  5826. // Make a Zombie Function
  5827. make_a_zombie(mode, id)
  5828. {
  5829. // Get alive players count
  5830. static iPlayersnum
  5831. iPlayersnum = fnGetAlive()
  5832.  
  5833. // Not enough players, come back later!
  5834. if (iPlayersnum < 1)
  5835. {
  5836. set_task(10.0, "make_zombie_task", TASK_MAKEZOMBIE)
  5837. return;
  5838. }
  5839.  
  5840. #if defined AMBIENCE_SOUNDS
  5841. // Start ambience sounds after a mode begins
  5842. remove_task(TASK_AMBIENCESOUNDS)
  5843. set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  5844. #endif
  5845.  
  5846. // Get prevent consecutive modes setting
  5847. static preventconsecutive
  5848. preventconsecutive = get_pcvar_num(cvar_preventconsecutive)
  5849.  
  5850. // Round starting
  5851. g_newround = false
  5852. g_survround = false
  5853. g_nemround = false
  5854. g_swarmround = false
  5855. g_plagueround = false
  5856. g_synapsisround = false
  5857. g_armageddonround = false
  5858. g_weskerround = false
  5859. g_terminatorround = false
  5860. g_depredadorround = false
  5861. g_assassinround = false
  5862. g_apocalypsisround = false
  5863. g_invasionround = false
  5864. g_revelacionround = false
  5865.  
  5866. // Set up some common vars
  5867. static forward_id, name[32], iZombies, iMaxZombies
  5868.  
  5869. if ((mode == MODE_NONE && (!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)
  5870. {
  5871. // Survivor Mode
  5872. g_survround = true
  5873. g_lastmode = MODE_SURVIVOR
  5874.  
  5875. // Choose player randomly?
  5876. if (mode == MODE_NONE)
  5877. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  5878.  
  5879. // Remember id for calling our forward later
  5880. forward_id = id
  5881. static iSurvivor, iMaxSurvivor
  5882. iMaxSurvivor = 4
  5883.  
  5884. while (iSurvivor < iMaxSurvivor)
  5885. {
  5886. // Keep looping through all players
  5887. if (++id > g_maxplayers) id = 1
  5888.  
  5889. // Dead or already a zombie
  5890. if (!is_user_alive(id) || g_zombie[id])
  5891. continue;
  5892.  
  5893. humanme(id, 1)
  5894. iSurvivor++
  5895. }
  5896.  
  5897. iSurvivor = 0
  5898.  
  5899. // Turn the remaining players into zombies
  5900. for (id = 1; id <= g_maxplayers; id++)
  5901. {
  5902. // Not alive
  5903. if (!is_user_alive(id))
  5904. continue;
  5905.  
  5906. // Survivor or already a zombie
  5907. if (g_survivor[id] || g_zombie[id])
  5908. continue;
  5909.  
  5910. // Turn into a zombie
  5911. zombieme(id, 0, 0, 1)
  5912. }
  5913.  
  5914. // Play survivor sound
  5915. PlaySound(sound_survivor[random_num(0, sizeof sound_survivor -1)]);
  5916.  
  5917. // Show Survivor HUD notice
  5918. set_hudmessage(20, 20, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  5919. ShowSyncHudMsg(0, g_MsgSync, "Modo Survivor !!!", name)
  5920.  
  5921. // Round start forward
  5922. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SURVIVOR, 0)
  5923. }
  5924. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_TERMINATOR) && random_num(1, get_pcvar_num(cvar_terminatorchance)) == get_pcvar_num(cvar_terminator) && iPlayersnum >= get_pcvar_num(cvar_terminatorminplayers)) || mode == MODE_TERMINATOR)
  5925. {
  5926. // Swarm Mode
  5927. g_survround = true
  5928. g_terminatorround = true
  5929. g_weskerround = false
  5930. g_lastmode = MODE_TERMINATOR
  5931.  
  5932. // Choose player randomly?
  5933. if (mode == MODE_NONE)
  5934. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  5935.  
  5936. // Remember id for calling our forward later
  5937. forward_id = id
  5938.  
  5939. static iTerminator, iMaxTerminator
  5940. iMaxTerminator = 4
  5941.  
  5942. while (iTerminator < iMaxTerminator)
  5943. {
  5944. // Keep looping through all players
  5945. if (++id > g_maxplayers) id = 1
  5946.  
  5947. // Dead or already a zombie
  5948. if (!is_user_alive(id) || g_zombie[id])
  5949. continue;
  5950.  
  5951. humanme(id, 3)
  5952. iTerminator++
  5953. }
  5954.  
  5955. // Turn the rest into zombie
  5956. for (id = 1; id <= g_maxplayers; id++)
  5957. {
  5958. // Not alive
  5959. if (!is_user_alive(id))
  5960. continue;
  5961.  
  5962. // continue
  5963. if (g_terminator[id] && g_survivor[id] || g_zombie[id])
  5964. continue;
  5965.  
  5966. // Turn into a zombie
  5967. zombieme(id, 0, 1, 0)
  5968. }
  5969.  
  5970. iTerminator = 0
  5971.  
  5972. // Play terminator sound
  5973. PlaySound(sound_survivor[random_num(0, sizeof sound_survivor -1)]);
  5974.  
  5975. // Show terminator HUD notice
  5976. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  5977. ShowSyncHudMsg(0, g_MsgSync, "Modo Terminator !!!")
  5978.  
  5979. // Round start forward
  5980. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_TERMINATOR, 0);
  5981.  
  5982. }
  5983. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_DEPREDADOR) && random_num(1, get_pcvar_num(cvar_depredadorchance)) == get_pcvar_num(cvar_depredador) && iPlayersnum >= get_pcvar_num(cvar_depredadorminplayers)) || mode == MODE_DEPREDADOR)
  5984. {
  5985. // Swarm Mode
  5986. g_nemround = true
  5987. g_depredadorround = true
  5988. g_lastmode = MODE_DEPREDADOR
  5989.  
  5990. // Choose player randomly?
  5991. if (mode == MODE_NONE)
  5992. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  5993.  
  5994. // Remember id for calling our forward later
  5995. forward_id = id
  5996.  
  5997. static iDepredador, iMaxDepredador
  5998. iMaxDepredador = 4
  5999. iDepredador = 0
  6000.  
  6001. while (iDepredador < iMaxDepredador)
  6002. {
  6003. // Keep looping through all players
  6004. if (++id > g_maxplayers) id = 1
  6005.  
  6006. // Choose random guy
  6007. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6008.  
  6009. // Dead or already a zombie
  6010. if (!is_user_alive(id) || g_zombie[id])
  6011. continue;
  6012.  
  6013. zombieme(id, 0, 2, 0)
  6014. fm_set_user_health(id, get_pcvar_num(cvar_depredadorbasehp)*fnGetPlaying()*2)
  6015. iDepredador++
  6016. }
  6017.  
  6018. // Turn the remaining players into survivors
  6019. for (id = 1; id <= g_maxplayers; id++)
  6020. {
  6021. // Only those of them who aren't zombies
  6022. if (!is_user_alive(id) || g_zombie[id])
  6023. continue
  6024.  
  6025. if (g_nemesis[id] && g_depredador[id] || g_survivor[id])
  6026. continue;
  6027.  
  6028. humanme(id, 1)
  6029. fm_set_user_health(id, get_pcvar_num(cvar_survbasehp)*fnGetPlaying())
  6030. }
  6031.  
  6032. // Play terminator sound
  6033. PlaySound(sound_survivor[random_num(0, sizeof sound_survivor -1)]);
  6034.  
  6035. // Show terminator HUD notice
  6036. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6037. ShowSyncHudMsg(0, g_MsgSync, "Modo Depredador !!!")
  6038.  
  6039. // Round start forward
  6040. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_DEPREDADOR, 0);
  6041.  
  6042. }
  6043. else if ((mode == MODE_NONE && (!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)
  6044. {
  6045. // Swarm Mode
  6046. g_nemround = true
  6047. g_depredadorround = false
  6048. g_assassinround = true
  6049. g_lastmode = MODE_ASSASSIN
  6050.  
  6051. // Choose player randomly?
  6052. if (mode == MODE_NONE)
  6053. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6054.  
  6055. // Set lighting
  6056. turn_off_lights(id)
  6057.  
  6058. // Remember id for calling our forward later
  6059. forward_id = id
  6060.  
  6061. zombieme(id, 0, 3, 0)
  6062.  
  6063. // Turn the remaining players into humans
  6064. for (id = 1; id <= g_maxplayers; id++)
  6065. {
  6066. // Only those of them who aren't zombies
  6067. if (!is_user_alive(id) || g_assassin[id])
  6068. continue
  6069.  
  6070. // Remove previous tasks
  6071. remove_task(id+TASK_TEAM)
  6072.  
  6073. // Switch to CT
  6074. if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
  6075. {
  6076. fm_set_user_team(id, CS_TEAM_CT)
  6077. fm_user_team_update(id)
  6078. }
  6079. }
  6080.  
  6081. new name[33]
  6082. get_user_name(forward_id, name, 32)
  6083.  
  6084. // Show terminator HUD notice
  6085. set_hudmessage(0, 0, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6086. ShowSyncHudMsg(0, g_MsgSync, "Modo Assassin !!!", name)
  6087.  
  6088. // Round start forward
  6089. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_ASSASSIN, forward_id);
  6090.  
  6091. }
  6092. else if ((mode == MODE_NONE && (!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)
  6093. {
  6094. // Swarm Mode
  6095. g_swarmround = true
  6096. g_lastmode = MODE_SWARM
  6097.  
  6098. // Turn every T into a zombie
  6099. for (id = 1; id <= g_maxplayers; id++)
  6100. {
  6101. // Not alive
  6102. if (!is_user_alive(id))
  6103. continue;
  6104.  
  6105. // Not a Terrorist
  6106. if (fm_get_user_team(id) != CS_TEAM_T)
  6107. continue;
  6108.  
  6109. // Turn into a zombie
  6110. zombieme(id, 0, 0, 1)
  6111. }
  6112.  
  6113. // Play swarm sound
  6114. PlaySound(sound_swarm[random_num(0, sizeof sound_swarm -1)]);
  6115.  
  6116. // Show Swarm HUD notice
  6117. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6118. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SWARM")
  6119.  
  6120. // Round start forward
  6121. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SWARM, 0);
  6122. }
  6123. else if ((mode == MODE_NONE && (!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)
  6124. {
  6125. // Multi Infection Mode
  6126. g_lastmode = MODE_MULTI
  6127.  
  6128. // iMaxZombies is rounded up, in case there aren't enough players
  6129. iMaxZombies = floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil)
  6130. iZombies = 0
  6131.  
  6132. // Randomly turn iMaxZombies players into zombies
  6133. while (iZombies < iMaxZombies)
  6134. {
  6135. // Keep looping through all players
  6136. if (++id > g_maxplayers) id = 1
  6137.  
  6138. // Dead or already a zombie
  6139. if (!is_user_alive(id) || g_zombie[id])
  6140. continue;
  6141.  
  6142. // Random chance
  6143. if (random_num(0, 1))
  6144. {
  6145. // Turn into a zombie
  6146. zombieme(id, 0, 0, 1)
  6147. iZombies++
  6148. }
  6149. }
  6150.  
  6151. // Turn the remaining players into humans
  6152. for (id = 1; id <= g_maxplayers; id++)
  6153. {
  6154. // Only those of them who aren't zombies
  6155. if (!is_user_alive(id) || g_zombie[id])
  6156. continue
  6157.  
  6158. // Remove previous tasks
  6159. remove_task(id+TASK_TEAM)
  6160.  
  6161. // Switch to CT
  6162. if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
  6163. {
  6164. fm_set_user_team(id, CS_TEAM_CT)
  6165. fm_user_team_update(id)
  6166. }
  6167. }
  6168.  
  6169. // Play multi infection sound
  6170. PlaySound(sound_multi[random_num(0, sizeof sound_multi -1)]);
  6171.  
  6172. // Show Multi Infection HUD notice
  6173. set_hudmessage(200, 50, 0, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6174. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_MULTI")
  6175.  
  6176. // Round start forward
  6177. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_MULTI, 0);
  6178. }
  6179. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_SYNAPSIS) && random_num(1, get_pcvar_num(cvar_synapsischance)) == get_pcvar_num(cvar_synapsis) && floatround((iPlayersnum-2)*get_pcvar_float(cvar_synapsisratio), floatround_ceil) >= 1 && iPlayersnum >= get_pcvar_num(cvar_synapsisminplayers)) || mode == MODE_SYNAPSIS)
  6180. {
  6181. static iNemesis, iSurvivor, iMaxNemesis, iMaxSurvivor
  6182. iMaxNemesis = 7
  6183. iMaxSurvivor = 3
  6184.  
  6185. g_synapsisround = true
  6186. g_plagueround = true
  6187. g_lastmode = MODE_SYNAPSIS
  6188.  
  6189. while (iSurvivor < iMaxSurvivor)
  6190. {
  6191. // Keep looping through all players
  6192. if (++id > g_maxplayers) id = 1
  6193.  
  6194. // Choose random guy
  6195. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6196.  
  6197. // Continue
  6198. if (g_survivor[id] || g_nemesis[id])
  6199. continue;
  6200.  
  6201. // Not alive
  6202. if (!is_user_alive(id))
  6203. continue;
  6204.  
  6205. humanme(id, 1)
  6206.  
  6207. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguesurvhpmulti)))
  6208. iSurvivor++
  6209. }
  6210.  
  6211. while (iNemesis < iMaxNemesis)
  6212. {
  6213. // Keep looping through all players
  6214. if (++id > g_maxplayers) id = 1
  6215.  
  6216. // Choose random guy
  6217. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6218.  
  6219. // Continue
  6220. if (g_survivor[id] || g_nemesis[id])
  6221. continue;
  6222.  
  6223. // Not alive
  6224. if (!is_user_alive(id))
  6225. continue;
  6226.  
  6227. zombieme(id, 0, 1, 0)
  6228.  
  6229. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguenemhpmulti)) * 3)
  6230. iNemesis++
  6231. }
  6232.  
  6233. // Finish
  6234. for (id = 1; id <= g_maxplayers; id++)
  6235. {
  6236. // Only those of them who arent zombies or survivor
  6237. if (!is_user_alive(id) || g_nemesis[id] )
  6238. continue
  6239.  
  6240. // Remove previous tasks
  6241. remove_task(id+TASK_TEAM)
  6242. fm_set_user_team(id, CS_TEAM_CT)
  6243. set_task(0.1+g_teams_i, "fm_set_user_team_msg", id+TASK_TEAM)
  6244. g_teams_i += 0.1; // increase teams task counter
  6245. }
  6246.  
  6247. // Show hud message
  6248. set_hudmessage(0, 0, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6249. ShowSyncHudMsg(0, g_MsgSync, "Modo Synapsis !!!")
  6250. iSurvivor = 0
  6251. iNemesis = 0
  6252.  
  6253. // Round start forward
  6254. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SYNAPSIS, 0);
  6255. }
  6256. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_INVASION) && random_num(1, get_pcvar_num(cvar_invasionchance)) == get_pcvar_num(cvar_invasion) && iPlayersnum >= get_pcvar_num(cvar_invasionminplayers)) || mode == MODE_INVASION)
  6257. {
  6258. new iMaxAssassin, iAssassin
  6259.  
  6260. // Invasion Mode
  6261. g_invasionround = true
  6262. g_plagueround = true
  6263. g_lastmode = MODE_INVASION
  6264.  
  6265. // iMaxAssassin is rounded up, in case there aren't enough players
  6266. iMaxAssassin = floatround((iPlayersnum * 0.5), floatround_ceil)
  6267. iAssassin = 0
  6268.  
  6269. // Randomly turn iMaxZombies players into depredators
  6270. while (iAssassin < iMaxAssassin)
  6271. {
  6272. // Keep looping through all players
  6273. if (++id > g_maxplayers) id = 1
  6274.  
  6275. // Choose random guy
  6276. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6277.  
  6278. // Dead or already a zombie or survivor
  6279. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6280. continue;
  6281.  
  6282. // Turn into a Assassin
  6283. zombieme(id, 0, 3, 0)
  6284. fm_set_user_health(id, get_pcvar_num(cvar_assassinbasehp)*fnGetPlaying()*2)
  6285. iAssassin++
  6286. }
  6287.  
  6288. // Turn the remaining players into Terminators
  6289. for (id = 1; id <= g_maxplayers; id++)
  6290. {
  6291. // Only those of them who arent zombies or survivor
  6292. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6293. continue;
  6294.  
  6295. // Turn into a Terminators
  6296. humanme(id, 3)
  6297. fm_set_user_health(id, get_pcvar_num(cvar_terminator_basehp)*fnGetPlaying())
  6298. }
  6299.  
  6300. // Play apocalypsis sound
  6301. PlaySound(sound_armageddon[random_num(0, sizeof sound_armageddon -1)])
  6302.  
  6303. // Show Swarm HUD notice
  6304. set_hudmessage(255, 30, 40, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6305. ShowSyncHudMsg(0, g_MsgSync, "Modo Invasion !!!")
  6306.  
  6307.  
  6308. // Round start forward
  6309. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_INVASION, 0);
  6310. }
  6311. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_APOCALYPSIS) && random_num(1, get_pcvar_num(cvar_apocalypsischance)) == get_pcvar_num(cvar_apocalypsis) && iPlayersnum >= get_pcvar_num(cvar_apocalypsisminplayers)) || mode == MODE_APOCALYPSIS)
  6312. {
  6313. new iMaxDepredators, iDepredators
  6314.  
  6315. // Apocalypsis Mode
  6316. g_apocalypsisround = true
  6317. g_plagueround = true
  6318. g_lastmode = MODE_APOCALYPSIS
  6319.  
  6320. // iMaxDepredators is rounded up, in case there aren't enough players
  6321. iMaxDepredators = floatround((iPlayersnum * 0.5), floatround_ceil)
  6322. iDepredators = 0
  6323.  
  6324. // Randomly turn iMaxZombies players into depredators
  6325. while (iDepredators < iMaxDepredators)
  6326. {
  6327. // Keep looping through all players
  6328. if (++id > g_maxplayers) id = 1
  6329.  
  6330. // Choose random guy
  6331. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6332.  
  6333. // Dead or already a zombie or survivor
  6334. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6335. continue;
  6336.  
  6337. // Turn into a Depredator
  6338. zombieme(id, 0, 2, 0)
  6339. fm_set_user_health(id, get_pcvar_num(cvar_depredadorbasehp)*fnGetPlaying() *2)
  6340. iDepredators++
  6341. }
  6342.  
  6343. // Turn the remaining players into wesker
  6344. for (id = 1; id <= g_maxplayers; id++)
  6345. {
  6346. // Only those of them who arent zombies or survivor
  6347. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6348. continue;
  6349.  
  6350. // Turn into a Wesker
  6351. humanme(id, 2)
  6352. fm_set_user_health(id, get_pcvar_num(cvar_weskerhp)*fnGetPlaying())
  6353. }
  6354.  
  6355. // Play apocalypsis sound
  6356. PlaySound(sound_apocalypsis[random_num(0, sizeof sound_apocalypsis -1)])
  6357.  
  6358. // Show Swarm HUD notice
  6359. set_hudmessage(255, 100, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6360. ShowSyncHudMsg(0, g_MsgSync, "Modo Apocalypsis !!!")
  6361.  
  6362.  
  6363. // Round start forward
  6364. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_APOCALYPSIS, 0);
  6365. }
  6366. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_REVELACION) && random_num(1, get_pcvar_num(cvar_revelacionchance)) == get_pcvar_num(cvar_revelacion) && iPlayersnum >= get_pcvar_num(cvar_revelacionminplayers)) || mode == MODE_REVELACION)
  6367. {
  6368. new iMaxDepredador, iDepredador, iMaxWesker, iWesker, iAssassin, iMaxAssassin
  6369.  
  6370. // Revelacion Mode
  6371. g_revelacionround = true
  6372. g_plagueround = true
  6373. g_lastmode = MODE_REVELACION
  6374.  
  6375. if (!g_revelacionround)
  6376. return;
  6377.  
  6378. iMaxDepredador = floatround((iPlayersnum * 0.25), floatround_ceil)
  6379. iDepredador = 0
  6380.  
  6381. while (iDepredador < iMaxDepredador)
  6382. {
  6383. // Keep looping through all players
  6384. if (++id > g_maxplayers) id = 1
  6385.  
  6386. // Choose random guy
  6387. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6388.  
  6389. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6390. continue;
  6391.  
  6392. zombieme(id, 0, 2, 0)
  6393. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_depredadorbasehp)) * 12)
  6394. iDepredador++
  6395. }
  6396.  
  6397. iMaxAssassin = floatround((iPlayersnum * 0.25), floatround_ceil)
  6398. iAssassin = 0
  6399.  
  6400. while (iAssassin < iMaxAssassin)
  6401. {
  6402. // Keep looping through all players
  6403. if (++id > g_maxplayers) id = 1
  6404.  
  6405. // Choose random guy
  6406. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6407.  
  6408. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6409. continue;
  6410.  
  6411. zombieme(id, 0, 3, 0)
  6412. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_assassinbasehp)) * 14)
  6413. iAssassin++
  6414. }
  6415.  
  6416. iMaxWesker = floatround((iPlayersnum * 0.25), floatround_ceil)
  6417. iWesker = 0
  6418.  
  6419. while (iWesker < iMaxWesker)
  6420. {
  6421. // Keep looping through all players
  6422. if (++id > g_maxplayers) id = 1
  6423.  
  6424. // Choose random guy
  6425. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6426.  
  6427. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6428. continue;
  6429.  
  6430. humanme(id, 2)
  6431. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_weskerhp)) * 8)
  6432. iWesker++
  6433. }
  6434.  
  6435. for (id = 1; id <= g_maxplayers; id++)
  6436. {
  6437. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6438. continue;
  6439.  
  6440. humanme(id, 3)
  6441. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_terminator_basehp)) * 6)
  6442. }
  6443.  
  6444. PlaySound(sound_armageddon[random_num(0, sizeof sound_armageddon -1)])
  6445.  
  6446. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6447. ShowSyncHudMsg(0, g_MsgSync, "Modo Revelacion !!!")
  6448.  
  6449. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_REVELACION, 0);
  6450. }
  6451. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_ARMAGEDDON) && random_num(1, get_pcvar_num(cvar_armagedonchance)) == get_pcvar_num(cvar_armagedon) && floatround((iPlayersnum-2)*get_pcvar_float(cvar_armagedonratio), floatround_ceil) >= 1 && iPlayersnum >= get_pcvar_num(cvar_armagedonminplayers)) || mode == MODE_ARMAGEDDON)
  6452. {
  6453. new iMaxZombies, iZombies
  6454.  
  6455. // Armageddon Mode
  6456. g_armageddonround = true
  6457. g_plagueround = true
  6458. g_lastmode = MODE_ARMAGEDDON
  6459.  
  6460. // iMaxZombies is rounded up, in case there aren't enough players
  6461. iMaxZombies = floatround((iPlayersnum * 0.5), floatround_ceil)
  6462. iZombies = 0
  6463.  
  6464. // Randomly turn iMaxZombies players into Nemesis
  6465. while (iZombies < iMaxZombies)
  6466. {
  6467. // Keep looping through all players
  6468. if (++id > g_maxplayers) id = 1
  6469.  
  6470. // Choose random guy
  6471. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6472.  
  6473. // Dead or already a zombie or survivor
  6474. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6475. continue;
  6476.  
  6477. // Turn into a Nemesis
  6478. zombieme(id, 0, 1, 0)
  6479. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguenemhpmulti)) * 3)
  6480. iZombies++
  6481. }
  6482.  
  6483. // Turn the remaining players into survivors
  6484. for (id = 1; id <= g_maxplayers; id++)
  6485. {
  6486. // Only those of them who arent zombies or survivor
  6487. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6488. continue;
  6489.  
  6490. // Turn into a Survivor
  6491. humanme(id, 1)
  6492. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguesurvhpmulti)))
  6493. }
  6494.  
  6495. // Play plague sound
  6496. PlaySound(sound_armageddon[random_num(0, sizeof sound_armageddon -1)])
  6497.  
  6498. // Show Swarm HUD notice
  6499. set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6500. ShowSyncHudMsg(0, g_MsgSync, "Modo Armageddon !!!")
  6501.  
  6502.  
  6503. // Round start forward
  6504. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_ARMAGEDDON, 0);
  6505. }
  6506. else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_WESKER) && random_num(1, get_pcvar_num(cvar_weskerchance)) == get_pcvar_num(cvar_wesker) && iPlayersnum >= get_pcvar_num(cvar_weskerminplayers)) || mode == MODE_WESKER)
  6507. {
  6508. // wesker Mode
  6509. g_survround = true
  6510. g_weskerround = true
  6511. g_lastmode = MODE_WESKER
  6512.  
  6513. // Choose player randomly?
  6514. if (mode == MODE_NONE)
  6515. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6516.  
  6517. // Remember id for calling our forward later
  6518. forward_id = id
  6519.  
  6520. humanme(id, 2)
  6521.  
  6522. // Turn the rest of players into a zombie
  6523. for (id = 1; id <= g_maxplayers; id++)
  6524. {
  6525. // Not alive
  6526. if (!is_user_alive(id))
  6527. continue;
  6528.  
  6529. // Survivor or already a zombie
  6530. if (g_survivor[id] || g_zombie[id])
  6531. continue;
  6532.  
  6533. // Turn into a zombie
  6534. zombieme(id, 0, 0, 1)
  6535. }
  6536.  
  6537. // Play swarm sound
  6538. PlaySound(sound_survivor[random_num(0, sizeof sound_survivor -1)]);
  6539.  
  6540. // Get player's name
  6541. get_user_name(forward_id, name, sizeof name - 1)
  6542.  
  6543. // Show wesker HUD notice
  6544. set_hudmessage(185, 135, 15, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6545. ShowSyncHudMsg(0, g_MsgSync, "%s is Wesker !!!", name)
  6546.  
  6547. // Round start forward
  6548. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_WESKER, forward_id);
  6549. }
  6550. else if ((mode == MODE_NONE && (!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
  6551. && 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)
  6552. {
  6553. // Plague Mode
  6554. g_plagueround = true
  6555. g_lastmode = MODE_PLAGUE
  6556.  
  6557. // Turn specified amount of players into Survivors
  6558. static iSurvivors, iMaxSurvivors
  6559. iMaxSurvivors = get_pcvar_num(cvar_plaguesurvnum)
  6560. iSurvivors = 0
  6561.  
  6562. while (iSurvivors < iMaxSurvivors)
  6563. {
  6564. // Choose random guy
  6565. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6566.  
  6567. // Already a survivor?
  6568. if (g_survivor[id])
  6569. continue;
  6570.  
  6571. // If not, turn him into one
  6572. humanme(id, 1)
  6573. iSurvivors++
  6574.  
  6575. // Apply survivor health multiplier
  6576. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguesurvhpmulti)))
  6577. }
  6578.  
  6579. // Turn specified amount of players into Nemesis
  6580. static iNemesis, iMaxNemesis
  6581. iMaxNemesis = get_pcvar_num(cvar_plaguenemnum)
  6582. iNemesis = 0
  6583.  
  6584. while (iNemesis < iMaxNemesis)
  6585. {
  6586. // Choose random guy
  6587. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6588.  
  6589. // Already a survivor or nemesis?
  6590. if (g_survivor[id] || g_nemesis[id])
  6591. continue;
  6592.  
  6593. // If not, turn him into one
  6594. zombieme(id, 0, 1, 0)
  6595. iNemesis++
  6596.  
  6597. // Apply nemesis health multiplier
  6598. fm_set_user_health(id, floatround(pev(id, pev_health)*get_pcvar_float(cvar_plaguenemhpmulti)))
  6599. }
  6600.  
  6601. // iMaxZombies is rounded up, in case there aren't enough players
  6602. iMaxZombies = floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)
  6603. iZombies = 0
  6604.  
  6605. // Randomly turn iMaxZombies players into zombies
  6606. while (iZombies < iMaxZombies)
  6607. {
  6608. // Keep looping through all players
  6609. if (++id > g_maxplayers) id = 1
  6610.  
  6611. // Dead or already a zombie or survivor
  6612. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6613. continue;
  6614.  
  6615. // Random chance
  6616. if (random_num(0, 1))
  6617. {
  6618. // Turn into a zombie
  6619. zombieme(id, 0, 0, 1)
  6620. iZombies++
  6621. }
  6622. }
  6623.  
  6624. // Turn the remaining players into humans
  6625. for (id = 1; id <= g_maxplayers; id++)
  6626. {
  6627. // Only those of them who arent zombies or survivor
  6628. if (!is_user_alive(id) || g_zombie[id] || g_survivor[id])
  6629. continue;
  6630.  
  6631. // Remove previous tasks
  6632. remove_task(id+TASK_TEAM)
  6633.  
  6634. // Switch to CT
  6635. if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
  6636. {
  6637. fm_set_user_team(id, CS_TEAM_CT)
  6638. fm_user_team_update(id)
  6639. }
  6640. }
  6641.  
  6642. // Play plague sound
  6643. PlaySound(sound_plague[random_num(0, sizeof sound_plague -1)]);
  6644.  
  6645. // Show Plague HUD notice
  6646. set_hudmessage(0, 50, 200, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6647. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_PLAGUE")
  6648.  
  6649. // Round start forward
  6650. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_PLAGUE, 0);
  6651. }
  6652. else
  6653. {
  6654. // Single Infection Mode or Nemesis Mode
  6655.  
  6656. // Choose player randomly?
  6657. if (mode == MODE_NONE)
  6658. id = fnGetRandomAlive(random_num(1, iPlayersnum))
  6659.  
  6660. // Remember id for calling our forward later
  6661. forward_id = id
  6662.  
  6663. if ((mode == MODE_NONE && (!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)
  6664. {
  6665. // Nemesis Mode
  6666. g_nemround = true
  6667. g_lastmode = MODE_NEMESIS
  6668.  
  6669. // Turn player into nemesis
  6670. zombieme(id, 0, 1, 0)
  6671. }
  6672. else
  6673. {
  6674. // Single Infection Mode
  6675. g_lastmode = MODE_INFECTION
  6676.  
  6677. // Turn player into the first zombie
  6678. zombieme(id, 0, 0, 0)
  6679. }
  6680.  
  6681. // Remaining players should be humans (CTs)
  6682. for (id = 1; id <= g_maxplayers; id++)
  6683. {
  6684. // Not alive
  6685. if (!is_user_alive(id))
  6686. continue;
  6687.  
  6688. // First zombie/nemesis
  6689. if (g_zombie[id])
  6690. continue;
  6691.  
  6692. // Remove previous tasks
  6693. remove_task(id+TASK_TEAM)
  6694.  
  6695. // Switch to CT
  6696. if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
  6697. {
  6698. fm_set_user_team(id, CS_TEAM_CT)
  6699. fm_user_team_update(id)
  6700. }
  6701. }
  6702.  
  6703. if (g_nemround)
  6704. {
  6705. // Play Nemesis sound
  6706. PlaySound(sound_nemesis[random_num(0, sizeof sound_nemesis -1)]);
  6707.  
  6708. // Get player's name
  6709. get_user_name(forward_id, name, sizeof name - 1)
  6710.  
  6711. // Show Nemesis HUD notice
  6712. set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
  6713. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_NEMESIS", name)
  6714.  
  6715. // Round start forward
  6716. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_NEMESIS, forward_id);
  6717. }
  6718. else
  6719. {
  6720. // Get player's name
  6721. get_user_name(forward_id, name, sizeof name - 1)
  6722.  
  6723. // Show First Zombie HUD notice
  6724. set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  6725. ShowSyncHudMsg(0, g_MsgSync, "%L",LANG_PLAYER, "NOTICE_FIRST", name)
  6726.  
  6727. // Round start forward
  6728. ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_INFECTION, forward_id);
  6729. }
  6730. }
  6731.  
  6732. // Last Zombie Check
  6733. set_task(0.1, "fnCheckLastZombie")
  6734. }
  6735.  
  6736. public turn_off_lights(id)
  6737. {
  6738. if (g_assassinround)
  6739. {
  6740. engfunc(EngFunc_LightStyle, 0, "a")
  6741. set_task(0.1, "turn_off_lights", id)
  6742. }
  6743. }
  6744.  
  6745. // Zombie Me Function (player id, infector, turn into a nemesis, special mode)
  6746. zombieme(id, infector, nemesis, specialmode)
  6747. {
  6748. // Pre user infect forward
  6749. ExecuteForward(g_fwUserInfected_pre, g_fwDummyResult, id, infector)
  6750.  
  6751. // Show zombie class menu if they haven't chosen any (e.g. just connected)
  6752. if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
  6753. set_task(2.0, "show_menu_zclass", id)
  6754.  
  6755. // Set selected zombie class
  6756. g_zombieclass[id] = g_zombieclassnext[id]
  6757. // If no class selected yet, use the first (default) one
  6758. if (g_zombieclass[id] == ZCLASS_NONE) g_zombieclass[id] = 0
  6759.  
  6760. // Way to go...
  6761. g_zombie[id] = true
  6762. g_survivor[id] = false
  6763.  
  6764. // Set zombie attributes based on the mode
  6765. if (!specialmode)
  6766. {
  6767. switch (nemesis)
  6768. {
  6769. case 0:
  6770. {
  6771. if (fnGetZombies() == 1)
  6772. {
  6773.  
  6774. // First zombie
  6775. g_firstzombie[id] = true
  6776.  
  6777. // Set health and gravity
  6778. fm_set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp)) * (ammount_zhealth(g_skill_points[id][1][1]) + 1))
  6779. set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_skill_points[id][1][3]))
  6780.  
  6781. give_item(id, "weapon_hegrenade")
  6782.  
  6783. // Infection sound
  6784. engfunc(EngFunc_EmitSound, id, CHAN_VOICE, zombie_infect[random_num(0, sizeof zombie_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  6785. }
  6786. else
  6787. {
  6788.  
  6789. // Infected by someone
  6790.  
  6791. // Set health and gravity
  6792. fm_set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp)) * (ammount_zhealth(g_skill_points[id][1][1]) + 1))
  6793. set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] - ammount_zgravity(g_skill_points[id][1][3]))
  6794.  
  6795. // Infection sound
  6796. engfunc(EngFunc_EmitSound, id, CHAN_VOICE, zombie_infect[random_num(0, sizeof zombie_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  6797.  
  6798. // Get player's name
  6799. static name[32]
  6800. get_user_name(id, name, sizeof name - 1)
  6801.  
  6802. // Show Infection HUD notice
  6803. set_hudmessage(255, 0, 0, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  6804.  
  6805. if (infector) // infected by someone?
  6806. {
  6807. static name2[32]
  6808. get_user_name(infector, name2, sizeof name2 - 1)
  6809. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT2", name, name2)
  6810. }
  6811.  
  6812. else ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_INFECT", name)
  6813. }
  6814. }
  6815. case 1:
  6816. {
  6817. // Nemesis
  6818. g_nemesis[id] = true
  6819. g_assassin[id] = false
  6820. g_depredador[id] = false
  6821.  
  6822. // Get nemesis health setting
  6823. static nembasehealth
  6824. nembasehealth = get_pcvar_num(cvar_nembasehp)
  6825.  
  6826. // Set health [0 = auto]
  6827. fm_set_user_health(id, nembasehealth*fnGetAlive())
  6828.  
  6829. // Set gravity
  6830. set_pev(id, pev_gravity, get_pcvar_float(cvar_nemgravity))
  6831. }
  6832. case 2:
  6833. {
  6834. // Depredador
  6835. g_nemesis[id] = true
  6836. g_depredador[id] = true
  6837. g_assassin[id] = false
  6838.  
  6839. // Get depredador health setting
  6840. static depredadorbasehealth
  6841. depredadorbasehealth = get_pcvar_num(cvar_depredadorbasehp)
  6842.  
  6843. // Set health [0 = auto]
  6844. fm_set_user_health(id, depredadorbasehealth*fnGetAlive())
  6845.  
  6846. // Set gravity
  6847. set_pev(id, pev_gravity, get_pcvar_float(cvar_depredadorgravity))
  6848. }
  6849. case 3:
  6850. {
  6851. // Assassin
  6852. g_nemesis[id] = true
  6853. g_depredador[id] = false
  6854. g_assassin[id] = true
  6855.  
  6856. // Get depredador health setting
  6857. static assassinbasehp
  6858. assassinbasehp = get_pcvar_num(cvar_assassinbasehp)
  6859.  
  6860. // Set health [0 = auto]
  6861. fm_set_user_health(id, assassinbasehp*fnGetAlive())
  6862.  
  6863. // Set gravity
  6864. set_pev(id, pev_gravity, get_pcvar_float(cvar_assassingravity))
  6865. }
  6866. }
  6867. }
  6868. else
  6869. {
  6870. // Survivor/multi infection/swarm/plague/infection grenade
  6871.  
  6872. // Set health and gravity
  6873. fm_set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp)) + ammount_zhealth(g_skill_points[id][1][1]))
  6874. set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] * ammount_gravity(g_skill_points[id][1][3]))
  6875. }
  6876.  
  6877. // Remove previous tasks
  6878. remove_task(id+TASK_TEAM)
  6879. remove_task(id+TASK_MODEL)
  6880. remove_task(id+TASK_BLOOD)
  6881.  
  6882. // Switch to T
  6883. if (fm_get_user_team(id) != CS_TEAM_T) // need to change team?
  6884. {
  6885. fm_set_user_team(id, CS_TEAM_T)
  6886. fm_user_team_update(id)
  6887. }
  6888.  
  6889. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  6890.  
  6891. // Set the right model
  6892. if (g_nemesis[id] && !g_depredador[id] && !g_assassin[id])
  6893. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_nemesis[random_num(0, sizeof model_nemesis -1)])
  6894. else if (g_nemesis[id] && g_depredador[id])
  6895. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_depredador[random_num(0, sizeof model_depredador -1)])
  6896. else if (g_nemesis[id] && !g_depredador[id] && g_assassin[id])
  6897. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_assassin[random_num(0, sizeof model_assassin -1)])
  6898. else
  6899. {
  6900. if (get_pcvar_num(cvar_adminmodelszombie) && get_user_flags(id) & ACCESS_FLAG3)
  6901. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin_zombie[random_num(0, sizeof model_admin_zombie -1)])
  6902. else
  6903. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_zclass_model[g_zombieclass[id]])
  6904. }
  6905.  
  6906. // Set model on player model entity
  6907. fm_set_playermodel_ent(id)
  6908.  
  6909. // Nemesis glow / remove glow on player model entity
  6910. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow) && !g_depredador[id] && !g_assassin[id])
  6911. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  6912. else if (g_nemesis[id] && g_depredador[id])
  6913. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25)
  6914. else if (g_nemesis[id] && !g_depredador[id] && g_assassin[id])
  6915. fm_set_rendering(g_ent_playermodel[id])
  6916. else
  6917. fm_set_rendering(g_ent_playermodel[id])
  6918.  
  6919. #else
  6920.  
  6921. // Set the right model, after checking that we don't already have it
  6922. static currentmodel[32], already_has_model, i, iRand
  6923. already_has_model = false
  6924.  
  6925. // Get current model and compare it with current one
  6926. fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
  6927.  
  6928. if (g_nemesis[id] && !g_depredador[id] && !g_assassin[id])
  6929. {
  6930. for (i = 0; i < sizeof model_nemesis; i++)
  6931. if (equal(model_nemesis[i], currentmodel)) already_has_model = true;
  6932.  
  6933. if (!already_has_model)
  6934. {
  6935. iRand = random_num(0, sizeof model_nemesis -1)
  6936. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_nemesis[iRand])
  6937. #if defined SET_MODELINDEX_OFFSET
  6938. fm_set_user_model_index(id, g_modelindex_nemesis[iRand])
  6939. #endif
  6940. }
  6941. }
  6942. else if (g_nemesis[id] && g_depredador[id])
  6943. {
  6944. for (i = 0; i < sizeof model_depredador; i++)
  6945. if (equal(model_nemesis[i], currentmodel)) already_has_model = true;
  6946.  
  6947. if (!already_has_model)
  6948. {
  6949. iRand = random_num(0, sizeof model_depredador -1)
  6950. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_depredador[iRand])
  6951. #if defined SET_MODELINDEX_OFFSET
  6952. fm_set_user_model_index(id, g_modelindex_depredador[iRand])
  6953. #endif
  6954. }
  6955. }
  6956. else if (g_nemesis[id] && g_assassin[id])
  6957. {
  6958. for (i = 0; i < sizeof model_assassin; i++)
  6959. if (equal(model_assassin[i], currentmodel)) already_has_model = true;
  6960.  
  6961. if (!already_has_model)
  6962. {
  6963. iRand = random_num(0, sizeof model_assassin -1)
  6964. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_assassin[iRand])
  6965. #if defined SET_MODELINDEX_OFFSET
  6966. fm_set_user_model_index(id, g_modelindex_assassin[iRand])
  6967. #endif
  6968. }
  6969. }
  6970. else
  6971. {
  6972. if (get_pcvar_num(cvar_adminmodelszombie) && get_user_flags(id) & ACCESS_FLAG3)
  6973. {
  6974. for (i = 0; i < sizeof model_admin_zombie; i++)
  6975. if (equal(model_admin_zombie[i], currentmodel)) already_has_model = true;
  6976.  
  6977. if (!already_has_model)
  6978. {
  6979. iRand = random_num(0, sizeof model_admin_zombie -1)
  6980. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin_zombie[iRand])
  6981. #if defined SET_MODELINDEX_OFFSET
  6982. fm_set_user_model_index(id, g_modelindex_admin_zombie[iRand])
  6983. #endif
  6984. }
  6985. }
  6986. else
  6987. {
  6988. if (equal(g_zclass_model[g_zombieclass[id]], currentmodel)) already_has_model = true;
  6989.  
  6990. if (!already_has_model)
  6991. {
  6992. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_zclass_model[g_zombieclass[id]])
  6993. #if defined SET_MODELINDEX_OFFSET
  6994. fm_set_user_model_index(id, g_zclass_modelindex[g_zombieclass[id]])
  6995. #endif
  6996. }
  6997. }
  6998. }
  6999.  
  7000. // Need to change the model?
  7001. if (!already_has_model)
  7002. {
  7003. // An additional delay is offset at round start
  7004. // since SVC_BAD is more likely to be triggered there
  7005. if (g_newround)
  7006. set_task(5.0*MODELCHANGE_DELAY, "fm_user_model_update", id+TASK_MODEL)
  7007. else
  7008. fm_user_model_update(id+TASK_MODEL)
  7009. }
  7010.  
  7011. // Nemesis glow / remove glow
  7012. if (g_nemesis[id] && get_pcvar_num(cvar_nemglow) && !g_depredador[id] && !g_assassin[id])
  7013. fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 25)
  7014. else if (g_nemesis[id] && g_depredador[id])
  7015. fm_set_rendering(id, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25)
  7016. else if (g_nemesis[id] && !g_depredador[id] && g_assassin[id])
  7017. fm_set_rendering(id)
  7018. else
  7019. fm_set_rendering(id)
  7020.  
  7021. #endif
  7022.  
  7023. // Remove any zoom (bugfix)
  7024. fm_remove_user_zoom(id)
  7025.  
  7026. // Remove armor
  7027. set_pev(id, pev_armorvalue, 0.0)
  7028.  
  7029. // Drop weapons when infected
  7030. drop_weapons(id, 1)
  7031. drop_weapons(id, 2)
  7032.  
  7033. // Strip zombies from guns and give them a knife
  7034. fm_strip_user_weapons(id)
  7035. fm_give_item(id, "weapon_knife")
  7036.  
  7037. // Fancy effects
  7038. infection_effects(id)
  7039.  
  7040. // Nemesis aura task
  7041. if (g_nemesis[id] && get_pcvar_num(cvar_nemaura) && !g_assassin[id])
  7042. zombie_aura(id+TASK_BLOOD)
  7043.  
  7044. // Get nightvision give setting
  7045. static nvggive
  7046. nvggive = get_pcvar_num(cvar_nvggive)
  7047.  
  7048. // Give Zombies Night Vision?
  7049. if (nvggive)
  7050. {
  7051. if (!is_user_bot(id))
  7052. {
  7053. g_nvision[id] = true
  7054.  
  7055. // Turn on Night Vision automatically?
  7056. if (nvggive == 1)
  7057. {
  7058. g_nvisionenabled[id] = true
  7059.  
  7060. // Custom nvg?
  7061. if (get_pcvar_num(cvar_cnvg))
  7062. {
  7063. remove_task(id+TASK_NVISION)
  7064. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  7065. }
  7066. else
  7067. set_user_gnvision(id, 1)
  7068. }
  7069. // Turn off nightvision when infected (bugfix)
  7070. else if (g_nvisionenabled[id])
  7071. {
  7072. if (!get_pcvar_num(cvar_cnvg)) set_user_gnvision(id, 0)
  7073. g_nvisionenabled[id] = false
  7074. }
  7075. }
  7076. else
  7077. fm_set_bot_nvg(id, 1); // turn on NVG for bots
  7078. }
  7079. // Disable nightvision when infected (bugfix)
  7080. else if (g_nvision[id])
  7081. {
  7082. if (g_nvisionenabled[id] && !get_pcvar_num(cvar_cnvg)) set_user_gnvision(id, 0)
  7083. g_nvision[id] = false
  7084. g_nvisionenabled[id] = false
  7085. }
  7086.  
  7087. // Get FOV setting
  7088. static fov
  7089. fov = get_pcvar_num(cvar_zombiefov)
  7090.  
  7091. // Set custom FOV?
  7092. if (fov != 90 && fov != 0)
  7093. {
  7094. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  7095. write_byte(fov) // angle
  7096. message_end()
  7097. }
  7098.  
  7099. // Call the bloody task
  7100. if (!g_nemesis[id] && get_pcvar_num(cvar_zombiebleeding))
  7101. set_task(0.7, "make_blood", id+TASK_BLOOD, _, _, "b")
  7102.  
  7103. // Idle sounds task
  7104. if (!g_nemesis[id])
  7105. set_task(random_float(50.0, 70.0), "zombie_play_idle", id+TASK_BLOOD, _, _, "b")
  7106.  
  7107. // Turn off zombie's flashlight
  7108. turn_off_flashlight(id)
  7109.  
  7110. // Remove survivor's aura (bugfix)
  7111. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  7112.  
  7113. // Remove spawn protection (bugfix)
  7114. g_nodamage[id] = false
  7115. set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  7116.  
  7117. // Post user infect forward
  7118. ExecuteForward(g_fwUserInfected_post, g_fwDummyResult, id, infector)
  7119.  
  7120. // Last Zombie Check
  7121. set_task(0.1, "fnCheckLastZombie")
  7122. }
  7123.  
  7124. // Function Human Me (player id, turn into a survivor)
  7125. humanme(id, survivor)
  7126. {
  7127. // Pre user humanize forward
  7128. ExecuteForward(g_fwUserHumanized_pre, g_fwDummyResult, id)
  7129.  
  7130. // Show human class menu if they haven't chosen any (e.g. just connected)
  7131. if (g_humanclassnext[id] == HCLASS_NONE && get_pcvar_num(cvar_hclasses))
  7132. set_task(2.0, "show_menu_hclass", id)
  7133.  
  7134. // Set selected zombie class
  7135. g_humanclass[id] = g_humanclassnext[id]
  7136. // If no class selected yet, use the first (default) one
  7137. if (g_humanclass[id] == HCLASS_NONE) g_humanclass[id] = 0
  7138.  
  7139. // Reset some vars
  7140. g_zombie[id] = false
  7141. g_nemesis[id] = false
  7142. g_firstzombie[id] = false
  7143. g_nodamage[id] = false
  7144. g_canbuy[id] = true
  7145. g_nvision[id] = false
  7146. g_nvisionenabled[id] = false
  7147.  
  7148. // Set human attributes based on the mode
  7149. switch (survivor)
  7150. {
  7151. case 0:
  7152. {
  7153. // Human taking an antidote
  7154.  
  7155. // Set health
  7156. fm_set_user_health(id, g_hclass_hp[g_humanclass[id]] + ammount_health(g_skill_points[id][0][1]))
  7157. set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] - ammount_gravity(g_skill_points[id][0][4]))
  7158. set_user_armor(id, g_hclass_armor[g_humanclass[id]] + ammount_armor(g_skill_points[id][0][3]))
  7159.  
  7160. // Set gravity, unless frozen
  7161. if (!g_frozen[id]) set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]] + ammount_gravity(g_skill_points[id][0][4]))
  7162.  
  7163. // Strip off from weapons
  7164. fm_strip_user_weapons(id)
  7165. fm_give_item(id, "weapon_knife")
  7166.  
  7167. // Show custom buy menu?
  7168. if (get_pcvar_num(cvar_buycustom))
  7169. set_task(0.4, "show_menu_buy1", id+TASK_SPAWN)
  7170.  
  7171. // Antidote sound
  7172. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, sound_antidote[random_num(0, sizeof sound_antidote - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  7173.  
  7174. // Get player's name
  7175. static name[32]
  7176. get_user_name(id, name, sizeof name - 1)
  7177.  
  7178. // Show Antidote HUD notice
  7179. set_hudmessage(0, 0, 255, HUD_INFECT_X, HUD_INFECT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
  7180. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_ANTIDOTE", name)
  7181. }
  7182. case 1:
  7183. {
  7184. // Survivor
  7185. g_survivor[id] = true
  7186. g_wesker[id] = false
  7187. g_terminator[id] = false
  7188.  
  7189. // Get survivor health setting
  7190. static survbasehealth
  7191. survbasehealth = get_pcvar_num(cvar_survbasehp)
  7192.  
  7193. // Set Health [0 = auto]
  7194. fm_set_user_health(id, survbasehealth*fnGetAlive())
  7195.  
  7196. // Set Gravity
  7197. set_pev(id, pev_gravity, get_pcvar_float(cvar_survgravity))
  7198.  
  7199. // Get survivor's weapon setting
  7200. static survweapon[32]
  7201. get_pcvar_string(cvar_survweapon, survweapon, sizeof survweapon - 1)
  7202.  
  7203. // Strip survivor from weapons and give him his own
  7204. fm_strip_user_weapons(id)
  7205. fm_give_item(id, "weapon_knife")
  7206. fm_give_item(id, survweapon)
  7207.  
  7208. // Turn off his flashlight
  7209. turn_off_flashlight(id)
  7210.  
  7211. // Give the survivor a bright light
  7212. if (get_pcvar_num(cvar_survaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  7213.  
  7214. // Survivor bots will also need nightvision to see in the dark
  7215. if (is_user_bot(id)) fm_set_bot_nvg(id, 1);
  7216.  
  7217. // Remove armor
  7218. set_pev(id, pev_armorvalue, 0.0)
  7219. }
  7220. case 2:
  7221. {
  7222. // Wesker
  7223. g_survivor[id] = true
  7224. g_wesker[id] = true
  7225. g_terminator[id] = false
  7226.  
  7227. // Turn off his flashlight
  7228. turn_off_flashlight(id)
  7229.  
  7230. // Give the survivor a bright light
  7231. if (get_pcvar_num(cvar_survaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  7232.  
  7233. // Survivor bots will also need nightvision to see in the dark
  7234. if (is_user_bot(id)) fm_set_bot_nvg(id, 1);
  7235.  
  7236. fm_strip_user_weapons(id)
  7237. fm_give_item(id, "weapon_knife")
  7238. fm_give_item(id, "weapon_deagle")
  7239.  
  7240. static weskerhealth
  7241. weskerhealth = get_pcvar_num(cvar_weskerhp)
  7242. fm_set_user_health(id, weskerhealth*fnGetAlive())
  7243.  
  7244. set_pev(id, pev_gravity, get_pcvar_float(cvar_weskergravity))
  7245. }
  7246. case 3:
  7247. {
  7248. // Terminator
  7249. g_survivor[id] = true
  7250. g_wesker[id] = false
  7251. g_terminator[id] = true
  7252.  
  7253. // Turn off his flashlight
  7254. turn_off_flashlight(id)
  7255.  
  7256. // Give the survivor a bright light
  7257. if (get_pcvar_num(cvar_survaura)) set_pev(id, pev_effects, pev(id, pev_effects) | EF_BRIGHTLIGHT)
  7258.  
  7259. // Survivor bots will also need nightvision to see in the dark
  7260. if (is_user_bot(id)) fm_set_bot_nvg(id, 1);
  7261.  
  7262. fm_strip_user_weapons(id)
  7263. fm_give_item(id, "weapon_knife")
  7264. fm_give_item(id, "weapon_m3")
  7265. fm_give_item(id, "weapon_hegrenade")
  7266.  
  7267. static terminatorhealth
  7268. terminatorhealth = get_pcvar_num(cvar_terminator_basehp)
  7269. fm_set_user_health(id, terminatorhealth*fnGetAlive())
  7270.  
  7271. set_pev(id, pev_gravity, get_pcvar_float(cvar_terminatorgravity))
  7272. }
  7273. }
  7274.  
  7275. // Remove previous tasks
  7276. remove_task(id+TASK_TEAM)
  7277. remove_task(id+TASK_MODEL)
  7278. remove_task(id+TASK_BLOOD)
  7279.  
  7280. // Switch to CT
  7281. if (fm_get_user_team(id) != CS_TEAM_CT) // need to change team?
  7282. {
  7283. fm_set_user_team(id, CS_TEAM_CT)
  7284. fm_user_team_update(id)
  7285. }
  7286.  
  7287. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  7288.  
  7289. // Set the right model
  7290. if (g_survivor[id] && !g_wesker[id] && !g_terminator[id])
  7291. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_survivor[random_num(0, sizeof model_survivor -1)])
  7292. else if (g_wesker[id] && g_survivor[id])
  7293. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_wesker[random_num(0, sizeof model_wesker -1)])
  7294. else if (g_terminator[id] && g_survivor[id])
  7295. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_terminator[random_num(0, sizeof model_terminator -1)])
  7296. else
  7297. {
  7298. if (get_pcvar_num(cvar_adminmodelshuman) && get_user_flags(id) & ACCESS_FLAG3)
  7299. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_admin[random_num(0, sizeof model_admin -1)])
  7300. else
  7301. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_hclass_model[g_humanclass[id]])
  7302. }
  7303.  
  7304. // Set model on player model entity
  7305. fm_set_playermodel_ent(id)
  7306.  
  7307. // Set survivor glow / remove glow, unless frozen
  7308. if (g_survivor[id] && get_pcvar_num(cvar_survglow) && !g_wesker[id] && !g_terminator[id])
  7309. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  7310. else if (g_wesker[id] && g_survivor[id])
  7311. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 185, 135, 15, kRenderNormal, 25)
  7312. else if (g_terminator[id] && g_survivor[id])
  7313. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 20, 255, 20, kRenderNormal, 25)
  7314. else if (!g_frozen[id])
  7315. if if (g_zombie[id] && g_zombieclass[id] == 5)
  7316. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25)
  7317. else
  7318. fm_set_rendering(g_ent_playermodel[id])
  7319.  
  7320. #else
  7321.  
  7322. // Set the right model, after checking that we don't already have it
  7323. static currentmodel[32], already_has_model, i, iRand
  7324. already_has_model = false;
  7325.  
  7326. // Get current model and compare it with current one
  7327. fm_get_user_model(id, currentmodel, sizeof currentmodel - 1);
  7328.  
  7329. if (g_survivor[id] && !g_wesker[id] && !g_terminator[id])
  7330. {
  7331. for (i = 0; i < sizeof model_survivor; i++)
  7332. if (equal(model_survivor[i], currentmodel)) already_has_model = true;
  7333.  
  7334. if (!already_has_model)
  7335. {
  7336. iRand = random_num(0, sizeof model_survivor -1)
  7337. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_survivor[iRand])
  7338. #if defined SET_MODELINDEX_OFFSET
  7339. fm_set_user_model_index(id, g_modelindex_survivor[iRand])
  7340. #endif
  7341. }
  7342. }
  7343. else if (g_wesker[id] && g_survivor[id])
  7344. {
  7345. for (i = 0; i < sizeof model_wesker; i++)
  7346. if (equal(model_wesker[i], currentmodel)) already_has_model = true;
  7347.  
  7348. if (!already_has_model)
  7349. {
  7350. iRand = random_num(0, sizeof model_wesker -1)
  7351. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_wesker[iRand])
  7352. #if defined SET_MODELINDEX_OFFSET
  7353. fm_set_user_model_index(id, g_modelindex_wesker[iRand])
  7354. #endif
  7355. }
  7356. }
  7357. else if (g_terminator[id] && g_survivor[id])
  7358. {
  7359. for (i = 0; i < sizeof model_terminator; i++)
  7360. if (equal(model_terminator[i], currentmodel)) already_has_model = true;
  7361.  
  7362. if (!already_has_model)
  7363. {
  7364. iRand = random_num(0, sizeof model_terminator -1)
  7365. copy(g_playermodel[id], sizeof g_playermodel[] - 1, model_terminator[iRand])
  7366. #if defined SET_MODELINDEX_OFFSET
  7367. fm_set_user_model_index(id, g_modelindex_terminator[iRand])
  7368. #endif
  7369. }
  7370. }
  7371. else
  7372. {
  7373. if (equal(g_hclass_model[g_humanclass[id]], currentmodel)) already_has_model = true;
  7374.  
  7375. if (!already_has_model)
  7376. {
  7377. copy(g_playermodel[id], sizeof g_playermodel[] - 1, g_hclass_model[g_humanclass[id]])
  7378. #if defined SET_MODELINDEX_OFFSET
  7379. fm_set_user_model_index(id, g_hclass_modelindex[g_humanclass[id]])
  7380. #endif
  7381. }
  7382. }
  7383.  
  7384.  
  7385. // Need to change the model?
  7386. if (!already_has_model)
  7387. {
  7388. // An additional delay is offset at round start
  7389. // since SVC_BAD is more likely to be triggered there
  7390. if (g_newround)
  7391. set_task(5.0*MODELCHANGE_DELAY, "fm_user_model_update", id+TASK_MODEL)
  7392. else
  7393. fm_user_model_update(id+TASK_MODEL)
  7394. }
  7395.  
  7396. // Set survivor glow / remove glow, unless frozen
  7397. if (g_survivor[id] && get_pcvar_num(cvar_survglow) && !g_wesker[id] && !g_terminator[id])
  7398. fm_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  7399. else if (g_wesker[id] && g_survivor[id])
  7400. fm_set_rendering(id, kRenderFxGlowShell, 185, 135, 15, kRenderNormal, 25)
  7401. else if (g_terminator[id] && g_survivor[id])
  7402. fm_set_rendering(id, kRenderFxGlowShell, 20, 255, 20, kRenderNormal, 25)
  7403. else if (!g_frozen[id])
  7404. if (g_zombie[id] && g_zombieclass[id] == 5)
  7405. fm_set_rendering(id, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25)
  7406. else
  7407. fm_set_rendering(id)
  7408.  
  7409. #endif
  7410.  
  7411. // Get FOV setting
  7412. static fov
  7413. fov = get_pcvar_num(cvar_zombiefov)
  7414.  
  7415. // Restore FOV?
  7416. if (fov != 90 && fov != 0)
  7417. {
  7418. message_begin(MSG_ONE, g_msgSetFOV, _, id)
  7419. write_byte(90) // angle
  7420. message_end()
  7421. }
  7422.  
  7423. // Disable nightvision
  7424. if (is_user_bot(id)) fm_set_bot_nvg(id, 0)
  7425. else if (!get_pcvar_num(cvar_cnvg)) set_user_gnvision(id, 0)
  7426.  
  7427. // Post user humanize forward
  7428. ExecuteForward(g_fwUserHumanized_post, g_fwDummyResult, id)
  7429.  
  7430. // Last Zombie Check
  7431. set_task(0.1, "fnCheckLastZombie")
  7432. }
  7433.  
  7434. /*================================================================================
  7435. [Other Functions and Tasks]
  7436. =================================================================================*/
  7437.  
  7438. // Register Ham Forwards for CZ bots
  7439. public register_ham_czbots(id)
  7440. {
  7441. // Make sure it's a CZ bot and it's still connected
  7442. if (g_hamczbots || !get_pcvar_num(cvar_botquota) || !is_user_connected(id) || !is_user_bot(id))
  7443. return;
  7444.  
  7445. RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
  7446. RegisterHamFromEntity(Ham_Killed, id, "fw_PlayerKilled")
  7447. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  7448. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  7449.  
  7450. // Ham forwards for CZ bots succesfully registered
  7451. g_hamczbots = true
  7452.  
  7453. // If the bot has already spawned, call the forward manually for him
  7454. if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
  7455. }
  7456.  
  7457. // Disable minmodels task
  7458. public disable_minmodels(id)
  7459. {
  7460. if (!is_user_connected(id)) return;
  7461. client_cmd(id, "cl_minmodels 0")
  7462. }
  7463.  
  7464. // Bots automatically buy extra items
  7465. public bot_buy_extras(taskid)
  7466. {
  7467. // Nemesis or Survivor shouldnt get extra items
  7468. if (g_survivor[ID_SPAWN] || g_nemesis[ID_SPAWN] || !is_user_alive(ID_SPAWN))
  7469. return;
  7470.  
  7471. if (!g_zombie[ID_SPAWN]) // human bots
  7472. {
  7473. // Attempt to buy Night Vision
  7474. buy_extra_item(ID_SPAWN, EXTRA_NVISION)
  7475.  
  7476. // Attempt to buy a weapon
  7477. buy_extra_item(ID_SPAWN, random_num(EXTRA_WEAPONS_STARTID, EXTRAS_CUSTOM_STARTID-1))
  7478. }
  7479. else // zombie bots
  7480. {
  7481. // Attempt to buy an Antidote
  7482. buy_extra_item(ID_SPAWN, EXTRA_ANTIDOTE)
  7483. }
  7484. }
  7485.  
  7486. // Balance Teams Task
  7487. public balance_teams()
  7488. {
  7489. // Get users playing
  7490. static iPlayersnum
  7491. iPlayersnum = fnGetPlaying()
  7492.  
  7493. // No players, don't bother
  7494. if (iPlayersnum < 1) return;
  7495.  
  7496. // Split players evenly
  7497. static g_team[33], id, iTerrors, iMaxTerrors, team
  7498. iMaxTerrors = iPlayersnum/2
  7499. iTerrors = 0
  7500.  
  7501. // First, mark everyone as CT
  7502. for (id = 1; id <= g_maxplayers; id++)
  7503. g_team[id] = CS_TEAM_CT
  7504.  
  7505. // Then randomly mark half of the players as Terrorists
  7506. while (iTerrors < iMaxTerrors)
  7507. {
  7508. // Keep looping through all players
  7509. if (++id > g_maxplayers) id = 1
  7510.  
  7511. // Skip if not connected
  7512. if (!is_user_connected(id))
  7513. continue;
  7514.  
  7515. team = fm_get_user_team(id)
  7516.  
  7517. // Skip if not playing
  7518. if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
  7519. continue;
  7520.  
  7521. // Already a Terrorist
  7522. if (g_team[id] == CS_TEAM_T)
  7523. continue;
  7524.  
  7525. // Random chance
  7526. if (random_num(0, 1))
  7527. {
  7528. g_team[id] = CS_TEAM_T
  7529. iTerrors++
  7530. }
  7531. }
  7532.  
  7533. // Set everyone's team for real
  7534. for (id = 1; id <= g_maxplayers; id++)
  7535. {
  7536. // Skip if not connected
  7537. if (!is_user_connected(id))
  7538. continue;
  7539.  
  7540. team = fm_get_user_team(id)
  7541.  
  7542. // Skip if not playing
  7543. if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
  7544. continue;
  7545.  
  7546. // Set team
  7547. remove_task(id+TASK_TEAM)
  7548. fm_set_user_team(id, g_team[id])
  7549. }
  7550. }
  7551.  
  7552. // Welcome Message Task
  7553. public welcome_msg()
  7554. {
  7555. // Show mod info
  7556. zp_colored_print(0, "^x01**** ^x04%s^x01 ****", g_modname)
  7557. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO1")
  7558. if (!get_pcvar_num(cvar_infammo)) zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "NOTICE_INFO2")
  7559.  
  7560. // Show T-virus HUD notice
  7561. set_hudmessage(0, 125, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
  7562. ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_VIRUS_FREE")
  7563. }
  7564.  
  7565. // Respawn Player Task
  7566. public respawn_player(taskid)
  7567. {
  7568. // Get player's team
  7569. static team
  7570. team = fm_get_user_team(ID_SPAWN)
  7571.  
  7572. // Respawn on infection rounds only
  7573. if (!g_endround && !g_survround && !g_swarmround && !g_nemround && !g_plagueround && team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED && !is_user_alive(ID_SPAWN))
  7574. {
  7575. // Set proper team before respawning, so that the TeamInfo message that's sent doesn't confuse PODBots
  7576. if (g_respawn_as_zombie[ID_SPAWN])
  7577. fm_set_user_team(ID_SPAWN, CS_TEAM_T)
  7578. else
  7579. fm_set_user_team(ID_SPAWN, CS_TEAM_CT)
  7580.  
  7581. // Respawning a player has never been so easy
  7582. ExecuteHamB(Ham_CS_RoundRespawn, ID_SPAWN)
  7583. }
  7584. }
  7585.  
  7586. // Check Round Task -check that we still have both zombies & humans on a round-
  7587. check_round(leaving_player)
  7588. {
  7589. // Round ended or make_a_zombie task still active
  7590. if (g_endround || task_exists(TASK_MAKEZOMBIE))
  7591. return;
  7592.  
  7593. // Get alive players count
  7594. static iPlayersnum
  7595. iPlayersnum = fnGetAlive()
  7596.  
  7597. // Last alive player, don't bother
  7598. if (iPlayersnum < 2)
  7599. return;
  7600.  
  7601. // Set up some common vars
  7602. static id, name[32]
  7603.  
  7604. // Last zombie disconnecting
  7605. if (g_zombie[leaving_player] && fnGetZombies() == 1)
  7606. {
  7607. // Only one CT left, don't bother
  7608. if (fnGetHumans() == 1 && fnGetCTs() == 1)
  7609. return;
  7610.  
  7611. // Pick a random one to take his place
  7612. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) {}
  7613.  
  7614. // Show last zombie left notice
  7615. get_user_name(id, name, sizeof name - 1)
  7616. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_ZOMBIE_LEFT", name)
  7617.  
  7618. // Turn into a Nemesis or just a zombie?
  7619. if (g_nemesis[leaving_player] && !g_plagueround)
  7620. make_a_zombie(MODE_NEMESIS, id)
  7621. else
  7622. zombieme(id, 0, 0, 0)
  7623. }
  7624.  
  7625. // Last human disconnecting
  7626. else if (!g_zombie[leaving_player] && fnGetHumans() == 1)
  7627. {
  7628. // Only one T left, don't bother
  7629. if (fnGetZombies() == 1 && fnGetTs() == 1)
  7630. return;
  7631.  
  7632. // Pick a random one to take his place
  7633. while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) {}
  7634.  
  7635. // Show last human left notice
  7636. get_user_name(id, name, sizeof name - 1)
  7637. zp_colored_print(0, "^x04[ZP]^x01 %L", LANG_PLAYER, "LAST_HUMAN_LEFT", name)
  7638.  
  7639. // Turn into a Survivor or just a human?
  7640. if (g_survivor[leaving_player] && !g_plagueround)
  7641. make_a_zombie(MODE_SURVIVOR, id)
  7642. else
  7643. humanme(id, 0)
  7644. }
  7645. }
  7646.  
  7647. // Lighting Effects Task
  7648. public lighting_effects()
  7649. {
  7650. // Lighting style ["a"-"z"]
  7651. static lights[2]
  7652. get_pcvar_string(cvar_lighting, lights, sizeof lights - 1)
  7653. strtolower(lights)
  7654.  
  7655. // Lighting disabled? ["0"]
  7656. if (lights[0] == '0')
  7657. {
  7658. // Task not needed anymore
  7659. remove_task(TASK_LIGHTING)
  7660. return;
  7661. }
  7662.  
  7663. // Darkest light settings?
  7664. if (lights[0] >= 'a' && lights[0] <= 'd')
  7665. {
  7666. // Get thunderclaps setting
  7667. static Float:thunderclap
  7668. thunderclap = get_pcvar_float(cvar_thunder)
  7669.  
  7670. // Set thunderclap tasks if neccesary
  7671. if (thunderclap > 0.0 && !task_exists(TASK_THUNDER_PRE) && !task_exists(TASK_THUNDER))
  7672. {
  7673. g_lights_i = 0
  7674. switch (random_num(0, 2))
  7675. {
  7676. case 0: set_task(thunderclap, "thunderclap1", TASK_THUNDER_PRE)
  7677. case 1: set_task(thunderclap, "thunderclap2", TASK_THUNDER_PRE)
  7678. case 2: set_task(thunderclap, "thunderclap3", TASK_THUNDER_PRE)
  7679. }
  7680. }
  7681.  
  7682. // Set lighting only when no thunderclaps are going on
  7683. if (!task_exists(TASK_THUNDER)) engfunc(EngFunc_LightStyle, 0, lights)
  7684. }
  7685. else
  7686. {
  7687. // Remove thunderclap tasks
  7688. remove_task(TASK_THUNDER_PRE)
  7689. remove_task(TASK_THUNDER)
  7690.  
  7691. // Set lighting
  7692. engfunc(EngFunc_LightStyle, 0, lights)
  7693. }
  7694. }
  7695.  
  7696. // Thunderclap 1
  7697. public thunderclap1()
  7698. {
  7699. // Play thunder sound
  7700. if (!g_lights_i) PlaySound(sound_thunder[random_num(0, sizeof sound_thunder - 1)])
  7701.  
  7702. // Set lighting
  7703. engfunc(EngFunc_LightStyle, 0, lights_thunder1[g_lights_i])
  7704. g_lights_i++
  7705.  
  7706. // Loop the task until we reach the end of the cycle
  7707. if (g_lights_i >= sizeof lights_thunder1)
  7708. {
  7709. remove_task(TASK_THUNDER)
  7710. lighting_effects()
  7711. }
  7712. else if (!task_exists(TASK_THUNDER))
  7713. set_task(0.1, "thunderclap1", TASK_THUNDER, _, _, "b")
  7714. }
  7715.  
  7716. // Thunderclap 2
  7717. public thunderclap2()
  7718. {
  7719. // Play thunder sound
  7720. if (!g_lights_i) PlaySound(sound_thunder[random_num(0, sizeof sound_thunder - 1)])
  7721.  
  7722. // Set lighting
  7723. engfunc(EngFunc_LightStyle, 0, lights_thunder2[g_lights_i])
  7724. g_lights_i++
  7725.  
  7726. // Loop the task until we reach the end of the cycle
  7727. if (g_lights_i >= sizeof lights_thunder2)
  7728. {
  7729. remove_task(TASK_THUNDER)
  7730. lighting_effects()
  7731. }
  7732. else if (!task_exists(TASK_THUNDER))
  7733. set_task(0.1, "thunderclap2", TASK_THUNDER, _, _, "b")
  7734. }
  7735.  
  7736. // Thunderclap 3
  7737. public thunderclap3()
  7738. {
  7739. // Play thunder sound
  7740. if (!g_lights_i) PlaySound(sound_thunder[random_num(0, sizeof sound_thunder - 1)])
  7741.  
  7742. // Set lighting
  7743. engfunc(EngFunc_LightStyle, 0, lights_thunder3[g_lights_i])
  7744. g_lights_i++
  7745.  
  7746. // Loop the task until we reach the end of the cycle
  7747. if (g_lights_i >= sizeof lights_thunder3)
  7748. {
  7749. remove_task(TASK_THUNDER)
  7750. lighting_effects()
  7751. }
  7752. else if (!task_exists(TASK_THUNDER))
  7753. set_task(0.1, "thunderclap3", TASK_THUNDER, _, _, "b")
  7754. }
  7755.  
  7756. #if defined AMBIENCE_SOUNDS
  7757. // Ambience Sound Effects Task
  7758. public ambience_sound_effects(taskid)
  7759. {
  7760. // Play a random sound depending on the round
  7761. static amb_sound[64], isound, Float:duration
  7762.  
  7763. if (g_nemround) // Nemesis Mode
  7764. {
  7765. isound = random_num(0, sizeof sound_ambience2 - 1)
  7766. copy(amb_sound, sizeof amb_sound -1, sound_ambience2[isound])
  7767. duration = sound_ambience2_duration[isound]
  7768. }
  7769. else if (g_survround) // Survivor Mode
  7770. {
  7771. isound = random_num(0, sizeof sound_ambience3 - 1)
  7772. copy(amb_sound, sizeof amb_sound -1, sound_ambience3[isound])
  7773. duration = sound_ambience3_duration[isound]
  7774. }
  7775. else if (g_swarmround) // Swarm Mode
  7776. {
  7777. isound = random_num(0, sizeof sound_ambience4 - 1)
  7778. copy(amb_sound, sizeof amb_sound -1, sound_ambience4[isound])
  7779. duration = sound_ambience4_duration[isound]
  7780. }
  7781. else if (g_plagueround) // Plague Mode
  7782. {
  7783. isound = random_num(0, sizeof sound_ambience5 - 1)
  7784. copy(amb_sound, sizeof amb_sound -1, sound_ambience5[isound])
  7785. duration = sound_ambience5_duration[isound]
  7786. }
  7787. else // Infection Mode
  7788. {
  7789. isound = random_num(0, sizeof sound_ambience1 - 1)
  7790. copy(amb_sound, sizeof amb_sound -1, sound_ambience1[isound])
  7791. duration = sound_ambience1_duration[isound]
  7792. }
  7793.  
  7794. // Check whether it's a wav or mp3 and play it on clients
  7795. if (equal(amb_sound[strlen(amb_sound)-4], ".mp3"))
  7796. client_cmd(0, "mp3 play ^"sound/%s^"", amb_sound)
  7797. else
  7798. PlaySound(amb_sound)
  7799.  
  7800. // The task should be called again after the sound is done playing
  7801. set_task(duration, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
  7802. }
  7803.  
  7804. // Ambience Sounds Stop Task
  7805. public ambience_sound_stop()
  7806. {
  7807. client_cmd(0, "mp3 stop; stopsound")
  7808. }
  7809. #endif
  7810.  
  7811. // Flashlight Charge Task
  7812. public flashlight_charge(taskid)
  7813. {
  7814. // Custom flashlight disabled or flashlight not available for player
  7815. if (g_zombie[ID_CHARGE] || g_survivor[ID_CHARGE] || !is_user_alive(ID_CHARGE))
  7816. {
  7817. // Task not needed anymore
  7818. remove_task(taskid);
  7819. return;
  7820. }
  7821.  
  7822. // Drain or charge?
  7823. if (g_flashlight[ID_CHARGE])
  7824. g_flashbattery[ID_CHARGE] -= get_pcvar_num(cvar_flashdrain)
  7825. else
  7826. g_flashbattery[ID_CHARGE] += get_pcvar_num(cvar_flashcharge)
  7827.  
  7828. // Battery fully charged
  7829. if (g_flashbattery[ID_CHARGE] >= 100)
  7830. {
  7831. // Don't exceed 100%
  7832. g_flashbattery[ID_CHARGE] = 100;
  7833.  
  7834. // Update flashlight battery on HUD
  7835. message_begin(MSG_ONE, g_msgFlashBat, _, ID_CHARGE)
  7836. write_byte(g_flashbattery[ID_CHARGE]) // battery
  7837. message_end()
  7838.  
  7839. // Task not needed anymore
  7840. remove_task(taskid);
  7841. return;
  7842. }
  7843.  
  7844. // Battery depleted
  7845. if (g_flashbattery[ID_CHARGE] <= 0)
  7846. {
  7847. // Turn it off
  7848. g_flashlight[ID_CHARGE] = false;
  7849. g_flashbattery[ID_CHARGE] = 0;
  7850.  
  7851. // Update flashlight status on HUD
  7852. message_begin(MSG_ONE, g_msgFlashlight, _, ID_CHARGE)
  7853. write_byte(g_flashlight[ID_CHARGE]) // toggle
  7854. write_byte(g_flashbattery[ID_CHARGE]) // battery
  7855. message_end()
  7856. }
  7857. else
  7858. {
  7859. // Update flashlight battery on HUD
  7860. message_begin(MSG_ONE_UNRELIABLE, g_msgFlashBat, _, ID_CHARGE)
  7861. write_byte(g_flashbattery[ID_CHARGE]) // battery
  7862. message_end()
  7863. }
  7864. }
  7865.  
  7866. // Remove Spawn Protection Task
  7867. public remove_spawn_protection(taskid)
  7868. {
  7869. // Not alive
  7870. if (!is_user_alive(ID_SPAWN))
  7871. return;
  7872.  
  7873. // Remove spawn protection
  7874. g_nodamage[ID_SPAWN] = false;
  7875. set_pev(ID_SPAWN, pev_effects, pev(ID_SPAWN, pev_effects) & ~EF_NODRAW)
  7876. }
  7877.  
  7878. // Task Hide Player's Money
  7879. public task_hide_money(taskid)
  7880. {
  7881. // Not alive
  7882. if (!is_user_alive(ID_SPAWN))
  7883. return;
  7884.  
  7885. // Hide money
  7886. message_begin(MSG_ONE, g_msgHideWeapon, _, ID_SPAWN)
  7887. write_byte(HIDE_MONEY) // what to hide bitsum
  7888. message_end()
  7889.  
  7890. // Hide the HL crosshair that's drawn
  7891. message_begin(MSG_ONE, g_msgCrosshair, _, ID_SPAWN)
  7892. write_byte(0) // toggle
  7893. message_end()
  7894. }
  7895.  
  7896. // Turn Off Game Flashlight
  7897. turn_off_flashlight(id)
  7898. {
  7899. // Check if flashlight is on
  7900. if (pev(id, pev_effects) & EF_DIMLIGHT)
  7901. {
  7902. // Turn it off
  7903. set_pev(id, pev_effects, pev(id, pev_effects) & ~EF_DIMLIGHT)
  7904.  
  7905. // Update HUD
  7906. message_begin(MSG_ONE, g_msgFlashlight, _, id)
  7907. write_byte(0) // toggle
  7908. write_byte(100) // battery
  7909. message_end()
  7910. }
  7911.  
  7912. // Clear any stored flashlight impulse (bugfix)
  7913. set_pev(id, pev_impulse, 0)
  7914. }
  7915.  
  7916.  
  7917. // Infection Grenade Explosion
  7918. infection_explode(ent)
  7919. {
  7920. // Round ended (bugfix)
  7921. if (g_endround) return;
  7922.  
  7923. // Get origin
  7924. static Float:originF[3]
  7925. pev(ent, pev_origin, originF)
  7926.  
  7927. // Make the explosion
  7928. create_blast(originF)
  7929.  
  7930. // Infection nade explode sound
  7931. engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, grenade_infect[random_num(0, sizeof grenade_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  7932.  
  7933. // Get attacker
  7934. static attacker
  7935. attacker = pev(ent, pev_owner)
  7936.  
  7937. // Collisions
  7938. static victim
  7939. victim = -1
  7940.  
  7941. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  7942. {
  7943. // Only effect alive non-spawnprotected humans
  7944. if (!is_user_alive(victim) || g_zombie[victim] || g_nodamage[victim])
  7945. continue;
  7946.  
  7947. // Last human is killed
  7948. if (fnGetHumans() == 1)
  7949. {
  7950. ExecuteHamB(Ham_Killed, victim, attacker, 0)
  7951. continue;
  7952. }
  7953.  
  7954. // Infected victim's sound
  7955. engfunc(EngFunc_EmitSound, victim, CHAN_VOICE, grenade_infect_player[random_num(0, sizeof grenade_infect_player - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  7956.  
  7957. SendDeathMsg(attacker, victim) // send death notice
  7958. FixDeadAttrib(victim) // fix the "dead" attrib on scoreboard
  7959. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect), 1, 1) // add corresponding frags & deaths
  7960.  
  7961. zombieme(victim, attacker, 0, 1) // turn into zombie
  7962. g_ammopacks[attacker] -= get_pcvar_num(cvar_ammoinfect)
  7963. update_ap(attacker, get_pcvar_num(cvar_ammoinfect)) // ammo packs given to zombie for infection
  7964. fm_set_user_health(attacker, pev(attacker, pev_health)+get_pcvar_num(cvar_zombiebonushp)) // infection HP bonus
  7965. }
  7966.  
  7967. // Get rid of the grenade
  7968. engfunc(EngFunc_RemoveEntity, ent)
  7969. }
  7970.  
  7971. // Fire Grenade Explosion
  7972. fire_explode(ent)
  7973. {
  7974. // Make the explosion
  7975. if (is_valid_ent(ent))
  7976. {
  7977. static Float: originF[3]
  7978. pev(ent, pev_origin, originF)
  7979.  
  7980. for (new i = 0; i < 25; i++)
  7981. {
  7982. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  7983. write_byte(TE_SPRITE) // TE_SPRITE
  7984. engfunc(EngFunc_WriteCoord, originF[0]+random_num(-150, 150)) // x
  7985. engfunc(EngFunc_WriteCoord, originF[1]+random_num(-150, 150)) // y,
  7986. engfunc(EngFunc_WriteCoord, originF[2]+80) // z
  7987. write_short(g_flameSpr) //sprite a usar
  7988. write_byte(10) //Tamaño
  7989. write_byte(255) //Saturacion (brightness)
  7990. message_end()
  7991.  
  7992. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  7993. write_byte(TE_DLIGHT)
  7994. engfunc(EngFunc_WriteCoord, originF[0]+random_num(-150, 150)) // x
  7995. engfunc(EngFunc_WriteCoord, originF[1]+random_num(-150, 150)) // y,
  7996. engfunc(EngFunc_WriteCoord, originF[2]+80) // z
  7997. write_byte(50) // radius
  7998. write_byte(255) // R
  7999. write_byte(112) // G
  8000. write_byte(40) // B
  8001. write_byte(30) // life
  8002. write_byte(30) // decay rate
  8003. message_end()
  8004. }
  8005.  
  8006. // Fire nade explode sound
  8007. PlaySound(grenade_fire)
  8008.  
  8009. // Collisions
  8010. static victim
  8011. victim = -1
  8012.  
  8013. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  8014. {
  8015. // Only effect alive zombies
  8016. if (!is_user_alive(victim) || !g_zombie[victim] || g_nodamage[victim])
  8017. continue;
  8018.  
  8019. // Heat icon?
  8020. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  8021. write_byte(0) // damage save
  8022. write_byte(0) // damage take
  8023. write_long(DMG_BURN) // damage type
  8024. write_coord(0) // x
  8025. write_coord(0) // y
  8026. write_coord(0) // z
  8027. message_end()
  8028.  
  8029. // Our task params
  8030. static params[1]
  8031.  
  8032. if (g_nemesis[victim]) // fire duration (nemesis takes less)
  8033. params[0] = get_pcvar_num(cvar_fireduration)
  8034. else
  8035. params[0] = get_pcvar_num(cvar_fireduration)*5
  8036.  
  8037. // Set burning task on victim
  8038. set_task(0.1, "burning_flame", victim+TASK_BLOOD, params, sizeof params)
  8039. }
  8040. }
  8041.  
  8042. // Get rid of the grenade
  8043. engfunc(EngFunc_RemoveEntity, ent)
  8044. }
  8045.  
  8046. // Frost Grenade Explosion
  8047. frost_explode(ent)
  8048. {
  8049. // Get origin
  8050. static Float:originF[3]
  8051. pev(ent, pev_origin, originF)
  8052.  
  8053. // Make the explosion
  8054. create_blast3(originF)
  8055.  
  8056. // Frost nade explode sound
  8057. engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, grenade_frost[random_num(0, sizeof grenade_frost - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8058.  
  8059. // Collisions
  8060. static victim
  8061. victim = -1
  8062.  
  8063. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_EXPLOSION_RADIUS)) != 0)
  8064. {
  8065. // Only effect alive unfrozen zombies
  8066. if (!is_user_alive(victim) || !g_zombie[victim] || g_frozen[victim] || g_nodamage[victim])
  8067. continue;
  8068.  
  8069. // Nemesis shouldn't be frozen
  8070. if (g_nemesis[victim])
  8071. {
  8072. // Get player's origin
  8073. static Float:origin2F[3]
  8074. pev(victim, pev_origin, origin2F)
  8075.  
  8076. // Broken glass sound
  8077. engfunc(EngFunc_EmitSound, victim, CHAN_BODY, grenade_frost_break[random_num(0, sizeof grenade_frost_break - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8078.  
  8079. // Glass shatter
  8080. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin2F, 0)
  8081. write_byte(TE_BREAKMODEL) // TE id
  8082. engfunc(EngFunc_WriteCoord, origin2F[0]) // x
  8083. engfunc(EngFunc_WriteCoord, origin2F[1]) // y
  8084. engfunc(EngFunc_WriteCoord, origin2F[2]+24.0) // z
  8085. write_coord(16) // size x
  8086. write_coord(16) // size y
  8087. write_coord(16) // size z
  8088. write_coord(random_num(-50, 50)) // velocity x
  8089. write_coord(random_num(-50, 50)) // velocity y
  8090. write_coord(25) // velocity z
  8091. write_byte(10) // random velocity
  8092. write_short(g_glassSpr) // model
  8093. write_byte(10) // count
  8094. write_byte(25) // life
  8095. write_byte(BREAK_GLASS) // flags
  8096. message_end()
  8097.  
  8098. continue;
  8099. }
  8100.  
  8101. // Freeze icon?
  8102. if (get_pcvar_num(cvar_hudicons))
  8103. {
  8104. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, victim)
  8105. write_byte(0) // damage save
  8106. write_byte(0) // damage take
  8107. write_long(DMG_DROWN) // damage type - DMG_FREEZE
  8108. write_coord(0) // x
  8109. write_coord(0) // y
  8110. write_coord(0) // z
  8111. message_end()
  8112. }
  8113.  
  8114. // Light blue glow while frozen
  8115. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  8116. fm_set_rendering(g_ent_playermodel[victim], kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  8117. #else
  8118. fm_set_rendering(victim, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  8119. #endif
  8120.  
  8121. // Freeze sound
  8122. engfunc(EngFunc_EmitSound, victim, CHAN_BODY, grenade_frost_player[random_num(0, sizeof grenade_frost_player - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8123.  
  8124. // Get freeze duration setting
  8125. static Float:freezeduration
  8126. freezeduration = get_pcvar_float(cvar_freezeduration)
  8127.  
  8128. // Add a blue tint to their screen
  8129. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, victim)
  8130. write_short(UNIT_SECOND*1) // duration
  8131. write_short(floatround(UNIT_SECOND*freezeduration)) // hold time
  8132. write_short(FFADE_IN) // fade type
  8133. write_byte(0) // red
  8134. write_byte(50) // green
  8135. write_byte(200) // blue
  8136. write_byte(100) // alpha
  8137. message_end()
  8138.  
  8139. // Prevent from jumping
  8140. if (pev(victim, pev_flags) & FL_ONGROUND)
  8141. set_pev(victim, pev_gravity, 999999.9) // set really high
  8142. else
  8143. set_pev(victim, pev_gravity, 0.000001) // no gravity
  8144.  
  8145. // Set a task to remove the freeze
  8146. g_frozen[victim] = true;
  8147. set_task(freezeduration, "remove_freeze", victim)
  8148. }
  8149.  
  8150. // Get rid of the grenade
  8151. engfunc(EngFunc_RemoveEntity, ent)
  8152. }
  8153.  
  8154. // Remove freeze task
  8155. public remove_freeze(id)
  8156. {
  8157. // Not alive or not frozen anymore
  8158. if (!g_frozen[id] || !is_user_alive(id))
  8159. return;
  8160.  
  8161. // Unfreeze
  8162. g_frozen[id] = false;
  8163.  
  8164. // Restore normal gravity
  8165. if (g_zombie[id])
  8166. set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]])
  8167. else
  8168. set_pev(id, pev_gravity, g_hclass_grav[g_humanclass[id]])
  8169.  
  8170. // Broken glass sound
  8171. engfunc(EngFunc_EmitSound, id, CHAN_BODY, grenade_frost_break[random_num(0, sizeof grenade_frost_break - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8172.  
  8173. // Remove glow
  8174. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  8175. if (g_zombie[id] && g_zombieclass[id] == 5)
  8176. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 25)
  8177. else
  8178. fm_set_rendering(g_ent_playermodel[id])
  8179. #else
  8180. if (g_zombie[id] && g_zombieclass[id] == 5)
  8181. fm_set_rendering(id, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 25)
  8182. else
  8183. fm_set_rendering(id)
  8184. #endif
  8185.  
  8186. // Get player's origin
  8187. static Float:origin2F[3]
  8188. pev(id, pev_origin, origin2F)
  8189.  
  8190. // Glass shatter
  8191. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin2F, 0)
  8192. write_byte(TE_BREAKMODEL) // TE id
  8193. engfunc(EngFunc_WriteCoord, origin2F[0]) // x
  8194. engfunc(EngFunc_WriteCoord, origin2F[1]) // y
  8195. engfunc(EngFunc_WriteCoord, origin2F[2]+24.0) // z
  8196. write_coord(16) // size x
  8197. write_coord(16) // size y
  8198. write_coord(16) // size z
  8199. write_coord(random_num(-50, 50)) // velocity x
  8200. write_coord(random_num(-50, 50)) // velocity y
  8201. write_coord(25) // velocity z
  8202. write_byte(10) // random velocity
  8203. write_short(g_glassSpr) // model
  8204. write_byte(10) // count
  8205. write_byte(25) // life
  8206. write_byte(BREAK_GLASS) // flags
  8207. message_end()
  8208. }
  8209.  
  8210. // Remove Stuff Task
  8211. public remove_stuff()
  8212. {
  8213. static ent, removedoors
  8214. removedoors = get_pcvar_num(cvar_removedoors)
  8215.  
  8216. // Remove rotating doors
  8217. if (removedoors > 0)
  8218. {
  8219. ent = -1;
  8220. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door_rotating")) != 0)
  8221. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  8222. }
  8223.  
  8224. // Remove all doors
  8225. if (removedoors > 1)
  8226. {
  8227. ent = -1;
  8228. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_door")) != 0)
  8229. engfunc(EngFunc_SetOrigin, ent, Float:{8192.0 ,8192.0 ,8192.0})
  8230. }
  8231.  
  8232. // Triggered lights
  8233. if (!get_pcvar_num(cvar_triggered))
  8234. {
  8235. ent = -1
  8236. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "light")) != 0)
  8237. {
  8238. dllfunc(DLLFunc_Use, ent, 0); // turn off the light
  8239. set_pev(ent, pev_targetname, 0) // prevent it from being triggered
  8240. }
  8241. }
  8242. }
  8243.  
  8244. // Set Custom Weapon Models
  8245. public replace_models(id)
  8246. {
  8247. // Not alive
  8248. if (!is_user_alive(id))
  8249. return;
  8250.  
  8251. switch (g_currentweapon[id])
  8252. {
  8253. case CSW_KNIFE: // Custom knife models
  8254. {
  8255. if (g_zombie[id] && !g_newround && !g_endround)
  8256. {
  8257. if (g_nemesis[id] && !g_assassin[id] && !g_depredador[id]) // Nemesis
  8258. {
  8259. set_pev(id, pev_viewmodel2, model_vknife_nemesis)
  8260. set_pev(id, pev_weaponmodel2, p_knife_nemesis)
  8261. }
  8262. else if (g_nemesis[id] && g_assassin[id] && !g_depredador[id])
  8263. {
  8264. set_pev(id, pev_viewmodel2, v_knife_assassin)
  8265. set_pev(id, pev_weaponmodel2, p_knife_nemesis)
  8266. }
  8267. else if (g_nemesis[id] && g_depredador[id] && !g_assassin[id])
  8268. {
  8269. set_pev(id, pev_viewmodel2, v_knife_depredador)
  8270. set_pev(id, pev_weaponmodel2, p_knife_nemesis)
  8271. }
  8272. else // Zombies
  8273. {
  8274. static mdl[100]
  8275. formatex(mdl, sizeof mdl - 1, "models/zombie_plague/%s", g_zclass_clawmodel[g_zombieclass[id]])
  8276. set_pev(id, pev_viewmodel2, mdl)
  8277. set_pev(id, pev_weaponmodel2, "")
  8278. }
  8279. }
  8280. else // Humans
  8281. {
  8282. static mdl[100]
  8283. formatex(mdl, sizeof mdl - 1, model_vknife_human)
  8284. set_pev(id, pev_viewmodel2, mdl)
  8285. set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
  8286. }
  8287. }
  8288. case CSW_M249: // Survivor's M249
  8289. {
  8290. if (g_survivor[id])
  8291. set_pev(id, pev_viewmodel2, model_vm249_survivor)
  8292. }
  8293. case CSW_HEGRENADE: // Infection bomb or fire grenade
  8294. {
  8295. if (g_zombie[id] && !g_newround && !g_endround)
  8296. set_pev(id, pev_viewmodel2, model_grenade_infect)
  8297. else
  8298. set_pev(id, pev_viewmodel2, model_grenade_fire)
  8299. }
  8300. case CSW_FLASHBANG: // Frost grenade
  8301. {
  8302. set_pev(id, pev_viewmodel2, model_grenade_frost)
  8303. }
  8304. case CSW_SMOKEGRENADE: // Flare grenade
  8305. {
  8306. set_pev(id, pev_viewmodel2, v_campo)
  8307. }
  8308. case CSW_UMP45:
  8309. {
  8310. set_pev(id, pev_viewmodel2, v_ump45)
  8311. set_pev(id, pev_weaponmodel2, p_ump45)
  8312. }
  8313. case CSW_M3:
  8314. {
  8315. if (g_terminator[id] && g_survivor[id])
  8316. {
  8317.  
  8318. set_pev(id, pev_viewmodel2, v_m3_terminator)
  8319. set_pev(id, pev_weaponmodel2, p_m3_terminator)
  8320. }
  8321. else
  8322. {
  8323. set_pev(id, pev_viewmodel2, v_spas12)
  8324. }
  8325. }
  8326. case CSW_DEAGLE:
  8327. {
  8328. if (g_wesker[id] && g_survivor[id])
  8329. {
  8330. set_pev(id, pev_viewmodel2, v_deagle_fire)
  8331. set_pev(id, pev_weaponmodel2, p_deagle_fire)
  8332. }
  8333. }
  8334. case CSW_M4A1:
  8335. {
  8336. if (g_colt[id])
  8337. {
  8338. set_pev(id, pev_viewmodel2, v_colt)
  8339. set_pev(id, pev_weaponmodel2, p_colt)
  8340. }
  8341. }
  8342. }
  8343.  
  8344. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  8345. fm_set_weaponmodel_ent(id)
  8346. #endif
  8347. }
  8348.  
  8349. // Reset Player Vars
  8350. reset_vars(id, resetall)
  8351. {
  8352. g_zombie[id] = false
  8353. g_nemesis[id] = false
  8354. g_survivor[id] = false
  8355. g_firstzombie[id] = false
  8356. g_lastzombie[id] = false
  8357. g_lasthuman[id] = false
  8358. g_frozen[id] = false
  8359. g_nodamage[id] = false
  8360. g_respawn_as_zombie[id] = false
  8361. g_nvision[id] = false
  8362. g_nvisionenabled[id] = false
  8363. g_flashlight[id] = false
  8364. g_flashbattery[id] = 100
  8365. g_canbuy[id] = true
  8366.  
  8367. if (resetall)
  8368. {
  8369. g_ammopacks[id] = 5
  8370. g_zombieclass[id] = ZCLASS_NONE
  8371. g_zombieclassnext[id] = ZCLASS_NONE
  8372. g_humanclass[id] = HCLASS_NONE
  8373. g_humanclassnext[id] = HCLASS_NONE
  8374. g_damagedealt[id] = 0
  8375. WPN_AUTO_ON = 0
  8376. }
  8377. }
  8378.  
  8379. // Set spectators nightvision
  8380. public spec_nvision(id)
  8381. {
  8382. // Not connected, playing, or bot
  8383. if (!is_user_connected(id) || is_user_alive(id) || is_user_bot(id))
  8384. return;
  8385.  
  8386. // Give Night Vision?
  8387. if (get_pcvar_num(cvar_nvggive))
  8388. {
  8389. g_nvision[id] = true
  8390.  
  8391. // Turn on Night Vision automatically?
  8392. if (get_pcvar_num(cvar_nvggive) == 1)
  8393. {
  8394. g_nvisionenabled[id] = true
  8395.  
  8396. // Custom nvg?
  8397. if (get_pcvar_num(cvar_cnvg))
  8398. {
  8399. remove_task(id+TASK_NVISION)
  8400. set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  8401. }
  8402. else
  8403. set_user_gnvision(id, 1)
  8404. }
  8405. }
  8406. }
  8407.  
  8408. // Show HUD Task
  8409. public ShowHUD(taskid)
  8410. {
  8411. static id
  8412. id = ID_SHOWHUD;
  8413.  
  8414. // Player died?
  8415. if (!is_user_alive(id))
  8416. {
  8417. // Get spectating target
  8418. id = pev(id, PEV_SPEC_TARGET)
  8419.  
  8420. // Target not alive
  8421. if (!is_user_alive(id)) return;
  8422. }
  8423.  
  8424. // Format the classname
  8425. static class[32]
  8426.  
  8427. if (g_zombie[id]) // zombies
  8428. {
  8429.  
  8430. if (g_nemesis[id] && !g_depredador[id] && !g_assassin[id])
  8431. formatex(class, sizeof class - 1, "%L", ID_SHOWHUD,"CLASS_NEMESIS")
  8432. else if (g_nemesis[id] && g_depredador[id])
  8433. formatex(class, sizeof class - 1, "Depredador")
  8434. else if (g_nemesis[id] && g_assassin[id])
  8435. formatex(class, sizeof class - 1, "Assassin")
  8436. else
  8437. copy(class, sizeof class - 1, g_zclass_name[g_zombieclass[id]])
  8438. }
  8439. else // humans
  8440. {
  8441. if (g_survivor[id] && !g_wesker[id] && !g_terminator[id])
  8442. formatex(class, sizeof class - 1, "%L", ID_SHOWHUD,"CLASS_SURVIVOR")
  8443. else if (g_survivor[id] && g_wesker[id])
  8444. formatex(class, sizeof class - 1, "Wesker")
  8445. else if (g_terminator[id] && g_survivor[id])
  8446. formatex(class, sizeof class - 1, "Terminator")
  8447. else
  8448. copy(class, sizeof class - 1, g_hclass_name[g_humanclass[id]])
  8449. }
  8450.  
  8451. // Spectating someone else?
  8452. if (id != ID_SHOWHUD)
  8453. {
  8454. static name[32]
  8455. get_user_name(id, name, sizeof name - 1)
  8456.  
  8457. // Show name, health, class, and ammo packs
  8458. set_hudmessage(255, 255, 255, 0.57, 0.86, 0, 6.0, 1.1, 0.0, 0.0, -1)
  8459. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "Spectating: %s^nHP: %s - Clase: %s - AmmoPacks: %s - Level: %d", name, Puntuacion(pev(id, pev_health)), class, Puntuacion(g_ammopacks[id]), g_level[id])
  8460. }
  8461. else
  8462. {
  8463. // Show health, class and ammo packs
  8464. set_hudmessage(red[id], green[id], blue[id], g_hud_pos[id][0], g_hud_pos[id][1], efecto[id], 6.0, 1.1, 0.0, 0.0, -1)
  8465. ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "|Vida: %s|^n|Chaleco: %s|^n|Clase: %s|^n|AmmoPacks: %s (%d%%)|^n|Level: %d|^n|Restantes: %s|^n|Speed: %f", Puntuacion(pev(ID_SHOWHUD, pev_health)), Puntuacion(get_user_armor(id)), class, Puntuacion(g_ammopacks[id]),(g_ammopacks[id] - Levels[g_level[id] - 1]) * 100 / (Levels[g_level[id]] - Levels[g_level[id] - 1]), g_level[id], Puntuacion(Levels[g_level[id]] - g_ammopacks[id]), get_user_maxspeed(id))
  8466. }
  8467. }
  8468.  
  8469. // Play idle zombie sounds
  8470. public zombie_play_idle(taskid)
  8471. {
  8472. // Round ended/new one starting
  8473. if (g_endround || g_newround)
  8474. return;
  8475.  
  8476. // Last zombie?
  8477. if (g_lastzombie[ID_BLOOD])
  8478. engfunc(EngFunc_EmitSound, ID_BLOOD, CHAN_VOICE, zombie_idle_last[random_num(0, sizeof zombie_idle_last - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8479. else
  8480. engfunc(EngFunc_EmitSound, ID_BLOOD, CHAN_VOICE, zombie_idle[random_num(0, sizeof zombie_idle - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  8481. }
  8482.  
  8483. // Madness Over Task
  8484. public madness_over(taskid)
  8485. {
  8486. g_nodamage[ID_BLOOD] = false
  8487. }
  8488.  
  8489. // Place user at a random spawn
  8490. do_random_spawn(id)
  8491. {
  8492. // No spawns?
  8493. if (!g_spawnCount)
  8494. return;
  8495.  
  8496. // Get whether the player is crouching
  8497. static hull
  8498. hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  8499.  
  8500. // Choose random spawn to start looping at
  8501. static sp_index, i
  8502. sp_index = random_num(0, g_spawnCount - 1)
  8503.  
  8504. // Try to find a clear spawn
  8505. for (i = sp_index + 1; i != 999; i++)
  8506. {
  8507. // Start over when we reach the end
  8508. if (i >= g_spawnCount) i = 0
  8509.  
  8510. // Free spawn space?
  8511. if (is_hull_vacant(g_spawns[i], hull))
  8512. {
  8513. // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  8514. engfunc(EngFunc_SetOrigin, id, g_spawns[i])
  8515. break;
  8516. }
  8517.  
  8518. // Loop completed, no free space found
  8519. if (i == sp_index) break;
  8520. }
  8521. }
  8522.  
  8523. // Get Zombies -returns alive zombies number-
  8524. fnGetZombies()
  8525. {
  8526. static iZombies, id
  8527. iZombies = 0
  8528.  
  8529. for (id = 1; id <= g_maxplayers; id++)
  8530. {
  8531. if (is_user_alive(id) && g_zombie[id])
  8532. iZombies++
  8533. }
  8534.  
  8535. return iZombies;
  8536. }
  8537.  
  8538. // Get Humans -returns alive humans number-
  8539. fnGetHumans()
  8540. {
  8541. static iHumans, id
  8542. iHumans = 0
  8543.  
  8544. for (id = 1; id <= g_maxplayers; id++)
  8545. {
  8546. if (is_user_alive(id) && !g_zombie[id])
  8547. iHumans++
  8548. }
  8549.  
  8550. return iHumans;
  8551. }
  8552.  
  8553. // Get Alive -returns alive players number-
  8554. fnGetAlive()
  8555. {
  8556. static iAlive, id
  8557. iAlive = 0
  8558.  
  8559. for (id = 1; id <= g_maxplayers; id++)
  8560. {
  8561. if (is_user_alive(id))
  8562. iAlive++
  8563. }
  8564.  
  8565. return iAlive;
  8566. }
  8567.  
  8568. // Get Random Alive -returns index of alive player number n -
  8569. fnGetRandomAlive(n)
  8570. {
  8571. static iAlive, id
  8572. iAlive = 0
  8573.  
  8574. for (id = 1; id <= g_maxplayers; id++)
  8575. {
  8576. if (is_user_alive(id))
  8577. iAlive++
  8578.  
  8579. if (iAlive == n)
  8580. return id;
  8581. }
  8582.  
  8583. return -1;
  8584. }
  8585.  
  8586. // Get Playing -returns number of users playing-
  8587. fnGetPlaying()
  8588. {
  8589. static iPlaying, id, team
  8590. iPlaying = 0
  8591.  
  8592. for (id = 1; id <= g_maxplayers; id++)
  8593. {
  8594. if (is_user_connected(id))
  8595. {
  8596. team = fm_get_user_team(id)
  8597.  
  8598. if (team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)
  8599. iPlaying++
  8600. }
  8601. }
  8602.  
  8603. return iPlaying;
  8604. }
  8605.  
  8606. // Get CTs -returns number of CTs connected-
  8607. fnGetCTs()
  8608. {
  8609. static iCTs, id
  8610. iCTs = 0
  8611.  
  8612. for (id = 1; id <= g_maxplayers; id++)
  8613. {
  8614. if (is_user_connected(id))
  8615. {
  8616. if (fm_get_user_team(id) == CS_TEAM_CT)
  8617. iCTs++
  8618. }
  8619. }
  8620.  
  8621. return iCTs;
  8622. }
  8623.  
  8624. // Get Ts -returns number of Ts connected-
  8625. fnGetTs()
  8626. {
  8627. static iTs, id
  8628. iTs = 0
  8629.  
  8630. for (id = 1; id <= g_maxplayers; id++)
  8631. {
  8632. if (is_user_connected(id))
  8633. {
  8634. if (fm_get_user_team(id) == CS_TEAM_T)
  8635. iTs++
  8636. }
  8637. }
  8638.  
  8639. return iTs;
  8640. }
  8641.  
  8642. // Last Zombie Check -check for last zombie and set its flag-
  8643. public fnCheckLastZombie()
  8644. {
  8645. static id
  8646. for (id = 1; id <= g_maxplayers; id++)
  8647. {
  8648. // Last zombie
  8649. if (g_zombie[id] && is_user_alive(id) && fnGetZombies() == 1)
  8650. g_lastzombie[id] = true
  8651. else
  8652. g_lastzombie[id] = false
  8653.  
  8654. // Last human
  8655. if (!g_zombie[id] && !g_survivor[id] && is_user_alive(id) && fnGetHumans() == 1)
  8656. {
  8657. // Reward extra hp for last human?
  8658. if (!g_lasthuman[id]) fm_set_user_health(id, pev(id, pev_health)+get_pcvar_num(cvar_humanlasthp))
  8659. g_lasthuman[id] = true
  8660. }
  8661. else
  8662. g_lasthuman[id] = false
  8663. }
  8664. }
  8665.  
  8666. // Save player's stats into the database
  8667. save_stats(id)
  8668. {
  8669. // Get user name
  8670. static name[32]
  8671. get_user_name(id, name, sizeof name - 1)
  8672.  
  8673. // Check whether there is another record already in that slot
  8674. if (db_name[id][0] && !equal(name, db_name[id]))
  8675. {
  8676. // If DB size is exceeded, write over old records
  8677. if (db_slot_i >= sizeof db_name)
  8678. db_slot_i = g_maxplayers+1
  8679.  
  8680. // Move previous record onto an additional save slot
  8681. copy(db_name[db_slot_i], sizeof db_name[] - 1, db_name[id])
  8682. db_ammopacks[db_slot_i] = db_ammopacks[id]
  8683. db_zombieclass[db_slot_i] = db_zombieclass[id]
  8684. db_slot_i++
  8685. }
  8686.  
  8687. // Now save the current player stats
  8688. copy(db_name[id], sizeof db_name[] - 1, name) // name
  8689. db_ammopacks[id] = g_ammopacks[id] // ammo packs
  8690. db_zombieclass[id] = g_zombieclassnext[id] // zombie class
  8691. }
  8692.  
  8693. // Load player's stats from the database (if a record is found)
  8694. load_stats(id)
  8695. {
  8696. // Get user name
  8697. static name[32], i
  8698. get_user_name(id, name, sizeof name - 1)
  8699.  
  8700. // Look for a matching record in the DB
  8701. for (i = 0; i < sizeof db_name; i++)
  8702. {
  8703. if (equal(name, db_name[i]))
  8704. {
  8705. // Bingo!
  8706. g_ammopacks[id] = db_ammopacks[i]
  8707. g_zombieclass[id] = db_zombieclass[i]
  8708. g_zombieclassnext[id] = db_zombieclass[i]
  8709. return;
  8710. }
  8711. }
  8712. }
  8713.  
  8714. // Checks if a player should leap
  8715. allowed_leap(id)
  8716. {
  8717. // Leap available for zombies/nemesis/survivor only
  8718. if ((!g_zombie[id] && !g_survivor[id]) || g_frozen[id])
  8719. return false;
  8720.  
  8721. // Nemesis cvar not enabled
  8722. if (g_nemesis[id] && !get_pcvar_num(cvar_leapnemesis))
  8723. return false;
  8724.  
  8725. // Survivor cvar not enabled
  8726. if (g_survivor[id] && !get_pcvar_num(cvar_leapsurvivor))
  8727. return false;
  8728.  
  8729. // Get zombie cvar
  8730. static leapzombies
  8731. leapzombies = get_pcvar_num(cvar_leapzombies)
  8732.  
  8733. // Zombie cvar not enabled
  8734. if (leapzombies == 0 && !g_nemesis[id] && !g_survivor[id])
  8735. return false;
  8736.  
  8737. // Not the first zombie
  8738. if (leapzombies == 2 && !g_nemesis[id] && !g_survivor[id] && !g_firstzombie[id])
  8739. return false;
  8740.  
  8741. // Not the last zombie
  8742. if (leapzombies == 3 && !g_nemesis[id] && !g_survivor[id] && !g_lastzombie[id])
  8743. return false;
  8744.  
  8745. // Get currently pressed buttons
  8746. static buttons
  8747. buttons = pev(id, pev_button)
  8748.  
  8749. // Not doing a longjump (added bot support)
  8750. if ((!(buttons & IN_JUMP) || !(buttons & IN_DUCK)) && !is_user_bot(id))
  8751. return false;
  8752.  
  8753. // Get cooldown cvar
  8754. static Float:cooldown
  8755. cooldown = g_survivor[id] ? get_pcvar_float(cvar_leapsurvivorcooldown) : g_nemesis[id] ? get_pcvar_float(cvar_leapnemesiscooldown) : get_pcvar_float(cvar_leapzombiescooldown)
  8756.  
  8757. // Cooldown not over yet
  8758. if (get_gametime() - g_lastleaptime[id] < cooldown)
  8759. return false;
  8760.  
  8761. // Not on ground or not enough speed
  8762. if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
  8763. return false;
  8764.  
  8765. return true;
  8766. }
  8767.  
  8768. // Checks if a player should be Pain Shock Free
  8769. allowed_painshockfree(id)
  8770. {
  8771. // Pain shock free available for zombies/nemesis/survivor only
  8772. if (!g_zombie[id] && !g_survivor[id])
  8773. return false;
  8774.  
  8775. // Nemesis cvar not enabled
  8776. if (g_nemesis[id] && !get_pcvar_num(cvar_nempainfree))
  8777. return false;
  8778.  
  8779. // Survivor cvar not enabled
  8780. if (g_survivor[id] && !get_pcvar_num(cvar_survpainfree))
  8781. return false;
  8782.  
  8783. // Get zombie cvar
  8784. static zombiepainfree
  8785. zombiepainfree = get_pcvar_num(cvar_zombiepainfree)
  8786.  
  8787. // Zombie cvar not enabled
  8788. if (zombiepainfree == 0 && !g_survivor[id] && !g_nemesis[id])
  8789. return false;
  8790.  
  8791. // Not the last zombie
  8792. if (zombiepainfree == 2 && !g_survivor[id] && !g_nemesis[id] && !g_lastzombie[id])
  8793. return false;
  8794.  
  8795. // Not on ground
  8796. if (!(pev(id, pev_flags) & FL_ONGROUND))
  8797. return false;
  8798.  
  8799. return true;
  8800. }
  8801.  
  8802. // Checks if a player is allowed to be zombie
  8803. allowed_zombie(id)
  8804. {
  8805. if (g_zombie[id] || g_swarmround || g_nemround || g_survround || g_plagueround || g_endround || !is_user_alive(id) || task_exists(TASK_WELCOMEMSG) || (!g_zombie[id] && fnGetHumans() == 1))
  8806. return false;
  8807.  
  8808. return true;
  8809. }
  8810.  
  8811. // Checks if a player is allowed to be human
  8812. allowed_human(id)
  8813. {
  8814. if (!g_zombie[id] || g_swarmround || g_nemround || g_survround || g_plagueround || g_endround || !is_user_alive(id) || task_exists(TASK_WELCOMEMSG) || (g_zombie[id] && fnGetZombies() == 1))
  8815. return false;
  8816.  
  8817. return true;
  8818. }
  8819.  
  8820. // Checks if a player is allowed to be survivor
  8821. allowed_survivor(id)
  8822. {
  8823. if (g_endround || !g_newround || !is_user_alive(id) || !get_pcvar_num(cvar_surv) || task_exists(TASK_WELCOMEMSG) || fnGetAlive() < get_pcvar_num(cvar_survminplayers))
  8824. return false;
  8825.  
  8826. return true;
  8827. }
  8828.  
  8829. // Checks if a player is allowed to be nemesis
  8830. allowed_nemesis(id)
  8831. {
  8832. if (g_endround || !g_newround || !is_user_alive(id) || !get_pcvar_num(cvar_nem) || task_exists(TASK_WELCOMEMSG) || fnGetAlive() < get_pcvar_num(cvar_nemminplayers))
  8833. return false;
  8834.  
  8835. return true;
  8836. }
  8837.  
  8838. // Checks if a player is allowed to respawn
  8839. allowed_respawn(id)
  8840. {
  8841. static team
  8842. team = fm_get_user_team(id)
  8843.  
  8844. if (g_endround || g_survround || g_swarmround || g_nemround || g_plagueround || team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED || !is_user_connected(id) || is_user_alive(id))
  8845. return false;
  8846.  
  8847. return true;
  8848. }
  8849.  
  8850. // Checks if swarm mode is allowed
  8851. allowed_swarm()
  8852. {
  8853. if (g_endround || !g_newround || !get_pcvar_num(cvar_swarm) || task_exists(TASK_WELCOMEMSG) || fnGetAlive() < get_pcvar_num(cvar_swarmminplayers))
  8854. return false;
  8855.  
  8856. return true;
  8857. }
  8858.  
  8859. // Checks if multi infection mode is allowed
  8860. allowed_multi()
  8861. {
  8862. if (g_endround || !g_newround || !get_pcvar_num(cvar_multi) || task_exists(TASK_WELCOMEMSG) || floatround(fnGetAlive()*get_pcvar_float(cvar_multiratio), floatround_ceil) < 2 || floatround(fnGetAlive()*get_pcvar_float(cvar_multiratio), floatround_ceil) >= fnGetAlive() || fnGetAlive() < get_pcvar_num(cvar_multiminplayers))
  8863. return false;
  8864.  
  8865. return true;
  8866. }
  8867.  
  8868. // Checks if plague mode is allowed
  8869. allowed_plague()
  8870. {
  8871. if (g_endround || !g_newround || !get_pcvar_num(cvar_plague) || task_exists(TASK_WELCOMEMSG) || floatround((fnGetAlive()-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) < 1
  8872. || 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 || fnGetAlive() < get_pcvar_num(cvar_plagueminplayers))
  8873. return false;
  8874.  
  8875. return true;
  8876. }
  8877. command_assassin(id, player)
  8878. {
  8879. static name1[32], name2[32]
  8880. get_user_name(id, name1, sizeof name1 - 1)
  8881. get_user_name(player, name2, 31)
  8882.  
  8883. // Show activity?
  8884. switch (get_pcvar_num(cvar_showactivity))
  8885. {
  8886. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s turn into Assassin", name2)
  8887. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s turn into Assassin", name1, name2)
  8888. }
  8889.  
  8890. // Log to Zombie Plague log file?
  8891. if (get_pcvar_num(cvar_logcommands))
  8892. {
  8893. static logdata[100], authid[32], ip[16]
  8894. get_user_authid(id, authid, sizeof authid - 1)
  8895. get_user_ip(id, ip, sizeof ip - 1, 1)
  8896. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s turn into Assassin (Players: %d/%d)", name1, authid, ip, name2, fnGetPlaying(), g_maxplayers)
  8897. log_to_file("zombieplague.log", logdata)
  8898. }
  8899.  
  8900. remove_task(TASK_MAKEZOMBIE)
  8901. make_a_zombie(MODE_ASSASSIN, player)
  8902. }
  8903. command_depredador(id)
  8904. {
  8905. static name1[32], name2[32]
  8906. get_user_name(id, name1, sizeof name1 - 1)
  8907.  
  8908. // Show activity?
  8909. switch (get_pcvar_num(cvar_showactivity))
  8910. {
  8911. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Start Mode Depredador")
  8912. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Start Mode Depredador", name1)
  8913. }
  8914.  
  8915. // Log to Zombie Plague log file?
  8916. if (get_pcvar_num(cvar_logcommands))
  8917. {
  8918. static logdata[100], authid[32], ip[16]
  8919. get_user_authid(id, authid, sizeof authid - 1)
  8920. get_user_ip(id, ip, sizeof ip - 1, 1)
  8921. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s Start Mode Depredador (Players: %d/%d)", name1, authid, ip, name2, fnGetPlaying(), g_maxplayers)
  8922. log_to_file("zombieplague.log", logdata)
  8923. }
  8924.  
  8925. remove_task(TASK_MAKEZOMBIE)
  8926. make_a_zombie(MODE_DEPREDADOR, 0)
  8927. }
  8928. command_invasion(id)
  8929. {
  8930. static name1[32]
  8931. get_user_name(id, name1, sizeof name1 - 1)
  8932.  
  8933. // Show activity?
  8934. switch (get_pcvar_num(cvar_showactivity))
  8935. {
  8936. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Iniciar Invasion")
  8937. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Iniciar Invasion", name1)
  8938. }
  8939.  
  8940. // Log to Zombie Plague log file?
  8941. if (get_pcvar_num(cvar_logcommands))
  8942. {
  8943. static logdata[100], authid[32], ip[16]
  8944. get_user_authid(id, authid, sizeof authid - 1)
  8945. get_user_ip(id, ip, sizeof ip - 1, 1)
  8946. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - Iniciar Invasion (Players: %d/%d)", name1, authid, ip, fnGetPlaying(), g_maxplayers)
  8947. log_to_file("zombieplague.log", logdata)
  8948. }
  8949.  
  8950. remove_task(TASK_MAKEZOMBIE)
  8951. make_a_zombie(MODE_INVASION, 0)
  8952. }
  8953. command_apocalypsis(id)
  8954. {
  8955. static name1[32]
  8956. get_user_name(id, name1, sizeof name1 - 1)
  8957.  
  8958. // Show activity?
  8959. switch (get_pcvar_num(cvar_showactivity))
  8960. {
  8961. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Iniciar Apocalypsis")
  8962. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Iniciar Apocalypsis", name1)
  8963. }
  8964.  
  8965. // Log to Zombie Plague log file?
  8966. if (get_pcvar_num(cvar_logcommands))
  8967. {
  8968. static logdata[100], authid[32], ip[16]
  8969. get_user_authid(id, authid, sizeof authid - 1)
  8970. get_user_ip(id, ip, sizeof ip - 1, 1)
  8971. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - Iniciar Apocalypsis (Players: %d/%d)", name1, authid, ip, fnGetPlaying(), g_maxplayers)
  8972. log_to_file("zombieplague.log", logdata)
  8973. }
  8974.  
  8975. remove_task(TASK_MAKEZOMBIE)
  8976. make_a_zombie(MODE_APOCALYPSIS, 0)
  8977. }
  8978.  
  8979. command_revelacion(id)
  8980. {
  8981. static name1[32]
  8982. get_user_name(id, name1, sizeof name1 - 1)
  8983.  
  8984. // Show activity?
  8985. switch (get_pcvar_num(cvar_showactivity))
  8986. {
  8987. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Iniciar Revelacion")
  8988. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Iniciar Revelacion", name1)
  8989. }
  8990.  
  8991. // Log to Zombie Plague log file?
  8992. if (get_pcvar_num(cvar_logcommands))
  8993. {
  8994. static logdata[100], authid[32], ip[16]
  8995. get_user_authid(id, authid, sizeof authid - 1)
  8996. get_user_ip(id, ip, sizeof ip - 1, 1)
  8997. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - Iniciar Revelacion (Players: %d/%d)", name1, authid, ip, fnGetPlaying(), g_maxplayers)
  8998. log_to_file("zombieplague.log", logdata)
  8999. }
  9000.  
  9001. remove_task(TASK_MAKEZOMBIE)
  9002. make_a_zombie(MODE_REVELACION, 0)
  9003. }
  9004.  
  9005. command_armageddon(id)
  9006. {
  9007. static name1[32]
  9008. get_user_name(id, name1, sizeof name1 - 1)
  9009.  
  9010. // Show activity?
  9011. switch (get_pcvar_num(cvar_showactivity))
  9012. {
  9013. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Iniciar Armageddon")
  9014. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Iniciar Armageddon", name1)
  9015. }
  9016.  
  9017. // Log to Zombie Plague log file?
  9018. if (get_pcvar_num(cvar_logcommands))
  9019. {
  9020. static logdata[100], authid[32], ip[16]
  9021. get_user_authid(id, authid, sizeof authid - 1)
  9022. get_user_ip(id, ip, sizeof ip - 1, 1)
  9023. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - Iniciar Armageddon (Players: %d/%d)", name1, authid, ip, fnGetPlaying(), g_maxplayers)
  9024. log_to_file("zombieplague.log", logdata)
  9025. }
  9026.  
  9027. remove_task(TASK_MAKEZOMBIE)
  9028. make_a_zombie(MODE_ARMAGEDDON, 0)
  9029. }
  9030. // Admin Command. zp_zombie
  9031. command_zombie(id, player)
  9032. {
  9033. static name1[32], name2[32]
  9034. get_user_name(id, name1, sizeof name1 - 1)
  9035. get_user_name(player, name2, sizeof name2 - 1)
  9036.  
  9037. // Show activity?
  9038. switch (get_pcvar_num(cvar_showactivity))
  9039. {
  9040. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s %L", name2, LANG_PLAYER, "CMD_INFECT")
  9041. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s %L", name1, name2, LANG_PLAYER, "CMD_INFECT")
  9042. }
  9043.  
  9044. // Log to Zombie Plague log file?
  9045. if (get_pcvar_num(cvar_logcommands))
  9046. {
  9047. static logdata[100], authid[32], ip[16]
  9048. get_user_authid(id, authid, sizeof authid - 1)
  9049. get_user_ip(id, ip, sizeof ip - 1, 1)
  9050. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", name1, authid, ip, name2, LANG_SERVER, "CMD_INFECT", fnGetPlaying(), g_maxplayers)
  9051. log_to_file("zombieplague.log", logdata)
  9052. }
  9053.  
  9054. // New round?
  9055. if (g_newround)
  9056. {
  9057. // Set as first zombie
  9058. remove_task(TASK_MAKEZOMBIE)
  9059. make_a_zombie(MODE_INFECTION, player)
  9060. }
  9061. else
  9062. {
  9063. // Just infect
  9064. zombieme(player, 0, 0, 0)
  9065. }
  9066. }
  9067.  
  9068. // Admin Command. zp_human
  9069. command_human(id, player)
  9070. {
  9071. static name1[32], name2[32]
  9072. get_user_name(id, name1, sizeof name1 - 1)
  9073. get_user_name(player, name2, sizeof name2 - 1)
  9074.  
  9075. // Show activity?
  9076. switch (get_pcvar_num(cvar_showactivity))
  9077. {
  9078. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s %L", name2, LANG_PLAYER, "CMD_DISINFECT")
  9079. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s %L", name1, name2, LANG_PLAYER, "CMD_DISINFECT")
  9080. }
  9081.  
  9082. // Log to Zombie Plague log file?
  9083. if (get_pcvar_num(cvar_logcommands))
  9084. {
  9085. static logdata[100], authid[32], ip[16]
  9086. get_user_authid(id, authid, sizeof authid - 1)
  9087. get_user_ip(id, ip, sizeof ip - 1, 1)
  9088. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", name1, authid, ip, name2, LANG_SERVER,"CMD_DISINFECT", fnGetPlaying(), g_maxplayers)
  9089. log_to_file("zombieplague.log", logdata)
  9090. }
  9091.  
  9092. // Turn to human
  9093. humanme(player, 0)
  9094. }
  9095.  
  9096. // Admin Command: zp_synapsis
  9097. command_synapsis(id)
  9098. {
  9099. static name1[32]
  9100. get_user_name(id, name1, sizeof name1 - 1)
  9101.  
  9102. // Show activity?
  9103. switch (get_pcvar_num(cvar_showactivity))
  9104. {
  9105. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Iniciar Synapsis")
  9106. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Iniciar Synapsis", name1)
  9107. }
  9108.  
  9109. // Log to Zombie Plague log file?
  9110. if (get_pcvar_num(cvar_logcommands))
  9111. {
  9112. static logdata[100], authid[32], ip[16]
  9113. get_user_authid(id, authid, sizeof authid - 1)
  9114. get_user_ip(id, ip, sizeof ip - 1, 1)
  9115. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %L (Players: %d/%d)", name1, authid, ip, LANG_SERVER, "CMD_SWARM", fnGetPlaying(), g_maxplayers)
  9116. log_to_file("zombieplague.log", logdata)
  9117. }
  9118.  
  9119. // Call Swarm Mode
  9120. remove_task(TASK_MAKEZOMBIE)
  9121. make_a_zombie(MODE_SYNAPSIS, 0)
  9122. }
  9123.  
  9124. // Admin Command. zp_terminator
  9125. command_terminator(id)
  9126. {
  9127. static name1[32]
  9128. get_user_name(id, name1, 31)
  9129.  
  9130. switch(get_pcvar_num(cvar_showactivity))
  9131. {
  9132. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Start Terminator Mode")
  9133. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Start Terminator Mode", name1)
  9134. }
  9135.  
  9136. if (get_pcvar_num(cvar_logcommands))
  9137. {
  9138. static ip[33], authid[33], logdata[33]
  9139. get_user_ip(id, ip, 32)
  9140. get_user_authid(id, authid, 32)
  9141. formatex(logdata, 32, "ADMIN %s <%s><%s> Players:(%d/%d) - %s Start Mode Terminator", name1, ip, authid, fnGetAlive(), get_maxplayers())
  9142. }
  9143.  
  9144. remove_task(TASK_MAKEZOMBIE)
  9145. make_a_zombie(MODE_TERMINATOR, 0)
  9146. }
  9147.  
  9148. // Admin Command. zp_survivor
  9149. command_survivor(id)
  9150. {
  9151. static name1[32]
  9152. get_user_name(id, name1, sizeof name1 - 1)
  9153.  
  9154. // Show activity?
  9155. switch (get_pcvar_num(cvar_showactivity))
  9156. {
  9157. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - Start Mode Survivor")
  9158. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - Start Mode Survivor", name1)
  9159. }
  9160.  
  9161. // Log to Zombie Plague log file?
  9162. if (get_pcvar_num(cvar_logcommands))
  9163. {
  9164. static logdata[100], authid[32], ip[16]
  9165. get_user_authid(id, authid, sizeof authid - 1)
  9166. get_user_ip(id, ip, sizeof ip - 1, 1)
  9167. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - Start Mode Survivor (Players: %d/%d)", name1, authid, ip, LANG_SERVER,"CMD_SURVIVAL", fnGetPlaying(), g_maxplayers)
  9168. log_to_file("zombieplague.log", logdata)
  9169. }
  9170.  
  9171. // Turn into a Survivor
  9172. remove_task(TASK_MAKEZOMBIE)
  9173. make_a_zombie(MODE_SURVIVOR, 0)
  9174. }
  9175.  
  9176. // Admin Command. zp_wesker
  9177. command_wesker(id, player)
  9178. {
  9179. static name1[32], name2[32]
  9180. get_user_name(id, name1, sizeof name1 - 1)
  9181. get_user_name(player, name2, sizeof name2 - 1)
  9182.  
  9183. // Show activity?
  9184. switch (get_pcvar_num(cvar_showactivity))
  9185. {
  9186. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s turn into Wesker", name2)
  9187. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s turn into Wesker", name1, name2)
  9188. }
  9189.  
  9190. // Log to Zombie Plague log file?
  9191. if (get_pcvar_num(cvar_logcommands))
  9192. {
  9193. static logdata[100], authid[32], ip[16]
  9194. get_user_authid(id, authid, sizeof authid - 1)
  9195. get_user_ip(id, ip, sizeof ip - 1, 1)
  9196. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s turn into wesker (Players: %d/%d)", name1, authid, ip, name2, fnGetPlaying(), g_maxplayers)
  9197. log_to_file("zombieplague.log", logdata)
  9198. }
  9199.  
  9200. // Turn into a Wesker
  9201. remove_task(TASK_MAKEZOMBIE)
  9202. make_a_zombie(MODE_WESKER, player)
  9203. }
  9204.  
  9205. // Admin Command. zp_nemesis
  9206. command_nemesis(id, player)
  9207. {
  9208. static name1[32], name2[32]
  9209. get_user_name(id, name1, sizeof name1 - 1)
  9210. get_user_name(player, name2, sizeof name2 - 1)
  9211.  
  9212. // Show activity?
  9213. switch (get_pcvar_num(cvar_showactivity))
  9214. {
  9215. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s %L", name2, LANG_PLAYER, "CMD_NEMESIS")
  9216. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s %L", name1, name2, LANG_PLAYER, "CMD_NEMESIS")
  9217. }
  9218.  
  9219. // Log to Zombie Plague log file?
  9220. if (get_pcvar_num(cvar_logcommands))
  9221. {
  9222. static logdata[100], authid[32], ip[16]
  9223. get_user_authid(id, authid, sizeof authid - 1)
  9224. get_user_ip(id, ip, sizeof ip - 1, 1)
  9225. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", name1, authid, ip, name2, LANG_SERVER,"CMD_NEMESIS", fnGetPlaying(), g_maxplayers)
  9226. log_to_file("zombieplague.log", logdata)
  9227. }
  9228.  
  9229. // Turn into a Nemesis
  9230. remove_task(TASK_MAKEZOMBIE)
  9231. make_a_zombie(MODE_NEMESIS, player)
  9232. }
  9233.  
  9234. // Admin Command. zp_respawn
  9235. command_respawn(id, player)
  9236. {
  9237. static name1[32], name2[32]
  9238. get_user_name(id, name1, sizeof name1 - 1)
  9239. get_user_name(player, name2, sizeof name2 - 1)
  9240.  
  9241. // Show activity?
  9242. switch (get_pcvar_num(cvar_showactivity))
  9243. {
  9244. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %s %L", name2, LANG_PLAYER, "CMD_RESPAWN")
  9245. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %s %L", name1, name2, LANG_PLAYER, "CMD_RESPAWN")
  9246. }
  9247.  
  9248. // Log to Zombie Plague log file?
  9249. if (get_pcvar_num(cvar_logcommands))
  9250. {
  9251. static logdata[100], authid[32], ip[16]
  9252. get_user_authid(id, authid, sizeof authid - 1)
  9253. get_user_ip(id, ip, sizeof ip - 1, 1)
  9254. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", name1, authid, ip, name2, LANG_SERVER, "CMD_RESPAWN", fnGetPlaying(), g_maxplayers)
  9255. log_to_file("zombieplague.log", logdata)
  9256. }
  9257.  
  9258. // Get deathmatch mode status
  9259. static deathmatch
  9260. deathmatch = get_pcvar_num(cvar_deathmatch)
  9261.  
  9262. // Respawn as zombie?
  9263. if (deathmatch == 2 || (deathmatch == 3 && random_num(0, 1)) || (deathmatch == 4 && fnGetZombies() < fnGetAlive()/2))
  9264. g_respawn_as_zombie[player] = true
  9265.  
  9266. respawn_player(player+TASK_SPAWN);
  9267. }
  9268.  
  9269. // Admin Command. zp_swarm
  9270. command_swarm(id)
  9271. {
  9272. static name1[32]
  9273. get_user_name(id, name1, sizeof name1 - 1)
  9274.  
  9275. // Show activity?
  9276. switch (get_pcvar_num(cvar_showactivity))
  9277. {
  9278. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %L", LANG_PLAYER, "CMD_SWARM")
  9279. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %L", name1, LANG_PLAYER, "CMD_SWARM")
  9280. }
  9281.  
  9282. // Log to Zombie Plague log file?
  9283. if (get_pcvar_num(cvar_logcommands))
  9284. {
  9285. static logdata[100], authid[32], ip[16]
  9286. get_user_authid(id, authid, sizeof authid - 1)
  9287. get_user_ip(id, ip, sizeof ip - 1, 1)
  9288. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %L (Players: %d/%d)", name1, authid, ip, LANG_SERVER, "CMD_SWARM", fnGetPlaying(), g_maxplayers)
  9289. log_to_file("zombieplague.log", logdata)
  9290. }
  9291.  
  9292. // Call Swarm Mode
  9293. remove_task(TASK_MAKEZOMBIE)
  9294. make_a_zombie(MODE_SWARM, 0)
  9295. }
  9296.  
  9297. // Admin Command. zp_multi
  9298. command_multi(id)
  9299. {
  9300. static name1[32]
  9301. get_user_name(id, name1, sizeof name1 - 1)
  9302.  
  9303. // Show activity?
  9304. switch (get_pcvar_num(cvar_showactivity))
  9305. {
  9306. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %L", LANG_PLAYER, "CMD_MULTI")
  9307. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %L", name1, LANG_PLAYER, "CMD_MULTI")
  9308. }
  9309.  
  9310. // Log to Zombie Plague log file?
  9311. if (get_pcvar_num(cvar_logcommands))
  9312. {
  9313. static logdata[100], authid[32], ip[16]
  9314. get_user_authid(id, authid, sizeof authid - 1)
  9315. get_user_ip(id, ip, sizeof ip - 1, 1)
  9316. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %L (Players: %d/%d)", name1, authid, ip, LANG_SERVER,"CMD_MULTI", fnGetPlaying(), g_maxplayers)
  9317. log_to_file("zombieplague.log", logdata)
  9318. }
  9319.  
  9320. // Call Multi Infection
  9321. remove_task(TASK_MAKEZOMBIE)
  9322. make_a_zombie(MODE_MULTI, 0)
  9323. }
  9324.  
  9325. // Admin Command. zp_plague
  9326. command_plague(id)
  9327. {
  9328. static name1[32]
  9329. get_user_name(id, name1, sizeof name1 - 1)
  9330.  
  9331. // Show activity?
  9332. switch (get_pcvar_num(cvar_showactivity))
  9333. {
  9334. case 1: zp_colored_print(id, "^x04[ZP]^x01 ADMIN - %L", LANG_PLAYER, "CMD_PLAGUE")
  9335. case 2: zp_colored_print(id, "^x04[ZP]^x01 ADMIN %s - %L", name1, LANG_PLAYER, "CMD_PLAGUE")
  9336. }
  9337.  
  9338. // Log to Zombie Plague log file?
  9339. if (get_pcvar_num(cvar_logcommands))
  9340. {
  9341. static logdata[100], authid[32], ip[16]
  9342. get_user_authid(id, authid, sizeof authid - 1)
  9343. get_user_ip(id, ip, sizeof ip - 1, 1)
  9344. formatex(logdata, sizeof logdata - 1, "ADMIN %s <%s><%s> - %L (Players: %d/%d)", name1, authid, ip, LANG_SERVER,"CMD_PLAGUE", fnGetPlaying(), g_maxplayers)
  9345. log_to_file("zombieplague.log", logdata)
  9346. }
  9347.  
  9348. // Call Plague Mode
  9349. remove_task(TASK_MAKEZOMBIE)
  9350. make_a_zombie(MODE_PLAGUE, 0)
  9351. }
  9352.  
  9353. /*================================================================================
  9354. [Custom Natives]
  9355. =================================================================================*/
  9356.  
  9357. // Native: zp_get_user_zombie
  9358. public native_get_user_zombie(id)
  9359. {
  9360. return g_zombie[id];
  9361. }
  9362. public native_get_user_reset(id)
  9363. {
  9364. return g_reset[id];
  9365. }
  9366. public native_get_user_level(id)
  9367. {
  9368. return g_reset[id];
  9369. }
  9370. public native_set_user_reset(id, amount)
  9371. {
  9372. return g_reset[id] += amount
  9373. }
  9374. public native_set_user_level(id, amount)
  9375. {
  9376. return g_level[id] += amount
  9377. }
  9378. // Native: zp_get_user_terminator
  9379. public native_get_user_terminator(id)
  9380. {
  9381. return g_terminator[id];
  9382. }
  9383.  
  9384. // Native: zp_get_user_nemesis
  9385. public native_get_user_nemesis(id)
  9386. {
  9387. return g_nemesis[id];
  9388. }
  9389.  
  9390. // Native: zp_get_user_survivor
  9391. public native_get_user_survivor(id)
  9392. {
  9393. return g_survivor[id];
  9394. }
  9395.  
  9396. public native_get_user_first_zombie(id)
  9397. {
  9398. return g_firstzombie[id];
  9399. }
  9400.  
  9401. // Native: zp_get_user_last_zombie
  9402. public native_get_user_last_zombie(id)
  9403. {
  9404. return g_lastzombie[id];
  9405. }
  9406.  
  9407. // Native: zp_get_user_last_human
  9408. public native_get_user_last_human(id)
  9409. {
  9410. return g_lasthuman[id];
  9411. }
  9412.  
  9413. // Native: zp_get_user_zombie_class
  9414. public native_get_user_zombie_class(id)
  9415. {
  9416. return g_zombieclass[id];
  9417. }
  9418.  
  9419. // Native: zp_set_user_zombie_class
  9420. public native_set_user_zombie_class(id, classid)
  9421. {
  9422. g_zombieclassnext[id] = classid
  9423. }
  9424.  
  9425. // Native: zp_get_user_human_class
  9426. public native_get_user_human_class(id)
  9427. {
  9428. return g_humanclass[id];
  9429. }
  9430.  
  9431. // Native: zp_set_user_zombie_class
  9432. public native_set_user_human_class(id, classid)
  9433. {
  9434. g_humanclassnext[id] = classid
  9435. }
  9436.  
  9437. // Native: zp_get_user_ammo_packs
  9438. public native_get_user_ammo_packs(id)
  9439. {
  9440. return g_ammopacks[id];
  9441. }
  9442.  
  9443. // Native: zp_set_user_ammo_packs
  9444. public native_set_user_ammo_packs(id, amount)
  9445. {
  9446. g_ammopacks[id] = amount;
  9447. }
  9448.  
  9449. // Native: zp_get_zombie_maxhealth
  9450. public native_get_zombie_maxhealth(id)
  9451. {
  9452. if (g_zombie[id] && !g_nemesis[id])
  9453. {
  9454. if (g_firstzombie[id])
  9455. return floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp));
  9456. else
  9457. return g_zclass_hp[g_zombieclass[id]];
  9458. }
  9459. return -1;
  9460. }
  9461.  
  9462. // Native: zp_get_user_batteries
  9463. public native_get_user_batteries(id)
  9464. {
  9465. return g_flashbattery[id];
  9466. }
  9467.  
  9468. // Native: zp_set_user_batteries
  9469. public native_set_user_batteries(id, value)
  9470. {
  9471. g_flashbattery[id] = value;
  9472. }
  9473.  
  9474. // Native: zp_infect_user
  9475. public native_infect_user(id, infector)
  9476. {
  9477. // Not allowed to be zombie or round not started yet
  9478. if (!allowed_zombie(id) || g_newround)
  9479. return 0;
  9480.  
  9481. // Infect
  9482. zombieme(id, infector, 0, 0)
  9483. return 1;
  9484. }
  9485.  
  9486. // Native: zp_disinfect_user
  9487. public native_disinfect_user(id)
  9488. {
  9489. // Not allowed to be human
  9490. if (!allowed_human(id))
  9491. return 0;
  9492.  
  9493. // Turn to human
  9494. humanme(id, 0)
  9495. return 1;
  9496. }
  9497.  
  9498. // Native: zp_respawn_user
  9499. public native_respawn_user(id, team)
  9500. {
  9501. // Respawn not allowed
  9502. if (!allowed_respawn(id))
  9503. return 0;
  9504.  
  9505. // Respawn as zombie?
  9506. g_respawn_as_zombie[id] = (team == ZP_TEAM_ZOMBIE) ? true : false
  9507.  
  9508. // Respawnish!
  9509. respawn_player(id+TASK_SPAWN)
  9510. return 1;
  9511. }
  9512.  
  9513. // Native: zp_has_round_started
  9514. public native_has_round_started()
  9515. {
  9516. return !g_newround;
  9517. }
  9518.  
  9519. // Native: zp_is_nemesis_round
  9520. public native_is_nemesis_round()
  9521. {
  9522. return g_nemround;
  9523. }
  9524.  
  9525. // Native: zp_is_survivor_round
  9526. public native_is_survivor_round()
  9527. {
  9528. return g_survround;
  9529. }
  9530.  
  9531. // Native: zp_is_swarm_round
  9532. public native_is_swarm_round()
  9533. {
  9534. return g_swarmround;
  9535. }
  9536.  
  9537. // Native: zp_is_plague_round
  9538. public native_is_plague_round()
  9539. {
  9540. return g_plagueround;
  9541. }
  9542.  
  9543. // Native: zp_is_plague_round
  9544. public native_is_wesker_round()
  9545. {
  9546. return g_weskerround;
  9547. }
  9548.  
  9549. // Native: zp_register_extra_item
  9550. public native_register_extra_item(const name[], cost, team)
  9551. {
  9552. // Reached extra items limit
  9553. if (g_extraitem_i >= sizeof g_extraitem_name)
  9554. return -1;
  9555.  
  9556. // Strings passed byref
  9557. param_convert(1)
  9558.  
  9559. // Add the item
  9560. copy(g_extraitem_name[g_extraitem_i], sizeof g_extraitem_name[] - 1, name)
  9561. g_extraitem_cost[g_extraitem_i] = cost
  9562. g_extraitem_team[g_extraitem_i] = team
  9563.  
  9564. // Increase registered items counter
  9565. g_extraitem_i++
  9566.  
  9567. // Return id under which we registered the item
  9568. return g_extraitem_i-1;
  9569. }
  9570.  
  9571. // Function: zp_register_extra_item (to be used within this plugin only)
  9572. native_register_extra_item2(const name[], cost, team)
  9573. {
  9574. // Reached extra items limit
  9575. if (g_extraitem_i >= sizeof g_extraitem_name)
  9576. return;
  9577.  
  9578. // Add the item
  9579. copy(g_extraitem_name[g_extraitem_i], sizeof g_extraitem_name[] - 1, name)
  9580. g_extraitem_cost[g_extraitem_i] = cost
  9581. g_extraitem_team[g_extraitem_i] = team
  9582.  
  9583. // Increase registered items counter
  9584. g_extraitem_i++
  9585. }
  9586.  
  9587. // Native: zp_register_zombie_class
  9588. public native_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback)
  9589. {
  9590. // Reached zombie classes limit
  9591. if (g_zclass_i >= sizeof g_zclass_name)
  9592. return -1;
  9593.  
  9594. // Strings passed byref
  9595. param_convert(1)
  9596. param_convert(2)
  9597. param_convert(3)
  9598. param_convert(4)
  9599.  
  9600. // Add the class
  9601. copy(g_zclass_name[g_zclass_i], sizeof g_zclass_name[] - 1, name)
  9602. copy(g_zclass_info[g_zclass_i], sizeof g_zclass_info[] - 1, info)
  9603. copy(g_zclass_model[g_zclass_i], sizeof g_zclass_model[] - 1, model)
  9604. copy(g_zclass_clawmodel[g_zclass_i], sizeof g_zclass_clawmodel[] - 1, clawmodel)
  9605. g_zclass_hp[g_zclass_i] = hp
  9606. g_zclass_spd[g_zclass_i] = speed
  9607. g_zclass_grav[g_zclass_i] = gravity
  9608. g_zclass_kb[g_zclass_i] = knockback
  9609.  
  9610. // Precache custom models and retrieve the modelindex
  9611. new prec_mdl[100]
  9612. formatex(prec_mdl, sizeof prec_mdl - 1, "models/player/%s/%s.mdl", model, model)
  9613. g_zclass_modelindex[g_zclass_i] = engfunc(EngFunc_PrecacheModel, prec_mdl)
  9614. formatex(prec_mdl, sizeof prec_mdl - 1, "models/zombie_plague/%s", clawmodel)
  9615. engfunc(EngFunc_PrecacheModel, prec_mdl)
  9616.  
  9617. // Increase registered classes counter
  9618. g_zclass_i++
  9619.  
  9620. // Return id under which we registered the class
  9621. return g_zclass_i-1;
  9622. }
  9623.  
  9624. // Native: zp_register_human_class
  9625. public native_register_human_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:damage, armor, level)
  9626. {
  9627. // Reached zombie classes limit
  9628. if (g_hclass_i >= sizeof g_hclass_name)
  9629. return -1;
  9630.  
  9631. // Strings passed byref
  9632. param_convert(1)
  9633. param_convert(2)
  9634. param_convert(3)
  9635. param_convert(4)
  9636.  
  9637. // Add the class
  9638. copy(g_hclass_name[g_hclass_i], sizeof g_hclass_name[] - 1, name)
  9639. copy(g_hclass_info[g_hclass_i], sizeof g_hclass_info[] - 1, info)
  9640. copy(g_hclass_model[g_hclass_i], sizeof g_hclass_model[] - 1, model)
  9641. copy(g_hclass_clawmodel[g_hclass_i], sizeof g_hclass_clawmodel[] - 1, clawmodel)
  9642. g_hclass_hp[g_hclass_i] = hp
  9643. g_hclass_spd[g_hclass_i] = speed
  9644. g_hclass_grav[g_hclass_i] = gravity
  9645. g_hclass_dmg[g_hclass_i] = damage
  9646. g_hclass_armor[g_hclass_i] = armor
  9647. g_hclass_lvl[g_hclass_i] = level
  9648.  
  9649. // Precache custom models and retrieve the modelindex
  9650. new prec_mdl[100]
  9651. formatex(prec_mdl, sizeof prec_mdl - 1, "models/player/%s/%s.mdl", model, model)
  9652. g_hclass_modelindex[g_hclass_i] = engfunc(EngFunc_PrecacheModel, prec_mdl)
  9653. formatex(prec_mdl, sizeof prec_mdl - 1, "models/zombie_plague/%s", clawmodel)
  9654. engfunc(EngFunc_PrecacheModel, prec_mdl)
  9655.  
  9656. // Increase registered classes counter
  9657. g_hclass_i++
  9658.  
  9659. // Return id under which we registered the class
  9660. return g_hclass_i-1;
  9661. }
  9662.  
  9663. /*================================================================================
  9664. [Custom Messages]
  9665. =================================================================================*/
  9666.  
  9667. // Custom Night Vision
  9668. public set_user_nvision(taskid)
  9669. {
  9670. // Not meant to have nvision or not enabled
  9671. if (!g_nvision[ID_NVISION] || !g_nvisionenabled[ID_NVISION])
  9672. {
  9673. // Task not needed anymore
  9674. remove_task(taskid);
  9675. return;
  9676. }
  9677.  
  9678. // Get player origin and alive status
  9679. static Float:originF[3]
  9680. pev(ID_NVISION, pev_origin, originF)
  9681.  
  9682. // Nightvision message
  9683. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_NVISION)
  9684. write_byte(TE_DLIGHT) // TE id
  9685. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9686. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9687. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9688. write_byte(get_pcvar_num(cvar_nvgsize)) // radius
  9689.  
  9690. // Night Vision
  9691. if (g_nemesis[ID_NVISION] || (g_zombie[ID_NVISION] && g_nodamage[ID_NVISION]))
  9692. {
  9693. write_byte(255) // r
  9694. write_byte(0) // g
  9695. write_byte(0) // b
  9696. }
  9697. else
  9698. {
  9699. write_byte(g_nvg[ID_NVISION][0]) // r
  9700. write_byte(g_nvg[ID_NVISION][1]) // g
  9701. write_byte(g_nvg[ID_NVISION][2]) // b
  9702. }
  9703.  
  9704. write_byte(2) // life
  9705. write_byte(0) // decay rate
  9706. message_end()
  9707. }
  9708.  
  9709. // Game Nightvision
  9710. set_user_gnvision(id, toggle)
  9711. {
  9712. // Toggle NVG message
  9713. message_begin(MSG_ONE, g_msgNVGToggle, _, id)
  9714. write_byte(toggle) // toggle
  9715. message_end()
  9716. }
  9717.  
  9718. // Custom Flashlight
  9719. public set_user_flashlight(taskid)
  9720. {
  9721. // Not meant to have flashlight / not enabled / depleted
  9722. if (!g_flashlight[ID_FLASH] || g_flashbattery[ID_FLASH] <= 0)
  9723. {
  9724. // Task not needed anymore
  9725. remove_task(taskid);
  9726. return;
  9727. }
  9728.  
  9729. // Disable flashlight if it shouldn't be available
  9730. if (g_zombie[ID_FLASH] || g_survivor[ID_FLASH] || !is_user_alive(ID_FLASH))
  9731. {
  9732. // Turn it off
  9733. g_flashlight[ID_FLASH] = false;
  9734.  
  9735. // Update flashlight HUD
  9736. message_begin(MSG_ONE, g_msgFlashlight, _, ID_FLASH)
  9737. write_byte(0) // toggle
  9738. write_byte(100) // battery
  9739. message_end()
  9740.  
  9741. // Task not needed anymore
  9742. remove_task(taskid);
  9743. return;
  9744. }
  9745.  
  9746. // Get player and aiming origins
  9747. static Float:originF[3], Float:destoriginF[3], i
  9748. pev(ID_FLASH, pev_origin, originF)
  9749. fm_get_aim_origin(ID_FLASH, destoriginF)
  9750.  
  9751. // Make sure it's within the max distance
  9752. if (get_distance_f(originF, destoriginF) > get_pcvar_float(cvar_flashdist))
  9753. return;
  9754.  
  9755. // Send to every player?
  9756. if (get_pcvar_num(cvar_flashshowall))
  9757. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, destoriginF, 0)
  9758. else
  9759. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, ID_FLASH)
  9760.  
  9761. // Flashlight
  9762. write_byte(TE_DLIGHT) // TE id
  9763. engfunc(EngFunc_WriteCoord, destoriginF[0]) // x
  9764. engfunc(EngFunc_WriteCoord, destoriginF[1]) // y
  9765. engfunc(EngFunc_WriteCoord, destoriginF[2]) // z
  9766. write_byte(get_pcvar_num(cvar_flashsize)) // radius
  9767. for (i = 1; i < get_maxplayers(); i++)
  9768. {
  9769. write_byte(g_flash_color[i][0]) // r
  9770. write_byte(g_flash_color[i][1]) // g
  9771. write_byte(g_flash_color[i][2]) // b
  9772. }
  9773. write_byte(3) // life
  9774. write_byte(0) // decay rate
  9775. message_end()
  9776. }
  9777.  
  9778. // Infection special effects
  9779. infection_effects(id)
  9780. {
  9781. // Screen fade?
  9782. if (get_pcvar_num(cvar_infectionscreenfade))
  9783. {
  9784. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
  9785. write_short(UNIT_SECOND*1) // duration
  9786. write_short(UNIT_SECOND*0) // hold time
  9787. write_short(FFADE_IN) // fade type
  9788. write_byte((g_nemesis[id]) ? get_pcvar_num(cvar_nemnvgcolor[0]) : get_pcvar_num(cvar_nvgcolor[0])) // r
  9789. write_byte((g_nemesis[id]) ? get_pcvar_num(cvar_nemnvgcolor[1]) : get_pcvar_num(cvar_nvgcolor[1])) // g
  9790. write_byte((g_nemesis[id]) ? get_pcvar_num(cvar_nemnvgcolor[2]) : get_pcvar_num(cvar_nvgcolor[2])) // b
  9791. write_byte (255) // alpha
  9792. message_end()
  9793. }
  9794.  
  9795. // Screen shake?
  9796. if (get_pcvar_num(cvar_infectionscreenshake))
  9797. {
  9798. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
  9799. write_short(UNIT_SECOND*4) // amplitude
  9800. write_short(UNIT_SECOND*2) // duration
  9801. write_short(UNIT_SECOND*10) // frequency
  9802. message_end()
  9803. }
  9804.  
  9805. // Infection icon?
  9806. if (get_pcvar_num(cvar_hudicons))
  9807. {
  9808. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
  9809. write_byte(0) // damage save
  9810. write_byte(0) // damage take
  9811. write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
  9812. write_coord(0) // x
  9813. write_coord(0) // y
  9814. write_coord(0) // z
  9815. message_end()
  9816. }
  9817.  
  9818. // Get player origin
  9819. static Float:originF[3]
  9820. pev(id, pev_origin, originF)
  9821.  
  9822. // Tracers?
  9823. if (get_pcvar_num(cvar_infectiontracers))
  9824. {
  9825. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  9826. write_byte(TE_IMPLOSION) // TE id
  9827. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9828. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9829. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9830. write_byte(128) // radius
  9831. write_byte(20) // count
  9832. write_byte(3) // duration
  9833. message_end()
  9834. }
  9835.  
  9836. // Particle burst?
  9837. if (get_pcvar_num(cvar_infectionparticles))
  9838. {
  9839. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  9840. write_byte(TE_PARTICLEBURST) // TE id
  9841. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9842. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9843. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9844. write_short(50) // radius
  9845. write_byte(70) // color
  9846. write_byte(3) // duration (will be randomized a bit)
  9847. message_end()
  9848. }
  9849.  
  9850. // Light sparkle?
  9851. if (get_pcvar_num(cvar_infectionsparkle))
  9852. {
  9853. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  9854. write_byte(TE_DLIGHT) // TE id
  9855. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9856. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9857. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9858. write_byte(20) // radius
  9859. write_byte(get_pcvar_num(cvar_nvgcolor[0])) // r
  9860. write_byte(get_pcvar_num(cvar_nvgcolor[1])) // g
  9861. write_byte(get_pcvar_num(cvar_nvgcolor[2])) // b
  9862. write_byte(2) // life
  9863. write_byte(0) // decay rate
  9864. message_end()
  9865. }
  9866. }
  9867.  
  9868. // Nemesis/madness aura task
  9869. public zombie_aura(taskid)
  9870. {
  9871. // Not nemesis, not in zombie madness
  9872. if (!g_nemesis[ID_BLOOD] && !g_nodamage[ID_BLOOD])
  9873. return;
  9874.  
  9875. // Get player origin
  9876. static Float:originF[3]
  9877. pev(ID_BLOOD, pev_origin, originF)
  9878.  
  9879. // Colored Aura
  9880. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  9881. write_byte(TE_DLIGHT) // TE id
  9882. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9883. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9884. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9885. write_byte(20) // radius
  9886. write_byte(get_pcvar_num(cvar_nemnvgcolor[0])) // r
  9887. write_byte(get_pcvar_num(cvar_nemnvgcolor[1])) // g
  9888. write_byte(get_pcvar_num(cvar_nemnvgcolor[2])) // b
  9889. write_byte(2) // life
  9890. write_byte(0) // decay rate
  9891. message_end()
  9892.  
  9893. // Keep sending aura messages
  9894. set_task(0.1, "zombie_aura", taskid)
  9895. }
  9896.  
  9897. // Make zombies leave footsteps and bloodstains on the floor
  9898. public make_blood(taskid)
  9899. {
  9900. // Only bleed when moving on ground
  9901. if (fm_get_speed(ID_BLOOD) < 80 || !(pev(ID_BLOOD, pev_flags) & FL_ONGROUND))
  9902. return;
  9903.  
  9904. // Get user origin
  9905. static Float:originF[3]
  9906. pev(ID_BLOOD, pev_origin, originF);
  9907.  
  9908. // If ducking set a little lower
  9909. if (pev(ID_BLOOD, pev_bInDuck))
  9910. originF[2] -= 18.0
  9911. else
  9912. originF[2] -= 36.0
  9913.  
  9914. // Send the decal message
  9915. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  9916. write_byte(TE_WORLDDECAL) // TE id
  9917. engfunc(EngFunc_WriteCoord, originF[0]) // x
  9918. engfunc(EngFunc_WriteCoord, originF[1]) // y
  9919. engfunc(EngFunc_WriteCoord, originF[2]) // z
  9920. write_byte(zombie_decals[random_num(0, sizeof zombie_decals - 1)] + (g_czero*12)) // random decal number (offsets +12 for CZ)
  9921. message_end()
  9922. }
  9923.  
  9924. // Bubble Grenade Explosion
  9925. public bubble_explode(id)
  9926. {
  9927. // Get origin
  9928. static Float:originF[3] // originF para llamar la entidad de create_blast4
  9929. pev(id, pev_origin, originF) // ...
  9930.  
  9931. // Create Blast
  9932. create_blast4(originF) // entidad de los anillos de explocion
  9933.  
  9934. new attacker // variable attacker ( ataque )
  9935. attacker = pev(id, pev_owner)
  9936.  
  9937. g_bubble_bomb[attacker] = false // variable de la bomba, seteamos en falso
  9938.  
  9939. set_pcvar_num(cvar_flaregrenades,1) // tomamos las cvar de la flare, para usarla como activador y desactivador de esta bomba.
  9940.  
  9941. // Create entitity
  9942. new iEntity = create_entity("info_target") // creamo la entidad con su determinado objetivo
  9943.  
  9944. if(!is_valid_ent(iEntity)) // determinamos que la entidad esta en false
  9945. return PLUGIN_HANDLED // tramitamos nuevamente
  9946.  
  9947. new Float: Origin[3] // origen
  9948. entity_get_vector(id, EV_VEC_origin, Origin)
  9949.  
  9950. entity_set_string(iEntity, EV_SZ_classname, entclas) // llamamos ala clase de entidad
  9951.  
  9952. entity_set_vector(iEntity,EV_VEC_origin, Origin) // no se que es
  9953. entity_set_model(iEntity, w_campo) // modelo dela burbuja
  9954. entity_set_int(iEntity, EV_INT_solid, SOLID_TRIGGER) // no se que es
  9955. entity_set_size(iEntity, Float: {-110.0, -110.0, -110.0}, Float: {110.0, 110.0, 110.0}) // size de la entidad ( campo ) osea el tamaño
  9956. entity_set_int(iEntity, EV_INT_renderfx, kRenderFxGlowShell) // le damos el glow
  9957. entity_set_int(iEntity, EV_INT_rendermode, kRenderTransAlpha) // hacemos que sea transparente
  9958. entity_set_float(iEntity, EV_FL_renderamt, 50.0) // le damos la intensidad
  9959.  
  9960. #if defined RANDOM_COLOR // color por default
  9961. if(is_valid_ent(iEntity))
  9962. {
  9963. new Float:vColor[3]
  9964.  
  9965. for(new i; i < 3; i++)
  9966. vColor[i] = random_float(0.0, 255.0)
  9967.  
  9968. entity_set_vector(iEntity, EV_VEC_rendercolor, vColor)
  9969. }
  9970. #endif
  9971.  
  9972. #if defined ONE_COLOR
  9973. entity_set_vector(iEntity, EV_VEC_rendercolor, colour_force_shield)
  9974. #endif
  9975.  
  9976. #if defined CAMPO_TASK
  9977. set_task(30.0, "DeleteEntity", iEntity)
  9978. #endif
  9979.  
  9980. return PLUGIN_CONTINUE;
  9981. }
  9982.  
  9983. // Flare Lighting
  9984. public flare_lighting(args[5])
  9985. {
  9986. static id; id = pev( FLARE_ENTITY, pev_owner )
  9987.  
  9988. // Unexistant flare entity?
  9989. if (!pev_valid(FLARE_ENTITY))
  9990. return;
  9991.  
  9992. // Flare depleted -clean up the mess-
  9993. if (FLARE_DURATION <= 0)
  9994. {
  9995. engfunc(EngFunc_RemoveEntity, FLARE_ENTITY)
  9996. return;
  9997. }
  9998.  
  9999. // Get origin
  10000. static Float:originF[3]
  10001. pev(FLARE_ENTITY, pev_origin, originF)
  10002.  
  10003. // Lighting
  10004. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  10005. write_byte(TE_DLIGHT) // TE id
  10006. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10007. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10008. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10009. write_byte(get_pcvar_num(cvar_flaresize)) // radius
  10010. write_byte(g_flare_color[id][0]) // r
  10011. write_byte(g_flare_color[id][1]) // g
  10012. write_byte(g_flare_color[id][2]) // b
  10013. write_byte(51) //life
  10014. write_byte((FLARE_DURATION < 2) ? 3 : 0) //decay rate
  10015. message_end()
  10016.  
  10017. // Sparks
  10018. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10019. write_byte(TE_SPARKS) // TE id
  10020. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10021. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10022. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10023. message_end()
  10024.  
  10025. // Decrease task cycle counter
  10026. FLARE_DURATION -= 1;
  10027.  
  10028. // Keep sending flare messaegs
  10029. set_task(5.0, "flare_lighting", TASK_NADES, args, sizeof args)
  10030. }
  10031.  
  10032. // Burning Flames
  10033. public burning_flame(args[1], taskid)
  10034. {
  10035. // Get player origin and flags
  10036. static Float:originF[3], flags
  10037. pev(ID_BLOOD, pev_origin, originF)
  10038. flags = pev(ID_BLOOD, pev_flags)
  10039.  
  10040. // Madness mode - in water - burning stopped
  10041. if (g_nodamage[ID_BLOOD] || (flags & FL_INWATER) || FLAME_DURATION < 1)
  10042. {
  10043. // Smoke sprite
  10044. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10045. write_byte(TE_SMOKE) // TE id
  10046. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10047. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10048. engfunc(EngFunc_WriteCoord, originF[2]-50.0) // z
  10049. write_short(g_smokeSpr) // sprite
  10050. write_byte(random_num(15, 20)) // scale
  10051. write_byte(random_num(10, 20)) // framerate
  10052. message_end()
  10053.  
  10054. return;
  10055. }
  10056.  
  10057. // Randomly play burning zombie scream sounds (not for nemesis)
  10058. if (!random_num(0, 20) && !g_nemesis[ID_BLOOD])
  10059. engfunc(EngFunc_EmitSound, ID_BLOOD, CHAN_VOICE, grenade_fire_player[random_num(0, sizeof grenade_fire_player - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  10060.  
  10061. // Get fire slow down setting
  10062. static Float:slowdown
  10063. slowdown = get_pcvar_float(cvar_fireslowdown)
  10064.  
  10065. // Fire slow down, unless nemesis
  10066. if (slowdown > 0.0 && !g_nemesis[ID_BLOOD] && (flags & FL_ONGROUND))
  10067. {
  10068. static Float:velocity[3]
  10069. pev(ID_BLOOD, pev_velocity, velocity)
  10070. xs_vec_mul_scalar(velocity, slowdown, velocity)
  10071. set_pev(ID_BLOOD, pev_velocity, velocity)
  10072. }
  10073.  
  10074. // Get health and fire damage setting
  10075. static health, firedamage
  10076. health = pev(ID_BLOOD, pev_health)
  10077. firedamage = get_pcvar_num(cvar_firedamage)
  10078.  
  10079. // Take damage from the fire
  10080. if (health > firedamage)
  10081. fm_set_user_health(ID_BLOOD, health - firedamage)
  10082.  
  10083. // Flame sprite
  10084. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10085. write_byte(TE_SPRITE) // TE id
  10086. engfunc(EngFunc_WriteCoord, originF[0]+random_float(-5.0, 5.0)) // x
  10087. engfunc(EngFunc_WriteCoord, originF[1]+random_float(-5.0, 5.0)) // y
  10088. engfunc(EngFunc_WriteCoord, originF[2]+random_float(-10.0, 10.0)) // z
  10089. write_short(g_flameSpr) // sprite
  10090. write_byte(random_num(5, 10)) // scale
  10091. write_byte(200) // brightness
  10092. message_end()
  10093.  
  10094. // Decrease task cycle counter
  10095. FLAME_DURATION -= 1;
  10096.  
  10097. // Keep sending flame messaegs
  10098. set_task(0.2, "burning_flame", taskid, args, sizeof args)
  10099. }
  10100.  
  10101. // Infection Grenade: Green Blast
  10102. create_blast(const Float:originF[3])
  10103. {
  10104. // Smallest ring
  10105. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10106. write_byte(TE_BEAMCYLINDER) // TE id
  10107. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10108. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10109. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10110. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10111. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10112. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  10113. write_short(g_exploSpr) // sprite
  10114. write_byte(0) // startframe
  10115. write_byte(0) // framerate
  10116. write_byte(4) // life
  10117. write_byte(60) // width
  10118. write_byte(0) // noise
  10119. write_byte(0) // red
  10120. write_byte(200) // green
  10121. write_byte(0) // blue
  10122. write_byte(200) // brightness
  10123. write_byte(0) // speed
  10124. message_end()
  10125.  
  10126. // Medium ring
  10127. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10128. write_byte(TE_BEAMCYLINDER) // TE id
  10129. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10130. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10131. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10132. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10133. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10134. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  10135. write_short(g_exploSpr) // sprite
  10136. write_byte(0) // startframe
  10137. write_byte(0) // framerate
  10138. write_byte(4) // life
  10139. write_byte(60) // width
  10140. write_byte(0) // noise
  10141. write_byte(0) // red
  10142. write_byte(200) // green
  10143. write_byte(0) // blue
  10144. write_byte(200) // brightness
  10145. write_byte(0) // speed
  10146. message_end()
  10147.  
  10148. // Largest ring
  10149. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10150. write_byte(TE_BEAMCYLINDER) // TE id
  10151. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10152. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10153. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10154. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10155. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10156. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  10157. write_short(g_exploSpr) // sprite
  10158. write_byte(0) // startframe
  10159. write_byte(0) // framerate
  10160. write_byte(4) // life
  10161. write_byte(60) // width
  10162. write_byte(0) // noise
  10163. write_byte(0) // red
  10164. write_byte(200) // green
  10165. write_byte(0) // blue
  10166. write_byte(200) // brightness
  10167. write_byte(0) // speed
  10168. message_end()
  10169. }
  10170.  
  10171. // Bubble Grenade: Yellow Blast
  10172. create_blast4(const Float:originF[3])
  10173. {
  10174. // Smallest ring / anillo de explcion 1
  10175. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10176. write_byte(TE_BEAMCYLINDER) // TE id
  10177. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10178. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10179. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10180. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10181. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10182. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  10183. write_short(g_exploSpr) // sprite de los anillos
  10184. write_byte(0) // startframe / fotograma inicial
  10185. write_byte(0) // framerate / imágenes por segundo
  10186. write_byte(4) // life
  10187. write_byte(60) // width / ancho
  10188. write_byte(0) // noise / ruido
  10189. write_byte(255) // red: rojo
  10190. write_byte(255) // green: verde
  10191. write_byte(255) // blue: azul
  10192. write_byte(200) // brightness / brillo
  10193. write_byte(0) // speed / rapidez
  10194. message_end()
  10195.  
  10196. // Medium ring
  10197. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10198. write_byte(TE_BEAMCYLINDER) // TE id
  10199. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10200. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10201. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10202. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10203. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10204. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  10205. write_short(g_exploSpr) // sprite
  10206. write_byte(0) // startframe / fotograma inicial
  10207. write_byte(0) // framerate / imágenes por segundo
  10208. write_byte(4) // life
  10209. write_byte(60) // width / ancho
  10210. write_byte(0) // noise / ruido
  10211. write_byte(255) // red: rojo
  10212. write_byte(255) // green: verde
  10213. write_byte(255) // blue: azul
  10214. write_byte(200) // brightness / brillo
  10215. write_byte(0) // speed / rapidez
  10216. message_end()
  10217.  
  10218. // Largest ring
  10219. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10220. write_byte(TE_BEAMCYLINDER) // TE id
  10221. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10222. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10223. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10224. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10225. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10226. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  10227. write_short(g_exploSpr) // sprite
  10228. write_byte(0) // startframe / fotograma inicial
  10229. write_byte(0) // framerate / imágenes por segundo
  10230. write_byte(4) // life
  10231. write_byte(60) // width / ancho
  10232. write_byte(0) // noise / ruido
  10233. write_byte(255) // red: rojo
  10234. write_byte(255) // green: verde
  10235. write_byte(255) // blue: azul
  10236. write_byte(200) // brightness / brillo
  10237. write_byte(0) // speed / rapidez
  10238. message_end()
  10239. }
  10240.  
  10241. // Fire Grenade: Fire Blast
  10242. /*create_blast2(const Float:originF[3])
  10243. {
  10244. // Smallest ring
  10245. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10246. write_byte(TE_BEAMCYLINDER) // TE id
  10247. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10248. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10249. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10250. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10251. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10252. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  10253. write_short(g_exploSpr) // sprite
  10254. write_byte(0) // startframe
  10255. write_byte(0) // framerate
  10256. write_byte(4) // life
  10257. write_byte(60) // width
  10258. write_byte(0) // noise
  10259. write_byte(200) // red
  10260. write_byte(100) // green
  10261. write_byte(0) // blue
  10262. write_byte(200) // brightness
  10263. write_byte(0) // speed
  10264. message_end()
  10265.  
  10266. // Medium ring
  10267. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10268. write_byte(TE_BEAMCYLINDER) // TE id
  10269. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10270. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10271. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10272. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10273. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10274. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  10275. write_short(g_exploSpr) // sprite
  10276. write_byte(0) // startframe
  10277. write_byte(0) // framerate
  10278. write_byte(4) // life
  10279. write_byte(60) // width
  10280. write_byte(0) // noise
  10281. write_byte(200) // red
  10282. write_byte(50) // green
  10283. write_byte(0) // blue
  10284. write_byte(200) // brightness
  10285. write_byte(0) // speed
  10286. message_end()
  10287.  
  10288. // Largest ring
  10289. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10290. write_byte(TE_BEAMCYLINDER) // TE id
  10291. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10292. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10293. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10294. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  10295. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  10296. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  10297. write_short(g_exploSpr) // sprite
  10298. write_byte(0) // startframe
  10299. write_byte(0) // framerate
  10300. write_byte(4) // life
  10301. write_byte(60) // width
  10302. write_byte(0) // noise
  10303. write_byte(200) // red
  10304. write_byte(0) // green
  10305. write_byte(0) // blue
  10306. write_byte(200) // brightness
  10307. write_byte(0) // speed
  10308. message_end()
  10309. }*/
  10310.  
  10311. // Frost Grenade: Freeze Blast
  10312. create_blast3(const Float:originF[3])
  10313. {
  10314. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10315. write_byte(TE_SPRITETRAIL)
  10316. engfunc(EngFunc_WriteCoord, originF[0]) // X
  10317. engfunc(EngFunc_WriteCoord, originF[1]) // Y
  10318. engfunc(EngFunc_WriteCoord, originF[2]) // Z
  10319. engfunc(EngFunc_WriteCoord, originF[0]) // X
  10320. engfunc(EngFunc_WriteCoord, originF[1]) // Y
  10321. engfunc(EngFunc_WriteCoord, originF[2]) // Z
  10322. write_short(Efecto) //Sprite que usaremos
  10323. write_byte(2000) //Cantidades de sprites que generara
  10324. write_byte(1) //Vida
  10325. write_byte(4) //Tamaño
  10326. write_byte(60) //Velocidad
  10327. write_byte(60) //Velocidad
  10328. message_end()
  10329.  
  10330. // Luz Dinamica
  10331. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  10332. write_byte(TE_DLIGHT) // TE id
  10333. engfunc(EngFunc_WriteCoord, originF[0]) // x
  10334. engfunc(EngFunc_WriteCoord, originF[1]) // y
  10335. engfunc(EngFunc_WriteCoord, originF[2]) // z
  10336. write_byte(50) // radio
  10337. write_byte(0) // r
  10338. write_byte(150) // g
  10339. write_byte(255) // b
  10340. write_byte(30) // vida en 0.1, 30 = 3 segundos
  10341. write_byte(30) // velocidad de decaimiento
  10342. message_end()
  10343. }
  10344.  
  10345. // Fix Dead Attrib on scoreboard
  10346. FixDeadAttrib(id)
  10347. {
  10348. message_begin(MSG_BROADCAST, g_msgScoreAttrib)
  10349. write_byte(id) // id
  10350. write_byte(0) // attrib
  10351. message_end()
  10352. }
  10353.  
  10354. // Send Death Message for infections
  10355. SendDeathMsg(attacker, victim)
  10356. {
  10357. message_begin(MSG_BROADCAST, g_msgDeathMsg)
  10358. write_byte(attacker) // killer
  10359. write_byte(victim) // victim
  10360. write_byte(1) // headshot flag
  10361. write_string("infection") // killer's weapon
  10362. message_end()
  10363. }
  10364.  
  10365. // Update Player Frags and Deaths
  10366. UpdateFrags(attacker, victim, frags, deaths, scoreboard)
  10367. {
  10368. // Set attacker frags
  10369. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  10370.  
  10371. // Set victim deaths
  10372. fm_set_user_deaths(victim, fm_get_user_deaths(victim) + deaths)
  10373.  
  10374. // Update scoreboard with attacker and victim info
  10375. if (scoreboard)
  10376. {
  10377. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  10378. write_byte(attacker) // id
  10379. write_short(pev(attacker, pev_frags)) // frags
  10380. write_short(fm_get_user_deaths(attacker)) // deaths
  10381. write_short(0) // class?
  10382. write_short(fm_get_user_team(attacker)) // team
  10383. message_end()
  10384.  
  10385. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  10386. write_byte(victim) // id
  10387. write_short(pev(victim, pev_frags)) // frags
  10388. write_short(fm_get_user_deaths(victim)) // deaths
  10389. write_short(0) // class?
  10390. write_short(fm_get_user_team(victim)) // team
  10391. message_end()
  10392. }
  10393. }
  10394.  
  10395. // Plays a sound on clients
  10396. PlaySound(const sound[])
  10397. {
  10398. client_cmd(0, "spk ^"%s^"", sound)
  10399. }
  10400.  
  10401. SpkSound(id, const sound[])
  10402. {
  10403. client_cmd(id, "spk ^"%s^"", sound)
  10404. }
  10405.  
  10406. // Prints a colored message to target (use 0 for everyone), supports ML formatting.
  10407. // Note: I still need to make something like gungame's LANG_PLAYER_C to avoid unintended
  10408. // argument replacement when a function passes -1 (it will be considered a LANG_PLAYER)
  10409. zp_colored_print(target, const message[], any:...)
  10410. {
  10411. static buffer[512], i, argscount
  10412. argscount = numargs()
  10413.  
  10414. // Send to everyone
  10415. if (!target)
  10416. {
  10417. static player
  10418. for (player = 1; player <= g_maxplayers; player++)
  10419. {
  10420. // Not connected
  10421. if (!is_user_connected(player))
  10422. continue;
  10423.  
  10424. // Remember changed arguments
  10425. static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
  10426. changedcount = 0
  10427.  
  10428. // Replace LANG_PLAYER with player id
  10429. for (i = 2; i < argscount; i++)
  10430. {
  10431. if (getarg(i) == LANG_PLAYER)
  10432. {
  10433. setarg(i, 0, player)
  10434. changed[changedcount] = i
  10435. changedcount++
  10436. }
  10437. }
  10438.  
  10439. // Format message for player
  10440. vformat(buffer, sizeof buffer - 1, message, 3)
  10441.  
  10442. // Send it
  10443. message_begin(MSG_ONE, g_msgSayText, _, player)
  10444. write_byte(player)
  10445. write_string(buffer)
  10446. message_end()
  10447.  
  10448. // Replace back player id's with LANG_PLAYER
  10449. for (i = 0; i < changedcount; i++)
  10450. setarg(changed[i], 0, LANG_PLAYER)
  10451. }
  10452. }
  10453.  
  10454. // Send to specific target
  10455. else
  10456. {
  10457. /*
  10458. // Replace LANG_PLAYER with player id
  10459. for (i = 2; i < argscount; i++)
  10460. {
  10461. if (getarg(i) == LANG_PLAYER)
  10462. setarg(i, 0, target)
  10463. }
  10464. */
  10465.  
  10466. // Format message for player
  10467. vformat(buffer, sizeof buffer - 1, message, 3)
  10468.  
  10469. // Send it
  10470. message_begin(MSG_ONE, g_msgSayText, _, target)
  10471. write_byte(target)
  10472. write_string(buffer)
  10473. message_end()
  10474. }
  10475. }
  10476.  
  10477. /*================================================================================
  10478. [Stocks]
  10479. =================================================================================*/
  10480.  
  10481. // Set an entity's key value (from fakemeta_util)
  10482.  
  10483. stock fm_set_entity_visibility(index, visible = 1)
  10484. {
  10485. set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW);
  10486.  
  10487. return 1;
  10488. }
  10489.  
  10490. stock fm_set_kvd(entity, const key[], const value[], const classname[])
  10491. {
  10492. set_kvd(0, KV_ClassName, classname)
  10493. set_kvd(0, KV_KeyName, key)
  10494. set_kvd(0, KV_Value, value)
  10495. set_kvd(0, KV_fHandled, 0)
  10496.  
  10497. dllfunc(DLLFunc_KeyValue, entity, 0)
  10498. }
  10499.  
  10500. // Set entity's rendering type (from fakemeta_util)
  10501. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  10502. {
  10503. static Float:color[3]
  10504. color[0] = float(r)
  10505. color[1] = float(g)
  10506. color[2] = float(b)
  10507.  
  10508. set_pev(entity, pev_renderfx, fx)
  10509. set_pev(entity, pev_rendercolor, color)
  10510. set_pev(entity, pev_rendermode, render)
  10511. set_pev(entity, pev_renderamt, float(amount))
  10512. }
  10513.  
  10514. // Get entity's speed (from fakemeta_util)
  10515. stock fm_get_speed(entity)
  10516. {
  10517. static Float:velocity[3]
  10518. pev(entity, pev_velocity, velocity)
  10519.  
  10520. return floatround(vector_length(velocity));
  10521. }
  10522.  
  10523. // Get entity's aim origins (from fakemeta_util)
  10524. stock fm_get_aim_origin(id, Float:origin[3])
  10525. {
  10526. static Float:origin1F[3], Float:origin2F[3]
  10527. pev(id, pev_origin, origin1F)
  10528. pev(id, pev_view_ofs, origin2F)
  10529. xs_vec_add(origin1F, origin2F, origin1F)
  10530.  
  10531. pev(id, pev_v_angle, origin2F);
  10532. engfunc(EngFunc_MakeVectors, origin2F)
  10533. global_get(glb_v_forward, origin2F)
  10534. xs_vec_mul_scalar(origin2F, 9999.0, origin2F)
  10535. xs_vec_add(origin1F, origin2F, origin2F)
  10536.  
  10537. engfunc(EngFunc_TraceLine, origin1F, origin2F, 0, id, 0)
  10538. get_tr2(0, TR_vecEndPos, origin)
  10539. }
  10540.  
  10541. // Find entity by its owner (from fakemeta_util)
  10542. stock fm_find_ent_by_owner(entity, const classname[], owner)
  10543. {
  10544. while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
  10545.  
  10546. return entity;
  10547. }
  10548.  
  10549. // Set player's health (from fakemeta_util)
  10550. stock fm_set_user_health(id, health)
  10551. {
  10552. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  10553. }
  10554.  
  10555. // Give an item to a player (from fakemeta_util)
  10556. stock fm_give_item(id, const item[])
  10557. {
  10558. static ent
  10559. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  10560. if (!pev_valid(ent)) return;
  10561.  
  10562. static Float:originF[3]
  10563. pev(id, pev_origin, originF)
  10564. set_pev(ent, pev_origin, originF)
  10565. set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  10566. dllfunc(DLLFunc_Spawn, ent)
  10567.  
  10568. static save
  10569. save = pev(ent, pev_solid)
  10570. dllfunc(DLLFunc_Touch, ent, id)
  10571. if (pev(ent, pev_solid) != save)
  10572. return;
  10573.  
  10574. engfunc(EngFunc_RemoveEntity, ent)
  10575. }
  10576.  
  10577. // Strip user weapons (from fakemeta_util)
  10578. stock fm_strip_user_weapons(id)
  10579. {
  10580. static ent
  10581. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  10582. if (!pev_valid(ent)) return;
  10583.  
  10584. dllfunc(DLLFunc_Spawn, ent)
  10585. dllfunc(DLLFunc_Use, ent, id)
  10586. engfunc(EngFunc_RemoveEntity, ent)
  10587. }
  10588.  
  10589. // Collect random spawn points
  10590. stock load_spawns()
  10591. {
  10592. // Check for CSDM spawns of the current map
  10593. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  10594. get_configsdir(cfgdir, sizeof cfgdir - 1)
  10595. get_mapname(mapname, sizeof mapname - 1)
  10596. formatex(filepath, sizeof filepath - 1, "%s/csdm/%s.spawns.cfg", cfgdir, mapname)
  10597.  
  10598. // Load CSDM spawns if present
  10599. if (file_exists(filepath))
  10600. {
  10601. new csdmdata[10][6], file = fopen(filepath,"rt")
  10602.  
  10603. while (file && !feof(file))
  10604. {
  10605. fgets(file, linedata, sizeof linedata - 1)
  10606.  
  10607. // invalid spawn
  10608. if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  10609.  
  10610. // get spawn point data
  10611. 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)
  10612.  
  10613. // origin
  10614. g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
  10615. g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
  10616. g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
  10617.  
  10618. // increase spawn count
  10619. g_spawnCount++
  10620. if (g_spawnCount >= sizeof g_spawns) break;
  10621. }
  10622. if (file) fclose(file)
  10623. }
  10624. else
  10625. {
  10626. // if not, collect regular spawns
  10627. collect_spawns_ent("info_player_start")
  10628. collect_spawns_ent("info_player_deathmatch")
  10629. }
  10630. }
  10631.  
  10632. stock Puntuacion(number)
  10633. {
  10634. new str[15], strpointed[15], len
  10635. num_to_str(number, str, 14)
  10636. len= strlen(str)
  10637. new c
  10638. for (new i=0;i<len;i++)
  10639. {
  10640. if (i!=0 && ( (len-i)%3==0) )
  10641. {
  10642. add(strpointed, 14, ".", 1)
  10643. c++
  10644. add(strpointed[i+c], 1, str[i], 1)
  10645. }
  10646. else
  10647. {
  10648. add(strpointed[i+c], 1, str[i], 1)
  10649. }
  10650. }
  10651.  
  10652. return strpointed;
  10653. }
  10654.  
  10655. // Collect spawn points from entity origins
  10656. stock collect_spawns_ent(const classname[])
  10657. {
  10658. new ent = -1
  10659.  
  10660. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) != 0)
  10661. {
  10662. // get origin
  10663. new Float:originF[3]
  10664. pev(ent, pev_origin, originF)
  10665. g_spawns[g_spawnCount][0] = originF[0]
  10666. g_spawns[g_spawnCount][1] = originF[1]
  10667. g_spawns[g_spawnCount][2] = originF[2]
  10668.  
  10669. // increase spawn count
  10670. g_spawnCount++
  10671. if (g_spawnCount >= sizeof g_spawns) break;
  10672. }
  10673. }
  10674.  
  10675. // Drop primary/secondary weapons
  10676. stock drop_weapons(id, dropwhat)
  10677. {
  10678. // Get user weapons
  10679. static weapons[32], num, i, weaponid
  10680. num = 0 // reset passed weapons count (bugfix)
  10681. get_user_weapons(id, weapons, num)
  10682.  
  10683. // Loop through them and drop primaries or secondaries
  10684. for (i = 0; i < num; i++)
  10685. {
  10686. // Prevent re-indexing the array
  10687. weaponid = weapons[i]
  10688.  
  10689. if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  10690. {
  10691. // Get the weapon entity
  10692. static wname[32], weapon_ent
  10693. get_weaponname(weaponid, wname, sizeof wname - 1)
  10694. weapon_ent = fm_find_ent_by_owner(-1, wname, id);
  10695.  
  10696. // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  10697. set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, fm_get_user_bpammo(id, weaponid))
  10698.  
  10699. // Player drops the weapon and looses his bpammo
  10700. engclient_cmd(id, "drop", wname)
  10701. fm_set_user_bpammo(id, weaponid, 0)
  10702. }
  10703. }
  10704. }
  10705.  
  10706. // Stock by (probably) Twilight Suzuka -counts number of chars in a string
  10707. stock str_count(const str[], searchchar)
  10708. {
  10709. new count, i
  10710. //count = 0
  10711.  
  10712. for (i = 0; i <= strlen(str); i++)
  10713. {
  10714. if(str[i] == searchchar)
  10715. count++
  10716. }
  10717.  
  10718. return count;
  10719. }
  10720.  
  10721. // Checks if a space is vacant (credits to VEN)
  10722. stock is_hull_vacant(Float:origin[3], hull)
  10723. {
  10724. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
  10725.  
  10726. if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
  10727. return true;
  10728.  
  10729. return false;
  10730. }
  10731.  
  10732. // Check if a player is stuck (credits to VEN)
  10733. stock is_player_stuck(id)
  10734. {
  10735. static Float:originF[3]
  10736. pev(id, pev_origin, originF)
  10737.  
  10738. engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  10739.  
  10740. if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  10741. return true;
  10742.  
  10743. return false;
  10744. }
  10745.  
  10746. // Get User BP Ammo
  10747. stock fm_get_user_bpammo(id, weapon)
  10748. {
  10749. return get_pdata_int(id, AMMOOFFSET[weapon], OFFSET_LINUX);
  10750. }
  10751.  
  10752. // Set User BP Ammo
  10753. stock fm_set_user_bpammo(id, weapon, amount)
  10754. {
  10755. set_pdata_int(id, AMMOOFFSET[weapon], amount, OFFSET_LINUX)
  10756. }
  10757.  
  10758. // Set Weapon Clip Ammo
  10759. stock fm_set_weapon_ammo(entity, amount)
  10760. {
  10761. set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS)
  10762. }
  10763.  
  10764. // Get Weapon Clip Ammo
  10765. stock fm_get_weapon_ammo(entity)
  10766. {
  10767. return get_pdata_int(entity, OFFSET_CLIPAMMO, OFFSET_LINUX_WEAPONS);
  10768. }
  10769.  
  10770. // Set User Zoom
  10771. stock fm_remove_user_zoom(id)
  10772. {
  10773. set_pdata_int(id, OFFSET_ZOOMTYPE, CS_NO_ZOOM, OFFSET_LINUX)
  10774. }
  10775.  
  10776. // Get User Deaths
  10777. stock fm_get_user_deaths(id)
  10778. {
  10779. return get_pdata_int(id, OFFSET_CSDEATHS, OFFSET_LINUX);
  10780. }
  10781.  
  10782. // Set User Deaths
  10783. stock fm_set_user_deaths(id, value)
  10784. {
  10785. set_pdata_int(id, OFFSET_CSDEATHS, value, OFFSET_LINUX)
  10786. }
  10787.  
  10788. // Set User NVG for Bots
  10789. stock fm_set_bot_nvg(id, toggle)
  10790. {
  10791. if (toggle)
  10792. {
  10793. g_nvision[id] = true
  10794. set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id, OFFSET_NVGOGGLES, OFFSET_LINUX) | HAS_NVGOGGLES, OFFSET_LINUX)
  10795. }
  10796. else
  10797. {
  10798. g_nvision[id] = false
  10799. set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id, OFFSET_NVGOGGLES, OFFSET_LINUX) &~ HAS_NVGOGGLES, OFFSET_LINUX)
  10800. }
  10801. }
  10802.  
  10803. // Get User Team
  10804. stock fm_get_user_team(id)
  10805. {
  10806. return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  10807. }
  10808.  
  10809. // Set a Player's Team
  10810. stock fm_set_user_team(id, team)
  10811. {
  10812. set_pdata_int(id, OFFSET_CSTEAMS, team, OFFSET_LINUX)
  10813. }
  10814.  
  10815. // Update Player's Team on all clients (adding needed delays)
  10816. stock fm_user_team_update(id)
  10817. {
  10818. static Float:current_time
  10819. current_time = get_gametime()
  10820.  
  10821. if (current_time - g_teams_targettime >= 0.1)
  10822. {
  10823. set_task(0.1, "fm_set_user_team_msg", id+TASK_TEAM)
  10824. g_teams_targettime = current_time + 0.1
  10825. }
  10826. else
  10827. {
  10828. set_task(((g_teams_targettime + 0.1) - current_time), "fm_set_user_team_msg", id+TASK_TEAM)
  10829. g_teams_targettime = g_teams_targettime + 0.1
  10830. }
  10831. }
  10832.  
  10833. // Send User Team Message
  10834. public fm_set_user_team_msg(taskid)
  10835. {
  10836. // Beware: this message can now be picked up by other metamod
  10837. // plugins (yeah, that includes AMXX plugins as well)
  10838.  
  10839. // Set the switching team flag
  10840. g_switchingteam[ID_TEAM] = true
  10841.  
  10842. // Tell everyone my new team
  10843. emessage_begin(MSG_ALL, g_msgTeamInfo)
  10844. ewrite_byte(ID_TEAM) // player
  10845. ewrite_string(TEAMNAMES[fm_get_user_team(ID_TEAM)]) // team
  10846. emessage_end()
  10847.  
  10848. // Done switching team
  10849. g_switchingteam[ID_TEAM] = false
  10850. }
  10851.  
  10852. #if defined SET_MODELINDEX_OFFSET
  10853. // Set the precached model index (updates hitboxes server side)
  10854. stock fm_set_user_model_index(id, value)
  10855. {
  10856. set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
  10857. }
  10858. #endif
  10859.  
  10860. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  10861. // Set Player Model on Entity
  10862. stock fm_set_playermodel_ent(id)
  10863. {
  10864. // Make original player entity invisible
  10865. // but without hiding shadows or firing effects
  10866. fm_set_rendering(id, kRenderFxNone, 255, 255, 255, kRenderTransTexture, 1)
  10867.  
  10868. // Format model string
  10869. static model[100]
  10870. formatex(model, sizeof model - 1, "models/player/%s/%s.mdl", g_playermodel[id], g_playermodel[id])
  10871.  
  10872. // Set model on entity or make a new one if unexistant
  10873. if (!pev_valid(g_ent_playermodel[id]))
  10874. {
  10875. g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  10876. if (!pev_valid(g_ent_playermodel[id])) return;
  10877.  
  10878. set_pev(g_ent_playermodel[id], pev_classname, MODEL_ENT_CLASSNAME)
  10879. set_pev(g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW)
  10880. set_pev(g_ent_playermodel[id], pev_aiment, id)
  10881. set_pev(g_ent_playermodel[id], pev_owner, id)
  10882. }
  10883.  
  10884. engfunc(EngFunc_SetModel, g_ent_playermodel[id], model)
  10885. }
  10886.  
  10887. // Set Weapon Model on Entity
  10888. stock fm_set_weaponmodel_ent(id)
  10889. {
  10890. // Get player's p_ weapon model
  10891. static model[100]
  10892. pev(id, pev_weaponmodel2, model, sizeof model - 1)
  10893.  
  10894. // Set model on entity or make a new one if unexistant
  10895. if (!pev_valid(g_ent_weaponmodel[id]))
  10896. {
  10897. g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  10898. if (!pev_valid(g_ent_weaponmodel[id])) return;
  10899.  
  10900. set_pev(g_ent_weaponmodel[id], pev_classname, WEAPON_ENT_CLASSNAME)
  10901. set_pev(g_ent_weaponmodel[id], pev_movetype, MOVETYPE_FOLLOW)
  10902. set_pev(g_ent_weaponmodel[id], pev_aiment, id)
  10903. set_pev(g_ent_weaponmodel[id], pev_owner, id)
  10904. }
  10905.  
  10906. engfunc(EngFunc_SetModel, g_ent_weaponmodel[id], model)
  10907. }
  10908.  
  10909. // Remove Custom Model Entities
  10910. stock fm_remove_model_ents(id)
  10911. {
  10912. // Remove "playermodel" ent if present
  10913. if (pev_valid(g_ent_playermodel[id]))
  10914. {
  10915. engfunc(EngFunc_RemoveEntity, g_ent_playermodel[id])
  10916. g_ent_playermodel[id] = 0
  10917. }
  10918. // Remove "weaponmodel" ent if present
  10919. if (pev_valid(g_ent_weaponmodel[id]))
  10920. {
  10921. engfunc(EngFunc_RemoveEntity, g_ent_weaponmodel[id])
  10922. g_ent_weaponmodel[id] = 0
  10923. }
  10924. }
  10925. #else
  10926. // Set User Model
  10927. public fm_set_user_model(taskid)
  10928. {
  10929. set_user_info(ID_MODEL, "model", g_playermodel[ID_MODEL])
  10930. }
  10931.  
  10932. // Get User Model -model passed byref-
  10933. stock fm_get_user_model(player, model[], len)
  10934. {
  10935. get_user_info(player, "model", model, len)
  10936. }
  10937.  
  10938. // Update Player's Model on all clients (adding needed delays)
  10939. public fm_user_model_update(taskid)
  10940. {
  10941. static Float:current_time
  10942. current_time = get_gametime()
  10943.  
  10944. if (current_time - g_models_targettime >= MODELCHANGE_DELAY)
  10945. {
  10946. fm_set_user_model(taskid)
  10947. g_models_targettime = current_time
  10948. }
  10949. else
  10950. {
  10951. set_task(((g_models_targettime + MODELCHANGE_DELAY) - current_time), "fm_set_user_model", taskid)
  10952. g_models_targettime = g_models_targettime + MODELCHANGE_DELAY
  10953. }
  10954. }
  10955. #endif
  10956.  
  10957. public damage_msg(victim)
  10958. {
  10959. static name[32]
  10960. get_user_name(victim, name, sizeof name - 1)
  10961. new attacker = get_user_attacker(victim)
  10962. new damage = read_data(2)
  10963. set_hudmessage(42, 255, 255, -1.0, -1.0, 1, 6.0, 1.0)
  10964. show_hudmessage(attacker,"[Nombre: %s || Danio: %s]^n[Restante: %s || Arma: %s]", name, Puntuacion(damage), Puntuacion(get_user_health(victim)), get_user_weapon2(attacker))
  10965.  
  10966. return PLUGIN_CONTINUE
  10967. }
  10968.  
  10969. stock get_user_weapon2(victim)
  10970. {
  10971. new szWeapon[20];
  10972. get_weaponname(get_user_weapon(victim), szWeapon, charsmax(szWeapon));
  10973. replace(szWeapon, charsmax(szWeapon), "weapon_", "");
  10974.  
  10975. return szWeapon;
  10976. }
  10977.  
  10978. // Touch bomb bubble
  10979. public entity_touch(touched, toucher)
  10980. {
  10981.  
  10982. if(g_zombie[toucher] && !g_nodamage[toucher] && !g_nemesis[toucher])
  10983. {
  10984. new Float:pos_ptr[3], Float:pos_ptd[3], Float:push_power = get_pcvar_float(cvar_bubblepush)
  10985.  
  10986. pev(touched, pev_origin, pos_ptr)
  10987. pev(toucher, pev_origin, pos_ptd)
  10988.  
  10989. for(new i = 0; i < 3; i++)
  10990. {
  10991. pos_ptd[i] -= pos_ptr[i]
  10992. pos_ptd[i] *= push_power
  10993. }
  10994.  
  10995. set_pev(toucher, pev_velocity, pos_ptd)
  10996. set_pev(toucher, pev_impulse, pos_ptd)
  10997. }
  10998. }
  10999.  
  11000. // Hook bubble bomb
  11001. public hook_curwpn(id)
  11002. {
  11003. if(!is_user_alive(id))
  11004. return PLUGIN_CONTINUE;
  11005.  
  11006. if(!g_zombie[id])
  11007. {
  11008. new wID = read_data(2)
  11009. if(wID == CSW_SMOKEGRENADE)
  11010. set_pev(id, pev_viewmodel2, v_campo)
  11011. }
  11012.  
  11013. return PLUGIN_CONTINUE;
  11014. }
  11015.  
  11016.  
  11017. // Remove Entity / removemos la entidad con el task
  11018. public DeleteEntity(entity)
  11019. {
  11020. if(is_valid_ent(entity ))
  11021. remove_entity(entity)
  11022. }
  11023.  
  11024. public show_menu_player(id)
  11025. {
  11026. static menu[450], iLen
  11027. iLen = 0
  11028.  
  11029. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\yConfiguración^n^n")
  11030.  
  11031. new Name[33]
  11032. get_user_name(id, Name , 32)
  11033.  
  11034. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\wCuenta: \r%s^n^n", Name)
  11035.  
  11036. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\w Configuracion de \yColores^n^n", id)
  11037. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r1. \yColor de \rNIGHT VISION^n", id)
  11038. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r2. \yColor de \rHUD^n", id)
  11039. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r3. \yColor de \rLINTERNA^n", id)
  11040. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r4. \yColor de \rFLARE^n^n", id)
  11041.  
  11042. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\w Configuracion de \yPosiciones^n^n", id)
  11043. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r5. \yPosicionar \rHUD^n^n", id)
  11044.  
  11045. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\y VARIOS^n^n", id)
  11046. iLen += formatex(menu[iLen], sizeof menu - 1 - iLen, "\r7. \yLista de \rNIVELES^n", id)
  11047.  
  11048. show_menu(id, KEYSMENU, menu, -1, "Config Menu")
  11049. }
  11050.  
  11051. public menu_player(id, key)
  11052. {
  11053. switch (key)
  11054. {
  11055. case 0:
  11056. {
  11057. nvg_color(id)
  11058. }
  11059. case 1:
  11060. {
  11061. hud_color(id)
  11062. }
  11063. case 2:
  11064. {
  11065. flashlight_color(id)
  11066. }
  11067. case 3:
  11068. {
  11069. flare_color(id)
  11070. }
  11071. case 4:
  11072. {
  11073. hud_position(id)
  11074. }
  11075. case 6:
  11076. {
  11077. level_system(id)
  11078. }
  11079. }
  11080. }
  11081.  
  11082. public flashlight_color(id)
  11083. {
  11084. new menu, menu1[50]
  11085. formatex(menu1, 49, "Flash Light Color^n\yR: \r%d \yG: \r%d \yB: \r%d", g_flash_color[id][0], g_flash_color[id][1], g_flash_color[id][2])
  11086.  
  11087. menu = menu_create(menu1, "show_menu_flash_color")
  11088.  
  11089. new i, pos[10]
  11090. for (i = 0; i < 10; i++)
  11091. {
  11092. num_to_str(i, pos, 9)
  11093. menu_additem(menu, COLOR_NAMES[i], pos)
  11094. }
  11095. menu_setprop(menu,MPROP_EXITNAME,"\y Salir")
  11096. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  11097. menu_display(id, menu, 0)
  11098. return PLUGIN_HANDLED
  11099. }
  11100.  
  11101. public show_menu_flash_color(id, menu, item)
  11102. {
  11103. if (item == MENU_EXIT)
  11104. {
  11105. menu_destroy(menu)
  11106. show_menu_player(id)
  11107. return PLUGIN_HANDLED;
  11108. }
  11109.  
  11110. new Data[6], Name[64]
  11111. new Access, Callback
  11112. menu_item_getinfo(menu, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11113.  
  11114. new i
  11115. new Key; Key = str_to_num(Data)
  11116.  
  11117. for (i = 0; i < 3; i++)
  11118. g_flash_color[id][i] = COLOR_RGB[Key][i]
  11119.  
  11120. menu_destroy(menu)
  11121. flashlight_color(id)
  11122. return PLUGIN_HANDLED;
  11123. }
  11124.  
  11125.  
  11126. public hud_position(id)
  11127. {
  11128. new menu[150], menu1[150], pos[15], i
  11129.  
  11130. formatex(menu1, 149, "\yPosicion De \rHUD ^n\yX: \r%.3f \yY: \r%.3f", g_hud_pos[id][0], g_hud_pos[id][1])
  11131. new menuid = menu_create(menu1, "menu_hud_position")
  11132.  
  11133. for (i = 0; i < sizeof hud_stuff; i++)
  11134. {
  11135. num_to_str(i, pos, 14)
  11136. menu_additem(menuid, hud_stuff[i], pos)
  11137. }
  11138.  
  11139. formatex(menu, charsmax(menu), "Efecto\y: \r[%s]\w", (efecto[id] & (1 << 0)) ? "Si" : "No")
  11140. menu_additem(menuid, menu, "8")
  11141.  
  11142. menu_setprop(menuid,MPROP_EXITNAME,"\y Salir")
  11143. menu_setprop(menuid, MPROP_EXIT, MEXIT_ALL)
  11144. menu_display(id, menuid, 0)
  11145.  
  11146. return PLUGIN_HANDLED
  11147. }
  11148. public flare_color(id)
  11149. {
  11150. new menu, menu1[50]
  11151. formatex(menu1, 49, "Flare Color^n\yR: \r%d \yG: \r%d \yB: \r%d", g_flare_color[id][0], g_flare_color[id][1], g_flare_color[id][2])
  11152.  
  11153. menu = menu_create(menu1, "show_menu_flare_color")
  11154.  
  11155. new i, pos[10]
  11156. for (i = 0; i < 10; i++)
  11157. {
  11158. num_to_str(i, pos, 9)
  11159. menu_additem(menu, COLOR_NAMES[i], pos)
  11160. }
  11161. menu_setprop(menu,MPROP_EXITNAME,"\y Salir")
  11162. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  11163. menu_display(id, menu, 0)
  11164. return PLUGIN_HANDLED
  11165. }
  11166. public show_menu_flare_color(id, menu, item)
  11167. {
  11168. if (item == MENU_EXIT)
  11169. {
  11170. menu_destroy(menu)
  11171. show_menu_player(id)
  11172. return PLUGIN_HANDLED;
  11173. }
  11174.  
  11175. new Data[6], Name[64]
  11176. new Access, Callback
  11177. menu_item_getinfo(menu, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11178.  
  11179. new i
  11180. new Key; Key = str_to_num(Data)
  11181.  
  11182. for (i = 0; i < 3; i++)
  11183. g_flare_color[id][i] = COLOR_RGB[Key][i]
  11184.  
  11185. menu_destroy(menu)
  11186. flare_color(id)
  11187. return PLUGIN_HANDLED;
  11188. }
  11189.  
  11190. public menu_hud_position(id, menuid, item)
  11191. {
  11192. if (item == MENU_EXIT)
  11193. {
  11194. menu_destroy(menuid)
  11195. show_menu_player(id)
  11196. return PLUGIN_HANDLED;
  11197. }
  11198.  
  11199. new Data[6], Name[64]
  11200. new Access, Callback
  11201. menu_item_getinfo(menuid, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11202.  
  11203. switch (str_to_num(Data))
  11204. {
  11205. case 0:
  11206. {
  11207. g_hud_pos[id][0] -= 0.01
  11208. if(g_hud_pos[id][0] < 0.03)
  11209. g_hud_pos[id][0] = 1.0
  11210. }
  11211.  
  11212. case 1:
  11213. {
  11214. g_hud_pos[id][0] += 0.01
  11215. if(g_hud_pos[id][0] > 0.97)
  11216. g_hud_pos[id][0] = 0.0
  11217. }
  11218. case 2:
  11219. {
  11220. g_hud_pos[id][1] -= 0.01
  11221. if(g_hud_pos[id][1] < 0.03)
  11222. g_hud_pos[id][1] = 1.0
  11223. }
  11224. case 3:
  11225. {
  11226. g_hud_pos[id][1] += 0.01
  11227. if(g_hud_pos[id][1] > 0.97)
  11228. g_hud_pos[id][1] = 0.0
  11229. }
  11230. case 4:
  11231. {
  11232. g_hud_pos[id][0] = -1.0
  11233. g_hud_pos[id][1] = -1.0
  11234. }
  11235. case 5:
  11236. {
  11237. g_hud_pos[id][0] = 0.00
  11238. g_hud_pos[id][1] = 0.00
  11239. }
  11240. case 6:
  11241. {
  11242. g_hud_pos[id][0] = 0.929
  11243. g_hud_pos[id][1] = 0.00
  11244. }
  11245. case 8:
  11246. {
  11247. efecto[id] = (efecto[id] ^ (1 << 0))
  11248. }
  11249. }
  11250.  
  11251. menu_destroy(menuid)
  11252. remove_task(id+TASK_SHOWHUD)
  11253. ShowHUD(id+TASK_SHOWHUD)
  11254. set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
  11255. hud_position(id)
  11256.  
  11257. return PLUGIN_HANDLED;
  11258. }
  11259.  
  11260. public hud_color(id)
  11261. {
  11262. new menu1[150]
  11263. formatex(menu1, 149, "\yHud Colors ^n\yR: \r%d \yG: \r%d \yB: \r%d", red[id], green[id], blue[id])
  11264. new menu7 = menu_create(menu1, "menu_hud")
  11265.  
  11266. static i, num_color[10]
  11267. for (i = 0; i < 10; i++)
  11268. {
  11269. num_to_str(i, num_color, charsmax(num_color))
  11270. menu_additem(menu7, COLOR_NAMES[i], num_color)
  11271. }
  11272.  
  11273. menu_setprop(menu7,MPROP_EXITNAME,"\y Salir")
  11274. menu_setprop(menu7, MPROP_EXIT, MEXIT_ALL)
  11275. menu_display(id, menu7, 0)
  11276. return PLUGIN_HANDLED
  11277. }
  11278.  
  11279. public menu_hud(id, menu7, item)
  11280. {
  11281.  
  11282. if (item == MENU_EXIT)
  11283. {
  11284. menu_destroy(menu7)
  11285. show_menu_player(id)
  11286. return PLUGIN_HANDLED;
  11287. }
  11288.  
  11289. new Data[6], Name[64]
  11290. new Access, Callback
  11291. menu_item_getinfo(menu7, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11292. switch (str_to_num(Data))
  11293. {
  11294. case 0:
  11295. {
  11296. red[id] = 255
  11297. green[id] = 0
  11298. blue[id] = 0
  11299. }
  11300. case 1:
  11301. {
  11302. red[id] = 0
  11303. green[id] = 255
  11304. blue[id] = 0
  11305. }
  11306. case 2:
  11307. {
  11308. red[id] = 0
  11309. green[id] = 0
  11310. blue[id] = 255
  11311. }
  11312. case 3:
  11313. {
  11314. red[id] = 255
  11315. green[id] = 255
  11316. blue[id] = 0
  11317. }
  11318. case 4:
  11319. {
  11320. red[id] = 135
  11321. green[id] = 206
  11322. blue[id] = 255
  11323. }
  11324. case 5:
  11325. {
  11326. red[id] = 255
  11327. green[id] = 255
  11328. blue[id] = 255
  11329. }
  11330. case 6:
  11331. {
  11332. red[id] = 75
  11333. green[id] = 0
  11334. blue[id] = 130
  11335. }
  11336. case 7:
  11337. {
  11338. red[id] = 255
  11339. green[id] = 112
  11340. blue[id] = 40
  11341. }
  11342. case 8:
  11343. {
  11344. red[id] = 255
  11345. green[id] = 0
  11346. blue[id] = 255
  11347. }
  11348. case 9:
  11349. {
  11350. red[id] = 139
  11351. green[id] = 0
  11352. blue[id] = 255
  11353. }
  11354. }
  11355.  
  11356. menu_destroy(menu7)
  11357. hud_color(id)
  11358. return PLUGIN_HANDLED;
  11359. }
  11360.  
  11361. public nvg_color(id)
  11362. {
  11363. new menu1[150]
  11364. formatex(menu1, 149, "\yNight Vision Colors ^n\yR: \r%d \yG: \r%d \yB: \r%d", g_nvg[id][0], g_nvg[id][1], g_nvg[id][2])
  11365. new menu6 = menu_create(menu1, "menu_nvg")
  11366.  
  11367. static i, num_color[10]
  11368. for (i = 0; i < 10; i++)
  11369. {
  11370. num_to_str(i, num_color, charsmax(num_color))
  11371. menu_additem(menu6, COLOR_NAMES[i], num_color)
  11372. }
  11373.  
  11374. menu_setprop(menu6,MPROP_EXITNAME,"\y Salir")
  11375. menu_setprop(menu6, MPROP_EXIT, MEXIT_ALL)
  11376. menu_display(id, menu6, 0)
  11377. return PLUGIN_HANDLED
  11378. }
  11379.  
  11380. public menu_nvg(id, menu6, item)
  11381. {
  11382.  
  11383. if (item == MENU_EXIT)
  11384. {
  11385. menu_destroy(menu6)
  11386. show_menu_player(id)
  11387. return PLUGIN_HANDLED;
  11388. }
  11389.  
  11390. new Data[6], Name[64]
  11391. new Access, Callback
  11392. menu_item_getinfo(menu6, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11393.  
  11394. static Key; Key = (str_to_num(Data))
  11395. new i
  11396.  
  11397. for (i = 0; i < 3; i++)
  11398. g_nvg[id][i] = COLOR_RGB[Key][i]
  11399.  
  11400. menu_destroy(menu6)
  11401. nvg_color(id)
  11402. return PLUGIN_HANDLED;
  11403. }
  11404.  
  11405. public level_system(taskid)
  11406. {
  11407. static id
  11408. (taskid > g_maxplayers) ? (id = ID_SPAWN) : (id = taskid);
  11409.  
  11410. new niveles[630], Posicion[630]
  11411. new menu = menu_create("\y Lista de Niveles\r", "level_system_handler")
  11412.  
  11413. for(new i = 0; i < 640 ; i++)
  11414. {
  11415. if (g_level[id] >= i)
  11416. {
  11417. formatex(niveles, charsmax(niveles), "\y Level \r%d\y: \r%s \yAmmoPacks", i, Puntuacion(Levels[i]))
  11418. }
  11419. else
  11420. {
  11421. formatex(niveles, charsmax(niveles), "\d Level %d: %s AmmoPacks", i, Puntuacion(Levels[i]))
  11422. }
  11423. num_to_str(i, Posicion, charsmax(Posicion))
  11424. menu_additem(menu, niveles, Posicion)
  11425. }
  11426.  
  11427. menu_setprop(menu, MPROP_NEXTNAME, "\ySiguiente")
  11428. menu_setprop(menu, MPROP_BACKNAME, "\yAnterior")
  11429. menu_setprop(menu, MPROP_EXITNAME, "\ySalir")
  11430.  
  11431. menu_display(id, menu, 0)
  11432. return PLUGIN_HANDLED;
  11433. }
  11434.  
  11435. public level_system_handler(id, menu, item)
  11436. {
  11437. if(item == MENU_EXIT)
  11438. {
  11439. menu_destroy(menu)
  11440. return PLUGIN_HANDLED
  11441. }
  11442.  
  11443. new data[6], iName[64], access, callback
  11444. menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
  11445.  
  11446. switch(str_to_num(data))
  11447. {
  11448. case 1..630: level_system(id)
  11449. }
  11450.  
  11451. menu_destroy(menu)
  11452. return PLUGIN_HANDLED
  11453. }
  11454.  
  11455. public menu_reset(id)
  11456. {
  11457. static Menu[999], iLen
  11458. iLen = 0
  11459.  
  11460. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\yMenu De \rReseteo^n^n")
  11461.  
  11462. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\yTienes \r%d \y%s^n", g_reset[id], g_reset[id] == 1 ? "reset" : "resets")
  11463.  
  11464. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\w- \yCondiciones De \rReseteo \w-^n^n\rResetear\w:^n \y-\w Level 630^n \y-\w 150 Puntos Humanos^n \y-\w 150 Puntos Zombies^n^n\yGanaras\w:^n \y-\w Mas Velocidad^n \y-\w Mas Vida^n \y-\w Danio Aumentado^n \y-\w Mas Chaleco^n \y-\w 3 Puntos \y Gold [Zombies - Humanos]^n^n")
  11465.  
  11466. if (g_level[id] >= 630)
  11467. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r1. \yResetear !")
  11468. else
  11469. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r1. \dResetear [Te falta%s %d level%s]", 630 - g_level[id] == 1 ? "" : "n", 630 - g_level[id], 630 - g_level[id] == 1 ? "" : "s")
  11470.  
  11471. iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "^n\r0.\y Salir")
  11472.  
  11473. show_menu(id, KEYSMENU, Menu, -1, "Menu De Reseteo")
  11474. }
  11475.  
  11476. public reset_handler(id, key)
  11477. {
  11478. switch(key)
  11479. {
  11480. case 0:
  11481. {
  11482. if (g_level[id] >= 630)
  11483. {
  11484. client_cmd(id, "messagemode _Resetear_")
  11485.  
  11486. set_hudmessage(0, 200, 200, 0.00, 0.18, 1, 0.0, 3.0, 2.0, 1.0, -1)
  11487. ShowSyncHudMsg(0, g_MsgSync, "Para resetear escribe zp_reset y tu contraseña")
  11488. }
  11489. }
  11490. }
  11491. }
  11492.  
  11493. public Set_Hat(player, const model[])
  11494. {
  11495. g_HatEnt[player] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  11496.  
  11497. if (!pev_valid(g_HatEnt[player]))
  11498. return
  11499.  
  11500. if(!g_HatEnt[player])
  11501. {
  11502. set_pev(g_HatEnt[player], pev_movetype, MOVETYPE_FOLLOW)
  11503. set_pev(g_HatEnt[player], pev_aiment, player)
  11504. set_pev(g_HatEnt[player], pev_rendermode, kRenderNormal)
  11505. }
  11506.  
  11507. engfunc(EngFunc_SetModel, g_HatEnt[player], model)
  11508.  
  11509. if (g_zombie[player] && g_zombieclass[player] == 5)
  11510. set_pev(g_HatEnt[player], pev_rendercolor, {0.0, 255.0, 0.0})
  11511. }
  11512.  
  11513. public clcmd_reset(id)
  11514. {
  11515. static reset[33]
  11516.  
  11517. read_args(reset, charsmax(reset))
  11518.  
  11519. if(equal(reset, ""))
  11520. return PLUGIN_HANDLED
  11521.  
  11522. if(!equali(reset, "zp_reset %s"), password[id][0])
  11523. {
  11524. client_print(id, print_center, "Password Incorrecta !")
  11525. return PLUGIN_HANDLED
  11526. }
  11527. else
  11528. {
  11529. g_ammopacks[id] = 1
  11530. g_level[id] = 1
  11531. g_reset[id]++
  11532. dllfunc(DLLFunc_ClientKill, id)
  11533. g_menu_data[id][3] = 0
  11534. g_menu_data[id][4] = 0
  11535. g_menu_data[id][5] = 0
  11536. g_humanclass[id] = 0
  11537. g_humanclassnext[id] = 0
  11538. Save(id)
  11539.  
  11540. if (g_reset[id] >= 4)
  11541. {
  11542. Set_Hat(id, pirate2)
  11543. }
  11544. else
  11545. {
  11546. switch (g_reset[id])
  11547. {
  11548. case 1: Set_Hat(id, scream)
  11549. case 2: Set_Hat(id, jason)
  11550. case 3: Set_Hat(id, viking)
  11551. }
  11552. }
  11553. }
  11554.  
  11555. return PLUGIN_HANDLED;
  11556. }
  11557. // sistema de levels
  11558. public update_ap(id, amount)
  11559. {
  11560. if(g_ammopacks[id] + amount > Levels[sizeof Levels - 1] - 1)
  11561. return PLUGIN_HANDLED;
  11562.  
  11563. g_ammopacks[id] += amount
  11564.  
  11565. if(g_ammopacks[id] >= Levels[g_level[id]])
  11566. {
  11567. do
  11568. {
  11569. g_level[id]++
  11570. }
  11571.  
  11572. while(g_ammopacks[id] >= Levels[g_level[id]])
  11573. {
  11574.  
  11575. client_print(id, print_center, "Subiste al level %d", g_level[id])
  11576. SpkSound(id, Level_up)
  11577. }
  11578. }
  11579. return PLUGIN_HANDLED;
  11580. }
  11581.  
  11582. public reset_bools(id)
  11583. {
  11584. ak47_ak74[id] = false
  11585. ak47_br47[id] = false
  11586. ak47_thompson[id] = false
  11587. aug_delta[id] = false
  11588. aug_ocillator[id] = false
  11589. awp_131[id] = false
  11590. awp_fire[id] = false
  11591. awp_frost[id] = false
  11592. awp_intervention[id] = false
  11593. famas_131[id] = false
  11594. famas_f11[id] = false
  11595. g3sg1_fero[id] = false
  11596. g3sg1_fire[id] = false
  11597. g3sg1_frost[id] = false
  11598. galil_36[id] = false
  11599. galil_black[id] = false
  11600. m249_minigun[id] = false
  11601. m249_rpd[id] = false
  11602. m3_390[id] = false
  11603. m3_remington[id] = false
  11604. m3_spas12[id] = false
  11605. m4a1_colt[id] = false
  11606. m4a1_hugit[id] = false
  11607. m4a1_jt[id] = false
  11608. m4a1_m16[id] = false
  11609. mp5_dual[id] = false
  11610. mp5_mossberg[id] = false
  11611. mp5_tac[id] = false
  11612. mp5_tacticala4[id] = false
  11613. p90_41[id] = false
  11614. sg552_hk[id] = false
  11615. sg552_l9a1[id] = false
  11616. sg552_scar[id] = false
  11617. sg552_kar32[id] = false
  11618. sg550_scoutguard[id] = false
  11619. sg550_zeus[id] = false
  11620. ump45_tac[id] = false
  11621. m3_winchester[id] = false
  11622. xm1014_demon[id] = false
  11623. xm1014_serbu[id] = false
  11624. }
  11625.  
  11626. public menu_mejoras(id)
  11627. {
  11628. new menu = menu_create("Mejoras", "show_menu_mejoras")
  11629.  
  11630. menu_additem(menu, "Mejoras Humanas", "1")
  11631. menu_additem(menu, "Mejoras Zombie^n", "2")
  11632. menu_additem(menu, "Puntos Especiales^n", "3")
  11633. menu_additem(menu, "Resetear", "5")
  11634.  
  11635. menu_setprop(menu, MPROP_EXITNAME, "\ySalir")
  11636.  
  11637. menu_display(id, menu, 0)
  11638. return PLUGIN_HANDLED;
  11639. }
  11640.  
  11641. public show_menu_mejoras(id, menu, item)
  11642. {
  11643. if (item == MENU_EXIT)
  11644. {
  11645. menu_destroy(menu)
  11646. return PLUGIN_HANDLED;
  11647. }
  11648.  
  11649. new Data[5], Name[33], access, callback
  11650. menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback)
  11651.  
  11652. new Key; Key = str_to_num(Data)
  11653. switch (Key)
  11654. {
  11655. case 1: menu_mejoras_h(id)
  11656. case 2: menu_mejoras_z(id)
  11657. case 3: menu_mejoras_especiales(id)
  11658. case 5: menu_reset(id)
  11659. }
  11660.  
  11661. menu_destroy(menu)
  11662. return PLUGIN_HANDLED
  11663. }
  11664. public menu_mejoras_especiales(id)
  11665. {
  11666. new menu[999], len
  11667. len = 0
  11668.  
  11669. len += formatex(menu[len], sizeof menu - 1 - len, "\y Mejoras \r[Especiales]^n^n\y Tienes \w%d\y puntos para gastar^n", g_sp_skill_points[id])
  11670. len += formatex(menu[len], sizeof menu - 1 - len, "\y Los Puntos Especiales sirven para mejorar habilidades fuera del menu de mejoras normales^n")
  11671. len += formatex(menu[len], sizeof menu - 1 - len, "\y Para obtener Puntos \r[Especiales] \ydebes tener \w12 \ypuntos humanos, \w12 \ypuntos zombies ^n y luego \rcombinar^n^n")
  11672. if (g_skill_points_type[id][0] >= 12)
  11673. {
  11674. len += formatex(menu[len], sizeof menu - 1 - len, "\y Puntos Humanos Restantes: \w[COMPLETO]^n")
  11675. }
  11676. else
  11677. {
  11678. len += formatex(menu[len], sizeof menu - 1 - len, "\y Puntos Humanos Restantes: \w%d^n", 12 - g_skill_points_type[id][0])
  11679. }
  11680. if (g_skill_points_type[id][1] >= 12)
  11681. {
  11682. len += formatex(menu[len], sizeof menu - 1 - len, "\y Puntos Zombies Restantes: \w[COMPLETO]^n")
  11683. }
  11684. else
  11685. {
  11686. len += formatex(menu[len], sizeof menu - 1 - len, "\y Puntos Zombies Restantes: \w%d^n^n^n", 12 - g_skill_points_type[id][1])
  11687. }
  11688. if (g_skill_points_type[id][0] >= 12 && g_skill_points_type[id][1] >= 12)
  11689. {
  11690. len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \r Combinar!")
  11691. }
  11692. else
  11693. {
  11694. len += formatex(menu[len], sizeof menu - 1 - len, "\d1. Combinar!")
  11695. }
  11696. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r0. \y %L", id, "MENU_EXIT")
  11697.  
  11698. show_menu(id, KEYSMENU, menu, -1, "Mejoras Especiales")
  11699.  
  11700. }
  11701. public menu_mejoras_sp_handler(id, key)
  11702. {
  11703. switch (key)
  11704. {
  11705. case 0:
  11706. {
  11707. for (new i; i < 2; i++)
  11708. {
  11709. if (g_skill_points_type[i][i] >= 12)
  11710. {
  11711. g_skill_points_type[id][i] -= 12
  11712. g_sp_skill_points[id]++
  11713. }
  11714. }
  11715. }
  11716. }
  11717.  
  11718. menu_mejoras_especiales(id)
  11719. }
  11720. public menu_mejoras_h(id)
  11721. {
  11722. new menu[256], num[8], i, menu2
  11723.  
  11724. formatex(menu, 255, "\yMejoras \r[HUMANAS]\y^n^nPuntos para gastar: \w%d\y^n\yYa gastaste: \w%d", g_skill_points_type[id][0], g_gastados[id][0])
  11725.  
  11726. menu2 = menu_create(menu, "show_menu_mejoras_h")
  11727.  
  11728. for (i = 0; i < 6; i++)
  11729. {
  11730. num_to_str(i, num, 7)
  11731.  
  11732. if (g_skill_points[id][0][i] < g_mejoras_names_max[0][i])
  11733. {
  11734. if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][i]))
  11735. {
  11736. formatex(menu, charsmax(menu), "\yAumentar %s (%d/%d)\r \w[%d punto%s\w]%s", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s", espacio[0][i])
  11737. menu_additem(menu2, menu, num)
  11738. }
  11739. else
  11740. {
  11741. formatex(menu, charsmax(menu), "\dAumentar %s (%d/%d)\r \w[%d punto%s\w]%s", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s", espacio[0][i])
  11742. menu_additem(menu2, menu, num)
  11743. }
  11744. }
  11745. else
  11746. {
  11747. formatex(menu, charsmax(menu), "\dAumentar %s (%d/%d) \w[MAX\w]%s" , g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], espacio[0][i])
  11748. menu_additem(menu2, menu, num)
  11749. }
  11750. }
  11751.  
  11752. if (g_gastados[id][0] >= 1)
  11753. menu_additem(menu2, "\yResetear Mejoras", "7")
  11754. else
  11755. menu_additem(menu2, "\dResetear Mejoras", "7")
  11756.  
  11757. menu_setprop(menu2, MPROP_EXITNAME, "Salir")
  11758.  
  11759. menu_display(id, menu2)
  11760. }
  11761.  
  11762. public show_menu_mejoras_h(id, menu, item)
  11763. {
  11764. if (item == MENU_EXIT)
  11765. {
  11766. menu_destroy(menu)
  11767. return PLUGIN_HANDLED;
  11768. }
  11769.  
  11770. new Data[5], Name[33], access, callback
  11771. menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback)
  11772. new Key; Key = str_to_num(Data)
  11773. switch (Key)
  11774. {
  11775. case 7:
  11776. {
  11777. if (g_gastados[id][0] >= 1)
  11778. {
  11779. for (new i = 0; i < 6; i++)
  11780. {
  11781. g_skill_points[id][0][i] = 0
  11782. g_skill_points_type[id][0] += g_gastados[id][0]
  11783. g_gastados[id][0] = 0
  11784. }
  11785. }
  11786. menu_mejoras_h(id)
  11787. }
  11788. }
  11789.  
  11790. if (g_skill_points[id][0][Key] < g_mejoras_names_max[0][Key])
  11791. {
  11792. if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][Key]))
  11793. {
  11794. g_skill_points_type[id][0] -= costo(g_skill_points[id][0][Key])
  11795. g_gastados[id][0] += costo(g_skill_points[id][0][Key])
  11796. g_skill_points[id][0][Key]++
  11797. }
  11798. }
  11799. menu_destroy(menu)
  11800. menu_mejoras_h(id)
  11801. return PLUGIN_HANDLED
  11802. }
  11803.  
  11804. public menu_mejoras_z(id)
  11805. {
  11806. new menu2[256], pos[8], i, menu3
  11807.  
  11808. formatex(menu2, 255, "\yMejoras \r[ZOMBIES]^n^n\yPuntos para gastar: \w%d\y^n\yYa gastaste: \w%d", g_skill_points_type[id][1], g_gastados[id][1])
  11809.  
  11810. menu3 = menu_create(menu2, "show_menu_mejoras_z")
  11811.  
  11812. for (i = 0; i < 4; i++)
  11813. {
  11814. num_to_str(i, pos, 7)
  11815.  
  11816. if (g_skill_points[id][1][i] < g_mejoras_names_max[1][i])
  11817. {
  11818. if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][i]))
  11819. {
  11820. formatex(menu2, charsmax(menu2), "\yAumentar %s (%d/%d)\r \w[%d punto%s\w]%s", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s", espacio[1][i])
  11821. menu_additem(menu3, menu2, pos)
  11822. }
  11823. else
  11824. {
  11825. formatex(menu2, charsmax(menu2), "\dAumentar %s (%d/%d)\r \w[%d punto%s\w]%s", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s", espacio[1][i])
  11826. menu_additem(menu3, menu2, pos)
  11827. }
  11828. }
  11829. else
  11830. {
  11831. formatex(menu2, charsmax(menu2), "\dAumentar %s (%d/%d) \w[MAX\w]%s" , g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], espacio[1][i])
  11832. menu_additem(menu3, menu2, pos)
  11833. }
  11834. }
  11835.  
  11836. if (g_gastados[id][0] >= 1)
  11837. menu_additem(menu3, "\yResetear Mejoras", "7")
  11838. else
  11839. menu_additem(menu3, "\dResetear Mejoras", "7")
  11840. menu_setprop(menu3, MPROP_EXITNAME, "Salir")
  11841.  
  11842. menu_display(id, menu3)
  11843. }
  11844.  
  11845. public show_menu_mejoras_z(id, menu, item)
  11846. {
  11847. if (item == MENU_EXIT)
  11848. {
  11849. menu_destroy(menu)
  11850. return PLUGIN_HANDLED;
  11851. }
  11852.  
  11853. new Data[5], Name[33], access, callback
  11854. menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback)
  11855. new Key; Key = str_to_num(Data)
  11856.  
  11857. switch (Key)
  11858. {
  11859. case 7:
  11860. {
  11861. if (g_gastados[id][1] >= 1)
  11862. {
  11863. for (new i = 0; i < 6; i++)
  11864. {
  11865. g_skill_points[id][1][i] = 0
  11866. g_skill_points_type[id][1] += g_gastados[id][1]
  11867. g_gastados[id][1] = 0
  11868. }
  11869. }
  11870. menu_mejoras_z(id)
  11871. }
  11872. }
  11873. if (g_skill_points[id][1][Key] < g_mejoras_names_max[1][Key])
  11874. {
  11875. if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][Key]))
  11876. {
  11877. g_skill_points_type[id][1] -= costo(g_skill_points[id][1][Key])
  11878. g_gastados[id][1] += costo(g_skill_points[id][1][Key])
  11879. g_skill_points[id][1][Key]++
  11880. }
  11881. }
  11882. menu_destroy(menu)
  11883. menu_mejoras_z(id)
  11884. return PLUGIN_HANDLED
  11885. }
  11886.  
  11887. public show_menu_estadisticas(id)
  11888. {
  11889. new name[32]
  11890. get_user_name(id, name, 31)
  11891.  
  11892. static menu[256], len
  11893. len += formatex(menu[len], sizeof menu - 1 - len,"\yEstadisticas^n^n")
  11894. len += formatex(menu[len], sizeof menu - 1 - len,"\yNick: \w%s^n", name)
  11895. len += formatex(menu[len], sizeof menu - 1 - len,"\yLevel:\w %d^n", g_level[id])
  11896. len += formatex(menu[len], sizeof menu - 1 - len,"\yAmmo Packs:\w %s^n", Puntuacion(g_ammopacks[id]))
  11897. len += formatex(menu[len], sizeof menu - 1 - len,"\yRestantes:\w %s^n", Puntuacion(Levels[g_level[id]] - g_ammopacks[id]))
  11898. len += formatex(menu[len], sizeof menu - 1 - len,"\yResets:\w %d^n", g_reset[id])
  11899. len += formatex(menu[len], sizeof menu - 1 - len,"\yHuman SkillPoints: \w%s^n", Puntuacion(g_skill_points_type[id][0]))
  11900. len += formatex(menu[len], sizeof menu - 1 - len,"\yZombie SkillPoints: \w%s^n", Puntuacion(g_skill_points_type[id][1]))
  11901. len += formatex(menu[len], sizeof menu - 1 - len,"\yEspecial SkillPoints: \w%s^n", Puntuacion(g_sp_skill_points[id]))
  11902. len += formatex(menu[len], sizeof menu - 1 - len,"\yKills: \w%s^n^n", Puntuacion(g_kills[id]))
  11903. len += formatex(menu[len], sizeof menu - 1 - len,"\y\r1.\yVer tiempo Jugado")
  11904.  
  11905. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r0.\y %L", id, "MENU_EXIT")
  11906.  
  11907. show_menu(id, KEYSMENU, menu, -1, "Estadisticas")
  11908. }
  11909.  
  11910. public menu_estadisticas_handler(id, key)
  11911. {
  11912. switch (key)
  11913. {
  11914. case 0:
  11915. {
  11916. show_menu_tiempo_en_juego(id)
  11917. }
  11918.  
  11919. }
  11920. }
  11921. public chequear_hora(taskid)
  11922. {
  11923. static id
  11924. id = ID_SHOWHUD;
  11925.  
  11926. if (is_user_connected(id))
  11927. {
  11928. if (g_tiempo[id][0] > 59) // segundos
  11929. {
  11930. g_tiempo[id][0] = 0
  11931. g_tiempo[id][1]++
  11932. }
  11933. else
  11934. {
  11935. g_tiempo[id][0]++
  11936. }
  11937. if (g_tiempo[id][1] > 59) // minutos
  11938. {
  11939. g_tiempo[id][1] = 0
  11940. g_tiempo[id][2]++ // horas
  11941. }
  11942. }
  11943. }
  11944.  
  11945. public show_menu_tiempo_en_juego(id)
  11946. {
  11947. new data2[256], menu
  11948.  
  11949. formatex(data2, 255, "\yTe registraste el \w%s^n\yLlevas jugando \w%d Hora%s %d Minuto%s y %d Segundo%s", g_date[id], g_tiempo[id][2], g_tiempo[id][2] == 1 ? "" : "s", g_tiempo[id][1], g_tiempo[id][1] == 1 ? "" : "s", g_tiempo[id][0], g_tiempo[id][0] == 1 ? "" : "s")
  11950.  
  11951. menu = menu_create(data2, "menu_tiempo_en_juego")
  11952. menu_additem(menu, "Actualizar", "1")
  11953.  
  11954. menu_setprop(menu,MPROP_EXITNAME,"\y Salir")
  11955. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  11956. menu_display(id, menu, 0)
  11957. return PLUGIN_HANDLED
  11958. }
  11959.  
  11960. public menu_tiempo_en_juego(id, Menu1, item)
  11961. {
  11962. if (item == MENU_EXIT)
  11963. {
  11964. menu_destroy(Menu1)
  11965. return PLUGIN_HANDLED
  11966. }
  11967.  
  11968. new Data[6], Name[64]
  11969. new Access, Callback
  11970. menu_item_getinfo(Menu1, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)
  11971.  
  11972. new Key = str_to_num(Data)
  11973.  
  11974. switch (Key)
  11975. {
  11976. case 1:
  11977. {
  11978. show_menu_tiempo_en_juego(id)
  11979. }
  11980. }
  11981.  
  11982. menu_destroy(Menu1)
  11983. return PLUGIN_HANDLED
  11984. }
  11985.  
  11986. show_menu_cuenta(id)
  11987. {
  11988. static menu[250], len
  11989. len = 0
  11990.  
  11991. // Title
  11992. len += formatex(menu[len], sizeof menu - 1 - len, "\wZombie HellWorld \r1.0^n\yEditado por: \rKillLikoe^n^n")
  11993.  
  11994. len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \wLoguearme^n")
  11995. len += formatex(menu[len], sizeof menu - 1 - len, "\r2. \wRegistrarme^n")
  11996.  
  11997. show_menu(id, KEYSMENU, menu, -1, "Cuenta Menu")
  11998. }
  11999.  
  12000. show_menu_personajes(id)
  12001. {
  12002. new nivel[33][5], resets[33][5], personaje[33][5]
  12003. static menu[500], len
  12004. len = 0
  12005.  
  12006. if(!equal(g_personaje_nombre[id][1], ""))
  12007. personaje[id][0] = true
  12008.  
  12009. if(!equal(g_personaje_nombre[id][2], ""))
  12010. personaje[id][1] = true
  12011.  
  12012. if(!equal(g_personaje_nombre[id][3], ""))
  12013. personaje[id][2] = true
  12014.  
  12015. if(!equal(g_personaje_nombre[id][4], ""))
  12016. personaje[id][3] = true
  12017.  
  12018. if(!equal(g_personaje_nombre[id][5], ""))
  12019. personaje[id][4] = true
  12020.  
  12021. // Connect to SQL
  12022. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12023.  
  12024. if(SqlConnect == Empty_Handle)
  12025. {
  12026. log_amx("SQL Error: %s", g_Error)
  12027. return PLUGIN_HANDLED;
  12028. }
  12029.  
  12030. // Create Handle
  12031. new Handle:Query
  12032.  
  12033. if(personaje[id][0] || personaje[id][1] || personaje[id][2] || personaje[id][3] || personaje[id][4])
  12034. {
  12035. for (new i = 0; i < 5; i++)
  12036. {
  12037. if(personaje[id][i])
  12038. {
  12039. Query = SQL_PrepareQuery(SqlConnect, "SELECT `Level`, `Resets` FROM `personajes` WHERE (`Nombre` = '%s')", g_personaje_nombre[id][i+1])
  12040.  
  12041. // Query Execute ?
  12042. if (SQL_Execute(Query))
  12043. {
  12044. if (!SQL_NumResults(Query))
  12045. {
  12046. client_print(id, print_center, "El Personaje %s no existe !", g_personaje_nombre[id][i+1])
  12047. formatex(g_personaje_nombre[id][i+1], charsmax(g_personaje_nombre), "")
  12048. }
  12049. else
  12050. {
  12051. nivel[id][i] = SQL_ReadResult(Query, 0)
  12052. resets[id][i] = SQL_ReadResult(Query, 1)
  12053. }
  12054. }
  12055. else
  12056. {
  12057. SQL_QueryError(Query, g_Error, charsmax(g_Error))
  12058. set_fail_state(g_Error)
  12059. }
  12060. }
  12061. }
  12062. // Connection Closed
  12063. SQL_FreeHandle(Query)
  12064. SQL_FreeHandle(SqlConnect)
  12065. }
  12066.  
  12067. if(equal(g_date[id], ""))
  12068. get_time("%c - %Y", g_date[id], 32)
  12069.  
  12070. // Title
  12071. len += formatex(menu[len], sizeof menu - 1 - len, "\wCuenta: \r%s \w |---| \wCreada el: %s^n^n", cuenta[id], g_date[id])
  12072.  
  12073. if(equal(g_personaje_nombre[id][1], ""))
  12074. len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \wCrear Personaje \y(Slot 1)^n^n")
  12075. else
  12076. len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%s \w( Level : \r%d \w|| \wResets : \r%d \w)^n^n", g_personaje_nombre[id][1], nivel[id][0], resets[id][0])
  12077.  
  12078. if(equal(g_personaje_nombre[id][2], ""))
  12079. len += formatex(menu[len], sizeof menu - 1 - len, "\r2. \wCrear Personaje \y(Slot 2)^n^n")
  12080. else
  12081. len += formatex(menu[len], sizeof menu - 1 - len, "\r2. \w%s \w( Level : \r%d \w|| \wResets : \r%d \w)^n^n", g_personaje_nombre[id][2], nivel[id][1], resets[id][1])
  12082.  
  12083. if(equal(g_personaje_nombre[id][3], ""))
  12084. len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \wCrear Personaje \y(Slot 3)^n^n")
  12085. else
  12086. len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%s \w( Level : \r%d \w|| \wResets : \r%d \w)^n^n", g_personaje_nombre[id][3], nivel[id][2], resets[id][2])
  12087.  
  12088. if(equal(g_personaje_nombre[id][4], ""))
  12089. len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \wCrear Personaje \y(Slot 4)^n^n")
  12090. else
  12091. len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%s \w( Level : \r%d \w|| \wResets : \r%d \w)^n^n", g_personaje_nombre[id][4], nivel[id][3], resets[id][3])
  12092.  
  12093. if(equal(g_personaje_nombre[id][5], ""))
  12094. len += formatex(menu[len], sizeof menu - 1 - len, "\r5. \wCrear Personaje \y(Slot 5)^n^n")
  12095. else
  12096. len += formatex(menu[len], sizeof menu - 1 - len, "\r5. \w%s \w( Level : \r%d \w|| \wResets : \r%d \w)^n^n", g_personaje_nombre[id][5], nivel[id][4], resets[id][4])
  12097.  
  12098. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r7. \wCambiar contraseña^n")
  12099. len += formatex(menu[len], sizeof menu - 1 - len, "^n\r9. \wDesconectarse^n")
  12100.  
  12101. show_menu(id, KEYSMENU, menu, -1, "Personajes Menu")
  12102.  
  12103. return PLUGIN_HANDLED
  12104. }
  12105.  
  12106. show_menu_personaje_crear(id)
  12107. {
  12108. static menu[250], len
  12109. len = 0
  12110.  
  12111. // Title
  12112. len += formatex(menu[len], sizeof menu - 1 - len, "\wSeguro que quieres crear un personaje con el nombre de: \r%s \w?^n^n^n", g_playername[id])
  12113.  
  12114. len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \wSi^n")
  12115.  
  12116. len += formatex(menu[len], sizeof menu - 1 - len, "\r2. \wNo^n")
  12117.  
  12118. show_menu(id, KEYSMENU, menu, -1, "Personaje Crear Menu")
  12119. }
  12120.  
  12121. public menu_cuenta(id, key)
  12122. {
  12123. if(key != 0 && key != 1)
  12124. {
  12125. show_menu_cuenta(id)
  12126.  
  12127. return PLUGIN_HANDLED
  12128. }
  12129.  
  12130. switch (key)
  12131. {
  12132. case 0: login_cuenta(id)
  12133.  
  12134. case 1: crear_cuenta(id)
  12135. }
  12136.  
  12137. return PLUGIN_HANDLED;
  12138. }
  12139.  
  12140. public menu_personajes(id, key)
  12141. {
  12142. if(key == 0 || key == 1 || key == 2 || key == 3 || key == 4)
  12143. {
  12144. g_personaje[id] = key+1
  12145.  
  12146. if(equal(g_personaje_nombre[id][key+1], ""))
  12147. show_menu_personaje_crear(id)
  12148. else
  12149. {
  12150. new personaje[33][5]
  12151.  
  12152. if(!equal(g_personaje_nombre[id][1], ""))
  12153. personaje[id][0] = true
  12154.  
  12155. if(!equal(g_personaje_nombre[id][2], ""))
  12156. personaje[id][1] = true
  12157.  
  12158. if(!equal(g_personaje_nombre[id][3], ""))
  12159. personaje[id][2] = true
  12160.  
  12161. if(!equal(g_personaje_nombre[id][4], ""))
  12162. personaje[id][3] = true
  12163.  
  12164. if(!equal(g_personaje_nombre[id][5], ""))
  12165. personaje[id][4] = true
  12166.  
  12167. copy(g_personaje_nombre[id][0], charsmax(g_personaje_nombre), g_personaje_nombre[id][key+1])
  12168. g_login[id] = LOGIN_FULL
  12169. Load(id)
  12170. client_cmd(id, "chooseteam")
  12171. }
  12172.  
  12173. return PLUGIN_HANDLED
  12174. }
  12175.  
  12176. if(key == 6)
  12177. cambiar_contrasenia(id)
  12178.  
  12179. if (key == 8)
  12180. {
  12181. g_login[id] = 0
  12182. show_menu_cuenta(id)
  12183. }
  12184.  
  12185. return PLUGIN_HANDLED;
  12186. }
  12187.  
  12188. public menu_personaje_crear(id, key)
  12189. {
  12190. if(key == 0)
  12191. crear_personaje(id)
  12192. else if(key == 1)
  12193. show_menu_personajes(id)
  12194.  
  12195. return PLUGIN_HANDLED;
  12196. }
  12197.  
  12198. public Menu_Hook(iMsgid, iDest, id)
  12199. {
  12200. if(g_login[id] == 0)
  12201. show_menu_cuenta(id)
  12202. else if(g_login[id] == 1)
  12203. show_menu_personajes(id)
  12204. else if(g_login[id] == LOGIN_FULL)
  12205. return PLUGIN_CONTINUE
  12206.  
  12207. return PLUGIN_HANDLED
  12208. }
  12209.  
  12210. public crear_cuenta(id)
  12211. {
  12212. if(g_login[id] != 0)
  12213. return;
  12214.  
  12215. client_cmd(id, "messagemode Crear_Cuenta")
  12216.  
  12217. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12218. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu cuenta")
  12219.  
  12220. }
  12221.  
  12222. public filtro_crear_cuenta(id)
  12223. {
  12224. if(g_login[id] != 0)
  12225. return PLUGIN_HANDLED
  12226.  
  12227. // Obtenemos en un string lo que escribio como password
  12228. read_args(cuenta[id], charsmax(cuenta))
  12229.  
  12230. // Lo preparamos para analizar
  12231. remove_quotes(cuenta[id]), trim(cuenta[id])
  12232.  
  12233. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12234. ShowSyncHudMsg(id, g_MsgSync, "")
  12235.  
  12236. // Si solamente apreto enter lo omitiremos
  12237. if(equal(cuenta[id], ""))
  12238. return PLUGIN_HANDLED
  12239.  
  12240. // Verificamos que la password solo contenga una palabra
  12241. if(contain(cuenta[id], " ") != -1)
  12242. {
  12243. client_print(id, print_center, "La cuenta no debe contener espacios")
  12244.  
  12245. return PLUGIN_HANDLED
  12246. }
  12247.  
  12248. // Connect to SQL
  12249. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12250.  
  12251. if(SqlConnect == Empty_Handle)
  12252. {
  12253. log_amx("SQL Error: %s", g_Error)
  12254. return PLUGIN_HANDLED;
  12255. }
  12256. // Create Handle
  12257. new Handle:Query
  12258. Query = SQL_PrepareQuery(SqlConnect, "SELECT `Nombre` FROM `datos` WHERE (`Nombre` = '%s')", cuenta[id])
  12259.  
  12260. // Query Execute ?
  12261. if (SQL_Execute(Query))
  12262. {
  12263. if (!SQL_NumResults(Query))
  12264. {
  12265.  
  12266. crear_contrasenia(id)
  12267.  
  12268. // Connection Closed
  12269. SQL_FreeHandle(Query)
  12270. SQL_FreeHandle(SqlConnect)
  12271.  
  12272. return PLUGIN_HANDLED;
  12273. }
  12274. else
  12275. {
  12276. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12277. ShowSyncHudMsg(id, g_MsgSync, "")
  12278. client_print(id, print_center, "La cuenta %s ya existe!", cuenta[id])
  12279.  
  12280. show_menu_cuenta(id)
  12281.  
  12282. return PLUGIN_HANDLED;
  12283. }
  12284. }
  12285.  
  12286. // Connection Closed
  12287. SQL_FreeHandle(Query)
  12288. SQL_FreeHandle(SqlConnect)
  12289.  
  12290. return PLUGIN_CONTINUE
  12291. }
  12292.  
  12293. public crear_contrasenia(id)
  12294. {
  12295. if(g_login[id] != 0)
  12296. return;
  12297.  
  12298. client_cmd(id, "messagemode Crear_Contrasenia")
  12299. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12300. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu contraseña^n^nCuenta: %s", cuenta[id])
  12301. }
  12302.  
  12303. public filtro_crear_contrasenia(id)
  12304. {
  12305. if(g_login[id] != 0)
  12306. return PLUGIN_HANDLED
  12307.  
  12308. // Obtenemos en un string lo que escribio como password
  12309. read_args(password[id], charsmax(password))
  12310.  
  12311. // Lo preparamos para analizar
  12312. remove_quotes(password[id]), trim(password[id])
  12313.  
  12314. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12315. ShowSyncHudMsg(id, g_MsgSync, "")
  12316.  
  12317. // Si solamente apreto enter lo omitiremos
  12318. if(equal(password[id], ""))
  12319. return PLUGIN_HANDLED
  12320.  
  12321. // Verificamos que la password solo contenga una palabra
  12322. if(contain(password[id], " ") != -1)
  12323. {
  12324. client_print(id, print_center, "La contraseña no debe contener espacios")
  12325.  
  12326. return PLUGIN_HANDLED
  12327. }
  12328.  
  12329. verificar_contrasenia(id)
  12330.  
  12331. return PLUGIN_CONTINUE
  12332. }
  12333.  
  12334. public verificar_contrasenia(id)
  12335. {
  12336. if(g_login[id] != 0)
  12337. return;
  12338.  
  12339. client_cmd(id, "messagemode Verificar_Contrasenia")
  12340. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12341. ShowSyncHudMsg(id, g_MsgSync, "Verifica tu contrasenia^n^nCuenta: %s^nPassword1: %s", cuenta[id], password[id])
  12342. }
  12343.  
  12344. public filtro_crear_contrasenia_v(id)
  12345. {
  12346. if(g_login[id] != 0)
  12347. return PLUGIN_HANDLED
  12348.  
  12349. // Obtenemos en un string lo que escribio como password
  12350. read_args(password_v[id], charsmax(password_v))
  12351.  
  12352. // Lo preparamos para analizar
  12353. remove_quotes(password_v[id]), trim(password_v[id])
  12354.  
  12355. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, -1.0, 0.1, 0.1)
  12356. ShowSyncHudMsg(id, g_MsgSync, "")
  12357.  
  12358. // Si solamente apreto enter lo omitiremos
  12359. if(equal(password_v[id], ""))
  12360. return PLUGIN_HANDLED
  12361.  
  12362. // Verificamos que la password solo contenga una palabra
  12363. if(contain(password_v[id], " ") != -1)
  12364. {
  12365. client_print(id, print_center, "La contraseña no debe contener espacios")
  12366. return PLUGIN_HANDLED
  12367. }
  12368.  
  12369. if(!equal(password[id], password_v[id]))
  12370. {
  12371. client_print(id, print_center, "Las contraseñas no coinciden")
  12372.  
  12373. crear_contrasenia(id)
  12374. return PLUGIN_HANDLED
  12375. }
  12376.  
  12377. ingresar_email1(id)
  12378.  
  12379. return PLUGIN_CONTINUE
  12380. }
  12381. public ingresar_email1(id)
  12382. {
  12383. if(g_login[id] != 0)
  12384. return;
  12385.  
  12386. client_cmd(id, "messagemode Crear_email")
  12387. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12388. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu email^n^nShift + 2 = @^nShift + ' = _^n^nCuenta: %s^nPassword1: %s^nPassword2: %s", cuenta[id], password[id], password_v[id])
  12389. }
  12390.  
  12391.  
  12392. public filtro_crear_email(id)
  12393. {
  12394. if(g_login[id] != 0)
  12395. return PLUGIN_HANDLED;
  12396.  
  12397. static email[300]
  12398.  
  12399. remove_quotes(email)
  12400. read_args(email, charsmax(email))
  12401. trim(email)
  12402.  
  12403. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12404. ShowSyncHudMsg(id, g_MsgSync, "")
  12405.  
  12406. // Si solamente apreto enter lo omitiremos
  12407. if(equal(email, ""))
  12408. {
  12409. client_print(id, print_center, "Debes escribir algo")
  12410. show_menu_cuenta(id)
  12411. return PLUGIN_HANDLED;
  12412. }
  12413.  
  12414. // Verificamos que el email contenga una o mas palabras
  12415. if(contain(email, " ") != -1)
  12416. {
  12417. client_print(id, print_center, "El email no debe contener espacios")
  12418. show_menu_cuenta(id)
  12419. return PLUGIN_HANDLED;
  12420. }
  12421.  
  12422.  
  12423. // Verificamos que el email sea valido
  12424. for (new i = 0; i < sizeof email_valido; i++)
  12425. {
  12426. if( contain ( email, email_valido[i] ) != - 1)
  12427. {
  12428. client_print( id, print_center, "El email es valido" )
  12429. Valido[id] = true
  12430. break;
  12431. }
  12432. else
  12433. {
  12434. client_print( id, print_center, "El email no es valido" )
  12435. Valido[id] = false
  12436. client_cmd(id, "chooseteam")
  12437. break;
  12438. }
  12439. }
  12440.  
  12441. if ( Valido[id] )
  12442. {
  12443. remove_quotes(email)
  12444. read_args(email, charsmax(email))
  12445. trim(email)
  12446.  
  12447. // Connect to SQL
  12448. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12449.  
  12450. if(SqlConnect == Empty_Handle)
  12451. {
  12452. log_amx("SQL Error: %s", g_Error)
  12453. return PLUGIN_HANDLED;
  12454. }
  12455.  
  12456. // Create Handle
  12457. new Handle:Query
  12458. Query = SQL_PrepareQuery(SqlConnect, "INSERT INTO `datos` (`Nombre`, `Password`, `Date`, `Email`) VALUES ('%s', '%s', '%s', '%s');", cuenta[id], password[id], g_date[id], email)
  12459.  
  12460. // Query Execute ?
  12461. if (SQL_Execute(Query))
  12462. {
  12463. g_login[id] = 1
  12464. copy(g_personaje_nombre[id][0], charsmax(g_personaje_nombre), "")
  12465. copy(g_personaje_nombre[id][1], charsmax(g_personaje_nombre), "")
  12466. copy(g_personaje_nombre[id][2], charsmax(g_personaje_nombre), "")
  12467. copy(g_personaje_nombre[id][3], charsmax(g_personaje_nombre), "")
  12468. copy(g_personaje_nombre[id][4], charsmax(g_personaje_nombre), "")
  12469. copy(g_personaje_nombre[id][5], charsmax(g_personaje_nombre), "")
  12470. Save(id)
  12471. zp_colored_print(id, "^x04[ZP]^x01 Registro Exitoso")
  12472. zp_colored_print(id, "^x04[ZP]^x01 Cuenta: ^x04%s^x01 Password: ^x04%s^x01 Email: ^x04%s^x01", cuenta[id], password[id], email)
  12473. client_cmd(id, "chooseteam")
  12474.  
  12475. // Connection Closed
  12476. SQL_FreeHandle(Query)
  12477. SQL_FreeHandle(SqlConnect)
  12478.  
  12479. }
  12480. }
  12481. return PLUGIN_HANDLED
  12482. }
  12483.  
  12484. public login_cuenta(id)
  12485. {
  12486. if(g_login[id] != 0)
  12487. return;
  12488.  
  12489. client_cmd(id, "messagemode Cuenta")
  12490. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12491. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu cuenta")
  12492. }
  12493.  
  12494. public filtro_login_cuenta(id)
  12495. {
  12496. if(g_login[id] != 0)
  12497. return PLUGIN_HANDLED
  12498.  
  12499. // Obtenemos en un string lo que escribio como password
  12500. read_args(cuenta[id], charsmax(cuenta))
  12501.  
  12502. // Lo preparamos para analizar
  12503. remove_quotes(cuenta[id]), trim(cuenta[id])
  12504.  
  12505. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, 0.1, 100.0, 0.1, 0.1)
  12506. ShowSyncHudMsg(id, g_MsgSync, "")
  12507.  
  12508. // Si solamente apreto enter lo omitiremos
  12509. if(equal(cuenta[id], ""))
  12510. return PLUGIN_HANDLED
  12511.  
  12512. // Verificamos que la password solo contenga una palabra
  12513. if(contain(cuenta[id], " ") != -1)
  12514. {
  12515. client_print(id, print_center, "La cuenta debe ser 1 (una) palabra")
  12516. return PLUGIN_HANDLED
  12517. }
  12518.  
  12519. login_contrasenia(id)
  12520.  
  12521. return PLUGIN_CONTINUE
  12522. }
  12523.  
  12524. public login_contrasenia(id)
  12525. {
  12526. if(g_login[id] != 0)
  12527. return;
  12528.  
  12529. client_cmd(id, "messagemode Contrasenia")
  12530. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12531. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu contrasenia")
  12532. }
  12533.  
  12534.  
  12535. public filtro_login_contrasenia(id)
  12536. {
  12537. if(g_login[id] != 0)
  12538. return PLUGIN_HANDLED
  12539.  
  12540. // Obtenemos en un string lo que escribio como password
  12541. read_args(password[id], charsmax(password))
  12542.  
  12543. // Lo preparamos para analizar
  12544. remove_quotes(password[id]), trim(password[id])
  12545.  
  12546. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12547. ShowSyncHudMsg(id, g_MsgSync, "")
  12548.  
  12549. // Si solamente apreto enter lo omitiremos
  12550. if(equal(password[id], ""))
  12551. return PLUGIN_HANDLED
  12552.  
  12553. // Verificamos que la password solo contenga una palabra
  12554. if(contain(password[id], " ") != -1)
  12555. {
  12556. client_print(id, print_center, "La contraseña no debe contener espacios")
  12557. return PLUGIN_HANDLED
  12558. }
  12559.  
  12560. logear(id)
  12561.  
  12562. return PLUGIN_HANDLED
  12563. }
  12564.  
  12565. public logear(id)
  12566. {
  12567. // Connect to SQL
  12568. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12569.  
  12570. if(SqlConnect == Empty_Handle)
  12571. {
  12572. log_amx("SQL Error: %s", g_Error)
  12573. return PLUGIN_HANDLED;
  12574. }
  12575.  
  12576. // Create Handle
  12577. new Handle:Query
  12578. Query = SQL_PrepareQuery(SqlConnect, "SELECT `Personaje1`, `Personaje2`, `Personaje3`, `Personaje4`, `Personaje5`, `Date` FROM `zp_database`.`datos` WHERE (`Nombre` = '%s' AND `Password` = '%s')", cuenta[id], password[id])
  12579.  
  12580. // Query Execute ?
  12581. if (SQL_Execute(Query))
  12582. {
  12583. if (!SQL_NumResults(Query)) // No hay resultados ?
  12584. {
  12585. // Connection Closed
  12586. SQL_FreeHandle(Query)
  12587. SQL_FreeHandle(SqlConnect)
  12588.  
  12589. client_print(id, print_center, "La Cuenta y la password no coinciden o no existe")
  12590.  
  12591. show_menu_cuenta(id)
  12592. }
  12593. else // Si hay?
  12594. {
  12595. SQL_ReadResult(Query, 0, g_personaje_nombre[id][1], charsmax(g_personaje_nombre))
  12596. SQL_ReadResult(Query, 1, g_personaje_nombre[id][2], charsmax(g_personaje_nombre))
  12597. SQL_ReadResult(Query, 2, g_personaje_nombre[id][3], charsmax(g_personaje_nombre))
  12598. SQL_ReadResult(Query, 3, g_personaje_nombre[id][4], charsmax(g_personaje_nombre))
  12599. SQL_ReadResult(Query, 4, g_personaje_nombre[id][5], charsmax(g_personaje_nombre))
  12600. SQL_ReadResult(Query, 5, g_date[id], charsmax(g_date))
  12601.  
  12602.  
  12603. g_login[id] = 1;
  12604. client_cmd(id, "chooseteam")
  12605. client_print(id, print_center, "Login Exitoso!")
  12606.  
  12607. // Connection Closed
  12608. SQL_FreeHandle(Query)
  12609. SQL_FreeHandle(SqlConnect)
  12610. }
  12611. }
  12612.  
  12613. return PLUGIN_HANDLED
  12614. }
  12615.  
  12616. public cambiar_contrasenia(id)
  12617. {
  12618. if(g_login[id] != 1)
  12619. return;
  12620.  
  12621. client_cmd(id, "messagemode Contrasenia_Actual")
  12622.  
  12623. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12624. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu contraseña actual")
  12625. }
  12626.  
  12627. public ingresar_actual(id)
  12628. {
  12629. if(g_login[id] != 1)
  12630. return PLUGIN_HANDLED
  12631.  
  12632. new say[33][20]
  12633.  
  12634. // Obtenemos en un string lo que escribio como password
  12635. read_args(say[id] , charsmax(say))
  12636.  
  12637. // Lo preparamos para analizar
  12638. remove_quotes(say[id] ), trim(say[id] )
  12639.  
  12640. // Si solamente apreto enter lo omitiremos
  12641. if(equal(say[id] , ""))
  12642. return PLUGIN_HANDLED
  12643.  
  12644. // Verificamos que la password solo contenga una palabra
  12645. if(contain(say[id] , " ") != -1)
  12646. {
  12647. client_print(id, print_center, "La contraseña debe ser 1 (una) palabra")
  12648. show_menu_personajes(id)
  12649. return PLUGIN_HANDLED
  12650. }
  12651.  
  12652. // Verificamos que la password solo contenga una palabra
  12653. if(!equali(say[id] , password[id]))
  12654. {
  12655. client_print(id, print_center, "Las contraseñas no coinciden")
  12656. show_menu_personajes(id)
  12657. return PLUGIN_HANDLED
  12658. }
  12659.  
  12660. ingresar_password(id)
  12661.  
  12662. return PLUGIN_CONTINUE
  12663. }
  12664.  
  12665. public ingresar_password(id)
  12666. {
  12667. if(g_login[id] != 1)
  12668. return;
  12669.  
  12670. client_cmd(id, "messagemode Cambiar_Contrasenia")
  12671.  
  12672. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12673. ShowSyncHudMsg(id, g_MsgSync, "Ingresa tu nueva contraseña")
  12674. }
  12675.  
  12676. public filtro_cambiar_contrasenia(id)
  12677. {
  12678. if(g_login[id] != 1)
  12679. return PLUGIN_HANDLED
  12680.  
  12681. // Obtenemos en un string lo que escribio como password
  12682. read_args(password[id], charsmax(password))
  12683.  
  12684. // Lo preparamos para analizar
  12685. remove_quotes(password[id]), trim(password[id])
  12686.  
  12687.  
  12688. // Si solamente apreto enter lo omitiremos
  12689. if(equal(password[id], ""))
  12690. return PLUGIN_HANDLED
  12691.  
  12692. // Verificamos que la password solo contenga una palabra
  12693. if(contain(password[id], " ") != -1)
  12694. {
  12695. client_print(id, print_center, "La contraseña debe ser 1 (una) palabra")
  12696. show_menu_personajes(id)
  12697. return PLUGIN_HANDLED
  12698. }
  12699.  
  12700. cambiar_contrasenia_v(id)
  12701.  
  12702. return PLUGIN_CONTINUE
  12703. }
  12704.  
  12705. public cambiar_contrasenia_v(id)
  12706. {
  12707. if(g_login[id] != 1)
  12708. return;
  12709.  
  12710. client_cmd(id, "messagemode Verifica_Contrasenia")
  12711.  
  12712. set_hudmessage(255, 0, 0, 0.01, 0.03, 1, -1.0, 100.0, 0.1, 0.1)
  12713. ShowSyncHudMsg(id, g_MsgSync, "Vuelve a ingresar tu nueva contraseña")
  12714. }
  12715.  
  12716. public filtro_cambiar_contrasenia_v2(id)
  12717. {
  12718. if(g_login[id] != 1)
  12719. return PLUGIN_HANDLED
  12720.  
  12721. new chequear_password[33][33]
  12722.  
  12723. // Obtenemos en un string lo que escribio como password
  12724. read_args(chequear_password[id], charsmax(chequear_password))
  12725.  
  12726. // Lo preparamos para analizar
  12727. remove_quotes(chequear_password[id]), trim(chequear_password[id])
  12728.  
  12729. // Si solamente apreto enter lo omitiremos
  12730. if(equal(chequear_password[id], ""))
  12731. return PLUGIN_HANDLED
  12732.  
  12733. // Verificamos que la password solo contenga una palabra
  12734. if(contain(chequear_password[id], " ") != -1)
  12735. {
  12736. client_print(id, print_center, "La contraseña no debe contener espacios")
  12737.  
  12738. show_menu_personajes(id)
  12739. return PLUGIN_HANDLED
  12740. }
  12741.  
  12742. if(!equal(password[id], chequear_password[id]))
  12743. {
  12744. client_print(id, print_center, "Las contraseñas no coinciden")
  12745.  
  12746. show_menu_personajes(id)
  12747. return PLUGIN_HANDLED
  12748. }
  12749.  
  12750. copy(chequear_password[id], charsmax(chequear_password), password[id])
  12751.  
  12752. client_print(id, print_chat, "Tu contraseña nueva es: %s", password[id])
  12753.  
  12754. // Connect to SQL
  12755. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12756.  
  12757. if(SqlConnect == Empty_Handle)
  12758. {
  12759. log_amx("SQL Error: %s", g_Error)
  12760. return PLUGIN_HANDLED;
  12761. }
  12762.  
  12763. // Create Handle
  12764. new Handle:Query
  12765. Query = SQL_PrepareQuery(SqlConnect, "UPDATE `zp_database`.`datos` SET `Password` = '%s' WHERE `Nombre` = '%s'", password[id], cuenta[id])
  12766.  
  12767. // Query Execute ?
  12768. if (SQL_Execute(Query))
  12769. {
  12770. if (!SQL_NumResults(Query))
  12771. {
  12772. // Connection Closed
  12773. SQL_FreeHandle(Query)
  12774. SQL_FreeHandle(SqlConnect)
  12775. client_cmd(id, "chooseteam")
  12776.  
  12777. return PLUGIN_HANDLED;
  12778. }
  12779. }
  12780.  
  12781. // Connection Closed
  12782. SQL_FreeHandle(Query)
  12783. SQL_FreeHandle(SqlConnect)
  12784.  
  12785. return PLUGIN_CONTINUE
  12786. }
  12787.  
  12788. public crear_personaje(id)
  12789. {
  12790. // Connect to SQL
  12791. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12792.  
  12793. if(SqlConnect == Empty_Handle)
  12794. {
  12795. log_amx("SQL Error: %s", g_Error)
  12796. return PLUGIN_HANDLED;
  12797. }
  12798.  
  12799. // Create Handle
  12800. new Handle:Query
  12801. Query = SQL_PrepareQuery(SqlConnect, "SELECT `Nombre` FROM `zp_database`.`personajes` WHERE (`Nombre` = '%s')", g_playername[id])
  12802.  
  12803. // Query Execute ?
  12804. if (SQL_Execute(Query))
  12805. {
  12806. if (!SQL_MoreResults(Query))
  12807. {
  12808. Query = SQL_PrepareQuery(SqlConnect, "INSERT INTO `zp_database`.`personajes` ( `Nombre` ) VALUES ('%s');", g_playername[id])
  12809.  
  12810. // Query Execute ?
  12811. if (SQL_Execute(Query))
  12812. {
  12813. g_login[id] = 1
  12814.  
  12815. copy(g_personaje_nombre[id][0], charsmax(g_personaje_nombre), g_playername[id])
  12816. copy(g_personaje_nombre[id][g_personaje[id]], charsmax(g_personaje_nombre), g_playername[id])
  12817.  
  12818. Save(id)
  12819.  
  12820. client_print(id, print_center, "Personaje %s creado con exito !", g_personaje_nombre[id][0])
  12821.  
  12822. client_cmd(id, "chooseteam");
  12823.  
  12824. // Connection Closed
  12825. SQL_FreeHandle(Query)
  12826. SQL_FreeHandle(SqlConnect)
  12827.  
  12828. return PLUGIN_HANDLED
  12829. }
  12830. else
  12831. client_print(id, print_center, "El personaje no pudo ser creado")
  12832. }
  12833. else
  12834. {
  12835. client_print(id, print_center, "El nombre esta en uso!")
  12836. client_cmd(id, "chooseteam")
  12837. }
  12838. }
  12839.  
  12840. // Connection Closed
  12841. SQL_FreeHandle(Query)
  12842. SQL_FreeHandle(SqlConnect)
  12843.  
  12844. return PLUGIN_HANDLED;
  12845. }
  12846.  
  12847. public Save(id)
  12848. {
  12849. if (!g_login[id])
  12850. return PLUGIN_HANDLED;
  12851.  
  12852. // Connect to SQL
  12853. new Handle:Query, Handle:Query2, Handle:Query3, Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12854.  
  12855. if(SqlConnect == Empty_Handle)
  12856. {
  12857. log_amx("SQL Error: %s", g_Error)
  12858. return PLUGIN_HANDLED;
  12859. }
  12860.  
  12861. //---------------------------------------
  12862. // * First Query *
  12863. //---------------------------------------
  12864.  
  12865. Query = SQL_PrepareQuery(SqlConnect, "UPDATE `datos` SET `Personaje1` = '%s', `Personaje2` = '%s', `Personaje3` = '%s', `Personaje4` = '%s', `Personaje5` = '%s', `Date` = '%s' WHERE ( `Nombre` = '%s' AND `Password` = '%s' ) ",
  12866. g_personaje_nombre[id][1],
  12867. g_personaje_nombre[id][2],
  12868. g_personaje_nombre[id][3],
  12869. g_personaje_nombre[id][4],
  12870. g_personaje_nombre[id][5],
  12871. g_date[id],
  12872. cuenta[id],
  12873. password[id])
  12874.  
  12875. if(!SQL_Execute(Query))
  12876. {
  12877. SQL_QueryError(Query, g_Error, charsmax(g_Error))
  12878. set_fail_state(g_Error)
  12879. }
  12880.  
  12881. //---------------------------------------
  12882. // * Second Query *
  12883. //---------------------------------------
  12884.  
  12885.  
  12886. Query2 = SQL_PrepareQuery(SqlConnect, "UPDATE `personajes` SET `Level` = '%d', `AmmoPacks`= '%d',`Resets`= '%d',`PuntosH`= '%d', `PuntosZ`= '%d', `DanioH`= '%d', `DanioZ`= '%d', `ResistenciaH`= '%d', `VelocidadH`= '%d', `VelocidadZ`= '%d', `VitalidadH`= '%d', `VitalidadZ`= '%d', `GravedadH`= '%d', `GravedadZ`= '%d', `ChalecoH`= '%d', `NVG_COLOR0`= '%d', `NVG_COLOR1`= '%d',`NVG_COLOR2`= '%d', `HUD_POS0`= '%f', `HUD_POS1`= '%f', `HUD_COLOR0`= '%d' WHERE ( `Nombre` = '%s' ) ",
  12887. g_level[id],
  12888. g_ammopacks[id],
  12889. g_reset[id],
  12890. g_skill_points_type[id][0],
  12891. g_skill_points_type[id][1] ,
  12892. g_skill_points[id][0][0],
  12893. g_skill_points[id][1][0],
  12894. g_skill_points[id][0][5],
  12895. g_skill_points[id][0][2],
  12896. g_skill_points[id][1][2],
  12897. g_skill_points[id][0][1],
  12898. g_skill_points[id][1][1],
  12899. g_skill_points[id][0][4],
  12900. g_skill_points[id][1][3],
  12901. g_skill_points[id][0][3],
  12902. g_nvg[id][0],
  12903. g_nvg[id][1],
  12904. g_nvg[id][2],
  12905. g_hud_pos[id][0],
  12906. g_hud_pos[id][1],
  12907. red[id],
  12908. g_personaje_nombre[id][0])
  12909.  
  12910. if (!SQL_Execute(Query2))
  12911. {
  12912. SQL_QueryError(Query2, g_Error, charsmax(g_Error))
  12913. set_fail_state(g_Error)
  12914. }
  12915.  
  12916. //---------------------------------------
  12917. // * Third Query *
  12918. //---------------------------------------
  12919.  
  12920.  
  12921. Query3 = SQL_PrepareQuery(SqlConnect, "UPDATE `personajes` SET `HUD_COLOR1`= '%d', `HUD_COLOR2`= '%d', `HUD_EFFECT` = '%d', `HUMAN_CLASS` = '%d', `HUMAN_CLASSNEXT` = '%d', `ZOMBIE_CLASS` = '%d', `ZOMBIE_CLASSNEXT` = '%d', `WPN_ON` = '%d', `WPN_PRI` = '%d', `WPN_SEC` = '%d', `WPN_TER` = '%d', `PuntosSp` = '%d', `FLARE_COLOR0` = '%d', `FLARE_COLOR1` = '%d', `FLARE_COLOR2` = '%d', `GastadosH` = '%d', `GastadosZ` = '%d' WHERE ( `Nombre` = '%s' )",
  12922. green[id],
  12923. blue[id],
  12924. efecto[id],
  12925. g_humanclass[id],
  12926. g_humanclassnext[id],
  12927. g_zombieclass[id],
  12928. g_zombieclassnext[id],
  12929. g_menu_data[id][3],
  12930. g_menu_data[id][4],
  12931. g_menu_data[id][5],
  12932. g_menu_data[id][6],
  12933. g_sp_skill_points[id],
  12934. g_flare_color[id][0],
  12935. g_flare_color[id][1],
  12936. g_flare_color[id][2],
  12937. g_gastados[id][0],
  12938. g_gastados[id][1],
  12939. g_personaje_nombre[id][0])
  12940.  
  12941. if (!SQL_Execute(Query3))
  12942. {
  12943. SQL_QueryError(Query3, g_Error, charsmax(g_Error))
  12944. set_fail_state(g_Error)
  12945. }
  12946.  
  12947.  
  12948. //---------------------------------------
  12949. // * HANDLES *
  12950. //---------------------------------------
  12951.  
  12952. SQL_FreeHandle(Query)
  12953. SQL_FreeHandle(Query2)
  12954. SQL_FreeHandle(Query3)
  12955. SQL_FreeHandle(SqlConnect)
  12956.  
  12957. return PLUGIN_HANDLED
  12958. }
  12959.  
  12960. public Load(id)
  12961. {
  12962. // Connect to SQL
  12963. new Handle:SqlConnect = SQL_Connect(g_hTuple, ErrorCode, g_Error, 511)
  12964.  
  12965. if(SqlConnect == Empty_Handle)
  12966. {
  12967. log_amx("SQL Error: %s", g_Error)
  12968. return PLUGIN_HANDLED;
  12969. }
  12970.  
  12971. // Create Handle
  12972. new Handle:Query, Handle:Query2
  12973.  
  12974. Query = SQL_PrepareQuery(SqlConnect, "SELECT `Level`,`AmmoPacks`,`Resets`, `PuntosH`, `PuntosZ`, `DanioH`, `DanioZ`, `ResistenciaH`, `VelocidadH`, `VelocidadZ`, `VitalidadH`, `VitalidadZ`, `GravedadH`, `GravedadZ`, `ChalecoH`, `NVG_COLOR0`, `NVG_COLOR1`, `NVG_COLOR2`, `HUD_POS0`, `HUD_POS1`, `HUD_COLOR0` FROM `personajes` WHERE ( `Nombre` = '%s' )",
  12975. g_playername[id])
  12976.  
  12977. // Query Execute ?
  12978. if (!SQL_Execute(Query))
  12979. {
  12980.  
  12981. SQL_QueryError(Query, g_Error, charsmax(g_Error))
  12982. set_fail_state(g_Error)
  12983. }
  12984. else
  12985. {
  12986. if (SQL_NumResults(Query))
  12987. {
  12988. static hud_pos1[33], hud_pos2[33]
  12989.  
  12990. g_level[id] = SQL_ReadResult(Query, 0)
  12991. g_ammopacks[id] = SQL_ReadResult(Query, 1)
  12992. g_reset[id] = SQL_ReadResult(Query, 2)
  12993. g_skill_points_type[id][0] = SQL_ReadResult(Query, 3) // Puntos H
  12994. g_skill_points_type[id][1] = SQL_ReadResult(Query, 4) // Puntos Z
  12995. g_skill_points[id][0][0] = SQL_ReadResult(Query, 5) // Daño H
  12996. g_skill_points[id][1][0] = SQL_ReadResult(Query, 6) // Daño Z
  12997. g_skill_points[id][0][5] = SQL_ReadResult(Query, 7) // Defensa H
  12998. g_skill_points[id][0][2] = SQL_ReadResult(Query, 8) // Velocidad H
  12999. g_skill_points[id][1][2] = SQL_ReadResult(Query, 9) // Velocidad Z
  13000. g_skill_points[id][0][1] = SQL_ReadResult(Query, 10) // Vitalidad H
  13001. g_skill_points[id][1][1] = SQL_ReadResult(Query, 11) // Vitalidad Z
  13002. g_skill_points[id][0][4] = SQL_ReadResult(Query, 12) // Gravedad H
  13003. g_skill_points[id][1][3] = SQL_ReadResult(Query, 13) // Gravedad Z
  13004. g_skill_points[id][0][3] = SQL_ReadResult(Query, 14) // Chaleco H
  13005. g_nvg[id][0] = SQL_ReadResult(Query, 15)
  13006. g_nvg[id][1] = SQL_ReadResult(Query, 16)
  13007. g_nvg[id][2] = SQL_ReadResult(Query, 17)
  13008. SQL_ReadResult(Query, 18, hud_pos1[id], 32)
  13009. SQL_ReadResult(Query, 19, hud_pos2[id], 32)
  13010. g_hud_pos[id][0] = str_to_float(hud_pos1)
  13011. g_hud_pos[id][1] = str_to_float(hud_pos2)
  13012. red[id] = SQL_ReadResult(Query, 20)
  13013.  
  13014. }
  13015. }
  13016.  
  13017. Query2 = SQL_PrepareQuery(SqlConnect, "SELECT `HUD_COLOR1`, `HUD_COLOR2`, `HUD_EFFECT`, `HUMAN_CLASS`, `HUMAN_CLASSNEXT`, `ZOMBIE_CLASS`, `ZOMBIE_CLASSNEXT`, `WPN_ON`, `WPN_PRI`, `WPN_SEC`, `WPN_TER`, `PuntosSp`, `FLARE_COLOR0`, `FLARE_COLOR1`, `FLARE_COLOR2`, `GastadosH`, `GastadosZ` FROM `personajes` WHERE ( `Nombre` = '%s' )",
  13018. g_playername[id])
  13019.  
  13020. if (!SQL_Execute(Query2))
  13021. {
  13022. SQL_QueryError(Query, g_Error, charsmax(g_Error))
  13023. set_fail_state(g_Error)
  13024. }
  13025. else
  13026. {
  13027. if (SQL_NumResults(Query2))
  13028. {
  13029. green[id] = SQL_ReadResult(Query2, 0)
  13030. blue[id] = SQL_ReadResult(Query2, 1)
  13031. efecto[id] = SQL_ReadResult(Query2, 2)
  13032. g_humanclass[id] = SQL_ReadResult(Query2, 3)
  13033. g_humanclassnext[id] = SQL_ReadResult(Query2, 4)
  13034. g_zombieclass[id] = SQL_ReadResult(Query2, 5)
  13035. g_zombieclassnext[id] = SQL_ReadResult(Query2, 6)
  13036. g_menu_data[id][3] = SQL_ReadResult(Query2, 7)
  13037. g_menu_data[id][4] = SQL_ReadResult(Query2, 8)
  13038. g_menu_data[id][5] = SQL_ReadResult(Query2, 9)
  13039. g_menu_data[id][6] = SQL_ReadResult(Query2, 10)
  13040. g_sp_skill_points[id] = SQL_ReadResult(Query2, 11)
  13041. g_flare_color[id][0] = SQL_ReadResult(Query2, 12)
  13042. g_flare_color[id][1] = SQL_ReadResult(Query2, 13)
  13043. g_flare_color[id][2] = SQL_ReadResult(Query2, 14)
  13044. g_gastados[id][0] = SQL_ReadResult(Query2, 15)
  13045. g_gastados[id][1] = SQL_ReadResult(Query2, 16)
  13046.  
  13047. copy(g_playername[id], charsmax(g_playername), g_personaje_nombre[id][0])
  13048. SetUserName(id, g_personaje_nombre[id][0])
  13049.  
  13050. // Cache player's name
  13051. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  13052. replace_all(g_playername[id], charsmax(g_playername), "'", "")
  13053.  
  13054. client_print(id, print_center, "Personaje %s cargado con exito", g_personaje_nombre[id][0])
  13055.  
  13056. }
  13057. }
  13058.  
  13059. // Connection Closed
  13060. SQL_FreeHandle(Query)
  13061. SQL_FreeHandle(Query2)
  13062. SQL_FreeHandle(SqlConnect)
  13063.  
  13064. return PLUGIN_HANDLED
  13065.  
  13066. }
  13067.  
  13068. SetUserName(id, szNewName[], bool:bSilent = false, bool:bDeadInstantChange = true)
  13069. {
  13070. new szOldName[32]
  13071. get_user_info(id, "name", szOldName, charsmax(szOldName))
  13072. if( !equal(szOldName, szNewName) )
  13073. {
  13074. set_user_info(id, "name", szNewName)
  13075.  
  13076. if( is_user_connected(id) )
  13077. {
  13078. new iDeadFlag = pev(id, pev_deadflag)
  13079. if( iDeadFlag != DEAD_NO )
  13080. {
  13081. if( bDeadInstantChange )
  13082. {
  13083. set_pev(id, pev_netname, szNewName)
  13084. if( !bSilent )
  13085. {
  13086. set_pev(id, pev_deadflag, DEAD_NO)
  13087. dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id))
  13088. set_pev(id, pev_deadflag, iDeadFlag)
  13089. }
  13090. }
  13091. }
  13092. else if( bSilent )
  13093. {
  13094. set_pev(id, pev_netname, szNewName)
  13095. }
  13096. }
  13097. }
  13098. }
  13099.  
  13100. public warm_up(id)
  13101. {
  13102. client_print(id, print_center, "Warm Up: %d Seconds", iSec)
  13103.  
  13104. iSec--
  13105.  
  13106. if (iSec < 1)
  13107. {
  13108. server_cmd("sv_restart 1")
  13109. remove_task(TASK_ID)
  13110. }
  13111. else
  13112. set_task(1.0, "warm_up", TASK_ID)
  13113.  
  13114. return PLUGIN_HANDLED;
  13115. }
Add Comment
Please, Sign In to add comment