HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  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 "1.3"
  15. #define AUTHOR "Dias"
  16.  
  17. #define MIN_PLAYER 2
  18. #define DEFAULT_LIGHT "d"
  19. new USE_FOG = 1
  20. #define FOG_DENSITY "0.0010"
  21. #define FOG_COLOR "100 100 100"
  22.  
  23. // Human Config
  24. #define HUMAN_HEALTH 1000.0
  25. #define HUMAN_ARMOR 100.0
  26. #define HUMAN_GRAVITY 1.0
  27. #define HUMAN_SPEED 250.0
  28.  
  29. // Zombie Config
  30. #define ZOMBIE_HEALTH 14000.0
  31. #define ZOMBIE_ARMOR 100.0
  32. #define ZOMBIE_GRAVITY 0.875
  33. #define ZOMBIE_SPEED 350.0
  34. #define ZOMBIE_KNOCKBACK_POWER 500.0
  35.  
  36. #define SKY_NAME "hk"
  37.  
  38. // primary weapons (menu|game)
  39. new g_primaryweapons[][][] =
  40. {
  41. { "M4A1", "weapon_m4a1" },
  42. { "AK47", "weapon_ak47" },
  43. { "AUG", "weapon_aug" },
  44. { "SG552", "weapon_sg552" },
  45. { "Galil", "weapon_galil" },
  46. { "Famas", "weapon_famas" },
  47. { "MP5 Navy", "weapon_mp5navy" },
  48. { "XM1014", "weapon_xm1014" },
  49. { "M3", "weapon_m3" },
  50. { "P90", "weapon_p90" },
  51. { "M249", "weapon_m249" },
  52. { "SG550", "weapon_sg550" },
  53. { "G3SG1", "weapon_g3sg1" }
  54. }
  55.  
  56. // secondary weapons (menu|game)
  57. new g_secondaryweapons[][][] =
  58. {
  59. { "USP", "weapon_usp" },
  60. { "Deagle", "weapon_deagle" },
  61. { "Elite", "weapon_elite" }
  62. }
  63.  
  64. // grenade loadout (game)
  65. new g_grenades[][] =
  66. {
  67. "weapon_hegrenade",
  68. "weapon_smokegrenade"
  69. }
  70.  
  71. new const Game_Desc[] =
  72. "Zombie Escape. Version: 1.0. Coded: Dias"
  73.  
  74. new const ready_sound[1][] =
  75. {
  76. "zombie_escape/ZE_Ready.mp3"
  77. }
  78.  
  79. new const ambience_sound[1][] =
  80. {
  81. "zombie_escape/ZE_Ambience.mp3"
  82. }
  83.  
  84. new const zombieappear_sound[2][] =
  85. {
  86. "zombie_escape/zombi_coming_1.wav",
  87. "zombie_escape/zombi_coming_2.wav"
  88. }
  89.  
  90. new const zombieinfect_sound[2][] =
  91. {
  92. "zombie_escape/zombie/human_death_01.wav",
  93. "zombie_escape/zombie/human_death_02.wav"
  94. }
  95.  
  96. new const zombiehurt_sound[2][] =
  97. {
  98. "zombie_escape/zombie/zombi_hurt_01.wav",
  99. "zombie_escape/zombie/zombi_hurt_02.wav"
  100. }
  101.  
  102. new const zombieattack_sound[3][] =
  103. {
  104. "zombie_escape/zombie/zombi_attack_1.wav",
  105. "zombie_escape/zombie/zombi_attack_2.wav",
  106. "zombie_escape/zombie/zombi_attack_3.wav"
  107. }
  108.  
  109. new const zombieswing_sound[3][] =
  110. {
  111. "zombie_escape/zombie/zombi_swing_1.wav",
  112. "zombie_escape/zombie/zombi_swing_2.wav",
  113. "zombie_escape/zombie/zombi_swing_3.wav"
  114. }
  115.  
  116. new const zombiehitwall_sound[3][] =
  117. {
  118. "zombie_escape/zombie/zombi_wall_1.wav",
  119. "zombie_escape/zombie/zombi_wall_2.wav",
  120. "zombie_escape/zombie/zombi_wall_3.wav"
  121. }
  122.  
  123. new const count_sound[] = "zombie_escape/count/%i.wav"
  124. new const escape_suc_sound[] = "zombie_escape/zombi_escape_success.wav"
  125. new const escape_fail_sound[] = "zombie_escape/zombi_escape_fail.wav"
  126.  
  127. new const host_zombie_model[] = "tank_zombi_host"
  128. new const origin_zombie_model[] = "tank_zombi_origin"
  129. new const claws_model[] = "models/zombie_escape/v_knife_tank_zombi.mdl"
  130. new const sound_nvg[2][] = {"items/nvg_off.wav", "items/nvg_on.wav"}
  131.  
  132. new g_szObjectiveClassNames[][] =
  133. {
  134. "func_bomb_target",
  135. "info_bomb_target",
  136. "info_vip_start",
  137. "func_vip_safetyzone",
  138. "func_escapezone",
  139. "hostage_entity",
  140. "monster_scientist",
  141. "func_hostage_rescue",
  142. "info_hostage_rescue",
  143. "item_longjump"
  144. };
  145.  
  146.  
  147. enum
  148. {
  149. TASK_COUNTDOWN = 52000,
  150. TASK_COUNTDOWN2,
  151. TASK_AMBIENCE,
  152. TASK_ROUNDTIME
  153. }
  154.  
  155. enum
  156. {
  157. TEAM_T = 1,
  158. TEAM_CT = 2,
  159. TEAM_ALL = 5,
  160. TEAM_START = 6
  161. }
  162. enum
  163. {
  164. AL_NOT = 0,
  165. AL_ALIVE = 1,
  166. AL_BOTH = 2
  167. }
  168. enum
  169. {
  170. ZOMBIE_TYPE_HOST = 0,
  171. ZOMBIE_TYPE_ORIGIN
  172. }
  173.  
  174. new g_endround, g_count, bot_register, g_gamestart, g_default_model[33][64], score_hud, Float:delay_hud[33]
  175. new notice_hud, g_started, g_zombie[33], g_zombie_type[33], g_nvg[33], g_isalive[33], g_team_score[6]
  176.  
  177. new OrpheuHook:handleHookCheckMapConditions;
  178. new OrpheuHook:handleHookCheckWinConditions;
  179. new OrpheuHook:handleHookHasRoundTimeExpired;
  180.  
  181. new g_WinText[7][64], g_pGameRules
  182. #define set_mp_pdata(%1,%2) (OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
  183. #define get_mp_pdata(%1) (OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )
  184.  
  185. new bool:g_showmenu[33], bool:g_menufailsafe[33], g_player_weapons[33][2], g_menuposition[33]
  186. #define TASKID_WEAPONSMENU 564
  187. #define EQUIP_PRI (1<<0)
  188. #define EQUIP_SEC (1<<1)
  189. #define EQUIP_GREN (1<<2)
  190. #define EQUIP_ALL (1<<0 | 1<<1 | 1<<2)
  191.  
  192. #define OFFSET_LASTPRIM 368
  193. #define OFFSET_LASTSEC 369
  194. #define OFFSET_LASTKNI 370
  195.  
  196. #define OFFSET_DEATH 444
  197. #define OFFSET_TEAM 114
  198. #define OFFSET_ARMOR 112
  199. #define OFFSET_NVG 129
  200. #define OFFSET_CSMONEY 115
  201. #define OFFSET_PRIMARYWEAPON 116
  202. #define OFFSET_WEAPONTYPE 43
  203. #define OFFSET_CLIPAMMO 51
  204. #define EXTRAOFFSET_WEAPONS 4
  205.  
  206. #define OFFSET_AMMO_338MAGNUM 377
  207. #define OFFSET_AMMO_762NATO 378
  208. #define OFFSET_AMMO_556NATOBOX 379
  209. #define OFFSET_AMMO_556NATO 380
  210. #define OFFSET_AMMO_BUCKSHOT 381
  211. #define OFFSET_AMMO_45ACP 382
  212. #define OFFSET_AMMO_57MM 383
  213. #define OFFSET_AMMO_50AE 384
  214. #define OFFSET_AMMO_357SIG 385
  215. #define OFFSET_AMMO_9MM 386
  216.  
  217. #define fm_lastprimary(%1) get_pdata_cbase(id, OFFSET_LASTPRIM)
  218. #define fm_lastsecondry(%1) get_pdata_cbase(id, OFFSET_LASTSEC)
  219. #define fm_lastknife(%1) get_pdata_cbase(id, OFFSET_LASTKNI)
  220. #define fm_get_weapon_id(%1) get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
  221.  
  222. new const g_weapon_ammo[][] =
  223. {
  224. { -1, -1 },
  225. { 13, 200 },
  226. { -1, -1 },
  227. { 10, 200 },
  228. { -1, -1 },
  229. { 7, 200 },
  230. { -1, -1 },
  231. { 30, 200 },
  232. { 30, 200 },
  233. { -1, -1 },
  234. { 30, 200 },
  235. { 20, 200 },
  236. { 25, 000 },
  237. { 30, 200 },
  238. { 35, 200 },
  239. { 25, 200 },
  240. { 12, 200 },
  241. { 20, 200 },
  242. { 10, 200 },
  243. { 30, 200 },
  244. { 100, 200 },
  245. { 8, 200 },
  246. { 30, 200 },
  247. { 30, 200 },
  248. { 20, 200 },
  249. { -1, -1 },
  250. { 7, 200 },
  251. { 30, 200 },
  252. { 30, 200 },
  253. { -1, -1 },
  254. { 50, 200 }
  255. }
  256.  
  257. // Plugin & Precache & Config Zone
  258. public plugin_init()
  259. {
  260. static map_name[32]
  261. get_mapname(map_name, sizeof(map_name))
  262.  
  263. if(containi(map_name, "ze_") == -1)
  264. {
  265. set_fail_state("[ZE] Hibas Map")
  266. return
  267. }
  268.  
  269. register_plugin(PLUGIN, VERSION, AUTHOR)
  270.  
  271. format(g_WinText[TEAM_T], 63, "Escape Fail")
  272. format(g_WinText[TEAM_CT], 63, "Escape Success")
  273. format(g_WinText[TEAM_ALL], 63, "#Round_Draw")
  274. format(g_WinText[TEAM_START], 63, "#Game_Commencing")
  275.  
  276. register_menu("Equipment", 1023, "action_equip")
  277. register_menu("Primary", 1023, "action_prim")
  278. register_menu("Secondary", 1023, "action_sec")
  279.  
  280. // Event
  281. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  282. register_logevent("event_roundend", 2, "1=Round_End")
  283. register_event("TextMsg","event_roundend","a","2=#Game_Commencing","2=#Game_will_restart_in")
  284. register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
  285.  
  286. // Message
  287. register_message(get_user_msgid("Health"), "message_health")
  288. register_message(get_user_msgid("StatusIcon"), "message_StatusIcon")
  289.  
  290. // Forward & Ham
  291. register_forward(FM_EmitSound, "fw_EmitSound")
  292. register_forward(FM_GetGameDescription, "fw_GetGameDesc")
  293. RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1)
  294. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  295. RegisterHam(Ham_Killed, "player", "fw_Killed_Post", 1)
  296. RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  297. RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  298. RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  299.  
  300. PatchRoundInfinity()
  301.  
  302. set_cvar_string("sv_skyname", SKY_NAME)
  303.  
  304. notice_hud = CreateHudSyncObj(1)
  305. score_hud = CreateHudSyncObj(2)
  306.  
  307. register_clcmd("nightvision", "cmd_nightvision")
  308.  
  309. register_clcmd("jointeam", "cmd_jointeam")
  310. register_clcmd("chooseteam", "cmd_jointeam")
  311. }
  312.  
  313. public plugin_cfg()
  314. {
  315. static map_name[32]
  316. get_mapname(map_name, sizeof(map_name))
  317.  
  318. if(containi(map_name, "ze_") == -1)
  319. return
  320.  
  321. server_cmd("mp_freezetime 22.0")
  322. server_cmd("mp_roundtime 9.0")
  323. server_cmd("mp_friendlyfire 0")
  324. server_cmd("mp_startmoney 16000")
  325. }
  326.  
  327. public plugin_precache()
  328. {
  329. static map_name[32]
  330. get_mapname(map_name, sizeof(map_name))
  331.  
  332. if(containi(map_name, "ze_") == -1)
  333. return
  334.  
  335. OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"),"OnInstallGameRules",OrpheuHookPost)
  336.  
  337. new i, buffer[128]
  338. for(i = 0; i < sizeof(ready_sound); i++)
  339. {
  340. if(equal(ready_sound[i][strlen(ready_sound[i]) - 4], ".mp3"))
  341. {
  342. format(buffer, charsmax(buffer), "sound/%s", ready_sound[i])
  343. precache_generic(buffer)
  344. } else {
  345. precache_sound(ready_sound[i])
  346. }
  347. }
  348. for(i = 0; i < sizeof(ambience_sound); i++)
  349. {
  350. if(equal(ambience_sound[i][strlen(ambience_sound[i]) - 4], ".mp3"))
  351. {
  352. format(buffer, charsmax(buffer), "sound/%s", ambience_sound[i])
  353. precache_generic(buffer)
  354. } else {
  355. precache_sound(ambience_sound[i])
  356. }
  357. }
  358. for(i = 0; i < sizeof(zombieappear_sound); i++)
  359. precache_sound(zombieappear_sound[i])
  360. for(i = 0; i < sizeof(zombieinfect_sound); i++)
  361. precache_sound(zombieinfect_sound[i])
  362. for(i = 0; i < sizeof(zombiehurt_sound); i++)
  363. precache_sound(zombiehurt_sound[i])
  364. for(i = 0; i < sizeof(zombieattack_sound); i++)
  365. precache_sound(zombieattack_sound[i])
  366. for(i = 0; i < sizeof(zombieswing_sound); i++)
  367. precache_sound(zombieswing_sound[i])
  368. for(i = 0; i < sizeof(zombiehitwall_sound); i++)
  369. precache_sound(zombiehitwall_sound[i])
  370. for (i = 1; i <= 10; i++)
  371. {
  372. new sound_count[64]
  373. format(sound_count, sizeof sound_count - 1, count_sound, i)
  374.  
  375. precache_sound(sound_count)
  376. }
  377.  
  378. formatex(buffer, sizeof(buffer), "gfx/env/%sbk.tga", SKY_NAME)
  379. precache_generic(buffer)
  380. formatex(buffer, sizeof(buffer), "gfx/env/%sdn.tga", SKY_NAME)
  381. precache_generic(buffer)
  382. formatex(buffer, sizeof(buffer), "gfx/env/%sft.tga", SKY_NAME)
  383. precache_generic(buffer)
  384. formatex(buffer, sizeof(buffer), "gfx/env/%slf.tga", SKY_NAME)
  385. precache_generic(buffer)
  386. formatex(buffer, sizeof(buffer), "gfx/env/%srt.tga", SKY_NAME)
  387. precache_generic(buffer)
  388. formatex(buffer, sizeof(buffer), "gfx/env/%sup.tga", SKY_NAME)
  389. precache_generic(buffer)
  390.  
  391. precache_sound(escape_suc_sound)
  392. precache_sound(escape_fail_sound)
  393.  
  394. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", host_zombie_model, host_zombie_model)
  395. precache_model(buffer)
  396. formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", origin_zombie_model, origin_zombie_model)
  397. precache_model(buffer)
  398.  
  399. engfunc(EngFunc_PrecacheModel, claws_model)
  400.  
  401. if(USE_FOG == 1)
  402. {
  403. static ent
  404. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  405. if (pev_valid(ent))
  406. {
  407. fm_set_kvd(ent, "density", FOG_DENSITY, "env_fog")
  408. fm_set_kvd(ent, "rendercolor", FOG_COLOR, "env_fog")
  409. }
  410. }
  411.  
  412. register_forward(FM_Spawn, "fw_Spawn")
  413.  
  414. }
  415.  
  416. public plugin_end()
  417. {
  418. UnPatchRoundInfinity()
  419. }
  420.  
  421. public fw_Spawn(iEnt)
  422. {
  423. if (!pev_valid(iEnt))
  424. return FMRES_IGNORED;
  425.  
  426. static s_szClassName[32], s_iNum;
  427. pev(iEnt, pev_classname, s_szClassName, 31);
  428.  
  429. for (s_iNum = 0; s_iNum < sizeof g_szObjectiveClassNames; s_iNum++)
  430. {
  431. if (equal(s_szClassName, g_szObjectiveClassNames[s_iNum]))
  432. {
  433. engfunc(EngFunc_RemoveEntity, iEnt);
  434. return FMRES_SUPERCEDE;
  435. }
  436. }
  437.  
  438. return FMRES_IGNORED;
  439. }
  440.  
  441. public client_putinserver(id)
  442. {
  443. if(!bot_register && is_user_bot(id))
  444. {
  445. bot_register = 1
  446. set_task(1.0, "do_register", id)
  447. }
  448.  
  449. g_showmenu[id] = true
  450. g_isalive[id] = 0
  451. }
  452.  
  453. public client_disconnect(id)
  454. {
  455. g_isalive[id] = 0
  456. check_win_con()
  457. }
  458.  
  459. public do_register(id)
  460. {
  461. RegisterHamFromEntity(Ham_Spawn, id, "fw_Spawn_Post", 1)
  462. RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  463. RegisterHamFromEntity(Ham_Killed, id, "fw_Killed_Post", 1)
  464. }
  465.  
  466. public PatchRoundInfinity()
  467. {
  468. handleHookCheckMapConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckMapConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
  469. handleHookCheckWinConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckWinConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
  470.  
  471. if (is_linux_server())
  472. {
  473. handleHookHasRoundTimeExpired = OrpheuRegisterHook( OrpheuGetFunction( "HasRoundTimeExpired" , "CHalfLifeMultiplay" ), "CheckConditions" );
  474. }
  475. else
  476. {
  477. BytesToReplace("roundTimeCheck", { 0x90, 0x90, 0x90 } );
  478. }
  479. }
  480.  
  481. public UnPatchRoundInfinity()
  482. {
  483. OrpheuUnregisterHook( handleHookCheckMapConditions );
  484. OrpheuUnregisterHook( handleHookCheckWinConditions );
  485.  
  486. if (is_linux_server())
  487. {
  488. OrpheuUnregisterHook( handleHookHasRoundTimeExpired );
  489. }
  490. else
  491. {
  492. BytesToReplace("roundTimeCheck", { 0xF6, 0xC4, 0x41 } );
  493. }
  494. }
  495.  
  496. public OrpheuHookReturn:CheckConditions ()
  497. {
  498. OrpheuSetReturn( false );
  499. return OrpheuSupercede;
  500. }
  501.  
  502. public OnInstallGameRules()
  503. {
  504. g_pGameRules = OrpheuGetReturn()
  505. }
  506.  
  507. // End of Plugin & Precache & Config Zone
  508.  
  509. // Event: New Round
  510. public event_newround()
  511. {
  512. // Reset Vars
  513. g_endround = 0
  514. g_gamestart = 0
  515. g_count = 20
  516.  
  517. // Remove Task
  518. remove_task(TASK_COUNTDOWN)
  519. remove_task(TASK_COUNTDOWN2)
  520. remove_task(TASK_AMBIENCE)
  521. remove_task(TASK_ROUNDTIME)
  522.  
  523. if(get_player_num(TEAM_ALL, AL_ALIVE) < MIN_PLAYER)
  524. {
  525. client_printc(0, "!g[Zombie Escape]!n Nincs eleg jatekos a modhoz! Jatekosok : !t%i!n", MIN_PLAYER)
  526. g_started = 0
  527.  
  528. return
  529. }
  530.  
  531. client_printc(0, "!g[Zombie Escape]!n Keszen allsz? Sok szerencset!")
  532. PlaySound(0, ready_sound[random_num(0, charsmax(ready_sound))])
  533.  
  534. set_task(1.0, "do_countdown", TASK_COUNTDOWN, _, _, "b")
  535. set_task(get_cvar_float("mp_roundtime") * 60.0 + 43.0, "do_zombie_win", TASK_ROUNDTIME)
  536. }
  537.  
  538. public do_countdown(taskid)
  539. {
  540. if(g_endround)
  541. {
  542. remove_task(taskid)
  543. return
  544. }
  545.  
  546. if (!g_count)
  547. {
  548. start_game_now()
  549. remove_task(taskid)
  550. return
  551. }
  552.  
  553. if (g_count <= 10)
  554. {
  555. new sound[64]
  556. format(sound, charsmax(sound), count_sound, g_count)
  557. PlaySound(0, sound)
  558. }
  559.  
  560. new message[64]
  561. format(message, charsmax(message), "Készen allsz? Megnyitas %i masodperc mulva!", g_count)
  562.  
  563. client_print(0, print_center, message)
  564. //set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
  565. //ShowSyncHudMsg(0, notice_hud, message)
  566.  
  567. g_count--
  568. }
  569. // End of Event: New Round
  570.  
  571. // Event: Round End
  572. public event_roundend()
  573. {
  574. g_endround = 1
  575.  
  576. remove_task(TASK_COUNTDOWN)
  577. remove_task(TASK_COUNTDOWN2)
  578. remove_task(TASK_AMBIENCE)
  579. }
  580.  
  581. // End of Event: Round End
  582.  
  583. public cmd_jointeam(id)
  584. {
  585. if(!is_user_connected(id))
  586. return 1
  587.  
  588. if(cs_get_user_team(id) == CS_TEAM_CT || cs_get_user_team(id) == CS_TEAM_T)
  589. {
  590. open_game_menu(id)
  591. return 1
  592. }
  593.  
  594. return PLUGIN_CONTINUE
  595. }
  596.  
  597. public open_game_menu(id)
  598. {
  599. static menu
  600. menu = menu_create("Game Menu", "gamem_handle")
  601.  
  602. menu_additem(menu, "Equipment", "1", 0)
  603. menu_additem(menu, "Game Information", "2", 0)
  604.  
  605. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  606.  
  607. menu_display(id, menu, 0)
  608. }
  609.  
  610. public gamem_handle(id, menu, item)
  611. {
  612. if(item == MENU_EXIT)
  613. {
  614. menu_destroy(menu)
  615. return PLUGIN_HANDLED;
  616. }
  617.  
  618. new data[6], szName[64];
  619. new access, callback;
  620.  
  621. menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
  622.  
  623. new key = str_to_num(data);
  624.  
  625. switch(key)
  626. {
  627. case 1: // Equipment
  628. {
  629. g_showmenu[id] = true
  630. client_printc(id, "!g[Zombie Escape]!n Engedelyezve van az Equipment menu!")
  631. }
  632. case 2: // Game Info
  633. {
  634. show_motd(id, Game_Desc, "Jatek informacio")
  635. }
  636. }
  637.  
  638. return 0
  639. }
  640.  
  641. // NightVision
  642. public cmd_nightvision(id)
  643. {
  644. if (!is_user_alive(id) || !g_zombie[id]) return PLUGIN_HANDLED;
  645.  
  646. if (!g_nvg[id])
  647. {
  648. SwitchNvg(id, 1)
  649. PlaySound(id, sound_nvg[1])
  650. }
  651. else
  652. {
  653. SwitchNvg(id, 0)
  654. PlaySound(id, sound_nvg[0])
  655. }
  656.  
  657. return PLUGIN_CONTINUE
  658. }
  659.  
  660. stock SwitchNvg(id, mode)
  661. {
  662. if (!is_user_connected(id)) return;
  663.  
  664. g_nvg[id] = mode
  665. set_user_nvision(id)
  666. }
  667.  
  668. stock set_user_nvision(id)
  669. {
  670. if (!is_user_connected(id)) return;
  671.  
  672. new alpha
  673. if (g_nvg[id]) alpha = 70
  674. else alpha = 0
  675.  
  676. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, id)
  677. write_short(0) // duration
  678. write_short(0) // hold time
  679. write_short(0x0004) // fade type
  680. write_byte(253) // r
  681. write_byte(110) // g
  682. write_byte(110) // b
  683. write_byte(alpha) // alpha
  684. message_end()
  685.  
  686. if(g_nvg[id])
  687. {
  688. set_player_light(id, "z")
  689. } else {
  690. set_player_light(id, DEFAULT_LIGHT)
  691. }
  692. }
  693.  
  694. stock set_player_light(id, const LightStyle[])
  695. {
  696. message_begin(MSG_ONE, SVC_LIGHTSTYLE, .player = id)
  697. write_byte(0)
  698. write_string(LightStyle)
  699. message_end()
  700. }
  701. // End of NightVision
  702.  
  703. // Start Game
  704. public start_game_now()
  705. {
  706. g_gamestart = 1
  707.  
  708. PlaySound(0, ambience_sound[random_num(0, charsmax(ambience_sound))])
  709. set_task(105.0, "check_ambience_sound", TASK_AMBIENCE, _, _, "b")
  710.  
  711. // Make Zombies
  712. for(new i = 0; i < require_zombie(); i++)
  713. {
  714. set_user_zombie(get_random_player(TEAM_CT, AL_ALIVE), ZOMBIE_TYPE_ORIGIN)
  715. }
  716.  
  717. g_count = 7
  718. set_task(1.0, "do_count_rezombie", TASK_COUNTDOWN2, _, _, "b")
  719.  
  720. for(new i = 0; i < get_maxplayers(); i++)
  721. {
  722. if(is_user_connected(i) && is_user_alive(i) && !g_zombie[i])
  723. {
  724. set_user_maxspeed(i, HUMAN_SPEED)
  725. set_user_gravity(i, HUMAN_GRAVITY)
  726. }
  727. }
  728. }
  729.  
  730. public check_ambience_sound(taskid)
  731. {
  732. if(g_endround)
  733. {
  734. remove_task(taskid)
  735. return
  736. }
  737.  
  738. PlaySound(0, ambience_sound[random_num(0, charsmax(ambience_sound))])
  739. }
  740.  
  741. public do_count_rezombie(taskid)
  742. {
  743. if(g_endround)
  744. {
  745. remove_task(taskid)
  746. return
  747. }
  748.  
  749. if (!g_count)
  750. {
  751. release_zombie()
  752. remove_task(taskid)
  753. return
  754. }
  755.  
  756. set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
  757. ShowSyncHudMsg(0, notice_hud, "Zombik ki szabadulnak %i masodperc mulva!", g_count)
  758.  
  759. g_count--
  760. }
  761. // End of Start Game
  762.  
  763. // Game Main
  764. public release_zombie()
  765. {
  766. g_gamestart = 2
  767.  
  768. for(new i = 0; i < get_maxplayers(); i++)
  769. {
  770. if(!is_user_connected(i) || !is_user_alive(i))
  771. continue
  772. if(!g_zombie[i])
  773. continue
  774.  
  775. set_user_maxspeed(i, ZOMBIE_SPEED)
  776. set_user_gravity(i, ZOMBIE_GRAVITY)
  777. }
  778. }
  779.  
  780. public client_PostThink(id)
  781. {
  782. if(!is_user_alive(id))
  783. return
  784. if(get_gametime() - 1.0 > delay_hud[id])
  785. {
  786. set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 2.0, 2.0)
  787. ShowSyncHudMsg(id, score_hud, "Zombik vs Emberek^n %i --------- %i", g_team_score[TEAM_T], g_team_score[TEAM_CT])
  788.  
  789. delay_hud[id] = get_gametime()
  790. }
  791.  
  792. if(!g_gamestart)
  793. {
  794. if(!is_user_connected(id) || !is_user_alive(id))
  795. return
  796.  
  797. if(cs_get_user_team(id) != CS_TEAM_CT) cs_set_user_team(id, CS_TEAM_T)
  798. }
  799. if(g_gamestart != 1)
  800. return
  801. if(!g_zombie[id])
  802. return
  803.  
  804. if(get_user_maxspeed(id) != 0.1) set_user_maxspeed(id, 0.1)
  805. }
  806.  
  807. public set_user_zombie(id, zombie_type)
  808. {
  809. cs_set_user_team(id, TEAM_T)
  810.  
  811. g_zombie[id] = 1
  812. g_zombie_type[id] = zombie_type
  813.  
  814. set_user_health(id, zombie_type == 0 ? floatround(ZOMBIE_HEALTH / 2.0) : floatround(ZOMBIE_HEALTH))
  815. set_user_armor(id, floatround(ZOMBIE_ARMOR))
  816.  
  817. if(zombie_type == ZOMBIE_TYPE_HOST)
  818. {
  819. set_user_maxspeed(id, ZOMBIE_SPEED)
  820. set_user_gravity(id, ZOMBIE_GRAVITY)
  821. } else {
  822. set_user_maxspeed(id, 0.1)
  823. set_user_gravity(id, ZOMBIE_GRAVITY)
  824. }
  825.  
  826. cs_get_user_model(id, g_default_model[id], 63)
  827. cs_set_user_model(id, zombie_type == 0 ? host_zombie_model : origin_zombie_model)
  828. set_default_zombie(id, zombie_type)
  829.  
  830. emit_sound(id, CHAN_BODY, zombieinfect_sound[random_num(0, charsmax(zombieinfect_sound))], 1.0, ATTN_NORM, 0, PITCH_NORM)
  831. PlaySound(0, zombieappear_sound[random_num(0, charsmax(zombieappear_sound))])
  832.  
  833. SwitchNvg(id, 1)
  834. PlaySound(id, sound_nvg[1])
  835.  
  836. check_win_con()
  837. }
  838.  
  839. stock set_default_zombie(id, zombie_type)
  840. {
  841. if(!is_user_alive(id))
  842. return
  843. if(!g_zombie[id])
  844. return
  845.  
  846. if(zombie_type == ZOMBIE_TYPE_ORIGIN)
  847. {
  848. new player = -1, entity_num, entity_list[40]
  849. if(cs_get_user_team(id) == CS_TEAM_T)
  850. {
  851. while((player = find_ent_by_class(player, "info_player_deathmatch")))
  852. {
  853. entity_list[entity_num] = player
  854. entity_num++
  855. }
  856. } else if(cs_get_user_team(id) == CS_TEAM_CT) {
  857. while((player = find_ent_by_class(player, "info_player_start")))
  858. {
  859. entity_list[entity_num] = player
  860. entity_num++
  861. }
  862. }
  863.  
  864. new random_player1
  865. random_player1 = entity_list[random(entity_num)]
  866.  
  867. if(random_player1 != 0)
  868. {
  869. new Float:Origin[3]
  870. pev(random_player1, pev_origin, Origin)
  871.  
  872. if(check_spawn(Origin))
  873. {
  874. set_pev(id, pev_origin, Origin)
  875. } else {
  876. set_default_zombie(id, zombie_type)
  877. }
  878. } else {
  879. set_default_zombie(id, zombie_type)
  880. }
  881. }
  882.  
  883. // Remove any zoom (bugfix)
  884. cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  885.  
  886. // Remove armor
  887. cs_set_user_armor(id, 0, CS_ARMOR_NONE)
  888.  
  889. // Drop weapons when infected
  890. drop_weapons(id, 1)
  891. drop_weapons(id, 2)
  892.  
  893. // Strip zombies from guns and give them a knife
  894. fm_strip_user_weapons(id)
  895. fm_give_item(id, "weapon_knife")
  896. }
  897.  
  898. public event_CurWeapon(id)
  899. {
  900. if(!is_user_alive(id))
  901. return 1
  902. if(!g_zombie[id])
  903. return 1
  904. if(get_user_weapon(id) != CSW_KNIFE)
  905. {
  906. drop_weapons(id, 1)
  907. drop_weapons(id, 2)
  908.  
  909. engclient_cmd(id, "weapon_knife")
  910. } else {
  911. set_pev(id, pev_viewmodel2, claws_model)
  912. set_pev(id, pev_weaponmodel2, "")
  913. }
  914.  
  915. return 0
  916. }
  917.  
  918. public test(id)
  919. {
  920. }
  921.  
  922. // End of Game Main
  923.  
  924. public check_win_con()
  925. {
  926. if(g_endround)
  927. return
  928. if(!g_gamestart)
  929. return
  930.  
  931. if(get_player_num(TEAM_T, AL_ALIVE) == 0)
  932. {
  933. TerminateRound(TEAM_CT)
  934. } else if(get_player_num(TEAM_CT, AL_ALIVE) == 0) {
  935. TerminateRound(TEAM_T)
  936. }
  937. }
  938.  
  939. public do_zombie_win()
  940. {
  941. TerminateRound(TEAM_T)
  942. }
  943.  
  944. // Message
  945. public message_StatusIcon(msg_id, msg_dest, msg_entity)
  946. {
  947. static szMsg[8];
  948. get_msg_arg_string(2, szMsg ,7);
  949.  
  950. if(equal(szMsg, "buyzone") && get_msg_arg_int(1))
  951. {
  952. set_pdata_int(msg_entity, 235, get_pdata_int(msg_entity, 235) & ~(1<<0));
  953. return PLUGIN_HANDLED;
  954. }
  955.  
  956. return PLUGIN_CONTINUE;
  957. }
  958.  
  959. public message_health(msg_id, msg_dest, msg_entity)
  960. {
  961. static health
  962. health = get_msg_arg_int(1)
  963.  
  964. if(health > 255)
  965. set_msg_arg_int(1, get_msg_argtype(1), 255)
  966. }
  967. // End of Message
  968.  
  969. // Ham
  970. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  971. {
  972. // Block all those unneeeded hostage sounds
  973. if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
  974. return FMRES_SUPERCEDE;
  975.  
  976. // Replace these next sounds for zombies only
  977. if (!is_user_connected(id) || !g_zombie[id])
  978. return FMRES_IGNORED;
  979.  
  980. // Zombie being hit
  981. if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' ||
  982. sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
  983. {
  984. emit_sound(id, channel, zombiehurt_sound[random_num(0, charsmax(zombiehurt_sound))], volume, attn, flags, pitch)
  985. return FMRES_SUPERCEDE;
  986. }
  987.  
  988. // Zombie Attack
  989. new attack_type
  990. if (equal(sample,"weapons/knife_hitwall1.wav")) attack_type = 1
  991. else if (equal(sample,"weapons/knife_hit1.wav") ||
  992. equal(sample,"weapons/knife_hit3.wav") ||
  993. equal(sample,"weapons/knife_hit2.wav") ||
  994. equal(sample,"weapons/knife_hit4.wav") ||
  995. equal(sample,"weapons/knife_stab.wav")) attack_type = 2
  996. else if(equal(sample,"weapons/knife_slash1.wav") ||
  997. equal(sample,"weapons/knife_slash2.wav")) attack_type = 3
  998. if (attack_type)
  999. {
  1000. if (attack_type == 1) emit_sound(id, channel, zombiehitwall_sound[random_num(0, charsmax(zombiehitwall_sound))], volume, attn, flags, pitch)
  1001. else if (attack_type == 2) emit_sound(id, channel, zombieattack_sound[random_num(0, charsmax(zombieattack_sound))], volume, attn, flags, pitch)
  1002. else if (attack_type == 3) emit_sound(id, channel, zombieswing_sound[random_num(0, charsmax(zombieswing_sound))], volume, attn, flags, pitch)
  1003.  
  1004. return FMRES_SUPERCEDE;
  1005. }
  1006.  
  1007. return FMRES_IGNORED;
  1008. }
  1009.  
  1010. public fw_GetGameDesc()
  1011. {
  1012. forward_return(FMV_STRING, "Zombie Escape")
  1013. return FMRES_SUPERCEDE
  1014. }
  1015.  
  1016. public fw_Spawn_Post(id)
  1017. {
  1018. if (get_player_num(TEAM_ALL, AL_ALIVE) > 1 && !g_started)
  1019. {
  1020. g_started = 1
  1021. TerminateRound(TEAM_START)
  1022. }
  1023. if(!is_user_connected(id))
  1024. return HAM_IGNORED
  1025. if(g_gamestart)
  1026. return HAM_IGNORED
  1027.  
  1028. cs_set_user_team(id, TEAM_CT)
  1029. cs_set_user_money(id, 16000, 1)
  1030.  
  1031. g_isalive[id] = 1
  1032. g_zombie[id] = 0
  1033. g_zombie_type[id] = 0
  1034. g_nvg[id] = 0
  1035. g_menufailsafe[id] = false
  1036. if(TASKID_WEAPONSMENU + id) remove_task(TASKID_WEAPONSMENU + id)
  1037.  
  1038. set_user_nvision(id)
  1039.  
  1040. set_human_stuff(id)
  1041.  
  1042. if(g_showmenu[id])
  1043. display_equipmenu(id)
  1044. else
  1045. {
  1046. equipweapon(id, EQUIP_ALL)
  1047. }
  1048.  
  1049. return HAM_HANDLED
  1050. }
  1051.  
  1052. public display_equipmenu(id)
  1053. {
  1054. static menubody[512], len
  1055. len = formatex(menubody, 511, "\yFegyver Menu^n^n")
  1056.  
  1057. static bool:hasweap
  1058. hasweap = ((g_player_weapons[id][0]) != -1 && (g_player_weapons[id][1] != -1)) ? true : false
  1059.  
  1060. len += formatex(menubody[len], 511 - len,"\w1. Uj fegyver^n")
  1061. len += formatex(menubody[len], 511 - len,"\w2. Elozo fegyver^n^n")
  1062. len += formatex(menubody[len], 511 - len,"\w3. Pre-Weapon & Don't Show^n^n")
  1063. len += formatex(menubody[len], 511 - len,"\w5. Kilepes^n", id, "MENU_EXIT")
  1064.  
  1065. static keys
  1066. keys = (MENU_KEY_1|MENU_KEY_5)
  1067.  
  1068. if(hasweap)
  1069. keys |= (MENU_KEY_2|MENU_KEY_3)
  1070.  
  1071. show_menu(id, keys, menubody, -1, "Equipment")
  1072. }
  1073.  
  1074. public action_equip(id, key)
  1075. {
  1076. if(!is_user_alive(id) || g_zombie[id])
  1077. return PLUGIN_HANDLED
  1078.  
  1079. switch(key)
  1080. {
  1081. case 0: display_weaponmenu(id, 1, g_menuposition[id] = 0)
  1082. case 1: equipweapon(id, EQUIP_ALL)
  1083. case 2:
  1084. {
  1085. g_showmenu[id] = false
  1086. equipweapon(id, EQUIP_ALL)
  1087. client_printc(id, "!g[Zombie Escape]!n Nyomd meg az M betut a jatekmenujehez!")
  1088. }
  1089. }
  1090.  
  1091. if(key > 0)
  1092. {
  1093. g_menufailsafe[id] = false
  1094. remove_task(TASKID_WEAPONSMENU + id)
  1095. }
  1096. return PLUGIN_HANDLED
  1097. }
  1098.  
  1099.  
  1100. public display_weaponmenu(id, menuid, pos)
  1101. {
  1102. if(pos < 0 || menuid < 0)
  1103. return
  1104.  
  1105. static start
  1106. start = pos * 8
  1107.  
  1108. static maxitem
  1109. maxitem = menuid == 1 ? sizeof g_primaryweapons : sizeof g_secondaryweapons
  1110.  
  1111. if(start >= maxitem)
  1112. start = pos = g_menuposition[id]
  1113.  
  1114. static menubody[512], len
  1115. len = formatex(menubody, 511, "\y%s\w^n^n", menuid == 1 ? "Primary" : "Secondary")
  1116.  
  1117. static end
  1118. end = start + 8
  1119. if(end > maxitem)
  1120. end = maxitem
  1121.  
  1122. static keys
  1123. keys = MENU_KEY_0
  1124.  
  1125. static a, b
  1126. b = 0
  1127.  
  1128. for(a = start; a < end; ++a)
  1129. {
  1130. keys |= (1<<b)
  1131. len += formatex(menubody[len], 511 - len,"%d. %s^n", ++b, menuid == 1 ? g_primaryweapons[a][0]: g_secondaryweapons[a][0])
  1132. }
  1133.  
  1134. if(end != maxitem)
  1135. {
  1136. formatex(menubody[len], 511 - len, "^n9. %s^n0. %s", "More", pos ? "Back" : "Exit")
  1137. keys |= MENU_KEY_9
  1138. }
  1139. else
  1140. formatex(menubody[len], 511 - len, "^n0. %s", pos ? "Back" : "Exit")
  1141.  
  1142. show_menu(id, keys, menubody, -1, menuid == 1 ? "Primary" : "Secondary")
  1143. }
  1144.  
  1145. public action_prim(id, key)
  1146. {
  1147. if(!is_user_alive(id) || g_zombie[id])
  1148. return PLUGIN_HANDLED
  1149.  
  1150. switch(key)
  1151. {
  1152. case 8: display_weaponmenu(id, 1, ++g_menuposition[id])
  1153. case 9: display_weaponmenu(id, 1, --g_menuposition[id])
  1154. default:
  1155. {
  1156. g_player_weapons[id][0] = g_menuposition[id] * 8 + key
  1157. equipweapon(id, EQUIP_PRI)
  1158.  
  1159. display_weaponmenu(id, 2, g_menuposition[id] = 0)
  1160. }
  1161. }
  1162. return PLUGIN_HANDLED
  1163. }
  1164.  
  1165. public action_sec(id, key)
  1166. {
  1167. if(!is_user_alive(id) || g_zombie[id])
  1168. return PLUGIN_HANDLED
  1169.  
  1170. switch(key)
  1171. {
  1172. case 8: display_weaponmenu(id, 2, ++g_menuposition[id])
  1173. case 9: display_weaponmenu(id, 2, --g_menuposition[id])
  1174. default:
  1175. {
  1176. g_menufailsafe[id] = false
  1177. remove_task(TASKID_WEAPONSMENU + id)
  1178.  
  1179. g_player_weapons[id][1] = g_menuposition[id] * 8 + key
  1180. equipweapon(id, EQUIP_SEC)
  1181. equipweapon(id, EQUIP_GREN)
  1182. }
  1183. }
  1184. return PLUGIN_HANDLED
  1185. }
  1186.  
  1187.  
  1188. public set_human_stuff(id)
  1189. {
  1190. g_zombie[id] = 0
  1191. g_zombie_type[id] = 0
  1192.  
  1193. set_user_health(id, floatround(HUMAN_HEALTH))
  1194. set_user_armor(id, floatround(HUMAN_ARMOR))
  1195.  
  1196. if(equal(g_default_model[id], "NonModel")) // Don't Have Model
  1197. {
  1198. cs_get_user_model(id, g_default_model[id], 63)
  1199. } else {
  1200. cs_set_user_model(id, g_default_model[id])
  1201. }
  1202. }
  1203.  
  1204. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
  1205. {
  1206. if(g_gamestart < 2)
  1207. return HAM_SUPERCEDE
  1208. if(!is_user_connected(victim) || !is_user_connected(attacker))
  1209. return HAM_IGNORED
  1210. if(cs_get_user_team(attacker) == cs_get_user_team(victim))
  1211. return HAM_SUPERCEDE
  1212. if(g_zombie[attacker] && get_user_weapon(attacker) == CSW_KNIFE)
  1213. {
  1214. SendDeathMsg(attacker, victim)
  1215. FixDeadAttrib(victim)
  1216.  
  1217. update_frags(attacker, 1)
  1218. update_deaths(victim, 1)
  1219.  
  1220. set_user_zombie(victim, ZOMBIE_TYPE_HOST)
  1221. } else if(g_zombie[victim] && !g_zombie[attacker]) {
  1222. set_pdata_float(victim, 108, 1.0, 50)
  1223.  
  1224. static Float:MyOrigin[3]
  1225. pev(attacker, pev_origin, MyOrigin)
  1226.  
  1227. hook_ent2(victim, MyOrigin, ZOMBIE_KNOCKBACK_POWER, 2)
  1228. }
  1229.  
  1230. return HAM_HANDLED
  1231. }
  1232.  
  1233. public update_frags(id, frag)
  1234. {
  1235. if(!is_user_connected(id))
  1236. return
  1237.  
  1238. set_pev(id, pev_frags, float(pev(id, pev_frags) + frag))
  1239.  
  1240. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  1241. write_byte(id) // id
  1242. write_short(pev(id, pev_frags)) // frags
  1243. write_short(cs_get_user_deaths(id)) // deaths
  1244. write_short(0) // class?
  1245. write_short(get_pdata_int(id, 114, 5)) // team
  1246. message_end()
  1247. }
  1248.  
  1249. public update_deaths(id, death)
  1250. {
  1251. if(!is_user_connected(id))
  1252. return
  1253.  
  1254. cs_set_user_deaths(id, cs_get_user_deaths(id) + death)
  1255.  
  1256. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  1257. write_byte(id) // id
  1258. write_short(pev(id, pev_frags)) // frags
  1259. write_short(cs_get_user_deaths(id)) // deaths
  1260. write_short(0) // class?
  1261. write_short(get_pdata_int(id, 114, 5)) // team
  1262. message_end()
  1263. }
  1264.  
  1265. public fw_Killed_Post(id)
  1266. {
  1267. g_isalive[id] = 0
  1268. check_win_con()
  1269. }
  1270.  
  1271. public fw_TouchWeapon(weapon, id)
  1272. {
  1273. // Not a player
  1274. if (!is_user_connected(id))
  1275. return HAM_IGNORED
  1276. if (g_zombie[id])
  1277. return HAM_SUPERCEDE
  1278.  
  1279. return HAM_IGNORED
  1280. }
  1281. // End of Ham
  1282.  
  1283. // ============================ STOCK =================================
  1284. stock get_player_num(team, alive)
  1285. {
  1286. static player_num
  1287. player_num = 0
  1288.  
  1289. for(new i = 0; i < get_maxplayers(); i++)
  1290. {
  1291. if(!is_user_connected(i))
  1292. continue
  1293. if(alive == AL_NOT)
  1294. {
  1295. if(is_user_alive(i))
  1296. continue
  1297. } else if(alive == AL_ALIVE) {
  1298. if(!is_user_alive(i))
  1299. continue
  1300. }
  1301.  
  1302. if(team == TEAM_ALL)
  1303. {
  1304. if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
  1305. continue
  1306. } else if(team == TEAM_T) {
  1307. if(cs_get_user_team(i) != CS_TEAM_T)
  1308. continue
  1309. } else if(team == TEAM_CT) {
  1310. if(cs_get_user_team(i) != CS_TEAM_CT)
  1311. continue
  1312. }
  1313.  
  1314. player_num++
  1315. }
  1316.  
  1317. return player_num
  1318. }
  1319.  
  1320. stock get_random_player(team, alive)
  1321. {
  1322. static list_player[33], list_player_num
  1323. static total_player
  1324. total_player = get_player_num(team, alive)
  1325.  
  1326. for(new i = 0; i < total_player; i++)
  1327. list_player[i] = 0
  1328.  
  1329. list_player_num = 0
  1330.  
  1331. for(new i = 0; i < get_maxplayers(); i++)
  1332. {
  1333. if(!is_user_connected(i))
  1334. continue
  1335.  
  1336. if(alive == AL_NOT)
  1337. {
  1338. if(is_user_alive(i))
  1339. continue
  1340. } else if(alive == AL_ALIVE) {
  1341. if(!is_user_alive(i))
  1342. continue
  1343. }
  1344.  
  1345. if(team == TEAM_ALL)
  1346. {
  1347. if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
  1348. continue
  1349. } else if(team == TEAM_T) {
  1350. if(cs_get_user_team(i) != CS_TEAM_T)
  1351. continue
  1352. } else if(team == TEAM_CT) {
  1353. if(cs_get_user_team(i) != CS_TEAM_CT)
  1354. continue
  1355. }
  1356.  
  1357. list_player[list_player_num] = i
  1358. list_player_num++
  1359. }
  1360.  
  1361. static random_player; random_player = 0
  1362. random_player = list_player[random_num(0, list_player_num - 1)]
  1363.  
  1364. return random_player
  1365. }
  1366.  
  1367. stock PlaySound(id, const sound[])
  1368. {
  1369. if(id == 0)
  1370. {
  1371. if (equal(sound[strlen(sound)-4], ".mp3"))
  1372. client_cmd(0, "mp3 play ^"sound/%s^"", sound)
  1373. else
  1374. client_cmd(0, "spk ^"%s^"", sound)
  1375. } else {
  1376. if(is_user_connected(id)&& g_isalive[id])
  1377. {
  1378. if (equal(sound[strlen(sound)-4], ".mp3"))
  1379. client_cmd(id, "mp3 play ^"sound/%s^"", sound)
  1380. else
  1381. client_cmd(id, "spk ^"%s^"", sound)
  1382. }
  1383. }
  1384. }
  1385.  
  1386. stock client_printc(index, const text[], any:...)
  1387. {
  1388. new szMsg[128];
  1389. vformat(szMsg, sizeof(szMsg) - 1, text, 3);
  1390.  
  1391. replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
  1392. replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
  1393. replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
  1394.  
  1395. if(index == 0)
  1396. {
  1397. for(new i = 0; i < get_maxplayers(); i++)
  1398. {
  1399. if(g_isalive[i] && is_user_connected(i))
  1400. {
  1401. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i);
  1402. write_byte(i);
  1403. write_string(szMsg);
  1404. message_end();
  1405. }
  1406. }
  1407. } else {
  1408. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
  1409. write_byte(index);
  1410. write_string(szMsg);
  1411. message_end();
  1412. }
  1413. }
  1414.  
  1415. stock require_zombie()
  1416. {
  1417. switch(get_player_num(TEAM_CT, 1))
  1418. {
  1419. case 2..5: return 1
  1420. case 6..15: return 2
  1421. case 16..25: return 3
  1422. case 26..32: return 4
  1423. }
  1424.  
  1425. return 0
  1426. }
  1427.  
  1428. stock check_spawn(Float:Origin[3])
  1429. {
  1430. new Float:originE[3], Float:origin1[3], Float:origin2[3]
  1431. new ent = -1
  1432. while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "player")) != 0)
  1433. {
  1434. pev(ent, pev_origin, originE)
  1435.  
  1436. // xoy
  1437. origin1 = Origin
  1438. origin2 = originE
  1439. origin1[2] = origin2[2] = 0.0
  1440. if (vector_distance(origin1, origin2) <= 2 * 16.0)
  1441. {
  1442. // oz
  1443. origin1 = Origin
  1444. origin2 = originE
  1445. origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
  1446. if (vector_distance(origin1, origin2) <= 72.0) return 0;
  1447. }
  1448. }
  1449.  
  1450. return 1
  1451. }
  1452.  
  1453. // Drop primary/secondary weapons
  1454. stock drop_weapons(id, dropwhat)
  1455. {
  1456. // Get user weapons
  1457. static weapons[32], num, i, weaponid
  1458. num = 0 // reset passed weapons count (bugfix)
  1459. get_user_weapons(id, weapons, num)
  1460.  
  1461. // Weapon bitsums
  1462. 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)
  1463. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  1464.  
  1465. // Loop through them and drop primaries or secondaries
  1466. for (i = 0; i < num; i++)
  1467. {
  1468. // Prevent re-indexing the array
  1469. weaponid = weapons[i]
  1470.  
  1471. if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  1472. {
  1473. // Get weapon entity
  1474. static wname[32], weapon_ent
  1475. get_weaponname(weaponid, wname, charsmax(wname))
  1476. weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  1477.  
  1478. // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  1479. set_pev(weapon_ent, pev_iuser1, cs_get_user_bpammo(id, weaponid))
  1480.  
  1481. // Player drops the weapon and looses his bpammo
  1482. engclient_cmd(id, "drop", wname)
  1483. cs_set_user_bpammo(id, weaponid, 0)
  1484. }
  1485. }
  1486. }
  1487.  
  1488. stock BytesToReplace ( identifier[], const bytes[], const bytesLength = sizeof bytes )
  1489. {
  1490. new address;
  1491. OrpheuMemoryGet( identifier, address );
  1492.  
  1493. for ( new i; i < bytesLength; i++)
  1494. {
  1495. OrpheuMemorySetAtAddress( address, "roundTimeCheck|dummy", 1, bytes[ i ], address );
  1496. address++;
  1497. }
  1498.  
  1499. server_cmd( "sv_restart 1" );
  1500. }
  1501.  
  1502. stock bool:TerminateRound(team)
  1503. {
  1504. new winStatus;
  1505. new event;
  1506. new sound[64];
  1507.  
  1508. switch(team)
  1509. {
  1510. case TEAM_T:
  1511. {
  1512. winStatus = 2;
  1513. event = 9;
  1514. sound = escape_fail_sound
  1515. g_team_score[TEAM_T]++
  1516.  
  1517. client_print(0, print_center, "Sikertelen menekules")
  1518. }
  1519. case TEAM_CT:
  1520. {
  1521. winStatus = 1;
  1522. event = 8;
  1523. sound = escape_suc_sound
  1524. g_team_score[TEAM_CT]++
  1525.  
  1526. client_print(0, print_center, "Sikeres menekules")
  1527. }
  1528. case TEAM_ALL:
  1529. {
  1530. winStatus = 3;
  1531. event = 10;
  1532. sound = "radio/rounddraw.wav";
  1533.  
  1534. client_print(0, print_center, "Kor Draw")
  1535. }
  1536. case TEAM_START:
  1537. {
  1538. winStatus = 3;
  1539. event = 10;
  1540.  
  1541. client_print(0, print_center, "Kor Draw")
  1542. }
  1543. default:
  1544. {
  1545. return false;
  1546. }
  1547. }
  1548.  
  1549. g_endround = 1
  1550. EndRoundMessage(g_WinText[team], event)
  1551. RoundTerminating(winStatus, team == TEAM_START ? 3.0 : 5.0)
  1552. PlaySound(0, sound)
  1553.  
  1554. for(new i = 0; i < get_maxplayers(); i++)
  1555. {
  1556. if(!is_user_connected(i) || !is_user_alive(i))
  1557. continue
  1558. if(g_zombie[i])
  1559. {
  1560. update_deaths(i, 1)
  1561. } else {
  1562. update_frags(i, 3)
  1563. }
  1564. }
  1565.  
  1566. return true;
  1567. }
  1568.  
  1569. stock RoundTerminating( const winStatus, const Float:delay )
  1570. {
  1571. set_mp_pdata("m_iRoundWinStatus" , winStatus );
  1572. set_mp_pdata("m_fTeamCount" , get_gametime() + delay );
  1573. set_mp_pdata("m_bRoundTerminating", true );
  1574. }
  1575.  
  1576. stock EndRoundMessage( const message[], const event, const bool:notifyAllPlugins = false )
  1577. {
  1578. static OrpheuFunction:handleFuncEndRoundMessage;
  1579.  
  1580. if ( !handleFuncEndRoundMessage )
  1581. {
  1582. handleFuncEndRoundMessage = OrpheuGetFunction( "EndRoundMessage" );
  1583. }
  1584.  
  1585. ( notifyAllPlugins ) ?
  1586. OrpheuCallSuper( handleFuncEndRoundMessage, message, event ) :
  1587. OrpheuCall( handleFuncEndRoundMessage, message, event );
  1588. }
  1589.  
  1590. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
  1591. {
  1592. static Float:fl_Velocity[3]
  1593. static Float:EntOrigin[3]
  1594.  
  1595. pev(ent, pev_origin, EntOrigin)
  1596. static Float:distance_f
  1597. distance_f = get_distance_f(EntOrigin, VicOrigin)
  1598.  
  1599. new Float:fl_Time = distance_f / speed
  1600.  
  1601. if(type == 1)
  1602. {
  1603. fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
  1604. fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
  1605. fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
  1606. } else if(type == 2) {
  1607. fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
  1608. fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
  1609. fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
  1610. }
  1611.  
  1612. entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
  1613. }
  1614.  
  1615. stock equipweapon(id, weapon)
  1616. {
  1617. if(!is_user_alive(id) || !is_user_connected(id))
  1618. return
  1619.  
  1620. static weaponid[2], weaponent
  1621.  
  1622. if(weapon & EQUIP_PRI)
  1623. {
  1624. weaponent = fm_lastprimary(id)
  1625. weaponid[1] = get_weaponid(g_primaryweapons[g_player_weapons[id][0]][1])
  1626.  
  1627. if(pev_valid(weaponent))
  1628. {
  1629. weaponid[0] = fm_get_weapon_id(weaponent)
  1630. if(weaponid[0] != weaponid[1])
  1631. fm_strip_user_gun(id, weaponid[0])
  1632. }
  1633. else
  1634. weaponid[0] = -1
  1635.  
  1636. if(weaponid[0] != weaponid[1])
  1637. fm_give_item(id, g_primaryweapons[g_player_weapons[id][0]][1])
  1638.  
  1639. cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
  1640. }
  1641.  
  1642. if(weapon & EQUIP_SEC)
  1643. {
  1644. weaponent = fm_lastsecondry(id)
  1645. weaponid[1] = get_weaponid(g_secondaryweapons[g_player_weapons[id][1]][1])
  1646.  
  1647. if(pev_valid(weaponent))
  1648. {
  1649. weaponid[0] = fm_get_weapon_id(weaponent)
  1650. if(weaponid[0] != weaponid[1])
  1651. fm_strip_user_gun(id, weaponid[0])
  1652. }
  1653. else
  1654. weaponid[0] = -1
  1655.  
  1656. if(weaponid[0] != weaponid[1])
  1657. fm_give_item(id, g_secondaryweapons[g_player_weapons[id][1]][1])
  1658.  
  1659. cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
  1660. }
  1661.  
  1662. if(weapon & EQUIP_GREN)
  1663. {
  1664. static i
  1665. for(i = 0; i < sizeof g_grenades; i++) if(!user_has_weapon(id, get_weaponid(g_grenades[i])))
  1666. fm_give_item(id, g_grenades[i])
  1667. }
  1668. }
  1669.  
  1670. // Fix Dead Attrib on scoreboard
  1671. FixDeadAttrib(id)
  1672. {
  1673. message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
  1674. write_byte(id) // id
  1675. write_byte(0) // attrib
  1676. message_end()
  1677. }
  1678.  
  1679. // Send Death Message for infections
  1680. SendDeathMsg(attacker, victim)
  1681. {
  1682. message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg"))
  1683. write_byte(attacker) // killer
  1684. write_byte(victim) // victim
  1685. write_byte(1) // headshot flag
  1686. write_string("infection") // killer's weapon
  1687. message_end()
  1688. }
  1689.