SHARE
TWEET

Untitled

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