Advertisement
FlowiXx

Untitled

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