Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.38 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <fakemeta>
  5. #include <fakemeta_util>
  6. #include <hamsandwich>
  7. #include <cstrike>
  8. #include <fun>
  9. #include <orpheu>
  10. #include <orpheu_stocks>
  11. #include <orpheu_memory>
  12.  
  13. #define PLUGIN "Zombie Escape"
  14. #define VERSION "2.3 Fix"
  15. #define AUTHOR "Dias"
  16.  
  17. // Main Config
  18. #define CONFIG_FILE "zombie_escape.ini"
  19. #define OFFICIAL_LANG LANG_PLAYER
  20. const DMG_GRENADE = (1<<24)
  21.  
  22. //#define SET_MODELINDEX_OFFSET
  23. new allow_map_prefix[1][] =
  24. {
  25. "ze_"
  26. }
  27.  
  28. // Config Vars
  29. new cfg_min_player, cfg_default_light[2], cfg_zom_release_time, cfg_hum_freeze_time, cfg_round_time
  30. new cfg_use_fog, cfg_fog_density[16], cfg_fog_color[32]
  31. new cfg_human_health, cfg_human_armor, Float:cfg_human_gravity, Float:cfg_human_speed
  32. new cfg_zombie_health, cfg_zombie_armor, Float:cfg_zombie_gravity, Float:cfg_zombie_speed, Float:cfg_zombie_kbpower
  33. new cfg_skyname[10]
  34. new Array:human_model, Array:human_modelindex, Array:host_zombie_model, Array:host_zombie_modelindex, Array:origin_zombie_model, Array:origin_zombie_modelindex, Array:zombie_claws_model
  35. new Array:ready_sound, Array:ambience_sound, Array:zombieappear_sound, Array:zombieinfect_sound
  36. new Array:admin_model, Array:admin_modelindex, Array:admin_zombie_model, Array:admin_zombie_modelindex, Array:zombie_admin_claws_model
  37. new Array:zombiepain_sound, Array:zombieattack_sound, Array:zombieswing_sound, Array:zombiewall_sound
  38. new count_sound[64], Array:escape_suc_sound, Array:escape_fail_sound
  39.  
  40. new const sound_nvg[2][] = {"items/nvg_off.wav", "items/nvg_on.wav"}
  41.  
  42. // Game Vars
  43. new g_endround, g_count, bot_register, g_gamestart, score_hud, Float:delay_hud[33], stat_hud
  44. new notice_hud, g_started, g_zombie[33], g_zombie_type[33], g_nvg[33], g_team_score[6]
  45. new Float:g_spawn_origin[33][3], g_escape_point[33], g_escape_rank[4]
  46.  
  47. enum
  48. {
  49. RANK_NONE = 0,
  50. RANK_FIRST,
  51. RANK_SECOND,
  52. RANK_THIRD
  53. }
  54.  
  55. // Hardcode
  56. new g_primaryweapons[][][] =
  57. {
  58. { "M4A1", "weapon_m4a1" },
  59. { "AK47", "weapon_ak47" },
  60. { "AUG", "weapon_aug" },
  61. { "SG552", "weapon_sg552" },
  62. { "Galil", "weapon_galil" },
  63. { "Famas", "weapon_famas" },
  64. { "MP5 Navy", "weapon_mp5navy" },
  65. { "XM1014", "weapon_xm1014" },
  66. { "M3", "weapon_m3" },
  67. { "P90", "weapon_p90" },
  68. { "M249", "weapon_m249" },
  69. { "SG550", "weapon_sg550" },
  70. { "G3SG1", "weapon_g3sg1" }
  71. }
  72.  
  73. // secondary weapons (menu|game)
  74. new g_secondaryweapons[][][] =
  75. {
  76. { "USP", "weapon_usp" },
  77. { "Deagle", "weapon_deagle" },
  78. { "Elite", "weapon_elite" }
  79. }
  80.  
  81. // grenade loadout (game)
  82. new g_grenades[][] =
  83. {
  84. "weapon_hegrenade",
  85. "weapon_smokegrenade"
  86. }
  87.  
  88. new g_szObjectiveClassNames[][] =
  89. {
  90. "func_bomb_target",
  91. "info_bomb_target",
  92. "info_vip_start",
  93. "func_vip_safetyzone",
  94. "func_escapezone",
  95. "hostage_entity",
  96. "monster_scientist",
  97. "func_hostage_rescue",
  98. "info_hostage_rescue",
  99. "item_longjump"
  100. }
  101. enum
  102. {
  103. TASK_COUNTDOWN = 52000,
  104. TASK_COUNTDOWN2,
  105. TASK_AMBIENCE,
  106. TASK_ROUNDTIME
  107. }
  108. enum
  109. {
  110. TEAM_T = 1,
  111. TEAM_CT = 2,
  112. TEAM_ALL = 5,
  113. TEAM_START = 6
  114. }
  115. enum
  116. {
  117. AL_NOT = 0,
  118. AL_ALIVE = 1,
  119. AL_BOTH = 2
  120. }
  121. enum
  122. {
  123. ZOMBIE_TYPE_HOST = 0,
  124. ZOMBIE_TYPE_ORIGIN
  125. }
  126.  
  127. // Orpheu Vars
  128. new OrpheuHook:handleHookCheckMapConditions;
  129. new OrpheuHook:handleHookCheckWinConditions;
  130. new OrpheuHook:handleHookHasRoundTimeExpired;
  131.  
  132. // Orpheu Def
  133. new g_WinText[7][64], g_pGameRules
  134. #define set_mp_pdata(%1,%2) (OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
  135. #define get_mp_pdata(%1) (OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )
  136.  
  137. // Menu Weapon Code (Thank to Cheap_Suit)
  138. new bool:g_showmenu[33], bool:g_menufailsafe[33], g_player_weapons[33][2], g_menuposition[33]
  139. #define TASKID_WEAPONSMENU 564
  140. #define EQUIP_PRI (1<<0)
  141. #define EQUIP_SEC (1<<1)
  142. #define EQUIP_GREN (1<<2)
  143. #define EQUIP_ALL (1<<0 | 1<<1 | 1<<2)
  144.  
  145. #define OFFSET_LASTPRIM 368
  146. #define OFFSET_LASTSEC 369
  147. #define OFFSET_LASTKNI 370
  148.  
  149. #define OFFSET_DEATH 444
  150. #define OFFSET_TEAM 114
  151. #define OFFSET_ARMOR 112
  152. #define OFFSET_NVG 129
  153. #define OFFSET_CSMONEY 115
  154. #define OFFSET_PRIMARYWEAPON 116
  155. #define OFFSET_WEAPONTYPE 43
  156. #define OFFSET_CLIPAMMO 51
  157. #define EXTRAOFFSET_WEAPONS 4
  158.  
  159. #define OFFSET_AMMO_338MAGNUM 377
  160. #define OFFSET_AMMO_762NATO 378
  161. #define OFFSET_AMMO_556NATOBOX 379
  162. #define OFFSET_AMMO_556NATO 380
  163. #define OFFSET_AMMO_BUCKSHOT 381
  164. #define OFFSET_AMMO_45ACP 382
  165. #define OFFSET_AMMO_57MM 383
  166. #define OFFSET_AMMO_50AE 384
  167. #define OFFSET_AMMO_357SIG 385
  168. #define OFFSET_AMMO_9MM 386
  169.  
  170. #define fm_lastprimary(%1) get_pdata_cbase(id, OFFSET_LASTPRIM)
  171. #define fm_lastsecondry(%1) get_pdata_cbase(id, OFFSET_LASTSEC)
  172. #define fm_lastknife(%1) get_pdata_cbase(id, OFFSET_LASTKNI)
  173. #define fm_get_weapon_id(%1) get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
  174.  
  175. new const g_weapon_ammo[][] =
  176. {
  177. { -1, -1 },
  178. { 13, 200 },
  179. { -1, -1 },
  180. { 10, 200 },
  181. { -1, -1 },
  182. { 7, 200 },
  183. { -1, -1 },
  184. { 30, 200 },
  185. { 30, 200 },
  186. { -1, -1 },
  187. { 30, 200 },
  188. { 20, 200 },
  189. { 25, 000 },
  190. { 30, 200 },
  191. { 35, 200 },
  192. { 25, 200 },
  193. { 12, 200 },
  194. { 20, 200 },
  195. { 10, 200 },
  196. { 30, 200 },
  197. { 100, 200 },
  198. { 8, 200 },
  199. { 30, 200 },
  200. { 30, 200 },
  201. { 20, 200 },
  202. { -1, -1 },
  203. { 7, 200 },
  204. { 30, 200 },
  205. { 30, 200 },
  206. { -1, -1 },
  207. { 50, 200 }
  208. }
  209.  
  210. // Team API (Thank to WiLS)
  211. #define TEAMCHANGE_DELAY 0.1
  212.  
  213. #define TASK_TEAMMSG 200
  214. #define ID_TEAMMSG (taskid - TASK_TEAMMSG)
  215.  
  216. // CS Player PData Offsets (win32)
  217. #define PDATA_SAFE 2
  218. #define OFFSET_CSTEAMS 114
  219.  
  220. new const CS_TEAM_NAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
  221.  
  222. new Float:g_TeamMsgTargetTime
  223. new g_MsgTeamInfo, g_MsgScoreInfo
  224. new g_MaxPlayers
  225.  
  226.  
  227.  
  228. new Trie:TrieMemoryPatches;
  229. new Trie:TrieSigsNotFound;
  230. const MaxIdentLength = 64;
  231. const MaxBytes = 100;
  232.  
  233. enum PatchFunction
  234. {
  235. RoundTime,
  236. };
  237.  
  238. enum PatchError
  239. {
  240. bool:Active,
  241. bool:SigFound,
  242. bool:BrokenFlow,
  243. CurrIdent[ MaxIdentLength ],
  244. Attempts,
  245. FuncIndex
  246. };
  247.  
  248. enum _:Patch
  249. {
  250. OldBytes[ MaxBytes ],
  251. NewBytes[ MaxBytes ],
  252. NumBytes,
  253. Address
  254. };
  255.  
  256. new ErrorFilter[ PatchError ];
  257. new bool:SignatureFound[ PatchFunction ];
  258. new PatchesDatas[ Patch ];
  259.  
  260.  
  261. // Set Model
  262. #define OFFSET_MODELINDEX 491
  263. new g_model_locked[33]
  264.  
  265. // Ham:Speed
  266. new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame;
  267.  
  268. // Fowards
  269. #define MAX_FORWARD 5
  270. enum
  271. {
  272. FORWARD_NONE = 0,
  273. FORWARD_INFECTED,
  274. FORWARD_HUMANIZED,
  275. FORWARD_GAMESTART,
  276. FORWARD_ROUNDEND
  277. }
  278.  
  279. new g_forwards[MAX_FORWARD], g_fwDummyResult
  280.  
  281. // Custom GamePlay
  282. enum
  283. {
  284. START_TYPE_NEW = 0,
  285. START_ZOMBIE_APPEAR,
  286. START_ZOMBIE_RELEASE
  287. }
  288.  
  289. new g_gamestop[3]
  290.  
  291. // Player Config
  292. new g_ena_ready_sound[33], g_ena_background_sound[33]
  293.  
  294. // Plugin & Precache & Config Zone
  295. public plugin_init()
  296. {
  297. new map_name[32], check_index
  298. get_mapname(map_name, sizeof(map_name))
  299.  
  300. for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
  301. {
  302. if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
  303. break
  304. }
  305.  
  306. if(check_index == sizeof(allow_map_prefix))
  307. {
  308. set_fail_state("[ZE] Wrong Map")
  309. return
  310. }
  311.  
  312. register_plugin(PLUGIN, VERSION, AUTHOR)
  313.  
  314. register_cvar("ze_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  315. set_cvar_string("ze_version", VERSION)
  316.  
  317. // Lang
  318. register_dictionary("zombie_escape.txt")
  319.  
  320. format(g_WinText[TEAM_T], 63, "Escape Fail")
  321. format(g_WinText[TEAM_CT], 63, "Escape Success")
  322. format(g_WinText[TEAM_ALL], 63, "#Round_Draw")
  323. format(g_WinText[TEAM_START], 63, "#Game_Commencing")
  324.  
  325. register_menu("Equipment", 1023, "action_equip")
  326. register_menu("Primary", 1023, "action_prim")
  327. register_menu("Secondary", 1023, "action_sec")
  328.  
  329. // Event
  330. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  331. register_logevent("event_roundend", 2, "1=Round_End")
  332. register_event("TextMsg","event_roundend","a","2=#Game_Commencing","2=#Game_will_restart_in")
  333. register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
  334.  
  335. // Message
  336. register_message(get_user_msgid("Health"), "message_health")
  337. register_message(get_user_msgid("StatusIcon"), "message_StatusIcon")
  338.  
  339. // Forward & Ham
  340. register_forward(FM_EmitSound, "fw_EmitSound")
  341. register_forward(FM_GetGameDescription, "fw_GetGameDesc")
  342. register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
  343. RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1)
  344. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  345. RegisterHam(Ham_Killed, "player", "fw_Killed_Post", 1)
  346. RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  347. RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  348. RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  349. RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_PlayerResetMaxSpeed", 0)
  350.  
  351. PatchRoundInfinity()
  352.  
  353. set_cvar_string("sv_skyname", cfg_skyname)
  354.  
  355. // Hud
  356. notice_hud = CreateHudSyncObj(1)
  357. score_hud = CreateHudSyncObj(2)
  358. stat_hud = CreateHudSyncObj(3)
  359.  
  360. // Cache
  361. g_MsgTeamInfo = get_user_msgid("TeamInfo")
  362. g_MsgScoreInfo = get_user_msgid("ScoreInfo")
  363. g_MaxPlayers = get_maxplayers()
  364.  
  365. // Create Forwards
  366. g_forwards[FORWARD_INFECTED] = CreateMultiForward("ze_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
  367. g_forwards[FORWARD_HUMANIZED] = CreateMultiForward("ze_user_humanized", ET_IGNORE, FP_CELL)
  368. g_forwards[FORWARD_GAMESTART] = CreateMultiForward("ze_gamestart", ET_IGNORE, FP_CELL)
  369. g_forwards[FORWARD_ROUNDEND] = CreateMultiForward("ze_roundend", ET_IGNORE, FP_CELL)
  370.  
  371. // Some Commands
  372. register_clcmd("nightvision", "cmd_nightvision")
  373. register_clcmd("jointeam", "cmd_jointeam")
  374. register_clcmd("joinclass", "cmd_joinclass")
  375. register_clcmd("chooseteam", "cmd_jointeam")
  376.  
  377. set_task(60.0, "server_check", _, _, _, "b")
  378.  
  379. // Reset GamePlay
  380. native_reset_gameplay(0)
  381. }
  382.  
  383. public plugin_cfg()
  384. {
  385. new map_name[32], check_index
  386. get_mapname(map_name, sizeof(map_name))
  387.  
  388. for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
  389. {
  390. if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
  391. break
  392. }
  393.  
  394. if(check_index == sizeof(allow_map_prefix))
  395. return
  396.  
  397. set_cvar_float("mp_freezetime", float(cfg_hum_freeze_time) + 1.0)
  398. set_cvar_float("mp_roundtime", float(cfg_round_time))
  399. }
  400.  
  401. public plugin_precache()
  402. {
  403. new map_name[32], check_index
  404. get_mapname(map_name, sizeof(map_name))
  405.  
  406. for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
  407. {
  408. if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
  409. break
  410. }
  411.  
  412. if(check_index == sizeof(allow_map_prefix))
  413. return
  414.  
  415. OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"),"OnInstallGameRules",OrpheuHookPost)
  416.  
  417. // Create Array
  418. human_model = ArrayCreate(64, 1)
  419. human_modelindex = ArrayCreate(1, 1)
  420. admin_model = ArrayCreate(64, 1)
  421. admin_modelindex = ArrayCreate(1, 1)
  422. host_zombie_model = ArrayCreate(64, 1)
  423. host_zombie_modelindex = ArrayCreate(1, 1)
  424. admin_zombie_model = ArrayCreate(64, 1)
  425. admin_zombie_modelindex = ArrayCreate(1, 1)
  426. origin_zombie_model = ArrayCreate(64, 1)
  427. origin_zombie_modelindex = ArrayCreate(1, 1)
  428. zombie_claws_model = ArrayCreate(64, 1)
  429. zombie_admin_claws_model = ArrayCreate(64, 1)
  430.  
  431. ready_sound = ArrayCreate(64, 1)
  432. ambience_sound = ArrayCreate(64, 1)
  433. zombieappear_sound = ArrayCreate(64, 1)
  434. zombieinfect_sound = ArrayCreate(64, 1)
  435.  
  436. zombiepain_sound = ArrayCreate(64, 1)
  437. zombieattack_sound = ArrayCreate(64, 1)
  438. zombieswing_sound = ArrayCreate(64, 1)
  439. zombiewall_sound = ArrayCreate(64, 1)
  440.  
  441. escape_suc_sound = ArrayCreate(64, 1)
  442. escape_fail_sound = ArrayCreate(64, 1)
  443.  
  444. // Load Custom Config
  445. load_config_file()
  446.  
  447. new i, buffer[128], temp_string[256]
  448.  
  449. // Model
  450. for(i = 0; i < ArraySize(human_model); i++)
  451. {
  452. ArrayGetString(human_model, i, temp_string, sizeof(temp_string))
  453. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
  454.  
  455. ArrayPushCell(human_modelindex, precache_model(buffer))
  456. }
  457. for(i = 0; i < ArraySize(admin_model); i++)
  458. {
  459. ArrayGetString(admin_model, i, temp_string, sizeof(temp_string))
  460. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
  461.  
  462. ArrayPushCell(admin_modelindex, precache_model(buffer))
  463. }
  464. for(i = 0; i < ArraySize(origin_zombie_model); i++)
  465. {
  466. ArrayGetString(origin_zombie_model, i, temp_string, sizeof(temp_string))
  467. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
  468.  
  469. ArrayPushCell(origin_zombie_modelindex, precache_model(buffer))
  470. }
  471. for(i = 0; i < ArraySize(host_zombie_model); i++)
  472. {
  473. ArrayGetString(host_zombie_model, i, temp_string, sizeof(temp_string))
  474. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
  475.  
  476. ArrayPushCell(host_zombie_modelindex, precache_model(buffer))
  477. }
  478. for(i = 0; i < ArraySize(admin_zombie_model); i++)
  479. {
  480. ArrayGetString(admin_zombie_model, i, temp_string, sizeof(temp_string))
  481. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
  482.  
  483. ArrayPushCell(admin_zombie_modelindex, precache_model(buffer))
  484. }
  485. for(i = 0; i < ArraySize(zombie_claws_model); i++)
  486. {
  487. ArrayGetString(zombie_claws_model, i, temp_string, sizeof(temp_string))
  488. precache_model(temp_string)
  489. }
  490. for(i = 0; i < ArraySize(zombie_admin_claws_model); i++)
  491. {
  492. ArrayGetString(zombie_admin_claws_model, i, temp_string, sizeof(temp_string))
  493. precache_model(temp_string)
  494. }
  495.  
  496. // Sound
  497. for(i = 0; i < ArraySize(ready_sound); i++)
  498. {
  499. ArrayGetString(ready_sound, i, temp_string, sizeof(temp_string))
  500.  
  501. if(equal(temp_string[strlen(temp_string) - 4], ".mp3"))
  502. {
  503. format(buffer, charsmax(buffer), "sound/%s", temp_string)
  504. precache_generic(buffer)
  505. } else {
  506. precache_sound(temp_string)
  507. }
  508. }
  509. for(i = 0; i < ArraySize(ambience_sound); i++)
  510. {
  511. ArrayGetString(ambience_sound, i, temp_string, sizeof(temp_string))
  512.  
  513. if(equal(temp_string[strlen(temp_string) - 4], ".mp3"))
  514. {
  515. format(buffer, charsmax(buffer), "sound/%s", temp_string)
  516. precache_generic(buffer)
  517. } else {
  518. precache_sound(temp_string)
  519. }
  520. }
  521. for(i = 0; i < ArraySize(zombieappear_sound); i++)
  522. {
  523. ArrayGetString(zombieappear_sound, i, temp_string, sizeof(temp_string))
  524. precache_sound(temp_string)
  525. }
  526. for(i = 0; i < ArraySize(zombieinfect_sound); i++)
  527. {
  528. ArrayGetString(zombieinfect_sound, i, temp_string, sizeof(temp_string))
  529. precache_sound(temp_string)
  530. }
  531. for(i = 0; i < ArraySize(zombiepain_sound); i++)
  532. {
  533. ArrayGetString(zombiepain_sound, i, temp_string, sizeof(temp_string))
  534. precache_sound(temp_string)
  535. }
  536. for(i = 0; i < ArraySize(zombieattack_sound); i++)
  537. {
  538. ArrayGetString(zombieattack_sound, i, temp_string, sizeof(temp_string))
  539. precache_sound(temp_string)
  540. }
  541. for(i = 0; i < ArraySize(zombieswing_sound); i++)
  542. {
  543. ArrayGetString(zombieswing_sound, i, temp_string, sizeof(temp_string))
  544. precache_sound(temp_string)
  545. }
  546. for(i = 0; i < ArraySize(zombiewall_sound); i++)
  547. {
  548. ArrayGetString(zombiewall_sound, i, temp_string, sizeof(temp_string))
  549. precache_sound(temp_string)
  550. }
  551. for (i = 1; i <= 10; i++)
  552. {
  553. new sound_count[64]
  554. format(sound_count, sizeof sound_count - 1, count_sound, i)
  555. engfunc(EngFunc_PrecacheSound, sound_count)
  556. }
  557. for(i = 0; i < ArraySize(escape_suc_sound); i++)
  558. {
  559. ArrayGetString(escape_suc_sound, i, temp_string, sizeof(temp_string))
  560. precache_sound(temp_string)
  561. }
  562. for(i = 0; i < ArraySize(escape_fail_sound); i++)
  563. {
  564. ArrayGetString(escape_fail_sound, i, temp_string, sizeof(temp_string))
  565. precache_sound(temp_string)
  566. }
  567.  
  568. formatex(buffer, sizeof(buffer), "gfx/env/%sbk.tga", cfg_skyname)
  569. precache_generic(buffer)
  570. formatex(buffer, sizeof(buffer), "gfx/env/%sdn.tga", cfg_skyname)
  571. precache_generic(buffer)
  572. formatex(buffer, sizeof(buffer), "gfx/env/%sft.tga", cfg_skyname)
  573. precache_generic(buffer)
  574. formatex(buffer, sizeof(buffer), "gfx/env/%slf.tga", cfg_skyname)
  575. precache_generic(buffer)
  576. formatex(buffer, sizeof(buffer), "gfx/env/%srt.tga", cfg_skyname)
  577. precache_generic(buffer)
  578. formatex(buffer, sizeof(buffer), "gfx/env/%sup.tga", cfg_skyname)
  579. precache_generic(buffer)
  580.  
  581. if(cfg_use_fog == 1)
  582. {
  583. static ent
  584. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  585. if(pev_valid(ent))
  586. {
  587. DispatchKeyValue(ent, "density", cfg_fog_density)
  588. DispatchKeyValue(ent, "rendercolor", cfg_fog_color)
  589. DispatchSpawn(ent)
  590. }
  591. }
  592.  
  593. register_forward(FM_Spawn, "fw_Spawn")
  594. }
  595.  
  596. public plugin_end()
  597. {
  598. UnPatchRoundInfinity()
  599. }
  600.  
  601. public server_check()
  602. {
  603. // Check this every 60 second(s)
  604. check_win_con()
  605. }
  606.  
  607. public fw_Spawn(iEnt)
  608. {
  609. if (!pev_valid(iEnt))
  610. return FMRES_IGNORED;
  611.  
  612. static s_szClassName[32], s_iNum
  613. pev(iEnt, pev_classname, s_szClassName, 31)
  614.  
  615. for (s_iNum = 0; s_iNum < sizeof g_szObjectiveClassNames; s_iNum++)
  616. {
  617. if (equal(s_szClassName, g_szObjectiveClassNames[s_iNum]))
  618. {
  619. engfunc(EngFunc_RemoveEntity, iEnt)
  620. return FMRES_SUPERCEDE;
  621. }
  622. }
  623.  
  624. return FMRES_IGNORED
  625. }
  626.  
  627. public client_putinserver(id)
  628. {
  629. if(!bot_register && is_user_bot(id))
  630. {
  631. bot_register = 1
  632. set_task(1.0, "do_register", id)
  633. }
  634.  
  635. g_showmenu[id] = true
  636. g_escape_point[id] = 0
  637. g_ena_ready_sound[id] = g_ena_background_sound[id] = 1
  638. }
  639.  
  640. public client_disconnect(id)
  641. {
  642. remove_task(id+TASK_TEAMMSG)
  643. check_win_con()
  644. }
  645.  
  646. public do_register(id)
  647. {
  648. RegisterHamFromEntity(Ham_Spawn, id, "fw_Spawn_Post", 1)
  649. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  650. RegisterHamFromEntity(Ham_Killed, id, "fw_Killed_Post", 1)
  651. RegisterHamFromEntity(Ham_Player_ResetMaxSpeed, id, "fw_PlayerResetMaxSpeed", 0)
  652. }
  653.  
  654. public PatchRoundInfinity()
  655. {
  656. handleHookCheckMapConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckMapConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
  657. handleHookCheckWinConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckWinConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
  658.  
  659. if (is_linux_server())
  660. {
  661. handleHookHasRoundTimeExpired = OrpheuRegisterHook( OrpheuGetFunction( "HasRoundTimeExpired" , "CHalfLifeMultiplay" ), "CheckConditions" );
  662. } else
  663. {
  664. patchRoundTime .undo = false;
  665. //BytesToReplace("roundTimeCheck", { 0x90, 0x90, 0x90 } );
  666. }
  667. }
  668.  
  669. public UnPatchRoundInfinity()
  670. {
  671. OrpheuUnregisterHook( handleHookCheckMapConditions );
  672. OrpheuUnregisterHook( handleHookCheckWinConditions );
  673.  
  674. if(is_linux_server())
  675. {
  676. OrpheuUnregisterHook( handleHookHasRoundTimeExpired );
  677. } else
  678. {
  679. patchRoundTime .undo = true
  680. //BytesToReplace("roundTimeCheck", { 0xF6, 0xC4, 0x41 } );
  681. }
  682. }
  683.  
  684. public OrpheuHookReturn:CheckConditions ()
  685. {
  686. OrpheuSetReturn(false)
  687. return OrpheuSupercede
  688. }
  689.  
  690. public OnInstallGameRules()
  691. {
  692. g_pGameRules = OrpheuGetReturn()
  693. }
  694. public patchRoundTime( const bool:undo )
  695. {
  696. static const keyName[] = "RoundTime";
  697. static funcIndex; funcIndex || ( funcIndex = funcidx( "patchRoundTime" ) );
  698.  
  699. static bool:hasBackup;
  700. static bool:patched;
  701.  
  702. if( !undo )
  703. {
  704. if( !hasBackup )
  705. {
  706. if( SignatureFound[ RoundTime ] )
  707. {
  708. return;
  709. }
  710.  
  711. const numBytes = 5;
  712.  
  713. new const bytesToPath[ numBytes ] =
  714. {
  715. 0x90, 0x90, 0x90, 0x90, /* nop ... */
  716. 0xE9 /* call ... */
  717. };
  718.  
  719. setErrorFilter( .active = true, .attempts = 2, .functionIndex = funcIndex );
  720.  
  721. prepareData( RoundTime, keyName, "RoundTimeCheck_#1", bytesToPath, sizeof bytesToPath );
  722. prepareData( RoundTime, keyName, "RoundTimeCheck_#2", bytesToPath, sizeof bytesToPath );
  723.  
  724. hasBackup = true;
  725. }
  726.  
  727. if( !patched && getPatchDatas( keyName ) )
  728. {
  729. replaceBytes( PatchesDatas[ Address ], PatchesDatas[ NewBytes ], PatchesDatas[ NumBytes ] );
  730. patched = true;
  731.  
  732. if( ErrorFilter[ BrokenFlow ] )
  733. {
  734. ErrorFilter[ BrokenFlow ] = false;
  735. if (is_linux_server())
  736. {
  737. handleHookHasRoundTimeExpired = OrpheuRegisterHook( OrpheuGetFunction( "HasRoundTimeExpired" , "CHalfLifeMultiplay" ), "CheckConditions" );
  738. } else
  739. {
  740. patchRoundTime .undo = false;
  741. //BytesToReplace("roundTimeCheck", { 0x90, 0x90, 0x90 } );
  742. }
  743. }
  744. }
  745. }
  746. else if( hasBackup && patched && getPatchDatas( keyName ) )
  747. {
  748. replaceBytes( PatchesDatas[ Address ], PatchesDatas[ OldBytes ], PatchesDatas[ NumBytes ] );
  749. patched = false;
  750. }
  751. }
  752.  
  753. bool:getPatchDatas( const keyName[] )
  754. {
  755. return TrieGetArray( TrieMemoryPatches, keyName, PatchesDatas, sizeof PatchesDatas );
  756. }
  757.  
  758. prepareData( const PatchFunction:function, const keyName[], const memoryIdent[], const bytesList[], const bytesCount )
  759. {
  760. if( ErrorFilter[ SigFound ] )
  761. {
  762. return;
  763. }
  764.  
  765. TrieMemoryPatches || ( TrieMemoryPatches = TrieCreate() );
  766. TrieSigsNotFound || ( TrieSigsNotFound = TrieCreate() );
  767.  
  768. if( TrieKeyExists( TrieSigsNotFound, memoryIdent ) )
  769. {
  770. return;
  771. }
  772.  
  773. copy( ErrorFilter[ CurrIdent ], charsmax( ErrorFilter[ CurrIdent ] ), memoryIdent );
  774.  
  775. new address = getStartAddress( memoryIdent );
  776.  
  777. if( address )
  778. {
  779. setErrorFilter( .active = false, .sigFound = SignatureFound[ function ] = true );
  780.  
  781. getBytes( address, PatchesDatas[ OldBytes ], bytesCount );
  782. arrayCopy( .into = PatchesDatas[ NewBytes ], .from = bytesList, .len = bytesCount, .ignoreTags = false, .intoSize = sizeof PatchesDatas[ NewBytes ], .fromSize = bytesCount );
  783.  
  784. PatchesDatas[ NumBytes ] = bytesCount;
  785. PatchesDatas[ Address ] = address;
  786.  
  787. TrieSetArray( TrieMemoryPatches, keyName, PatchesDatas, sizeof PatchesDatas );
  788. }
  789. }
  790. arrayCopy( any:into[], const any:from[], len, bool:ignoreTags = false,
  791. intoTag = tagof into, intoSize = sizeof into, intoPos = 0,
  792. fromTag = tagof from, fromSize = sizeof from, fromPos = 0 )
  793. {
  794. if( !ignoreTags && intoTag != fromTag )
  795. {
  796. return 0;
  797. }
  798.  
  799. new i;
  800.  
  801. while( i < len )
  802. {
  803. if( intoPos >= intoSize || fromPos >= fromSize )
  804. {
  805. break;
  806. }
  807.  
  808. into[ intoPos++ ] = from[ fromPos++ ];
  809. i++;
  810. }
  811.  
  812. return i;
  813. }
  814.  
  815. setErrorFilter( const bool:active = false, const attempts = 0, const bool:sigFound = false, const functionIndex = 0 )
  816. {
  817. if( active && ErrorFilter[ Active ] )
  818. {
  819. return;
  820. }
  821.  
  822. ErrorFilter[ Active ] = active;
  823. ErrorFilter[ Attempts ] = attempts;
  824. ErrorFilter[ FuncIndex ] = functionIndex;
  825. ErrorFilter[ SigFound ] = sigFound;
  826. }
  827. getStartAddress( const identifier[] )
  828. {
  829. new address;
  830. OrpheuMemoryGet( identifier, address );
  831.  
  832. return address;
  833. }
  834. getBytes( const startAddress, bytesList[], const numBytes )
  835. {
  836. new const dataType[] = "byte";
  837. new address = startAddress;
  838.  
  839. for( new i = 0; i < numBytes; i++ )
  840. {
  841. bytesList[ i ] = OrpheuMemoryGetAtAddress( address, dataType, address );
  842. address++;
  843. }
  844. }
  845.  
  846. replaceBytes( const startAddress, const bytes[], const numBytes )
  847. {
  848. static const dataType[] = "byte";
  849.  
  850. new address = startAddress;
  851.  
  852. for( new i = 0; i < numBytes; i++)
  853. {
  854. OrpheuMemorySetAtAddress( address, dataType, 1, bytes[ i ], address );
  855. address++;
  856. }
  857. }
  858.  
  859.  
  860.  
  861.  
  862. public load_config_file()
  863. {
  864. // Build customization file path
  865. new path[64]
  866. get_configsdir(path, charsmax(path))
  867. format(path, charsmax(path), "%s/%s", path, CONFIG_FILE)
  868.  
  869. // File not present
  870. if (!file_exists(path))
  871. {
  872. new error[100]
  873. formatex(error, charsmax(error), "[ZE] Can't Load Config File: %s!", path)
  874. set_fail_state(error)
  875. return;
  876. }
  877.  
  878. // Set up some vars to hold parsing info
  879. new linedata[1024], key[64], value[960], section
  880.  
  881. // Open customization file for reading
  882. new file = fopen(path, "rt")
  883.  
  884. while (file && !feof(file))
  885. {
  886. // Read one line at a time
  887. fgets(file, linedata, charsmax(linedata))
  888.  
  889. // Replace newlines with a null character to prevent headaches
  890. replace(linedata, charsmax(linedata), "^n", "")
  891.  
  892. // Blank line or comment
  893. if (!linedata[0] || linedata[0] == ';') continue;
  894.  
  895. // New section starting
  896. if (linedata[0] == '[')
  897. {
  898. section++
  899. continue;
  900. }
  901.  
  902. // Get key and value(s)
  903. strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
  904.  
  905. // Trim spaces
  906. trim(key)
  907. trim(value)
  908.  
  909. switch (section)
  910. {
  911. case 1: // Main Config
  912. {
  913. if (equal(key, "MIN_PLAYER"))
  914. cfg_min_player = str_to_num(value)
  915. else if (equal(key, "DEFAULT_LIGHT"))
  916. copy(cfg_default_light, sizeof(cfg_default_light), value)
  917. else if (equal(key, "ZOMBIE_RELEASE_TIME"))
  918. cfg_zom_release_time = str_to_num(value)
  919. else if (equal(key, "HUMAN_FREEZE_TIME"))
  920. cfg_hum_freeze_time = str_to_num(value)
  921. else if (equal(key, "ROUND_TIME"))
  922. cfg_round_time = str_to_num(value)
  923.  
  924. }
  925. case 2: // Fog
  926. {
  927. if (equal(key, "FOG_ENABLE"))
  928. cfg_use_fog = str_to_num(value)
  929. else if (equal(key, "FOG_DENSITY"))
  930. copy(cfg_fog_density, sizeof(cfg_fog_density), value)
  931. else if (equal(key, "FOG_COLOR"))
  932. copy(cfg_fog_color, sizeof(cfg_fog_color), value)
  933. }
  934. case 3: // Human Config
  935. {
  936. if (equal(key, "HUMAN_HEALTH"))
  937. cfg_human_health = str_to_num(value)
  938. else if (equal(key, "HUMAN_ARMOR"))
  939. cfg_human_armor = str_to_num(value)
  940. else if (equal(key, "HUMAN_GRAVITY"))
  941. cfg_human_gravity = str_to_float(value)
  942. else if (equal(key, "HUMAN_SPEED"))
  943. cfg_human_speed = str_to_float(value)
  944. }
  945. case 4: // Zombie Config
  946. {
  947. if (equal(key, "ZOMBIE_HEALTH"))
  948. cfg_zombie_health = str_to_num(value)
  949. else if (equal(key, "ZOMBIE_ARMOR"))
  950. cfg_zombie_armor = str_to_num(value)
  951. else if (equal(key, "ZOMBIE_GRAVITY"))
  952. cfg_zombie_gravity = str_to_float(value)
  953. else if (equal(key, "ZOMBIE_SPEED"))
  954. cfg_zombie_speed = str_to_float(value)
  955. else if (equal(key, "ZOMBIE_KNOCKBACK_POWER"))
  956. cfg_zombie_kbpower = str_to_float(value)
  957. }
  958. case 5: // Sky
  959. {
  960. if(equal(key, "SKY_NAME"))
  961. copy(cfg_skyname, sizeof(cfg_skyname), value)
  962. }
  963. case 6: // Model
  964. {
  965. if (equal(key, "HUMAN_MODEL"))
  966. {
  967. // Parse sounds
  968. while(value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  969. {
  970. // Trim spaces
  971. trim(key)
  972. trim(value)
  973.  
  974. // Add to sounds array
  975. ArrayPushString(human_model, key)
  976. }
  977. }
  978. else if (equal(key, "ADMIN_MODEL"))
  979. {
  980. // Parse sounds
  981. while(value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  982. {
  983. // Trim spaces
  984. trim(key)
  985. trim(value)
  986.  
  987. // Add to sounds array
  988. ArrayPushString(admin_model, key)
  989. }
  990. }
  991. else if(equal(key, "ZOMBIE_ORIGIN_MODEL"))
  992. {
  993. // Parse sounds
  994. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  995. {
  996. // Trim spaces
  997. trim(key)
  998. trim(value)
  999.  
  1000. // Add to sounds array
  1001. ArrayPushString(origin_zombie_model, key)
  1002. }
  1003. }
  1004. else if(equal(key, "ZOMBIE_HOST_MODEL"))
  1005. {
  1006. // Parse sounds
  1007. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1008. {
  1009. // Trim spaces
  1010. trim(key)
  1011. trim(value)
  1012.  
  1013. // Add to sounds array
  1014. ArrayPushString(host_zombie_model, key)
  1015. }
  1016. }
  1017. else if(equal(key, "ZOMBIE_ADMIN_MODEL"))
  1018. {
  1019. // Parse sounds
  1020. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1021. {
  1022. // Trim spaces
  1023. trim(key)
  1024. trim(value)
  1025.  
  1026. // Add to sounds array
  1027. ArrayPushString(admin_zombie_model, key)
  1028. }
  1029. }
  1030. else if(equal(key, "ZOMBIE_CLAW_MODEL"))
  1031. {
  1032. // Parse sounds
  1033. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1034. {
  1035. // Trim spaces
  1036. trim(key)
  1037. trim(value)
  1038.  
  1039. // Add to sounds array
  1040. ArrayPushString(zombie_claws_model, key)
  1041. }
  1042. }
  1043. else if(equal(key, "ZOMBIE_ADMIN_CLAW_MODEL"))
  1044. {
  1045. // Parse sounds
  1046. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1047. {
  1048. // Trim spaces
  1049. trim(key)
  1050. trim(value)
  1051.  
  1052. // Add to sounds array
  1053. ArrayPushString(zombie_admin_claws_model, key)
  1054. }
  1055. }
  1056. }
  1057. case 7: // Sound
  1058. {
  1059. if (equal(key, "READY"))
  1060. {
  1061. // Parse weapons
  1062. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1063. {
  1064. // Trim spaces
  1065. trim(key)
  1066. trim(value)
  1067.  
  1068. // Add to weapons array
  1069. ArrayPushString(ready_sound, key)
  1070. }
  1071. }
  1072. else if (equal(key, "AMBIENCE"))
  1073. {
  1074. // Parse weapons
  1075. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1076. {
  1077. // Trim spaces
  1078. trim(key)
  1079. trim(value)
  1080.  
  1081. // Add to weapons array
  1082. ArrayPushString(ambience_sound, key)
  1083. }
  1084. }
  1085. if (equal(key, "ZOMBIE_APPEAR"))
  1086. {
  1087. // Parse weapons
  1088. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1089. {
  1090. // Trim spaces
  1091. trim(key)
  1092. trim(value)
  1093.  
  1094. // Add to weapons array
  1095. ArrayPushString(zombieappear_sound, key)
  1096. }
  1097. }
  1098. else if (equal(key, "PLAYER_INFECT"))
  1099. {
  1100. // Parse weapons
  1101. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1102. {
  1103. // Trim spaces
  1104. trim(key)
  1105. trim(value)
  1106.  
  1107. // Add to weapons array
  1108. ArrayPushString(zombieinfect_sound, key)
  1109. }
  1110. }
  1111. else if (equal(key, "ZOMBIE_PAIN"))
  1112. {
  1113. // Parse weapons
  1114. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1115. {
  1116. // Trim spaces
  1117. trim(key)
  1118. trim(value)
  1119.  
  1120. // Add to weapons array
  1121. ArrayPushString(zombiepain_sound, key)
  1122. }
  1123. }
  1124. else if (equal(key, "COUNTDOWN"))
  1125. {
  1126. copy(count_sound, sizeof(count_sound), value)
  1127. }
  1128. else if (equal(key, "ESCAPE_SUCCESS"))
  1129. {
  1130. // Parse weapons
  1131. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1132. {
  1133. // Trim spaces
  1134. trim(key)
  1135. trim(value)
  1136.  
  1137. // Add to weapons array
  1138. ArrayPushString(escape_suc_sound, key)
  1139. }
  1140. }
  1141. else if (equal(key, "ESCAPE_FAIL"))
  1142. {
  1143. // Parse weapons
  1144. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1145. {
  1146. // Trim spaces
  1147. trim(key)
  1148. trim(value)
  1149.  
  1150. // Add to weapons array
  1151. ArrayPushString(escape_fail_sound, key)
  1152. }
  1153. }
  1154. else if (equal(key, "ATTACK_HIT"))
  1155. {
  1156. // Parse weapons
  1157. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1158. {
  1159. // Trim spaces
  1160. trim(key)
  1161. trim(value)
  1162.  
  1163. // Add to weapons array
  1164. ArrayPushString(zombieattack_sound, key)
  1165. }
  1166. }
  1167. else if (equal(key, "ATTACK_MISS"))
  1168. {
  1169. // Parse weapons
  1170. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1171. {
  1172. // Trim spaces
  1173. trim(key)
  1174. trim(value)
  1175.  
  1176. // Add to weapons array
  1177. ArrayPushString(zombieswing_sound, key)
  1178. }
  1179. }
  1180. else if (equal(key, "ATTACK_WALL"))
  1181. {
  1182. // Parse weapons
  1183. while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
  1184. {
  1185. // Trim spaces
  1186. trim(key)
  1187. trim(value)
  1188.  
  1189. // Add to weapons array
  1190. ArrayPushString(zombiewall_sound, key)
  1191. }
  1192. }
  1193. }
  1194. }
  1195. }
  1196. if (file) fclose(file)
  1197. }
  1198.  
  1199. public plugin_natives()
  1200. {
  1201. new map_name[32], check_index
  1202. get_mapname(map_name, sizeof(map_name))
  1203.  
  1204. for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
  1205. {
  1206. if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
  1207. break
  1208. }
  1209.  
  1210. if(check_index == sizeof(allow_map_prefix))
  1211. return
  1212.  
  1213. // Check
  1214. register_native("ze_is_user_zombie", "native_get_zombie", 1)
  1215. register_native("ze_get_zombie_type", "native_get_zombie_type", 1)
  1216.  
  1217. // Set
  1218. register_native("ze_set_user_zombie", "native_set_zombie", 1)
  1219. register_native("ze_set_user_human", "native_set_human", 1)
  1220.  
  1221. // GamePlays
  1222. register_native("ze_set_stopgame", "native_set_stopgame", 1)
  1223. register_native("ze_reset_gameplay", "native_reset_gameplay", 1)
  1224. }
  1225. // End of Plugin & Precache & Config Zone
  1226.  
  1227. // Native
  1228. public native_get_zombie(id)
  1229. {
  1230. if(!is_user_connected(id))
  1231. return 0
  1232. if(!is_user_alive(id))
  1233. return 0
  1234.  
  1235. return g_zombie[id]
  1236. }
  1237.  
  1238. public native_get_zombie_type(id)
  1239. {
  1240. if(!is_user_connected(id))
  1241. return -1
  1242. if(!is_user_alive(id))
  1243. return -1
  1244.  
  1245. return g_zombie_type[id]
  1246. }
  1247.  
  1248. public native_set_zombie(id, zombie_type)
  1249. {
  1250. if(!is_user_connected(id))
  1251. return 0
  1252. if(!is_user_alive(id))
  1253. return 0
  1254. if(g_zombie[id])
  1255. return 0
  1256.  
  1257. set_user_zombie(id, zombie_type, 1)
  1258. return 1
  1259. }
  1260.  
  1261. public native_set_human(id)
  1262. {
  1263. if(!is_user_connected(id))
  1264. return 0
  1265. if(!is_user_alive(id))
  1266. return 0
  1267.  
  1268. set_human_stuff(id)
  1269. return 0
  1270. }
  1271.  
  1272. public native_set_stopgame(stop_type, stop)
  1273. {
  1274. g_gamestop[stop_type] = stop
  1275. return 1
  1276. }
  1277.  
  1278. public native_reset_gameplay(restart)
  1279. {
  1280. g_gamestop[START_TYPE_NEW] = 0
  1281. g_gamestop[START_ZOMBIE_APPEAR] = 0
  1282. g_gamestop[START_ZOMBIE_RELEASE] = 0
  1283.  
  1284. if(restart) TerminateRound(TEAM_START)
  1285. }
  1286. // End Of Native
  1287.  
  1288. // Event: New Round
  1289. public event_newround()
  1290. {
  1291. ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
  1292.  
  1293. // Reset Vars
  1294. g_endround = 0
  1295. g_gamestart = 0
  1296. g_count = cfg_hum_freeze_time
  1297.  
  1298. // Remove Task
  1299. remove_task(TASK_COUNTDOWN)
  1300. remove_task(TASK_COUNTDOWN2)
  1301. remove_task(TASK_ROUNDTIME)
  1302.  
  1303. ambience_sound_stop(0)
  1304. // Team
  1305. for(new player = 1; player <= g_MaxPlayers; player++)
  1306. {
  1307. remove_task(player+TASK_TEAMMSG)
  1308. remove_task(player+TASK_AMBIENCE)
  1309. }
  1310.  
  1311. if(g_gamestop[START_TYPE_NEW])
  1312. return
  1313.  
  1314. set_task(0.1, "event_newround2")
  1315. }
  1316.  
  1317. public event_newround2()
  1318. {
  1319. if(get_player_num(TEAM_ALL, AL_ALIVE) < cfg_min_player)
  1320. {
  1321. client_printc(0, "!g[Zombie Escape]!n %L", OFFICIAL_LANG, "NOT_ENOUGH_PLAYER", cfg_min_player)
  1322. g_started = 0
  1323.  
  1324. return
  1325. }
  1326.  
  1327. client_printc(0, "!g[Zombie Escape]!n %L", OFFICIAL_LANG, "GOOD_LUCK")
  1328.  
  1329. static temp_string[128]
  1330. ArrayGetString(ready_sound, random_num(0, ArraySize(ready_sound) - 1), temp_string, sizeof(temp_string))
  1331. for(new i = 0; i < g_MaxPlayers; i++)
  1332. {
  1333. if(!is_user_connected(i))
  1334. continue
  1335. if(!g_ena_ready_sound[i])
  1336. continue
  1337.  
  1338. PlaySound(i, temp_string)
  1339. }
  1340.  
  1341. set_task(1.0, "do_countdown", TASK_COUNTDOWN, _, _, "b")
  1342. set_task(get_cvar_float("mp_roundtime") * 60.0 + 43.0, "do_zombie_win", TASK_ROUNDTIME)
  1343. }
  1344.  
  1345. public do_countdown(taskid)
  1346. {
  1347. if(g_endround)
  1348. {
  1349. remove_task(taskid)
  1350. return
  1351. }
  1352.  
  1353. if (!g_count)
  1354. {
  1355. start_game_now()
  1356. remove_task(taskid)
  1357. return
  1358. }
  1359.  
  1360. if (g_count <= cfg_hum_freeze_time)
  1361. {
  1362. static sound[64]
  1363. format(sound, sizeof sound - 1, count_sound, g_count)
  1364. PlaySound(0, sound)
  1365. }
  1366.  
  1367. new message[64]
  1368. format(message, charsmax(message), "%L", OFFICIAL_LANG, "RUN_READY_COUNTDOWN", g_count)
  1369. client_print(0, print_center, message)
  1370.  
  1371. g_count--
  1372. }
  1373. // End of Event: New Round
  1374.  
  1375. // Event: Round End
  1376. public event_roundend()
  1377. {
  1378. g_endround = 1
  1379.  
  1380. remove_task(TASK_COUNTDOWN)
  1381. remove_task(TASK_COUNTDOWN2)
  1382. for(new i = 0; i < g_MaxPlayers; i++)
  1383. remove_task(i+TASK_AMBIENCE)
  1384. remove_task(TASK_ROUNDTIME)
  1385.  
  1386. ambience_sound_stop(0)
  1387. }
  1388.  
  1389. // End of Event: Round End
  1390.  
  1391. public cmd_jointeam(id)
  1392. {
  1393. if(!is_user_connected(id))
  1394. return 1
  1395.  
  1396. if(cs_get_user_team(id) == CS_TEAM_CT || cs_get_user_team(id) == CS_TEAM_T)
  1397. {
  1398. open_game_menu(id)
  1399. return 1
  1400. }
  1401.  
  1402. return PLUGIN_CONTINUE
  1403. }
  1404.  
  1405. public cmd_joinclass(id)
  1406. {
  1407. if(!is_user_connected(id))
  1408. return 1
  1409. if(cs_get_user_team(id) != CS_TEAM_CT || cs_get_user_team(id) != CS_TEAM_T)
  1410. return 0
  1411. if(g_gamestart == 1 || g_gamestart == 2)
  1412. {
  1413. fm_cs_set_user_team(id, CS_TEAM_CT, 1)
  1414.  
  1415. g_zombie[id] = 0
  1416. g_zombie_type[id] = 0
  1417. g_nvg[id] = 0
  1418. g_menufailsafe[id] = false
  1419.  
  1420. if(TASKID_WEAPONSMENU + id) remove_task(TASKID_WEAPONSMENU + id)
  1421. }
  1422.  
  1423. return 0
  1424. }
  1425.  
  1426. public open_game_menu(id)
  1427. {
  1428. static menu, string[128]
  1429.  
  1430. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "GAME_MENU_NAME")
  1431. menu = menu_create(string, "gamem_handle")
  1432.  
  1433. // Enable Equipment Menu
  1434. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "EQUIPMENT_NAME")
  1435. menu_additem(menu, string, "1", 0)
  1436.  
  1437. // Game Infomation
  1438. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "GAMEINFO_NAME")
  1439. menu_additem(menu, string, "2", 0)
  1440.  
  1441. // Game Infomation
  1442. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "PCONFIG_NAME")
  1443. menu_additem(menu, string, "3", 0)
  1444.  
  1445. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1446. menu_display(id, menu, 0)
  1447. }
  1448.  
  1449. public gamem_handle(id, menu, item)
  1450. {
  1451. if(!is_user_connected(id))
  1452. return
  1453.  
  1454. if(item == MENU_EXIT)
  1455. {
  1456. menu_destroy(menu)
  1457. return
  1458. }
  1459.  
  1460. new data[6], szName[64];
  1461. new access, callback;
  1462.  
  1463. menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
  1464.  
  1465. new key = str_to_num(data);
  1466.  
  1467. switch(key)
  1468. {
  1469. case 1: // Equipment
  1470. {
  1471. g_showmenu[id] = true
  1472. client_printc(id, "!g[Zombie Escape]!n %L", OFFICIAL_LANG, "EQUIP_ENABLE")
  1473. }
  1474. case 2: // Game Info
  1475. {
  1476. static string_name[128], string_data[1028]
  1477.  
  1478. // Game Infomation
  1479. formatex(string_name, sizeof(string_name), "%L", OFFICIAL_LANG, "GAMEINFO_NAME")
  1480. formatex(string_data, sizeof(string_data), "%L", OFFICIAL_LANG, "GAME_INFORMATION")
  1481.  
  1482. show_motd(id, string_data, string_name)
  1483. }
  1484. case 3: // Player Config
  1485. {
  1486. player_config(id)
  1487. }
  1488. }
  1489.  
  1490. return
  1491. }
  1492.  
  1493. // Player Config
  1494. public player_config(id)
  1495. {
  1496. static menu, string[128], on_off[10]
  1497.  
  1498. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "PCONFIG_NAME")
  1499. menu = menu_create(string, "pconfig_handle")
  1500.  
  1501. // Ready Sound
  1502. if(g_ena_ready_sound[id])
  1503. {
  1504. formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_ON")
  1505. formatex(string, sizeof(string), "%L \y%s", OFFICIAL_LANG, "PCONFIG_READY_SOUND", on_off)
  1506. } else {
  1507. formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_OFF")
  1508. formatex(string, sizeof(string), "%L \r%s", OFFICIAL_LANG, "PCONFIG_READY_SOUND", on_off)
  1509. }
  1510. menu_additem(menu, string, "1", 0)
  1511.  
  1512. // Background Sound
  1513. if(g_ena_background_sound[id])
  1514. {
  1515. formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_ON")
  1516. formatex(string, sizeof(string), "%L \y%s", OFFICIAL_LANG, "PCONFIG_BACKGROUND_SOUND", on_off)
  1517. } else {
  1518. formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_OFF")
  1519. formatex(string, sizeof(string), "%L \r%s", OFFICIAL_LANG, "PCONFIG_BACKGROUND_SOUND", on_off)
  1520. }
  1521. menu_additem(menu, string, "2", 0)
  1522.  
  1523. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1524. menu_display(id, menu, 0)
  1525. }
  1526.  
  1527. public pconfig_handle(id, menu, item)
  1528. {
  1529. if(!is_user_connected(id))
  1530. return
  1531.  
  1532. if(item == MENU_EXIT)
  1533. {
  1534. menu_destroy(menu)
  1535. return
  1536. }
  1537.  
  1538. new data[6], szName[64];
  1539. new access, callback;
  1540.  
  1541. menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
  1542.  
  1543. new key = str_to_num(data);
  1544.  
  1545. switch(key)
  1546. {
  1547. case 1: // Ready Sound
  1548. {
  1549. if(g_ena_ready_sound[id])
  1550. {
  1551. g_ena_ready_sound[id] = 0
  1552. if(g_gamestart == 0) ambience_sound_stop(id)
  1553. } else {
  1554. g_ena_ready_sound[id] = 1
  1555. if(g_gamestart == 0)
  1556. {
  1557. static temp_string[128]
  1558. ArrayGetString(ready_sound, random_num(0, ArraySize(ready_sound) - 1), temp_string, sizeof(temp_string))
  1559.  
  1560. PlaySound(id, temp_string)
  1561. }
  1562. }
  1563. player_config(id)
  1564. }
  1565. case 2: // Background Sound
  1566. {
  1567. if(g_ena_background_sound[id])
  1568. {
  1569. g_ena_background_sound[id] = 0
  1570. if(g_gamestart > 0) ambience_sound_stop(id)
  1571. } else {
  1572. g_ena_background_sound[id] = 1
  1573. if(g_gamestart > 0)
  1574. {
  1575. static temp_string[128]
  1576. ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
  1577.  
  1578. PlaySound(id, temp_string)
  1579. set_task(105.0, "check_ambience_sound", id+TASK_AMBIENCE, _, _, "b")
  1580. }
  1581. }
  1582. player_config(id)
  1583. }
  1584. }
  1585. }
  1586.  
  1587. // NightVision
  1588. public cmd_nightvision(id)
  1589. {
  1590. if (!is_user_alive(id) || !g_zombie[id]) return PLUGIN_HANDLED;
  1591.  
  1592. if (!g_nvg[id])
  1593. {
  1594. SwitchNvg(id, 1)
  1595. PlaySound(id, sound_nvg[1])
  1596. }
  1597. else
  1598. {
  1599. SwitchNvg(id, 0)
  1600. PlaySound(id, sound_nvg[0])
  1601. }
  1602.  
  1603. return PLUGIN_CONTINUE
  1604. }
  1605.  
  1606. public SwitchNvg(id, mode)
  1607. {
  1608. if (!is_user_connected(id)) return;
  1609.  
  1610. g_nvg[id] = mode
  1611. set_user_nvision(id)
  1612. }
  1613.  
  1614. public set_user_nvision(id)
  1615. {
  1616. if (!is_user_connected(id)) return;
  1617.  
  1618. new alpha
  1619. if (g_nvg[id]) alpha = 70
  1620. else alpha = 0
  1621.  
  1622. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, id)
  1623. write_short(0) // duration
  1624. write_short(0) // hold time
  1625. write_short(0x0004) // fade type
  1626. write_byte(253) // r
  1627. write_byte(110) // g
  1628. write_byte(110) // b
  1629. write_byte(alpha) // alpha
  1630. message_end()
  1631.  
  1632. if(g_nvg[id])
  1633. {
  1634. set_player_light(id, "z")
  1635. } else {
  1636. set_player_light(id, cfg_default_light)
  1637. }
  1638. }
  1639.  
  1640. public set_player_light(id, const LightStyle[])
  1641. {
  1642. message_begin(MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, .player = id)
  1643. write_byte(0)
  1644. write_string(LightStyle)
  1645. message_end()
  1646. }
  1647. // End of NightVision
  1648.  
  1649. // Start Game
  1650. public start_game_now()
  1651. {
  1652. g_gamestart = 1
  1653.  
  1654. static temp_string[128]
  1655. ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
  1656.  
  1657. for(new i = 0; i < g_MaxPlayers; i++)
  1658. {
  1659. if(!is_user_connected(i))
  1660. continue
  1661. if(!g_ena_background_sound[i])
  1662. continue
  1663.  
  1664. PlaySound(i, temp_string)
  1665. set_task(105.0, "check_ambience_sound", i+TASK_AMBIENCE, _, _, "b")
  1666. }
  1667.  
  1668. if(g_gamestop[START_ZOMBIE_APPEAR])
  1669. {
  1670. ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
  1671. return
  1672. }
  1673.  
  1674. // Make Zombies
  1675. for(new i = 0; i < require_zombie(); i++)
  1676. {
  1677. ExecuteForward(g_forwards[FORWARD_INFECTED], g_fwDummyResult, i, 0)
  1678. set_user_zombie(get_random_player(TEAM_CT, AL_ALIVE), ZOMBIE_TYPE_ORIGIN, 0)
  1679. }
  1680.  
  1681. g_count = cfg_zom_release_time
  1682. set_task(1.0, "do_count_rezombie", TASK_COUNTDOWN2, _, _, "b")
  1683.  
  1684. for(new i = 0; i < g_MaxPlayers; i++)
  1685. {
  1686. if(is_user_connected(i) && is_user_alive(i) && !g_zombie[i])
  1687. {
  1688. fm_reset_user_speed(i)
  1689. fm_set_user_speed(i, cfg_human_speed)
  1690. set_user_gravity(i, cfg_human_gravity)
  1691. }
  1692. }
  1693.  
  1694. ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
  1695. }
  1696.  
  1697. public check_ambience_sound(id)
  1698. {
  1699. id -= TASK_AMBIENCE
  1700.  
  1701. if(g_endround)
  1702. {
  1703. remove_task(id+TASK_AMBIENCE)
  1704. return
  1705. }
  1706. if(!g_ena_background_sound[id])
  1707. {
  1708. remove_task(id+TASK_AMBIENCE)
  1709. return
  1710. }
  1711.  
  1712. static temp_string[128]
  1713. ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
  1714.  
  1715. PlaySound(id, temp_string)
  1716. }
  1717.  
  1718. public do_count_rezombie(taskid)
  1719. {
  1720. if(g_endround)
  1721. {
  1722. remove_task(taskid)
  1723. return
  1724. }
  1725.  
  1726. if (!g_count)
  1727. {
  1728. release_zombie()
  1729. remove_task(taskid)
  1730. return
  1731. }
  1732.  
  1733. set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
  1734. ShowSyncHudMsg(0, notice_hud, "%L", OFFICIAL_LANG, "ZOMBIE_RELEASE_COUNTDOWN", g_count)
  1735.  
  1736. g_count--
  1737. }
  1738. // End of Start Game
  1739.  
  1740. // Game Main
  1741. public release_zombie()
  1742. {
  1743. g_gamestart = 2
  1744.  
  1745. if(g_gamestop[START_ZOMBIE_RELEASE])
  1746. {
  1747. ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
  1748. return
  1749. }
  1750.  
  1751. for(new i = 0; i < g_MaxPlayers; i++)
  1752. {
  1753. if(!is_user_connected(i) || !is_user_alive(i))
  1754. continue
  1755. if(!g_zombie[i])
  1756. continue
  1757.  
  1758. fm_set_user_speed(i, cfg_zombie_speed)
  1759. set_user_gravity(i, cfg_zombie_gravity)
  1760. }
  1761.  
  1762. ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
  1763. }
  1764.  
  1765. public client_PostThink(id)
  1766. {
  1767. if(!is_user_connected(id))
  1768. return
  1769. if(get_gametime() - 1.0 > delay_hud[id])
  1770. {
  1771. // Show Score
  1772. set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 2.0, 2.0)
  1773. ShowSyncHudMsg(id, score_hud, "%L", OFFICIAL_LANG, "HUD_SCORE", g_team_score[TEAM_T], g_team_score[TEAM_CT])
  1774.  
  1775. // Add Point for Who is Running Fast
  1776. if(!g_zombie[id])
  1777. {
  1778. static Float:Velocity[3], Speed
  1779.  
  1780. pev(id, pev_velocity, Velocity)
  1781. Speed = floatround(vector_length(Velocity))
  1782.  
  1783. switch(Speed)
  1784. {
  1785. case 210..229: g_escape_point[id] += 1
  1786. case 230..249: g_escape_point[id] += 2
  1787. case 250..300: g_escape_point[id] += 3
  1788. }
  1789. }
  1790.  
  1791. // Show Stat
  1792. show_stat(id)
  1793. delay_hud[id] = get_gametime()
  1794. }
  1795. /*if(!g_gamestart)
  1796. {
  1797. if(!is_user_alive(id))
  1798. return
  1799.  
  1800. if(cs_get_user_team(id) != CS_TEAM_CT)
  1801. {
  1802. set_human_stuff(id)
  1803. }
  1804. } else {
  1805. if(cs_get_user_team(id) == CS_TEAM_T && !g_zombie[id])
  1806. {
  1807. set_human_stuff(id)
  1808. }
  1809. }*/
  1810. }
  1811.  
  1812. public show_stat(id)
  1813. {
  1814. get_stat()
  1815. new temp_string_first[64], temp_string_second[64], temp_string_third[64], curid, Player_Name[64], none[32]
  1816.  
  1817. formatex(none, sizeof(none), "%L", OFFICIAL_LANG, "RANK_NONE")
  1818.  
  1819. // Rank First
  1820. curid = g_escape_rank[RANK_FIRST]
  1821. if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
  1822. {
  1823. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1824. formatex(temp_string_first, sizeof(temp_string_first), "%L", OFFICIAL_LANG, "RANK_FIRST", Player_Name)
  1825. } else {
  1826. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1827. formatex(temp_string_first, sizeof(temp_string_first), "%L", OFFICIAL_LANG, "RANK_FIRST", none)
  1828. }
  1829.  
  1830. // Rank Second
  1831. curid = g_escape_rank[RANK_SECOND]
  1832. if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
  1833. {
  1834. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1835. formatex(temp_string_second, sizeof(temp_string_second), "%L", OFFICIAL_LANG, "RANK_SECOND", Player_Name)
  1836. } else {
  1837. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1838. formatex(temp_string_second, sizeof(temp_string_second), "%L", OFFICIAL_LANG, "RANK_SECOND", none)
  1839. }
  1840.  
  1841. // Rank Third
  1842. curid = g_escape_rank[RANK_THIRD]
  1843. if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
  1844. {
  1845. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1846. formatex(temp_string_third, sizeof(temp_string_third), "%L", OFFICIAL_LANG, "RANK_THIRD", Player_Name)
  1847. } else {
  1848. get_user_name(curid, Player_Name, sizeof(Player_Name))
  1849. formatex(temp_string_third, sizeof(temp_string_third), "%L", OFFICIAL_LANG, "RANK_THIRD", none)
  1850. }
  1851.  
  1852. set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 2.0, 2.0)
  1853. ShowSyncHudMsg(id, stat_hud, "%L^n%s^n%s^n%s", OFFICIAL_LANG, "RANK_INFO", temp_string_first, temp_string_second, temp_string_third)
  1854. }
  1855.  
  1856. public get_stat()
  1857. {
  1858. static highest, current
  1859. highest = current = 0
  1860.  
  1861. // Rank First
  1862. for(new i = 0; i < g_MaxPlayers; i++)
  1863. {
  1864. if(!is_user_connected(i))
  1865. continue
  1866. if(!is_user_alive(i))
  1867. continue
  1868. if(g_zombie[i])
  1869. continue
  1870.  
  1871. if(g_escape_point[i] > highest)
  1872. {
  1873. current = i
  1874. highest = g_escape_point[i]
  1875. }
  1876. }
  1877. g_escape_rank[RANK_FIRST] = current
  1878.  
  1879. // Rank Second
  1880. highest = current = 0
  1881. for(new i = 0; i < g_MaxPlayers; i++)
  1882. {
  1883. if(!is_user_connected(i))
  1884. continue
  1885. if(!is_user_alive(i))
  1886. continue
  1887. if(g_zombie[i])
  1888. continue
  1889. if(g_escape_rank[RANK_FIRST] == i)
  1890. continue
  1891.  
  1892. if(g_escape_point[i] > highest)
  1893. {
  1894. current = i
  1895. highest = g_escape_point[i]
  1896. }
  1897. }
  1898. g_escape_rank[RANK_SECOND] = current
  1899.  
  1900. // Rank Third
  1901. highest = current = 0
  1902. for(new i = 0; i < g_MaxPlayers; i++)
  1903. {
  1904. if(!is_user_connected(i))
  1905. continue
  1906. if(!is_user_alive(i))
  1907. continue
  1908. if(g_zombie[i])
  1909. continue
  1910. if(g_escape_rank[RANK_FIRST] == i || g_escape_rank[RANK_SECOND] == i)
  1911. continue
  1912.  
  1913. if(g_escape_point[i] > highest)
  1914. {
  1915. current = i
  1916. highest = g_escape_point[i]
  1917. }
  1918. }
  1919. g_escape_rank[RANK_THIRD] = current
  1920. }
  1921.  
  1922. public set_user_zombie(id, zombie_type, forward_exec)
  1923. {
  1924. fm_cs_set_user_team(id, CS_TEAM_T, 1)
  1925.  
  1926. g_zombie[id] = 1
  1927. g_zombie_type[id] = zombie_type
  1928.  
  1929. set_user_health(id, zombie_type == 0 ? floatround(float(cfg_zombie_health) / 2.0) : cfg_zombie_health)
  1930. set_user_armor(id, cfg_zombie_armor)
  1931.  
  1932. if(zombie_type == ZOMBIE_TYPE_HOST)
  1933. fm_set_user_speed(id, cfg_zombie_speed)
  1934. else
  1935. {
  1936. if(!forward_exec || task_exists(TASK_COUNTDOWN2))
  1937. fm_set_user_speed(id, 0.1)
  1938. else fm_set_user_speed(id, cfg_zombie_speed)
  1939. }
  1940. set_user_gravity(id, cfg_zombie_gravity)
  1941.  
  1942. static temp_string[128], temp_string2[128], random1
  1943. if(get_user_flags(id) & ADMIN_LEVEL_G)
  1944. {
  1945. random1 = random_num(0, ArraySize(admin_zombie_model) - 1)
  1946.  
  1947. ArrayGetString(admin_zombie_model, random1, temp_string, sizeof(temp_string))
  1948. fm_cs_set_user_model(id, temp_string)
  1949.  
  1950. #if defined SET_MODELINDEX_OFFSET
  1951. static modelindex
  1952.  
  1953. modelindex = ArrayGetCell(admin_zombie_modelindex, random1)
  1954. fm_cs_set_user_model_index(id, modelindex)
  1955.  
  1956. #endif
  1957. }
  1958. else
  1959. {
  1960. if(!zombie_type) // Host
  1961. {
  1962. random1 = random_num(0, ArraySize(origin_zombie_model) - 1)
  1963.  
  1964. ArrayGetString(host_zombie_model, random1, temp_string, sizeof(temp_string))
  1965. fm_cs_set_user_model(id, temp_string)
  1966.  
  1967. #if defined SET_MODELINDEX_OFFSET
  1968. static modelindex
  1969.  
  1970. modelindex = ArrayGetCell(host_zombie_modelindex, random1)
  1971. fm_cs_set_user_model_index(id, modelindex)
  1972.  
  1973. #endif
  1974. }
  1975. else
  1976. { // Origin
  1977. random1 = random_num(0, ArraySize(origin_zombie_model) - 1)
  1978.  
  1979. ArrayGetString(origin_zombie_model, random1, temp_string, sizeof(temp_string))
  1980. fm_cs_set_user_model(id, temp_string)
  1981.  
  1982. #if defined SET_MODELINDEX_OFFSET
  1983. static modelindex
  1984.  
  1985. modelindex = ArrayGetCell(origin_zombie_modelindex, random1)
  1986. fm_cs_set_user_model_index(id, modelindex)
  1987. #endif
  1988. }
  1989. }
  1990.  
  1991. set_default_zombie(id, zombie_type)
  1992.  
  1993. //ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  1994.  
  1995. ArrayGetString(zombieinfect_sound, random_num(0, ArraySize(zombieinfect_sound) - 1), temp_string, sizeof(temp_string))
  1996. ArrayGetString(zombieappear_sound, random_num(0, ArraySize(zombieappear_sound) - 1), temp_string2, sizeof(temp_string2))
  1997.  
  1998. emit_sound(id, CHAN_BODY, temp_string, 1.0, ATTN_NORM, 0, PITCH_NORM)
  1999. PlaySound(0, temp_string2)
  2000.  
  2001. SwitchNvg(id, 1)
  2002. PlaySound(id, sound_nvg[1])
  2003.  
  2004. check_win_con()
  2005.  
  2006. set_task(0.5,"set_player_speed",id)
  2007. }
  2008.  
  2009. stock set_default_zombie(id, zombie_type)
  2010. {
  2011. if(!is_user_alive(id))
  2012. return
  2013. if(!g_zombie[id])
  2014. return
  2015.  
  2016. // Set Spawn Origin
  2017. if(zombie_type == ZOMBIE_TYPE_ORIGIN) set_pev(id, pev_origin, g_spawn_origin[id])
  2018.  
  2019. // Remove any zoom (bugfix)
  2020. cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  2021.  
  2022. // Remove armor
  2023. cs_set_user_armor(id, 0, CS_ARMOR_NONE)
  2024.  
  2025. // Drop weapons when infected
  2026. drop_weapons(id, 1)
  2027. drop_weapons(id, 2)
  2028.  
  2029. // Strip zombies from guns and give them a knife
  2030. strip_user_weapons(id)
  2031. give_item(id, "weapon_knife")
  2032.  
  2033. /*if(g_gamestart <= 1 || task_exists(TASK_COUNTDOWN2))
  2034. fm_set_user_speed(id, 0.1)
  2035. else fm_set_user_speed(id, cfg_zombie_speed)*/
  2036. }
  2037.  
  2038. public set_player_speed(id)
  2039. {
  2040. if(is_user_alive(id))
  2041. {
  2042. if(g_gamestart <= 1 || task_exists(TASK_COUNTDOWN2))
  2043. fm_set_user_speed(id, 0.1)
  2044. else fm_set_user_speed(id, cfg_zombie_speed)
  2045. }
  2046. }
  2047.  
  2048. public event_CurWeapon(id)
  2049. {
  2050. if(!is_user_alive(id))
  2051. return 1
  2052. if(!g_zombie[id])
  2053. return 1
  2054. if(get_user_weapon(id) != CSW_KNIFE)
  2055. {
  2056. drop_weapons(id, 1)
  2057. drop_weapons(id, 2)
  2058.  
  2059. engclient_cmd(id, "weapon_knife")
  2060. } else {
  2061. static temp_string[128]
  2062. if(get_user_flags(id) & ADMIN_LEVEL_G) {
  2063. ArrayGetString(zombie_admin_claws_model, random_num(0, ArraySize(zombie_admin_claws_model) - 1), temp_string, sizeof(temp_string))
  2064.  
  2065. set_pev(id, pev_viewmodel2, temp_string)
  2066. }
  2067. else {
  2068. ArrayGetString(zombie_claws_model, random_num(0, ArraySize(zombie_claws_model) - 1), temp_string, sizeof(temp_string))
  2069.  
  2070. set_pev(id, pev_viewmodel2, temp_string)
  2071.  
  2072. }
  2073. set_pev(id, pev_weaponmodel2, "")
  2074. }
  2075.  
  2076. return 0
  2077. }
  2078.  
  2079. // End of Game Main
  2080. public check_win_con()
  2081. {
  2082. if(g_endround)
  2083. return
  2084. if(!g_gamestart)
  2085. return
  2086.  
  2087. if(get_player_num(TEAM_T, AL_ALIVE) == 0)
  2088. {
  2089. TerminateRound(TEAM_CT)
  2090. } else if(get_player_num(TEAM_CT, AL_ALIVE) == 0) {
  2091. TerminateRound(TEAM_T)
  2092. }
  2093. }
  2094.  
  2095. public do_zombie_win()
  2096. {
  2097. TerminateRound(TEAM_T)
  2098. }
  2099.  
  2100. // Message
  2101. public message_StatusIcon(msg_id, msg_dest, msg_entity)
  2102. {
  2103. static szMsg[8];
  2104. get_msg_arg_string(2, szMsg ,7);
  2105.  
  2106. if(equal(szMsg, "buyzone") && get_msg_arg_int(1))
  2107. {
  2108. set_pdata_int(msg_entity, 235, get_pdata_int(msg_entity, 235) & ~(1<<0));
  2109. return PLUGIN_HANDLED;
  2110. }
  2111.  
  2112. return PLUGIN_CONTINUE;
  2113. }
  2114.  
  2115. public message_health(msg_id, msg_dest, msg_entity)
  2116. {
  2117. static health
  2118. health = get_msg_arg_int(1)
  2119.  
  2120. if(health > 255)
  2121. set_msg_arg_int(1, get_msg_argtype(1), 255)
  2122. }
  2123. // End of Message
  2124.  
  2125. // Ham
  2126. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  2127. {
  2128. // Block all those unneeeded hostage sounds
  2129. if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
  2130. return FMRES_SUPERCEDE;
  2131.  
  2132. // Replace these next sounds for zombies only
  2133. if (!is_user_connected(id) || !g_zombie[id])
  2134. return FMRES_IGNORED;
  2135.  
  2136. static temp_string[128]
  2137.  
  2138. // Zombie being hit
  2139. if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' ||
  2140. sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
  2141. {
  2142. ArrayGetString(zombiepain_sound, random_num(0, ArraySize(zombiepain_sound) - 1), temp_string, sizeof(temp_string))
  2143. emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
  2144.  
  2145. return FMRES_SUPERCEDE;
  2146. }
  2147.  
  2148. // Zombie Attack
  2149. new attack_type
  2150. if (equal(sample,"weapons/knife_hitwall1.wav")) attack_type = 1
  2151. else if (equal(sample,"weapons/knife_hit1.wav") ||
  2152. equal(sample,"weapons/knife_hit3.wav") ||
  2153. equal(sample,"weapons/knife_hit2.wav") ||
  2154. equal(sample,"weapons/knife_hit4.wav") ||
  2155. equal(sample,"weapons/knife_stab.wav")) attack_type = 2
  2156. else if(equal(sample,"weapons/knife_slash1.wav") ||
  2157. equal(sample,"weapons/knife_slash2.wav")) attack_type = 3
  2158. if (attack_type)
  2159. {
  2160. if (attack_type == 1)
  2161. {
  2162. ArrayGetString(zombiewall_sound, random_num(0, ArraySize(zombiewall_sound) - 1), temp_string, sizeof(temp_string))
  2163. emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
  2164. } else if (attack_type == 2) {
  2165. ArrayGetString(zombieattack_sound, random_num(0, ArraySize(zombieattack_sound) - 1), temp_string, sizeof(temp_string))
  2166. emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
  2167. } else if (attack_type == 3) {
  2168. ArrayGetString(zombieswing_sound, random_num(0, ArraySize(zombieswing_sound) - 1), temp_string, sizeof(temp_string))
  2169. emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
  2170. }
  2171.  
  2172. return FMRES_SUPERCEDE;
  2173. }
  2174.  
  2175. return FMRES_IGNORED;
  2176. }
  2177.  
  2178. public fw_GetGameDesc()
  2179. {
  2180. static GameName[64]
  2181. formatex(GameName, sizeof(GameName), "%s %s", PLUGIN, VERSION)
  2182.  
  2183. forward_return(FMV_STRING, GameName)
  2184. return FMRES_SUPERCEDE
  2185. }
  2186.  
  2187. public fw_SetClientKeyValue(id, const infobuffer[], const key[])
  2188. {
  2189. if(g_model_locked[id] && equal(key, "model"))
  2190. return FMRES_SUPERCEDE
  2191.  
  2192. return FMRES_HANDLED
  2193. }
  2194.  
  2195. public fw_Spawn_Post(id)
  2196. {
  2197. if (get_player_num(TEAM_ALL, AL_ALIVE) > 1 && !g_started)
  2198. {
  2199. g_started = 1
  2200. TerminateRound(TEAM_START)
  2201. }
  2202.  
  2203. if(!is_user_connected(id))
  2204. return HAM_IGNORED
  2205.  
  2206. g_zombie[id] = 0
  2207. g_zombie_type[id] = 0
  2208. g_nvg[id] = 0
  2209. g_menufailsafe[id] = false
  2210. g_escape_point[id] = 0
  2211.  
  2212. remove_task(TASKID_WEAPONSMENU + id)
  2213.  
  2214. // Get Your Origin
  2215. pev(id, pev_origin, g_spawn_origin[id])
  2216.  
  2217. if(g_gamestart)
  2218. {
  2219. set_user_zombie(id, ZOMBIE_TYPE_ORIGIN, g_gamestart == 2 ? 1 : 0)
  2220. return HAM_IGNORED
  2221. }
  2222.  
  2223. fm_cs_set_user_team(id, CS_TEAM_CT, 1)
  2224.  
  2225. set_task(random_float(0.1, 0.5), "set_user_nvision", id)
  2226. set_task(random_float(0.5, 3.5), "setctteam", id)
  2227. if(g_gamestart < 1)
  2228. {
  2229. fm_set_user_speed(id, 0.1)
  2230. } else {
  2231. fm_set_user_speed(id, cfg_human_speed)
  2232. }
  2233. // set_human_stuff(id)
  2234.  
  2235. if(g_showmenu[id])
  2236. display_equipmenu(id)
  2237. else
  2238. {
  2239. equipweapon(id, EQUIP_ALL)
  2240. }
  2241.  
  2242. return HAM_HANDLED
  2243. }
  2244.  
  2245. public display_equipmenu(id)
  2246. {
  2247. static menubody[512], len
  2248. len = formatex(menubody, 511, "\y%L^n^n", OFFICIAL_LANG, "WPNMENU_NAME")
  2249.  
  2250. static bool:hasweap
  2251. hasweap = ((g_player_weapons[id][0]) != -1 && (g_player_weapons[id][1] != -1)) ? true : false
  2252.  
  2253. len += formatex(menubody[len], 511 - len,"\w1. %L^n", OFFICIAL_LANG, "MENU_NEW_WEAPON")
  2254. len += formatex(menubody[len], 511 - len,"\w2. %L^n^n", OFFICIAL_LANG, "MENU_PRE_WEAPON")
  2255. len += formatex(menubody[len], 511 - len,"\w3. %L^n^n", OFFICIAL_LANG, "MENU_PRE_DONTSHOW")
  2256. len += formatex(menubody[len], 511 - len,"\w5. %L^n", OFFICIAL_LANG, "MENU_EXIT")
  2257.  
  2258. static keys
  2259. keys = (MENU_KEY_1|MENU_KEY_5)
  2260.  
  2261. if(hasweap)
  2262. keys |= (MENU_KEY_2|MENU_KEY_3)
  2263.  
  2264. static string[128]
  2265. formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "EQUIPMENT_NAME")
  2266.  
  2267. show_menu(id, keys, menubody, -1, string)
  2268. }
  2269.  
  2270. public action_equip(id, key)
  2271. {
  2272. if(!is_user_alive(id) || g_zombie[id])
  2273. return PLUGIN_HANDLED
  2274.  
  2275. switch(key)
  2276. {
  2277. case 0: display_weaponmenu(id, 1, g_menuposition[id] = 0)
  2278. case 1: equipweapon(id, EQUIP_ALL)
  2279. case 2:
  2280. {
  2281. g_showmenu[id] = false
  2282. equipweapon(id, EQUIP_ALL)
  2283. client_printc(id, "!g[Zombie Escape]!n %L", OFFICIAL_LANG, "HOW_ENA_EQUIPMENU")
  2284. }
  2285. }
  2286.  
  2287. if(key > 0)
  2288. {
  2289. g_menufailsafe[id] = false
  2290. remove_task(TASKID_WEAPONSMENU + id)
  2291. }
  2292. return PLUGIN_HANDLED
  2293. }
  2294.  
  2295.  
  2296. public display_weaponmenu(id, menuid, pos)
  2297. {
  2298. if(pos < 0 || menuid < 0)
  2299. return
  2300.  
  2301. static start
  2302. start = pos * 8
  2303.  
  2304. static maxitem
  2305. maxitem = menuid == 1 ? sizeof g_primaryweapons : sizeof g_secondaryweapons
  2306.  
  2307. if(start >= maxitem)
  2308. start = pos = g_menuposition[id]
  2309.  
  2310. static menubody[512], len, primary[64], secondary[64]
  2311.  
  2312. formatex(primary, sizeof(primary), "%L", OFFICIAL_LANG, "WPN_PRIMARY")
  2313. formatex(secondary, sizeof(secondary), "%L", OFFICIAL_LANG, "WPN_SECONDARY")
  2314.  
  2315. len = formatex(menubody, 511, "\y%s\w^n^n", menuid == 1 ? primary : secondary)
  2316.  
  2317. static end
  2318. end = start + 8
  2319. if(end > maxitem)
  2320. end = maxitem
  2321.  
  2322. static keys
  2323. keys = MENU_KEY_0
  2324.  
  2325. static a, b
  2326. b = 0
  2327.  
  2328. static string_next[32], string_back[32], string_exit[32]
  2329.  
  2330. formatex(string_next, sizeof(string_next), "%L", OFFICIAL_LANG, "MENU_NEXT")
  2331. formatex(string_back, sizeof(string_back), "%L", OFFICIAL_LANG, "MENU_BACK")
  2332. formatex(string_exit, sizeof(string_exit), "%L", OFFICIAL_LANG, "MENU_EXIT")
  2333.  
  2334. for(a = start; a < end; ++a)
  2335. {
  2336. keys |= (1<<b)
  2337. len += formatex(menubody[len], 511 - len,"%d. %s^n", ++b, menuid == 1 ? g_primaryweapons[a][0]: g_secondaryweapons[a][0])
  2338. }
  2339.  
  2340. if(end != maxitem)
  2341. {
  2342. formatex(menubody[len], 511 - len, "^n9. %s^n0. %s", string_next, pos ? string_back : string_exit)
  2343. keys |= MENU_KEY_9
  2344. }
  2345. else
  2346. formatex(menubody[len], 511 - len, "^n0. %s", pos ? string_back : string_exit)
  2347.  
  2348. show_menu(id, keys, menubody, -1, menuid == 1 ? primary : secondary)
  2349. }
  2350.  
  2351. public action_prim(id, key)
  2352. {
  2353. if(!is_user_alive(id) || g_zombie[id])
  2354. return PLUGIN_HANDLED
  2355.  
  2356. switch(key)
  2357. {
  2358. case 8: display_weaponmenu(id, 1, ++g_menuposition[id])
  2359. case 9: display_weaponmenu(id, 1, --g_menuposition[id])
  2360. default:
  2361. {
  2362. g_player_weapons[id][0] = g_menuposition[id] * 8 + key
  2363. equipweapon(id, EQUIP_PRI)
  2364.  
  2365. display_weaponmenu(id, 2, g_menuposition[id] = 0)
  2366. }
  2367. }
  2368. return PLUGIN_HANDLED
  2369. }
  2370.  
  2371. public action_sec(id, key)
  2372. {
  2373. if(!is_user_alive(id) || g_zombie[id])
  2374. return PLUGIN_HANDLED
  2375.  
  2376. switch(key)
  2377. {
  2378. case 8: display_weaponmenu(id, 2, ++g_menuposition[id])
  2379. case 9: display_weaponmenu(id, 2, --g_menuposition[id])
  2380. default:
  2381. {
  2382. g_menufailsafe[id] = false
  2383. remove_task(TASKID_WEAPONSMENU + id)
  2384.  
  2385. g_player_weapons[id][1] = g_menuposition[id] * 8 + key
  2386. equipweapon(id, EQUIP_SEC)
  2387. equipweapon(id, EQUIP_GREN)
  2388. }
  2389. }
  2390. return PLUGIN_HANDLED
  2391. }
  2392.  
  2393. public set_human_stuff(id)
  2394. {
  2395. fm_cs_set_user_team(id, CS_TEAM_CT, 1)
  2396.  
  2397. g_zombie[id] = 0
  2398. g_zombie_type[id] = 0
  2399.  
  2400. set_user_health(id, cfg_human_health)
  2401. set_user_armor(id, cfg_human_armor)
  2402. set_task(random_float(0.5, 3.0), "do_set_human_model", id)
  2403.  
  2404. if(g_gamestart < 1)
  2405. {
  2406. fm_set_user_speed(id, 0.1)
  2407. } else {
  2408. fm_set_user_speed(id, cfg_human_speed)
  2409. }
  2410.  
  2411. ExecuteForward(g_forwards[FORWARD_HUMANIZED], g_fwDummyResult, id)
  2412. }
  2413. public setctteam(id)
  2414. if(is_user_connected(id))
  2415. set_human_stuff(id)
  2416.  
  2417. public do_set_human_model(id)
  2418. {
  2419. static model[128], random1
  2420.  
  2421. if(get_user_flags(id) & ADMIN_LEVEL_G)
  2422. {
  2423. random1 = random_num(0, ArraySize(admin_model) - 1)
  2424. ArrayGetString(admin_model, random1, model, sizeof(model))
  2425.  
  2426. fm_cs_set_user_model(id, model)
  2427. #if defined SET_MODELINDEX_OFFSET
  2428. static modelindex
  2429.  
  2430. modelindex = ArrayGetCell(admin_modelindex, random1)
  2431. fm_cs_set_user_model_index(id, modelindex)
  2432. #endif
  2433. }
  2434. else
  2435. {
  2436. random1 = random_num(0, ArraySize(human_model) - 1)
  2437. ArrayGetString(human_model, random1, model, sizeof(model))
  2438.  
  2439. fm_cs_set_user_model(id, model)
  2440. #if defined SET_MODELINDEX_OFFSET
  2441. static modelindex
  2442.  
  2443. modelindex = ArrayGetCell(human_modelindex, random1)
  2444. fm_cs_set_user_model_index(id, modelindex)
  2445. #endif
  2446.  
  2447. }
  2448. }
  2449.  
  2450. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
  2451. {
  2452. if(g_gamestart < 2)
  2453. return HAM_SUPERCEDE
  2454. if(!is_user_connected(victim) || !is_user_connected(attacker))
  2455. return HAM_IGNORED
  2456. if(!g_zombie[victim] && !g_zombie[attacker])
  2457. return HAM_SUPERCEDE
  2458. if(g_zombie[victim] && g_zombie[attacker])
  2459. return HAM_SUPERCEDE
  2460. if(g_zombie[attacker] && get_user_weapon(attacker) == CSW_KNIFE)
  2461. {
  2462. if(damagebits == DMG_GRENADE)
  2463. return HAM_SUPERCEDE
  2464.  
  2465. OrpheuCall(OrpheuGetFunctionFromObject(g_pGameRules,"DeathNotice","CGameRules"), g_pGameRules, victim, attacker, inflictor)
  2466. FixDeadAttrib(victim)
  2467.  
  2468. update_frags(attacker, 1)
  2469. update_deaths(victim, 1)
  2470.  
  2471. set_user_zombie(victim, ZOMBIE_TYPE_HOST, 0)
  2472. ExecuteForward(g_forwards[FORWARD_INFECTED], g_fwDummyResult, victim, attacker)
  2473. } else if(g_zombie[victim] && !g_zombie[attacker]) {
  2474. set_pdata_float(victim, 108, 1.0, 50)
  2475.  
  2476. static Float:MyOrigin[3]
  2477. pev(attacker, pev_origin, MyOrigin)
  2478.  
  2479. hook_ent2(victim, MyOrigin, cfg_zombie_kbpower, 2)
  2480. }
  2481.  
  2482. return HAM_HANDLED
  2483. }
  2484.  
  2485. public update_frags(id, frag)
  2486. {
  2487. if(!is_user_connected(id))
  2488. return
  2489.  
  2490. set_pev(id, pev_frags, float(pev(id, pev_frags) + frag))
  2491.  
  2492. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  2493. write_byte(id) // id
  2494. write_short(pev(id, pev_frags)) // frags
  2495. write_short(cs_get_user_deaths(id)) // deaths
  2496. write_short(0) // class?
  2497. write_short(get_pdata_int(id, 114, 5)) // team
  2498. message_end()
  2499. }
  2500.  
  2501. public update_deaths(id, death)
  2502. {
  2503. if(!is_user_connected(id))
  2504. return
  2505.  
  2506. cs_set_user_deaths(id, cs_get_user_deaths(id) + death)
  2507.  
  2508. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  2509. write_byte(id) // id
  2510. write_short(pev(id, pev_frags)) // frags
  2511. write_short(cs_get_user_deaths(id)) // deaths
  2512. write_short(0) // class?
  2513. write_short(get_pdata_int(id, 114, 5)) // team
  2514. message_end()
  2515. }
  2516.  
  2517. public fw_Killed_Post(id)
  2518. {
  2519. check_win_con()
  2520. }
  2521.  
  2522. public fw_PlayerResetMaxSpeed(id)
  2523. {
  2524. if(!g_zombie[id])
  2525. return HAM_IGNORED
  2526. //
  2527. //return HAM_SUPERCEDE
  2528.  
  2529. //if(g_gamestart < 1 || task_exists(TASK_COUNTDOWN2))
  2530. // set_pev(id, pev_maxspeed, 1.0)
  2531. // else set_pev(id, pev_maxspeed, cfg_zombie_speed)
  2532.  
  2533. return HAM_SUPERCEDE
  2534. //return HAM_IGNORED
  2535. }
  2536.  
  2537. public fw_TouchWeapon(weapon, id)
  2538. {
  2539. // Not a player
  2540. if (!is_user_connected(id))
  2541. return HAM_IGNORED
  2542. if (g_zombie[id])
  2543. return HAM_SUPERCEDE
  2544.  
  2545. return HAM_IGNORED
  2546. }
  2547. // End of Ham
  2548.  
  2549. // Ambience Sounds Stop Task
  2550. public ambience_sound_stop(id)
  2551. {
  2552. if(id == 0)
  2553. {
  2554. client_cmd(0, "mp3 stop; stopsound")
  2555. } else {
  2556. if(!is_user_connected(id))
  2557. return
  2558.  
  2559. client_cmd(id, "mp3 stop; stopsound")
  2560. }
  2561. }
  2562.  
  2563. // ============================ STOCK =================================
  2564. stock get_player_num(team, alive)
  2565. {
  2566. static player_num
  2567. player_num = 0
  2568.  
  2569. for(new i = 0; i < g_MaxPlayers; i++)
  2570. {
  2571. if(!is_user_connected(i))
  2572. continue
  2573. if(alive == AL_NOT)
  2574. {
  2575. if(is_user_alive(i))
  2576. continue
  2577. } else if(alive == AL_ALIVE) {
  2578. if(!is_user_alive(i))
  2579. continue
  2580. }
  2581.  
  2582. if(team == TEAM_ALL)
  2583. {
  2584. if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
  2585. continue
  2586. } else if(team == TEAM_T) {
  2587. if(cs_get_user_team(i) != CS_TEAM_T)
  2588. continue
  2589. } else if(team == TEAM_CT) {
  2590. if(cs_get_user_team(i) != CS_TEAM_CT)
  2591. continue
  2592. }
  2593.  
  2594. player_num++
  2595. }
  2596.  
  2597. return player_num
  2598. }
  2599.  
  2600. stock get_random_player(team, alive)
  2601. {
  2602. static list_player[33], list_player_num
  2603. static total_player
  2604. total_player = get_player_num(team, alive)
  2605.  
  2606. for(new i = 0; i < total_player; i++)
  2607. list_player[i] = 0
  2608.  
  2609. list_player_num = 0
  2610.  
  2611. for(new i = 0; i < g_MaxPlayers; i++)
  2612. {
  2613. if(!is_user_connected(i))
  2614. continue
  2615.  
  2616. if(alive == AL_NOT)
  2617. {
  2618. if(is_user_alive(i))
  2619. continue
  2620. } else if(alive == AL_ALIVE) {
  2621. if(!is_user_alive(i))
  2622. continue
  2623. }
  2624.  
  2625. if(team == TEAM_ALL)
  2626. {
  2627. if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
  2628. continue
  2629. } else if(team == TEAM_T) {
  2630. if(cs_get_user_team(i) != CS_TEAM_T)
  2631. continue
  2632. } else if(team == TEAM_CT) {
  2633. if(cs_get_user_team(i) != CS_TEAM_CT)
  2634. continue
  2635. }
  2636.  
  2637. list_player[list_player_num] = i
  2638. list_player_num++
  2639. }
  2640.  
  2641. static random_player; random_player = 0
  2642. random_player = list_player[random_num(0, list_player_num - 1)]
  2643.  
  2644. return random_player
  2645. }
  2646.  
  2647. stock PlaySound(id, const sound[])
  2648. {
  2649. if(id == 0)
  2650. {
  2651. if (equal(sound[strlen(sound)-4], ".mp3"))
  2652. client_cmd(0, "mp3 play ^"sound/%s^"", sound)
  2653. else
  2654. client_cmd(0, "spk ^"%s^"", sound)
  2655. } else {
  2656. if(is_user_connected(id)&& is_user_alive(id))
  2657. {
  2658. if (equal(sound[strlen(sound)-4], ".mp3"))
  2659. client_cmd(id, "mp3 play ^"sound/%s^"", sound)
  2660. else
  2661. client_cmd(id, "spk ^"%s^"", sound)
  2662. }
  2663. }
  2664. }
  2665.  
  2666. stock client_printc(index, const text[], any:...)
  2667. {
  2668. new szMsg[128];
  2669. vformat(szMsg, sizeof(szMsg) - 1, text, 3);
  2670.  
  2671. replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
  2672. replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
  2673. replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
  2674.  
  2675. if(index == 0)
  2676. {
  2677. for(new i = 0; i < g_MaxPlayers; i++)
  2678. {
  2679. if(is_user_alive(i) && is_user_connected(i))
  2680. {
  2681. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i);
  2682. write_byte(i);
  2683. write_string(szMsg);
  2684. message_end();
  2685. }
  2686. }
  2687. } else {
  2688. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
  2689. write_byte(index);
  2690. write_string(szMsg);
  2691. message_end();
  2692. }
  2693. }
  2694.  
  2695. stock require_zombie()
  2696. {
  2697. switch(get_player_num(TEAM_CT, 1))
  2698. {
  2699. case 2..5: return 1
  2700. case 6..15: return 2
  2701. case 16..25: return 3
  2702. case 26..32: return 4
  2703. }
  2704.  
  2705. return 0
  2706. }
  2707.  
  2708. stock check_spawn(Float:Origin[3])
  2709. {
  2710. new Float:originE[3], Float:origin1[3], Float:origin2[3]
  2711. new ent = -1
  2712. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "player")) != 0)
  2713. {
  2714. pev(ent, pev_origin, originE)
  2715.  
  2716. // xoy
  2717. origin1 = Origin
  2718. origin2 = originE
  2719. origin1[2] = origin2[2] = 0.0
  2720. if (vector_distance(origin1, origin2) <= 2 * 16.0)
  2721. {
  2722. // oz
  2723. origin1 = Origin
  2724. origin2 = originE
  2725. origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
  2726. if (vector_distance(origin1, origin2) <= 72.0) return 0;
  2727. }
  2728. }
  2729.  
  2730. return 1
  2731. }
  2732.  
  2733. // Drop primary/secondary weapons
  2734. stock drop_weapons(id, dropwhat)
  2735. {
  2736. // Get user weapons
  2737. static weapons[32], num, i, weaponid
  2738. num = 0 // reset passed weapons count (bugfix)
  2739. get_user_weapons(id, weapons, num)
  2740.  
  2741. // Weapon bitsums
  2742. 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)
  2743. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  2744.  
  2745. // Loop through them and drop primaries or secondaries
  2746. for (i = 0; i < num; i++)
  2747. {
  2748. // Prevent re-indexing the array
  2749. weaponid = weapons[i]
  2750.  
  2751. if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  2752. {
  2753. // Get weapon entity
  2754. static wname[32], weapon_ent
  2755. get_weaponname(weaponid, wname, charsmax(wname))
  2756. weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  2757.  
  2758. // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  2759. set_pev(weapon_ent, pev_iuser1, cs_get_user_bpammo(id, weaponid))
  2760.  
  2761. // Player drops the weapon and looses his bpammo
  2762. engclient_cmd(id, "drop", wname)
  2763. cs_set_user_bpammo(id, weaponid, 0)
  2764. }
  2765. }
  2766. }
  2767.  
  2768. stock BytesToReplace ( identifier[], const bytes[], const bytesLength = sizeof bytes )
  2769. {
  2770. new address;
  2771. OrpheuMemoryGet( identifier, address );
  2772.  
  2773. for ( new i; i < bytesLength; i++)
  2774. {
  2775. OrpheuMemorySetAtAddress( address, "roundTimeCheck|dummy", 1, bytes[ i ], address );
  2776. address++;
  2777. }
  2778.  
  2779. server_cmd( "sv_restart 1" );
  2780. }
  2781.  
  2782. stock bool:TerminateRound(team)
  2783. {
  2784. new winStatus;
  2785. new event;
  2786. new sound[64];
  2787.  
  2788. switch(team)
  2789. {
  2790. case TEAM_T:
  2791. {
  2792. winStatus = 2;
  2793. event = 9;
  2794. ArrayGetString(escape_fail_sound, random_num(0, ArraySize(escape_fail_sound) - 1), sound, sizeof(sound))
  2795. g_team_score[TEAM_T]++
  2796.  
  2797. client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_FAIL")
  2798. }
  2799. case TEAM_CT:
  2800. {
  2801. winStatus = 1;
  2802. event = 8;
  2803. ArrayGetString(escape_suc_sound, random_num(0, ArraySize(escape_suc_sound) - 1), sound, sizeof(sound))
  2804. g_team_score[TEAM_CT]++
  2805.  
  2806. client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_SUCCESS")
  2807. }
  2808. case TEAM_ALL:
  2809. {
  2810. winStatus = 3;
  2811. event = 10;
  2812. sound = "radio/rounddraw.wav";
  2813.  
  2814. client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_DRAW")
  2815. }
  2816. case TEAM_START:
  2817. {
  2818. winStatus = 3;
  2819. event = 10;
  2820.  
  2821. client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_DRAW")
  2822. }
  2823. default:
  2824. {
  2825. return false;
  2826. }
  2827. }
  2828.  
  2829. g_endround = 1
  2830. EndRoundMessage(g_WinText[team], event)
  2831. RoundTerminating(winStatus, team == TEAM_START ? 3.0 : 5.0)
  2832. PlaySound(0, sound)
  2833.  
  2834. for(new i = 0; i < g_MaxPlayers; i++)
  2835. {
  2836. if(!is_user_connected(i) || !is_user_alive(i))
  2837. continue
  2838. if(g_zombie[i])
  2839. {
  2840. update_deaths(i, 1)
  2841. } else {
  2842. update_frags(i, 3)
  2843. g_escape_point[i] += 5
  2844. }
  2845. }
  2846.  
  2847. ExecuteForward(g_forwards[FORWARD_ROUNDEND], g_fwDummyResult, team)
  2848.  
  2849. return true;
  2850. }
  2851.  
  2852. stock RoundTerminating( const winStatus, const Float:delay )
  2853. {
  2854. set_mp_pdata("m_iRoundWinStatus" , winStatus );
  2855. set_mp_pdata("m_fTeamCount" , get_gametime() + delay );
  2856. set_mp_pdata("m_bRoundTerminating", true );
  2857. }
  2858.  
  2859. stock EndRoundMessage( const message[], const event, const bool:notifyAllPlugins = false )
  2860. {
  2861. static OrpheuFunction:handleFuncEndRoundMessage;
  2862.  
  2863. if ( !handleFuncEndRoundMessage )
  2864. {
  2865. handleFuncEndRoundMessage = OrpheuGetFunction( "EndRoundMessage" );
  2866. }
  2867.  
  2868. ( notifyAllPlugins ) ?
  2869. OrpheuCallSuper( handleFuncEndRoundMessage, message, event ) :
  2870. OrpheuCall( handleFuncEndRoundMessage, message, event );
  2871. }
  2872.  
  2873. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
  2874. {
  2875. static Float:fl_Velocity[3]
  2876. static Float:EntOrigin[3]
  2877.  
  2878. pev(ent, pev_origin, EntOrigin)
  2879. static Float:distance_f
  2880. distance_f = get_distance_f(EntOrigin, VicOrigin)
  2881.  
  2882. new Float:fl_Time = distance_f / speed
  2883.  
  2884. if(type == 1)
  2885. {
  2886. fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
  2887. fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
  2888. fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
  2889. } else if(type == 2) {
  2890. fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
  2891. fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
  2892. fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
  2893. }
  2894.  
  2895. entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
  2896. }
  2897.  
  2898. stock equipweapon(id, weapon)
  2899. {
  2900. if(!is_user_alive(id) || !is_user_connected(id))
  2901. return
  2902.  
  2903. static weaponid[2], weaponent
  2904.  
  2905. if(weapon & EQUIP_PRI)
  2906. {
  2907. weaponent = fm_lastprimary(id)
  2908. weaponid[1] = get_weaponid(g_primaryweapons[g_player_weapons[id][0]][1])
  2909.  
  2910. if(pev_valid(weaponent))
  2911. {
  2912. weaponid[0] = fm_get_weapon_id(weaponent)
  2913. if(weaponid[0] != weaponid[1])
  2914. fm_strip_user_gun(id, weaponid[0])
  2915. }
  2916. else
  2917. weaponid[0] = -1
  2918.  
  2919. if(weaponid[0] != weaponid[1])
  2920. give_item(id, g_primaryweapons[g_player_weapons[id][0]][1])
  2921.  
  2922. cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
  2923. }
  2924.  
  2925. if(weapon & EQUIP_SEC)
  2926. {
  2927. weaponent = fm_lastsecondry(id)
  2928. weaponid[1] = get_weaponid(g_secondaryweapons[g_player_weapons[id][1]][1])
  2929.  
  2930. if(pev_valid(weaponent))
  2931. {
  2932. weaponid[0] = fm_get_weapon_id(weaponent)
  2933. if(weaponid[0] != weaponid[1])
  2934. fm_strip_user_gun(id, weaponid[0])
  2935. }
  2936. else
  2937. weaponid[0] = -1
  2938.  
  2939. if(weaponid[0] != weaponid[1])
  2940. give_item(id, g_secondaryweapons[g_player_weapons[id][1]][1])
  2941.  
  2942. cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
  2943. }
  2944.  
  2945. if(weapon & EQUIP_GREN)
  2946. {
  2947. static i
  2948. for(i = 0; i < sizeof g_grenades; i++) if(!user_has_weapon(id, get_weaponid(g_grenades[i])))
  2949. give_item(id, g_grenades[i])
  2950. }
  2951. }
  2952.  
  2953. // Set a Player's Team
  2954. stock fm_cs_set_user_team(id, CsTeams:team, send_message)
  2955. {
  2956. // Prevent server crash if entity's private data not initalized
  2957. if (pev_valid(id) != PDATA_SAFE)
  2958. return;
  2959.  
  2960. // Already belongs to the team
  2961. if (cs_get_user_team(id) == team)
  2962. return;
  2963.  
  2964. // Remove previous team message task
  2965. remove_task(id+TASK_TEAMMSG)
  2966.  
  2967. // Set team offset
  2968. set_pdata_int(id, OFFSET_CSTEAMS, _:team)
  2969.  
  2970. // Send message to update team?
  2971. if (send_message) fm_user_team_update(id)
  2972. }
  2973.  
  2974. // Send User Team Message (Note: this next message can be received by other plugins)
  2975. public fm_cs_set_user_team_msg(taskid)
  2976. {
  2977. // Tell everyone my new team
  2978. emessage_begin(MSG_ALL, g_MsgTeamInfo)
  2979. ewrite_byte(ID_TEAMMSG) // player
  2980. ewrite_string(CS_TEAM_NAMES[_:cs_get_user_team(ID_TEAMMSG)]) // team
  2981. emessage_end()
  2982.  
  2983. // Fix for AMXX/CZ bots which update team paramater from ScoreInfo message
  2984. emessage_begin(MSG_BROADCAST, g_MsgScoreInfo)
  2985. ewrite_byte(ID_TEAMMSG) // id
  2986. ewrite_short(pev(ID_TEAMMSG, pev_frags)) // frags
  2987. ewrite_short(cs_get_user_deaths(ID_TEAMMSG)) // deaths
  2988. ewrite_short(0) // class?
  2989. ewrite_short(_:cs_get_user_team(ID_TEAMMSG)) // team
  2990. emessage_end()
  2991. }
  2992.  
  2993. // Update Player's Team on all clients (adding needed delays)
  2994. stock fm_user_team_update(id)
  2995. {
  2996. new Float:current_time
  2997. current_time = get_gametime()
  2998.  
  2999. if (current_time - g_TeamMsgTargetTime >= TEAMCHANGE_DELAY)
  3000. {
  3001. set_task(0.1, "fm_cs_set_user_team_msg", id+TASK_TEAMMSG)
  3002. g_TeamMsgTargetTime = current_time + TEAMCHANGE_DELAY
  3003. }
  3004. else
  3005. {
  3006. set_task((g_TeamMsgTargetTime + TEAMCHANGE_DELAY) - current_time, "fm_cs_set_user_team_msg", id+TASK_TEAMMSG)
  3007. g_TeamMsgTargetTime = g_TeamMsgTargetTime + TEAMCHANGE_DELAY
  3008. }
  3009. }
  3010.  
  3011. stock fm_cs_set_user_model(id, const model[])
  3012. {
  3013. g_model_locked[id] = 0
  3014. engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", model)
  3015. g_model_locked[id] = 1
  3016. }
  3017.  
  3018. stock fm_cs_set_user_model_index(id, model_index)
  3019. {
  3020. if (pev_valid(id) != PDATA_SAFE)
  3021. return;
  3022.  
  3023. set_pdata_int(id, OFFSET_MODELINDEX, model_index)
  3024. }
  3025.  
  3026. stock FixDeadAttrib(id)
  3027. {
  3028. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  3029. write_byte(id) // id
  3030. write_byte(0) // attrib
  3031. message_end()
  3032. }
  3033.  
  3034. // Set Speed
  3035. stock fm_set_user_speed(id, Float:Speed)
  3036. {
  3037. set_pev(id, pev_maxspeed, Speed)
  3038. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  3039. }
  3040.  
  3041. stock fm_reset_user_speed(id)
  3042. {
  3043. ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
  3044. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement