HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Biohazard mod
  2. *
  3. * by Cheap_Suit
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software Foundation,
  17. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. * In addition, as a special exception, the author gives permission to
  20. * link the code of this program with the Half-Life Game Engine ("HL
  21. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  22. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  23. * respects for all of the code used other than the HL Engine and MODs
  24. * from Valve. If you modify this file, you may extend this exception
  25. * to your version of the file, but you are not obligated to do so. If
  26. * you do not wish to do so, delete this exception statement from your
  27. * version.
  28. */
  29.  
  30. #define VERSION "1.93"
  31.  
  32. #include <amxmodx>
  33. #include <amxmisc>
  34. #include <fakemeta>
  35. #include <cstrike>
  36. #include <hamsandwich>
  37. #include <xs>
  38.  
  39. #tryinclude "biohazard.cfg"
  40.  
  41. #if AMXX_VERSION_NUM < 180
  42. #assert AMX Mod X v1.8.0 or greater library required!
  43. #elseif !defined _biohazardcfg_included
  44. #assert Biohazard configuration file required!
  45. #endif
  46.  
  47. #define OFFSET_DEATH 444
  48. #define OFFSET_TEAM 114
  49. #define OFFSET_ARMOR 112
  50. #define OFFSET_NVG 129
  51. #define OFFSET_PRIMARYWEAPON 116
  52. #define OFFSET_CLIPAMMO 51
  53. #define OFFSET_WEAPONTYPE 43
  54. #define EXTRAOFFSET_WEAPONS 4
  55.  
  56. #define OFFSET_AMMO_AWP 377
  57. #define OFFSET_AMMO_SCOUT 378
  58. #define OFFSET_AMMO_M249 379
  59. #define OFFSET_AMMO_FAMAS 380
  60. #define OFFSET_AMMO_M3 381
  61. #define OFFSET_AMMO_USP 382
  62. #define OFFSET_AMMO_FIVESEVEN 383
  63. #define OFFSET_AMMO_DEAGLE 384
  64. #define OFFSET_AMMO_P228 385
  65. #define OFFSET_AMMO_GLOCK18 386
  66.  
  67. #define AMMOID_FLASHBANG 11
  68. #define AMMOID_HEGRENADE 12
  69. #define AMMOID_SGGRENADE 13
  70. #define AMMOID_C4 14
  71.  
  72. #define TASKID_STRIPNGIVE 698
  73. #define TASKID_STARTROUND 153
  74. #define TASKID_NEWROUND 641
  75. #define TASKID_BALANCETEAM 375
  76. #define TASKID_UPDATESCR 264
  77. #define TASKID_SETZOMBIE 635
  78. #define TASKID_SPAWNDELAY 786
  79. #define TASKID_GIVENADES 922
  80.  
  81. #define EQUIP_PRI (1<<0)
  82. #define EQUIP_SEC (1<<1)
  83. #define EQUIP_GREN (1<<2)
  84. #define EQUIP_ALL (1<<0 | 1<<1 | 1<<2)
  85.  
  86. #define HAS_NVG (1<<0)
  87. #define ATTRIB_BOMB (1<<1)
  88. #define DMG_HEGRENADE (1<<24)
  89. #define AMMOID_NULL (1<<0 | 1<<AMMOID_FLASHBANG | 1<<AMMOID_HEGRENADE | 1<<AMMOID_SGGRENADE | 1<<AMMOID_C4)
  90. #define AMMOWP_NULL (1<<0 | 1<<CSW_KNIFE | 1<<CSW_FLASHBANG | 1<<CSW_HEGRENADE | 1<<CSW_SMOKEGRENADE | 1<<CSW_C4)
  91.  
  92. #define MAX_SPAWNS 128
  93. #define MAX_AMMO 200
  94. #define IMPULSE_FLASHLIGHT 100
  95. #define MODEL_CLASSNAME "player_model"
  96. #define KNIFE_MODEL "models/v_knife.mdl"
  97.  
  98. /*enum CsTeams
  99. {
  100. CS_TEAM_UNASSIGNED = 0,
  101. CS_TEAM_T = 1,
  102. CS_TEAM_CT = 2,
  103. CS_TEAM_SPECTATOR = 3
  104. }
  105.  
  106. enum CsArmorType
  107. {
  108. CS_ARMOR_NONE = 0,
  109. CS_ARMOR_KEVLAR = 1,
  110. CS_ARMOR_VESTHELM = 2
  111. }*/
  112.  
  113. #define cs_get_user_team(%1) CsTeams:get_pdata_int(%1, OFFSET_TEAM)
  114. #define cs_get_user_deaths(%1) get_pdata_int(%1, OFFSET_DEATH)
  115. #define reset_user_primary(%1) set_pdata_int(%1, OFFSET_PRIMARYWEAPON, 0)
  116. #define set_weapon_ammo(%1,%2) set_pdata_int(%1, OFFSET_CLIPAMMO, %2, EXTRAOFFSET_WEAPONS)
  117. #define set_user_deaths(%1,%2) set_pdata_int(%1, OFFSET_DEATH, %2)
  118. #define is_player_alive(%1) ((1 <= %1 <= g_maxplayers) && is_user_alive(%1))
  119. #define _random(%1) random_num(0, %1 - 1)
  120.  
  121. new cvar_regen_dly1, cvar_regen_dly2, cvar_randomspawn, cvar_zombie_spd, cvar_skyname, cvar_autobalance[2], cvar_starttime,
  122. cvar_lights, cvar_zombie_def, cvar_zombie_hp, cvar_blocknightvision, cvar_killbonus, cvar_gamedescription, cvar_enabled,
  123. cvar_autonvg, cvar_maxzombies, cvar_customsounds, cvar_hpbonus, cvar_knockback_hp, cvar_flashbang, cvar_weaponsmenu,
  124. cvar_zombie_atk, cvar_knockback_duck, cvar_hedmg_multi, cvar_zombie_regen, cvar_zombie_resist, cvar_buytime, cvar_ammo,
  125. cvar_zombie_instant, cvar_winsounds, cvar_botquota
  126.  
  127. new bool:g_brestorevel, Float:g_vecvel[3], bool:g_roundstarted, g_maxplayers, g_spawncount, bool:g_infecting, bool:g_gamestarted,
  128. Float:g_spawns[MAX_SPAWNS+1][9], g_zombieoftheround, g_fwd_spawn, bool:g_usingknifemodel, bool:g_usingplayermodel, g_equipmenu,
  129. g_primmenu, g_secmenu, g_fwd_result, g_fwd_infect, g_fwd_teamwin, g_fwd_gamestart, g_fwd_infect2, CsTeams:g_winningteam, g_radiofix,
  130. bool:g_czero, g_netclient_pdata, g_botclient_pdata, g_buyzone, Float:g_buytime
  131.  
  132. new bool:g_zombie[33], Float:g_regendelay[33], g_victim[33], bool:g_showmenu[33], g_weapons[33][2], bool:g_falling[33], g_lastteam[33],
  133. g_modelent[33], g_weaponent[33]
  134.  
  135. public plugin_precache()
  136. {
  137. register_plugin("Biohazard", VERSION, "cheap_suit")
  138. register_cvar("bh_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
  139. set_cvar_string("bh_version", VERSION)
  140.  
  141. cvar_enabled = register_cvar("bh_enabled", "1")
  142. if(!get_pcvar_num(cvar_enabled)) return
  143.  
  144. g_usingplayermodel = (strlen(g_zombie_model) > 0) ? true : false
  145. g_usingknifemodel = (strlen(g_zombie_claws) > 0) ? true : false
  146. if(g_usingplayermodel) precache_model(g_zombie_model)
  147. if(g_usingknifemodel) precache_model(g_zombie_claws)
  148.  
  149. new i
  150. for(i = 0; i < sizeof g_zombie_miss_sounds; i++) precache_sound(g_zombie_miss_sounds[i])
  151. for(i = 0; i < sizeof g_zombie_hit_sounds; i++) precache_sound(g_zombie_hit_sounds[i])
  152. for(i = 0; i < sizeof g_scream_sounds; i++) precache_sound(g_scream_sounds[i])
  153. for(i = 0; i < sizeof g_zombie_die_sounds; i++) precache_sound(g_zombie_die_sounds[i])
  154. for(i = 0; i < sizeof g_zombie_win_sounds; i++) precache_sound(g_zombie_win_sounds[i])
  155.  
  156. g_fwd_spawn = register_forward(FM_Spawn, "fwd_spawn")
  157. new zone = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_bomb_target"))
  158. if(zone) dllfunc(DLLFunc_Spawn, zone), set_pev(zone, pev_solid, SOLID_NOT)
  159.  
  160. g_buyzone = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_buyzone"))
  161. if(g_buyzone) dllfunc(DLLFunc_Spawn, g_buyzone), set_pev(g_buyzone, pev_solid, SOLID_NOT)
  162.  
  163. #if FOG_ENABLE
  164. new fog = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  165. if(fog)
  166. {
  167. new DENSITY[10]
  168. formatex(DENSITY, 9, "0.00%d", clamp(FOG_DENSITY, 1, 99))
  169.  
  170. fm_set_kvd(fog, "density", DENSITY, "env_fog")
  171. fm_set_kvd(fog, "rendercolor", FOG_COLOR, "env_fog")
  172. }
  173. #endif
  174. }
  175.  
  176. public plugin_init()
  177. {
  178. if(!get_pcvar_num(cvar_enabled)) return
  179.  
  180. cvar_gamedescription = register_cvar("bh_gamedescription", "HUN Biohazard")
  181. cvar_skyname = register_cvar("bh_skyname", "night")
  182. cvar_lights = register_cvar("bh_lights", "d")
  183. cvar_blocknightvision = register_cvar("bh_block_nvg", "1")
  184. cvar_starttime = register_cvar("bh_starttime", "10.0")
  185. cvar_randomspawn = register_cvar("bh_randomspawn", "1")
  186. cvar_customsounds = register_cvar("bh_customsounds", "1")
  187. cvar_winsounds = register_cvar("bh_winsounds", "1")
  188. cvar_autonvg = register_cvar("bh_autonvg", "1")
  189. cvar_killbonus = register_cvar("bh_zombie_kill_bonus", "2")
  190. cvar_buytime = register_cvar("bh_buytime", "0")
  191. cvar_weaponsmenu = register_cvar("bh_weaponsmenu", "0")
  192. cvar_ammo = register_cvar("bh_ammo", "1")
  193. cvar_hedmg_multi = register_cvar("bh_hedmg_multi", "1.0")
  194. cvar_maxzombies = register_cvar("bh_maxzombies", "25")
  195. cvar_flashbang = register_cvar("bh_flashbang", "1")
  196. cvar_zombie_instant = register_cvar("bh_zombie_instant", "1")
  197. cvar_zombie_hp = register_cvar("bh_zombie_hp", "135")
  198. cvar_knockback_hp = register_cvar("bh_zombie_kb_hp", "90")
  199. cvar_knockback_duck = register_cvar("bh_zombie_kb_duck", "1")
  200. cvar_hpbonus = register_cvar("bh_zombie_hp_bonus", "65")
  201. cvar_zombie_resist = register_cvar("bh_zombie_resist", "1")
  202. cvar_zombie_spd = register_cvar("bh_zombie_speed", "280.0")
  203. cvar_zombie_atk = register_cvar("bh_zombie_atk_multi", "2.0")
  204. cvar_zombie_def = register_cvar("bh_zombie_def_multi", "0.087")
  205. cvar_zombie_regen = register_cvar("bh_zombie_regen", "1")
  206. cvar_regen_dly1 = register_cvar("bh_zombie_regendly1", "2.0")
  207. cvar_regen_dly2 = register_cvar("bh_zombie_regendly2", "0.25")
  208. cvar_botquota = get_cvar_pointer("bot_quota")
  209. cvar_autobalance[0] = get_cvar_pointer("mp_autoteambalance")
  210. cvar_autobalance[1] = get_pcvar_num(cvar_autobalance[0])
  211. set_pcvar_num(cvar_autobalance[0], 0)
  212.  
  213. register_clcmd("nightvision", "cmd_nightvision")
  214. register_clcmd("chooseteam", "cmd_chooseteam")
  215. register_clcmd("say guns", "cmd_enablemenu")
  216. register_clcmd("say /guns", "cmd_enablemenu")
  217. register_clcmd("amx_infect", "cmd_infectuser", ADMIN_BAN, "<name or #userid>")
  218. register_menu("#RadioB", MENU_KEY_1, "cmd_fixradio", 1)
  219.  
  220. RegisterHam(Ham_Use, "func_tank", "bacon_use")
  221. RegisterHam(Ham_Use, "func_tankmortar", "bacon_use")
  222. RegisterHam(Ham_Use, "func_tankrocket", "bacon_use")
  223. RegisterHam(Ham_Use, "func_tanklaser", "bacon_use")
  224. RegisterHam(Ham_Touch, "weaponbox", "bacon_touch_weapon")
  225. RegisterHam(Ham_Touch, "armoury_entity", "bacon_touch_weapon")
  226. RegisterHam(Ham_Touch, "weapon_shield", "bacon_touch_weapon")
  227. RegisterHam(Ham_Item_Deploy, "weapon_knife", "bacon_item_deploy_post", 1)
  228. RegisterHam(Ham_Item_AttachToPlayer, "weapon_knife", "bacon_item_attachtoplayer_post", 1)
  229.  
  230. unregister_forward(FM_Spawn, g_fwd_spawn)
  231. register_forward(FM_PlayerPreThink, "fwd_playerprethink")
  232. register_forward(FM_PlayerPostThink, "fwd_playerpostthink")
  233. register_forward(FM_CmdStart, "fwd_cmdstart")
  234. register_forward(FM_EmitSound, "fwd_emitsound")
  235. register_forward(FM_GetGameDescription, "fwd_gamedescription")
  236. register_forward(FM_CreateNamedEntity, "fwd_createnamedentity")
  237. register_forward(FM_Sys_Error, "fwd_sys_error")
  238. register_forward(FM_PlayerPreThink, "fwd_playerprethink_post", 1)
  239. register_forward(FM_TraceLine, "fwd_traceline_post", 1)
  240. register_forward(FM_TraceHull, "fwd_tracehull_post", 1)
  241.  
  242. register_message(get_user_msgid("Battery"), "msg_battery")
  243. register_message(get_user_msgid("TextMsg"), "msg_textmsg")
  244. register_message(get_user_msgid("SendAudio"), "msg_sendaudio")
  245. register_message(get_user_msgid("DeathMsg"), "msg_deathmsg")
  246. register_message(get_user_msgid("ScreenFade"), "msg_screenfade")
  247. register_message(get_user_msgid("TeamInfo"), "msg_teaminfo")
  248. register_message(get_user_msgid("ClCorpse"), "msg_clcorpse")
  249. register_message(get_user_msgid("StatusIcon"), "msg_statusicon")
  250. register_message(get_user_msgid("ScoreAttrib"), "msg_scoreattrib")
  251. register_message(get_user_msgid("AmmoX"), "msg_ammox")
  252. register_message(get_user_msgid("CurWeapon"), "msg_curweapon")
  253.  
  254. register_event("TextMsg", "event_textmsg", "a", "2=#Game_will_restart_in")
  255. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  256. register_event("Damage", "event_damage", "be")
  257.  
  258. register_logevent("logevent_round_start", 2, "1=Round_Start")
  259. register_logevent("logevent_round_end", 2, "1=Round_End")
  260.  
  261. g_fwd_infect = CreateMultiForward("event_infect", ET_CONTINUE, FP_CELL, FP_CELL)
  262. g_fwd_infect2 = CreateMultiForward("event_infect2", ET_CONTINUE, FP_CELL)
  263. g_fwd_teamwin = CreateMultiForward("event_teamwin", ET_CONTINUE, FP_CELL)
  264. g_fwd_gamestart = CreateMultiForward("event_gamestart", ET_CONTINUE)
  265. g_maxplayers = get_maxplayers()
  266.  
  267. register_dictionary("biohazard.txt")
  268. build_menu(), get_spawnpoints()
  269.  
  270. new modname[7]; get_modname(modname, 6)
  271. g_czero = equal(modname,"czero") ? true : false
  272. }
  273.  
  274. public pdata_init(id)
  275. {
  276. RegisterHamFromEntity(Ham_TakeDamage, id, "bacon_takedamage")
  277. RegisterHamFromEntity(Ham_Spawn, id, "bacon_spawn_post", 1)
  278. }
  279.  
  280. public build_menu()
  281. {
  282. new title[32]
  283. formatex(title, 31, "%L", LANG_SERVER, "MENU_TITLE1")
  284. g_equipmenu = menu_create(title, "menu_equip", 0)
  285.  
  286. formatex(title, 31, "%L", LANG_SERVER, "MENU_TITLE2")
  287. g_primmenu = menu_create(title, "menu_prim", 0)
  288.  
  289. formatex(title, 31, "%L", LANG_SERVER, "MENU_TITLE3")
  290. g_secmenu = menu_create(title, "menu_sec", 0)
  291.  
  292. new name[32]
  293. formatex(name, 31, "%L", LANG_SERVER, "MENU_NEWWEAPONS")
  294. menu_additem(g_equipmenu, name, "1", 0, -1)
  295.  
  296. formatex(name, 31, "%L", LANG_SERVER, "MENU_PREVSETUP")
  297. menu_additem(g_equipmenu, name, "2", 0, -1)
  298.  
  299. formatex(name, 31, "%L", LANG_SERVER, "MENU_DONTSHOW")
  300. menu_additem(g_equipmenu, name, "3", 0, -1)
  301.  
  302. static i, num[3]
  303. for(i = 1; i < sizeof g_primmenunames; i++)
  304. {
  305. formatex(num, 2, "%d", i)
  306. menu_additem(g_primmenu, g_primmenunames[i], num, 0, -1)
  307. }
  308.  
  309. for(i = 1; i < sizeof g_secmenunames; i++)
  310. {
  311. formatex(num, 2, "%d", i)
  312. menu_additem(g_secmenu, g_secmenunames[i], num, 0, -1)
  313. }
  314. return PLUGIN_HANDLED
  315. }
  316.  
  317. public plugin_cfg()
  318. {
  319. new file[64]; get_configsdir(file, 63)
  320. format(file, 63, "%s/bh_cvars.cfg", file)
  321. if(file_exists(file)) server_cmd("exec %s", file), server_exec()
  322.  
  323. new light[2]
  324. get_pcvar_string(cvar_lights, light, 1)
  325.  
  326. if(strlen(light) > 0)
  327. {
  328. set_task(1.0, "task_lights", _, _, _, "b")
  329.  
  330. set_cvar_num("sv_skycolor_r", 0)
  331. set_cvar_num("sv_skycolor_g", 0)
  332. set_cvar_num("sv_skycolor_b", 0)
  333. }
  334.  
  335. new skyname[32]
  336. get_pcvar_string(cvar_skyname, skyname, 31)
  337.  
  338. if(strlen(skyname) > 0)
  339. set_cvar_string("sv_skyname", skyname)
  340. }
  341.  
  342. public plugin_end()
  343. set_pcvar_num(cvar_autobalance[0], cvar_autobalance[1]), destroyforwards()
  344.  
  345. public destroyforwards()
  346. {
  347. DestroyForward(g_fwd_infect), DestroyForward(g_fwd_infect2)
  348. DestroyForward(g_fwd_teamwin), DestroyForward(g_fwd_gamestart)
  349. }
  350.  
  351. public plugin_natives()
  352. {
  353. register_library("biohazardf")
  354. register_native("is_game_started", "native_game_started")
  355. register_native("is_user_zombie", "native_is_user_zombie")
  356. register_native("is_user_firstzombie", "native_is_user_firstzombie")
  357. register_native("infect_user", "native_infect_user")
  358. register_native("firstzombie", "native_first_zombie")
  359. }
  360.  
  361. public client_connect(id)
  362. {
  363. g_lastteam[id] = -1, remove_model(g_modelent[id])
  364. g_showmenu[id] = true, clear_clientdata(id)
  365. }
  366.  
  367. public client_putinserver(id)
  368. {
  369. if(!g_netclient_pdata) set_task(1.0, "task_netclient_pdata", id)
  370. if(g_czero && !g_botclient_pdata) set_task(1.0, "task_botclient_pdata", id)
  371. }
  372.  
  373. public client_disconnect(id)
  374. {
  375. remove_task(TASKID_SETZOMBIE + id), remove_task(TASKID_STRIPNGIVE + id)
  376. remove_task(TASKID_UPDATESCR + id), remove_task(TASKID_SPAWNDELAY + id)
  377. remove_task(TASKID_GIVENADES + id), remove_model(g_modelent[id])
  378. }
  379.  
  380. public clear_clientdata(id)
  381. {
  382. g_victim[id] = 0, g_regendelay[id] = 0.0
  383. g_lastteam[id] = 0, g_weaponent[id] = 0
  384. g_zombie[id] = false, g_falling[id] = false
  385. }
  386.  
  387. public remove_model(ent)
  388. {
  389. static id; id = pev(ent, pev_owner)
  390. if(pev_valid(ent)) engfunc(EngFunc_RemoveEntity, ent)
  391. g_modelent[id] = 0
  392. }
  393.  
  394. public cmd_enablemenu(id)
  395. {
  396. if(!get_pcvar_num(cvar_weaponsmenu))
  397. return PLUGIN_CONTINUE
  398.  
  399. client_print(id, print_chat, "%L", id, g_showmenu[id] == false ? "MENU_REENABLED" : "MENU_ALENABLED")
  400. g_showmenu[id] = true
  401.  
  402. return PLUGIN_HANDLED_MAIN
  403. }public cmd_nightvision(id)
  404. return (!g_zombie[id] && get_pcvar_num(cvar_blocknightvision)) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
  405.  
  406. public cmd_chooseteam(id)
  407. return g_zombie[id] ? PLUGIN_HANDLED : PLUGIN_CONTINUE
  408.  
  409. public cmd_fixradio()
  410. g_radiofix = true
  411.  
  412. public cmd_infectuser(id, level, cid)
  413. {
  414. if(!cmd_access(id, level, cid, 2))
  415. return PLUGIN_HANDLED_MAIN
  416.  
  417. static arg1[32], target
  418. read_argv(1, arg1, 31)
  419.  
  420. target = cmd_target(id, arg1, 0)
  421. if(!is_user_alive(target))
  422. {
  423. console_print(id, "%L", id, "CMD_INVALIDUSER")
  424. return PLUGIN_HANDLED_MAIN
  425. }
  426.  
  427. if(!allow_infection())
  428. {
  429. console_print(id, "%L", id, "CMD_MAXZOMBIES")
  430. return PLUGIN_HANDLED_MAIN
  431. }
  432.  
  433. if(!g_gamestarted)
  434. {
  435. console_print(id, "%L", id, "CMD_NOTSTARTED")
  436. return PLUGIN_HANDLED_MAIN
  437. }
  438.  
  439. if(!g_zombie[target])
  440. {
  441. infect_user(target)
  442.  
  443. static name[32]; get_user_name(target, name, 31)
  444. console_print(id, "%L", id, "CMD_INFECTED", name)
  445. }
  446. return PLUGIN_HANDLED_MAIN
  447. }
  448.  
  449. public msg_teaminfo(msgid, dest, id)
  450. {
  451. id = get_msg_arg_int(1)
  452. if(is_user_alive(id) || !g_gamestarted)
  453. return PLUGIN_CONTINUE
  454.  
  455. if(g_lastteam[id] == -1)
  456. return PLUGIN_CONTINUE
  457.  
  458. static team[4]; get_msg_arg_string(2, team, 3)
  459. if(team[0] != 'U' || team[1] != 'N' || team[2] != 'A')
  460. return PLUGIN_CONTINUE
  461.  
  462. id = randomly_pick_zombie()
  463. if(id)
  464. {
  465. if(!g_zombie[id])
  466. {
  467. infect_user(id)
  468.  
  469. static name[32]
  470. get_user_name(id, name, 31)
  471.  
  472. set_hudmessage(_, _, _, _, _, 1)
  473. show_hudmessage(0, "%L", LANG_PLAYER, "INFECTED_HUD", name)
  474. }
  475. else
  476. {
  477. cs_set_user_team2(id, CS_TEAM_CT)
  478. set_pev(id, pev_deadflag, DEAD_DISCARDBODY)
  479. }
  480. return PLUGIN_HANDLED
  481. }
  482. return PLUGIN_CONTINUE
  483. }
  484.  
  485. public msg_screenfade(msgid, dest, id)
  486. {
  487. if(!get_pcvar_num(cvar_flashbang) || !is_user_connected(id))
  488. return PLUGIN_CONTINUE
  489.  
  490. if(!g_zombie[id] ||!is_user_alive(id))
  491. {
  492. static data[4]
  493. data[0] = get_msg_arg_int(4); data[1] = get_msg_arg_int(5)
  494. data[2] = get_msg_arg_int(6); data[3] = get_msg_arg_int(7)
  495.  
  496. if(data[0] == 255 && data[1] == 255 && data[2] == 255 && data[3] > 199)
  497. return PLUGIN_HANDLED
  498. }
  499. return PLUGIN_CONTINUE
  500. }
  501.  
  502. public msg_battery(msgid, dest, id)
  503. {
  504. static armor; armor = get_msg_arg_int(1)
  505. if(armor > 0)
  506. {
  507. if(!is_user_alive(id) || !g_zombie[id])
  508. return PLUGIN_CONTINUE
  509.  
  510. static CsArmorType:armortype
  511. cs_get_user_armor2(id, armortype)
  512.  
  513. if(armortype != CS_ARMOR_NONE)
  514. cs_set_user_armor2(id, 0, CS_ARMOR_NONE)
  515.  
  516. set_msg_arg_int(1, ARG_SHORT, 0)
  517. }
  518. return PLUGIN_CONTINUE
  519. }
  520.  
  521. public msg_scoreattrib(msgid, dest, id)
  522. {
  523. static attrib; attrib = get_msg_arg_int(2)
  524. if(attrib == ATTRIB_BOMB) set_msg_arg_int(2, ARG_BYTE, 0)
  525. }
  526.  
  527. public msg_statusicon(msgid, dest, id)
  528. {
  529. if(!is_user_connected(id))
  530. return PLUGIN_CONTINUE
  531.  
  532. static icon[8]; get_msg_arg_string(2, icon, 7)
  533. if(icon[0] == 'c' && icon[1] == '4' || equal(icon, "defuser"))
  534. return PLUGIN_HANDLED
  535.  
  536. return PLUGIN_CONTINUE
  537. }
  538.  
  539. public msg_ammox(msgid, dest, id)
  540. {
  541. static ammotype; ammotype = get_pcvar_num(cvar_ammo)
  542. if(!is_user_alive(id) || g_zombie[id] || ammotype != 1)
  543. return PLUGIN_CONTINUE
  544.  
  545. static ammoid; ammoid = get_msg_arg_int(1)
  546. static bammo; bammo = get_msg_arg_int(2)
  547.  
  548. if(!(AMMOID_NULL & (1<<ammoid)) && bammo != MAX_AMMO)
  549. set_msg_arg_int(2, ARG_BYTE, MAX_AMMO)
  550.  
  551. return PLUGIN_CONTINUE
  552. }
  553.  
  554. public msg_curweapon(msgid, dest, id)
  555. {
  556. if(!is_user_alive(id) || !get_msg_arg_int(1))
  557. return PLUGIN_CONTINUE
  558.  
  559. static weapon; weapon = get_msg_arg_int(2)
  560. if(g_zombie[id])
  561. {
  562. if(weapon != CSW_KNIFE && !task_exists(TASKID_STRIPNGIVE + id))
  563. set_task(0.2, "task_stripngive", TASKID_STRIPNGIVE + id)
  564.  
  565. return PLUGIN_CONTINUE
  566. }
  567. else if(AMMOWP_NULL & (1<<weapon)) return PLUGIN_CONTINUE
  568.  
  569. static ammotype; ammotype = get_pcvar_num(cvar_ammo)
  570. if(!ammotype) return PLUGIN_CONTINUE
  571.  
  572. static max_clip; max_clip = get_weapon_maxclip(weapon)
  573. switch(ammotype)
  574. {
  575. case 1:
  576. {
  577. static ammo; ammo = get_user_bpammo(id, weapon)
  578. if(ammo < max_clip) set_user_bpammo(id, weapon, MAX_AMMO)
  579. }
  580. case 2:
  581. {
  582. static clip; clip = get_msg_arg_int(3)
  583. if(clip != max_clip) set_msg_arg_int(3, ARG_BYTE, max_clip)
  584.  
  585. if(!pev_valid(g_weaponent[id]) || (pev_valid(g_weaponent[id])
  586. && cs_get_weapon_id(g_weaponent[id]) != weapon))
  587. {
  588. static weaponname[32]; get_weaponname(weapon, weaponname, 31)
  589. g_weaponent[id] = fm_find_ent_by_owner(-1, weaponname, id)
  590. }
  591.  
  592. if(clip < 1 && pev_valid(g_weaponent[id]))
  593. set_weapon_ammo(g_weaponent[id], max_clip)
  594. }
  595. }
  596. return PLUGIN_CONTINUE
  597. }
  598.  
  599. public msg_deathmsg(msgid, dest, id)
  600. {
  601. static killer; killer = get_msg_arg_int(1)
  602. static victim; victim = get_msg_arg_int(2)
  603. if(!is_user_connected(killer))
  604. return PLUGIN_CONTINUE
  605.  
  606. if(g_zombie[killer])
  607. set_msg_arg_string(4, g_zombie_weapname)
  608.  
  609. else if(g_zombie[victim])
  610. set_pev(killer, pev_frags, pev(killer, pev_frags) + float(get_pcvar_num(cvar_killbonus)))
  611.  
  612. return PLUGIN_CONTINUE
  613. }
  614.  
  615. public msg_sendaudio(msgid, dest, id)
  616. {
  617. static audiocode [22]; get_msg_arg_string(2, audiocode, 21)
  618. if(equal(audiocode[7], "MOVEOUT") || equal(audiocode[7], "LOCKNLOAD")
  619. || equal(audiocode[7], "LETSGO") || (equal(audiocode[7], "GO") && !g_radiofix))
  620. set_msg_arg_string(2, "%!MRAD_ELIM"), g_radiofix = false
  621.  
  622. else if(equal(audiocode[7], "terwin") && get_pcvar_num(cvar_winsounds))
  623. set_msg_arg_string(2, g_zombie_win_sounds[_random(sizeof g_zombie_win_sounds)])
  624.  
  625. return PLUGIN_CONTINUE
  626. }
  627.  
  628. public msg_textmsg(msgid, dest, id)
  629. {
  630. if(get_msg_arg_int(1) != 4)
  631. return PLUGIN_CONTINUE
  632.  
  633. static txtmsg[25], winmsg[32]
  634. get_msg_arg_string(2, txtmsg, 24)
  635.  
  636. if(equal(txtmsg[1], "Game_bomb_drop"))
  637. return PLUGIN_HANDLED
  638.  
  639. else if(equal(txtmsg[1], "Terrorists_Win"))
  640. {
  641. formatex(winmsg, 31, "%L", LANG_SERVER, "WIN_ZOMBIES")
  642. set_msg_arg_string(2, winmsg)
  643.  
  644. g_winningteam = CS_TEAM_T
  645. }
  646. else if(equal(txtmsg[1], "Target_Saved") || equal(txtmsg[1], "CTs_Win"))
  647. {
  648. formatex(winmsg, 31, "%L", LANG_SERVER, "WIN_SURVIVORS")
  649. set_msg_arg_string(2, winmsg)
  650.  
  651. g_winningteam = CS_TEAM_CT
  652. }
  653. return PLUGIN_CONTINUE
  654. }
  655.  
  656. public msg_clcorpse(msgid, dest, id)
  657. {
  658. id = get_msg_arg_int(12)
  659. if(!g_zombie[id])
  660. return PLUGIN_CONTINUE
  661.  
  662. static ent; ent = fm_find_ent_by_owner(-1, MODEL_CLASSNAME, id)
  663. if(pev_valid(ent))
  664. {
  665. static model[64]
  666. pev(ent, pev_model, model, 63)
  667. set_msg_arg_string(1, model)
  668. }
  669. return PLUGIN_CONTINUE
  670. }
  671.  
  672. public logevent_round_start()
  673. {
  674. g_roundstarted = true
  675. if(get_pcvar_num(cvar_weaponsmenu))
  676. {
  677. static id, CsTeams:team
  678. for(id = 1; id <= g_maxplayers; id++) if(is_user_alive(id))
  679. {
  680. team = cs_get_user_team(id)
  681. if(team == CS_TEAM_T || team == CS_TEAM_CT)
  682. g_showmenu[id] == true ? menu_display(id, g_equipmenu, 0) : equipweapon(id, EQUIP_ALL)
  683. }
  684. }
  685. }
  686.  
  687. public logevent_round_end()
  688. {
  689. g_gamestarted = false, g_roundstarted = false
  690. remove_task(TASKID_BALANCETEAM), remove_task(TASKID_STARTROUND)
  691. set_task(1.5, "task_balanceteam", TASKID_BALANCETEAM)
  692.  
  693. if(g_winningteam > CS_TEAM_UNASSIGNED)
  694. {
  695. ExecuteForward(g_fwd_teamwin, g_fwd_result, g_winningteam)
  696. g_winningteam = CS_TEAM_UNASSIGNED
  697. }
  698. }
  699.  
  700. public event_textmsg()
  701. {
  702. static seconds[5]; read_data(3, seconds, 4)
  703. static Float:tasktime; tasktime = float(str_to_num(seconds)) - 0.5
  704. remove_task(TASKID_BALANCETEAM), set_task(tasktime, "task_balanceteam", TASKID_BALANCETEAM)
  705. }
  706.  
  707. public event_newround()
  708. {
  709. static buytime; buytime = get_pcvar_num(cvar_buytime)
  710. if(buytime) g_buytime = buytime + get_gametime()
  711.  
  712. g_gamestarted = false, g_roundstarted = false
  713. remove_task(TASKID_NEWROUND), remove_task(TASKID_STARTROUND)
  714.  
  715. set_task(0.1, "task_newround", TASKID_NEWROUND)
  716. set_task(get_pcvar_float(cvar_starttime), "task_startround", TASKID_STARTROUND)
  717. }
  718.  
  719. public event_damage(victim)
  720. {
  721. if(!is_user_alive(victim) || !g_gamestarted)
  722. return PLUGIN_CONTINUE
  723.  
  724. if(g_zombie[victim])
  725. {
  726. g_regendelay[victim] = get_gametime() + get_pcvar_float(cvar_regen_dly1)
  727. return PLUGIN_CONTINUE
  728. }
  729.  
  730. static attacker; attacker = get_user_attacker(victim)
  731. if(!is_user_alive(attacker) || !g_zombie[attacker] || g_infecting)
  732. return PLUGIN_CONTINUE
  733.  
  734. g_infecting = true
  735. if(g_victim[attacker] == victim)
  736. {
  737. static Float:frags; pev(attacker, pev_frags, frags)
  738. static deaths; deaths = cs_get_user_deaths(victim)
  739. set_pev(attacker, pev_frags, frags + 1.0)
  740. set_user_deaths(victim, deaths + 1)
  741.  
  742. static _msg_deathmsg
  743. if(!_msg_deathmsg) _msg_deathmsg = get_user_msgid("DeathMsg")
  744.  
  745. message_begin(MSG_ALL, _msg_deathmsg)
  746. write_byte(attacker)
  747. write_byte(victim)
  748. write_byte(0)
  749. write_string("infection")
  750. message_end()
  751.  
  752. infect_user(victim)
  753. ExecuteForward(g_fwd_infect, g_fwd_result, attacker, victim)
  754.  
  755. static params[2]; params[0] = attacker, params[1] = victim
  756. set_task(0.2, "task_updatescore", TASKID_UPDATESCR, params, 2)
  757.  
  758. g_victim[attacker] = 0
  759. }
  760. g_infecting = false
  761.  
  762. return PLUGIN_CONTINUE
  763. }
  764.  
  765. public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
  766. {
  767. if(sample[6] == 'n' && sample[7] == 'v' && sample[8] == 'g')
  768. return FMRES_SUPERCEDE
  769.  
  770. if(!is_user_connected(id) || !g_zombie[id])
  771. return FMRES_IGNORED
  772.  
  773. if(sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i' && get_pcvar_num(cvar_customsounds))
  774. {
  775. if(sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a')
  776. {
  777. emit_sound(id, channel, g_zombie_miss_sounds[_random(sizeof g_zombie_miss_sounds)], volume, attn, flag, pitch)
  778. return FMRES_SUPERCEDE
  779. }
  780. else if(sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't' || sample[14] == 's' && sample[15] == 't' && sample[16] == 'a')
  781. {
  782. if(sample[17] == 'w' && sample[18] == 'a' && sample[19] == 'l')
  783. emit_sound(id, channel, g_zombie_miss_sounds[_random(sizeof g_zombie_miss_sounds)], volume, attn, flag, pitch)
  784. else
  785. emit_sound(id, channel, g_zombie_hit_sounds[_random(sizeof g_zombie_hit_sounds)], volume, attn, flag, pitch)
  786.  
  787. return FMRES_SUPERCEDE
  788. }
  789. }
  790. else if(sample[7] == 'd' && (sample[8] == 'i' && sample[9] == 'e' || sample[12] == '6'))
  791. {
  792. emit_sound(id, channel, g_zombie_die_sounds[_random(sizeof g_zombie_die_sounds)], volume, attn, flag, pitch)
  793. return FMRES_SUPERCEDE
  794. }
  795. return FMRES_IGNORED
  796. }
  797.  
  798. public fwd_cmdstart(id, handle, seed)
  799. {
  800. if(!is_user_alive(id) || !g_zombie[id])
  801. return FMRES_IGNORED
  802.  
  803. static impulse; impulse = get_uc(handle, UC_Impulse)
  804. if(impulse == IMPULSE_FLASHLIGHT)
  805. {
  806. set_uc(handle, UC_Impulse, 0)
  807. return FMRES_SUPERCEDE
  808. }
  809. return FMRES_IGNORED
  810. }
  811.  
  812. public fwd_playerprethink(id)
  813. {
  814. if(!is_user_alive(id))
  815. return FMRES_IGNORED
  816.  
  817. static flag; flag = pev(id, pev_flags)
  818. if(get_pcvar_num(cvar_zombie_resist))
  819. {
  820. if(flag & FL_ONGROUND)
  821. {
  822. pev(id, pev_velocity, g_vecvel)
  823. g_brestorevel = true
  824. }
  825. }
  826.  
  827. if(g_zombie[id])
  828. {
  829. if(!(flag & FL_ONGROUND))
  830. {
  831. static Float:fallvelocity; pev(id, pev_flFallVelocity, fallvelocity)
  832. g_falling[id] = fallvelocity >= 350.0 ? true : false
  833. }
  834.  
  835. if(get_pcvar_num(cvar_zombie_regen))
  836. {
  837. static Float:health; pev(id, pev_health, health)
  838. static Float:zombiehp; zombiehp = float(get_pcvar_num(cvar_zombie_hp))
  839. if(health < zombiehp)
  840. {
  841. static Float:gametime; gametime = get_gametime()
  842. if(g_regendelay[id] < gametime)
  843. {
  844. set_pev(id, pev_health, health + 1.0)
  845. g_regendelay[id] = gametime + get_pcvar_float(cvar_regen_dly2)
  846. }
  847. }
  848. }
  849.  
  850. static ent; ent = g_modelent[id]
  851. if(pev_valid(ent))
  852. {
  853. if(!(pev(ent, pev_effects) & EF_NODRAW))
  854. {
  855. if(pev(id, pev_rendermode) != kRenderTransTexture)
  856. set_pev(id, pev_rendermode, kRenderTransTexture)
  857.  
  858. if(pev(id, pev_renderamt) != 0.0)
  859. set_pev(id, pev_renderamt, 0.0)
  860. }
  861. }
  862. }
  863. return FMRES_IGNORED
  864. }
  865.  
  866. public fwd_playerprethink_post(id)
  867. {
  868. if(!g_brestorevel)
  869. return FMRES_IGNORED
  870.  
  871. g_brestorevel = false
  872.  
  873. static flag; flag = pev(id, pev_flags)
  874. if(!(flag & FL_ONTRAIN))
  875. {
  876. static ent; ent = pev(id, pev_groundentity)
  877. if(pev_valid(ent) && (flag & FL_CONVEYOR))
  878. {
  879. static Float:vectemp[3]
  880. pev(id, pev_basevelocity, vectemp)
  881. xs_vec_add(g_vecvel, vectemp, g_vecvel)
  882. }
  883.  
  884. if(g_zombie[id])
  885. {
  886. static Float:health; pev(id, pev_health, health)
  887. static Float:kbhp; kbhp = float(get_pcvar_num(cvar_knockback_hp))
  888. if(get_pcvar_num(cvar_knockback_duck))
  889. {
  890. if(pev(id, pev_flags) & FL_DUCKING)
  891. set_pev(id, pev_velocity, g_vecvel)
  892. else if(health > kbhp)
  893. set_pev(id, pev_velocity, g_vecvel)
  894. }
  895. else if(health > kbhp) set_pev(id, pev_velocity, g_vecvel)
  896. }
  897. return FMRES_HANDLED
  898. }
  899. return FMRES_IGNORED
  900. }
  901.  
  902. public fwd_playerpostthink(id)
  903. {
  904. if(!is_user_alive(id))
  905. return FMRES_IGNORED
  906.  
  907. if(g_falling[id] && pev(id, pev_flags) & FL_ONGROUND)
  908. set_pev(id, pev_watertype, CONTENTS_WATER), g_falling[id] = false
  909.  
  910. if(get_pcvar_num(cvar_buytime))
  911. {
  912. if(g_buytime > get_gametime() && pev_valid(g_buyzone) && !g_zombie[id])
  913. dllfunc(DLLFunc_Touch, g_buyzone, id)
  914. }
  915. return FMRES_IGNORED
  916. }
  917.  
  918. public fwd_spawn(ent)
  919. {
  920. if(!pev_valid(ent))
  921. return FMRES_IGNORED
  922.  
  923. static objective_ents[][] =
  924. {
  925. "func_bomb_target", "info_bomb_target",
  926. "hostage_entity", "monster_scientist",
  927. "func_hostage_rescue", "info_hostage_rescue",
  928. "info_vip_start", "func_vip_safetyzone",
  929. "func_escapezone"
  930. }
  931.  
  932. static classname[32], i
  933. pev(ent, pev_classname, classname, 31)
  934.  
  935. if(equal(classname, "func_buyzone"))
  936. {
  937. set_pev(ent, pev_solid, SOLID_NOT)
  938. return FMRES_SUPERCEDE
  939. }
  940.  
  941. for(i = 0; i < sizeof objective_ents; ++i)
  942. {
  943. if(equal(classname, objective_ents[i]))
  944. {
  945. engfunc(EngFunc_RemoveEntity, ent)
  946. return FMRES_SUPERCEDE
  947. }
  948. }
  949. return FMRES_IGNORED
  950. }
  951.  
  952. public fwd_gamedescription()
  953. {
  954. static gamename[32]
  955. get_pcvar_string(cvar_gamedescription, gamename, 31)
  956. forward_return(FMV_STRING, gamename)
  957.  
  958. return FMRES_SUPERCEDE
  959. }
  960.  
  961. public fwd_traceline_post(Float:start[3], Float:end[3], nomonsters, id, trace)
  962. {
  963. if(!is_player_alive(id) || g_gamestarted)
  964. return FMRES_IGNORED
  965.  
  966. static target; target = get_tr2(trace, TR_pHit)
  967. if(is_player_alive(target))
  968. set_tr2(trace, TR_flFraction, 1.0)
  969.  
  970. return FMRES_IGNORED
  971. }
  972.  
  973. public fwd_tracehull_post(Float:start[3], Float:end[3], nomonsters, hull, id, trace)
  974. {
  975. if(!is_player_alive(id) || g_gamestarted)
  976. return FMRES_IGNORED
  977.  
  978. static target; target = get_tr2(trace, TR_pHit)
  979. if(is_player_alive(target))
  980. set_tr2(trace, TR_flFraction, 1.0)
  981.  
  982. return FMRES_IGNORED
  983. }
  984.  
  985. public fwd_createnamedentity(entclassname)
  986. {
  987. static classname[10]; engfunc(EngFunc_SzFromIndex, entclassname, classname, 9)
  988. return (classname[7] == 'c' && classname[8] == '4') ? FMRES_SUPERCEDE : FMRES_IGNORED
  989. }
  990.  
  991. public fwd_sys_error()
  992. destroyforwards()
  993.  
  994. public bacon_item_attachtoplayer_post(ent, id)
  995. {
  996. if(is_user_alive(id) && g_zombie[id])
  997. weapon_deployed(id)
  998. }
  999.  
  1000. public bacon_item_deploy_post(ent)
  1001. {
  1002. static id; id = pev(ent, pev_owner)
  1003. if(is_user_alive(id) && g_zombie[id])
  1004. weapon_deployed(id)
  1005. }
  1006.  
  1007. public weapon_deployed(id)
  1008. {
  1009. set_pev(id, pev_weaponmodel2, "")
  1010. if(g_usingknifemodel)
  1011. set_pev(id, pev_viewmodel2, g_zombie_claws)
  1012.  
  1013. set_pev(id, pev_maxspeed, get_pcvar_float(cvar_zombie_spd))
  1014. }
  1015.  
  1016. public bacon_use(ent, caller, activator, use_type, Float:value)
  1017. return (use_type == 2 && is_player_alive(caller) && g_zombie[caller]) ? HAM_SUPERCEDE : HAM_IGNORED
  1018.  
  1019. public bacon_takedamage(victim, inflictor, attacker, Float:damage, damagetype)
  1020. {
  1021. if(damagetype & DMG_GENERIC || victim == attacker || !is_user_alive(victim) || !is_user_connected(attacker))
  1022. return HAM_IGNORED
  1023.  
  1024. if(!g_gamestarted || (!g_zombie[victim] && !g_zombie[attacker]))
  1025. {
  1026. SetHamParamFloat(4, 0.0)
  1027. return HAM_HANDLED
  1028. }
  1029.  
  1030. static CsTeams:team[2]
  1031. team[0] = cs_get_user_team(attacker), team[1] = cs_get_user_team(victim)
  1032.  
  1033. if(team[0] == team[1])
  1034. return HAM_IGNORED
  1035.  
  1036. if(!g_zombie[attacker])
  1037. {
  1038. damage *= (damagetype & DMG_HEGRENADE) ? get_pcvar_float(cvar_hedmg_multi) : get_pcvar_float(cvar_zombie_def)
  1039. SetHamParamFloat(4, damage)
  1040.  
  1041. return HAM_HANDLED
  1042. }
  1043. else
  1044. {
  1045. if((damagetype & DMG_HEGRENADE) || get_user_weapon(attacker) != CSW_KNIFE)
  1046. SetHamParamFloat(4, 0.0)
  1047. else
  1048. {
  1049. static bool:infect; infect = allow_infection()
  1050. if(!get_pcvar_num(cvar_zombie_instant))
  1051. {
  1052. static Float:health; pev(victim, pev_health, health)
  1053. if(health > damage) infect = false
  1054. } else if(g_infecting) infect = false
  1055. g_victim[attacker] = infect ? victim : 0
  1056. damage *= get_pcvar_float(cvar_zombie_atk)
  1057. SetHamParamFloat(4, infect ? 0.0 : damage)
  1058. }
  1059. return HAM_HANDLED
  1060. }
  1061. return HAM_IGNORED
  1062. }
  1063.  
  1064. public bacon_spawn_post(id) if(is_user_alive(id))
  1065. {
  1066. if(g_zombie[id])
  1067. {
  1068. clear_clientdata(id), reset_user_model(id)
  1069. if(g_usingknifemodel)
  1070. {
  1071. static viewmodel[32]; pev(id, pev_viewmodel2, viewmodel, 31)
  1072. if(equal(viewmodel, g_zombie_claws)) set_pev(id, pev_viewmodel2, KNIFE_MODEL)
  1073. }
  1074. }
  1075. set_task(0.3, "task_spawned", TASKID_SPAWNDELAY + id)
  1076. }
  1077.  
  1078. public bacon_touch_weapon(ent, id)
  1079. return (is_player_alive(id) && g_zombie[id]) ? HAM_SUPERCEDE : HAM_IGNORED
  1080.  
  1081. public task_spawned(taskid)
  1082. {
  1083. static id; id = taskid - TASKID_SPAWNDELAY
  1084. if(is_user_alive(id))
  1085. {
  1086. if(pev(id, pev_body)) set_pev(id, pev_body, 0)
  1087.  
  1088. if(g_gamestarted)
  1089. {
  1090. static CsTeams:team; team = cs_get_user_team(id)
  1091. if(team == CS_TEAM_T) cs_set_user_team2(id, CS_TEAM_CT)
  1092. }
  1093.  
  1094. if(get_pcvar_num(cvar_weaponsmenu) && g_roundstarted && g_showmenu[id])
  1095. menu_display(id, g_equipmenu, 0)
  1096. }
  1097. }
  1098.  
  1099. public task_lights()
  1100. {
  1101. static light[2]
  1102. get_pcvar_string(cvar_lights, light, 1)
  1103. engfunc(EngFunc_LightStyle, 0, light)
  1104. }
  1105.  
  1106. public task_setzombie(taskid)
  1107. {
  1108. static id; id = taskid - TASKID_SETZOMBIE
  1109. set_zombie_attibutes(id)
  1110. }
  1111.  
  1112. public task_updatescore(params[])
  1113. {
  1114. if(!g_gamestarted) return
  1115.  
  1116. static attacker; attacker = params[0]
  1117. static victim; victim = params[1]
  1118.  
  1119. if(!is_user_connected(attacker))
  1120. return
  1121.  
  1122. static frags, deaths, team
  1123. frags = get_user_frags(attacker)
  1124. deaths = cs_get_user_deaths(attacker)
  1125. team = get_user_team(attacker)
  1126.  
  1127. static msg_scoreinfo
  1128. if(!msg_scoreinfo) msg_scoreinfo = get_user_msgid("ScoreInfo")
  1129.  
  1130. message_begin(MSG_ALL, msg_scoreinfo)
  1131. write_byte(attacker)
  1132. write_short(frags)
  1133. write_short(deaths)
  1134. write_short(0)
  1135. write_short(team)
  1136. message_end()
  1137.  
  1138. if(!is_user_connected(victim))
  1139. return
  1140.  
  1141. frags = get_user_frags(victim)
  1142. deaths = cs_get_user_deaths(victim)
  1143. team = get_user_team(victim)
  1144.  
  1145. message_begin(MSG_ALL, msg_scoreinfo)
  1146. write_byte(victim)
  1147. write_short(frags)
  1148. write_short(deaths)
  1149. write_short(0)
  1150. write_short(team)
  1151. message_end()
  1152. }
  1153.  
  1154. public task_stripngive(taskid)
  1155. {
  1156. static id; id = taskid - TASKID_STRIPNGIVE
  1157. if(is_user_alive(id))
  1158. {
  1159. fm_strip_user_weapons(id), reset_user_primary(id)
  1160. bacon_give_weapon(id, "weapon_knife")
  1161. }
  1162. }
  1163.  
  1164. public task_newround()
  1165. {
  1166. static players[32], num, i, id, newzombie
  1167. get_players(players, num, "a")
  1168.  
  1169. newzombie = players[_random(num)]
  1170. if(num > 2 && is_user_connected(g_zombieoftheround))
  1171. {
  1172. while(g_zombieoftheround == newzombie)
  1173. newzombie = players[_random(num)]
  1174. }
  1175. g_zombieoftheround = newzombie
  1176.  
  1177. for(i = 0; i < num; i++)
  1178. {
  1179. id = players[i]
  1180. client_print(id, print_chat, "%L %L", id, "SCAN_RESULTS", id, g_zombieoftheround == id ? "SCAN_INFECTED" : "SCAN_CLEAN")
  1181. }
  1182.  
  1183. if(get_pcvar_num(cvar_randomspawn))
  1184. randomly_place_everyone()
  1185. }
  1186.  
  1187. public task_startround()
  1188. {
  1189. static players[32], num, i, id, newzombie
  1190. get_players(players, num, "a")
  1191.  
  1192. if(num > 2 && !is_user_alive(g_zombieoftheround))
  1193. {
  1194. newzombie = players[_random(num)]
  1195. while(g_zombieoftheround == newzombie)
  1196. newzombie = players[_random(num)]
  1197.  
  1198. g_zombieoftheround = newzombie
  1199. }
  1200.  
  1201. if(!g_zombieoftheround) return
  1202.  
  1203. for(i = 0; i < num; i++)
  1204. {
  1205. id = players[i]
  1206. id == g_zombieoftheround ? infect_user(id) : cs_set_user_team2(id, CS_TEAM_CT)
  1207. }
  1208.  
  1209. static name[32]
  1210. get_user_name(g_zombieoftheround, name, 31)
  1211.  
  1212. set_hudmessage(_, _, _, _, _, 1)
  1213. show_hudmessage(0, "%L", LANG_PLAYER, "INFECTED_HUD", name)
  1214. client_print(0, print_chat, "%L", LANG_PLAYER, "INFECTED_TXT", name)
  1215.  
  1216. g_gamestarted = true, ExecuteForward(g_fwd_gamestart, g_fwd_result)
  1217. }
  1218.  
  1219. public task_balanceteam()
  1220. {
  1221. static players[CsTeams:3][32], count[CsTeams:3], i, id, CsTeams:team
  1222. get_players(players[CS_TEAM_UNASSIGNED], count[CS_TEAM_UNASSIGNED])
  1223. count[CS_TEAM_T] = 0, count[CS_TEAM_CT] = 0
  1224.  
  1225. for(i = 0; i < count[CS_TEAM_UNASSIGNED]; i++)
  1226. {
  1227. id = players[CS_TEAM_UNASSIGNED][i], team = cs_get_user_team(id)
  1228. if(team == CS_TEAM_T || team == CS_TEAM_CT)
  1229. players[team][count[team]++] = id
  1230. }
  1231.  
  1232. if(abs(count[CS_TEAM_T] - count[CS_TEAM_CT]) <= 1) return
  1233.  
  1234. static maxplayers; maxplayers = (count[CS_TEAM_T] + count[CS_TEAM_CT]) / 2
  1235. if(count[CS_TEAM_T] > maxplayers)
  1236. {
  1237. for(i = 0; i < (count[CS_TEAM_T] - maxplayers); i++)
  1238. cs_set_user_team(players[CS_TEAM_T][i], CS_TEAM_CT)
  1239. }
  1240. else
  1241. {
  1242. for(i = 0; i < (count[CS_TEAM_CT] - maxplayers); i++)
  1243. cs_set_user_team(players[CS_TEAM_CT][i], CS_TEAM_T)
  1244. }
  1245. }
  1246.  
  1247. public task_givenades(taskid)
  1248. {
  1249. static id, i; id = taskid - TASKID_GIVENADES
  1250. if(is_user_alive(id) && (strlen(g_grenades[0]) > 0))
  1251. {
  1252. for(i = 0; i < sizeof g_grenades; i++)
  1253. bacon_give_weapon(id, g_grenades[i])
  1254. }
  1255. }
  1256.  
  1257. public task_netclient_pdata(id) if(!g_netclient_pdata && is_user_connected(id))
  1258. {
  1259. if(!g_czero || !(pev(id, pev_flags) & FL_FAKECLIENT) || !get_pcvar_num(cvar_botquota))
  1260. pdata_init(id), g_netclient_pdata = 1
  1261. }
  1262.  
  1263. public task_botclient_pdata(id) if(!g_botclient_pdata && is_user_connected(id))
  1264. {
  1265. if((pev(id,pev_flags) & FL_FAKECLIENT) && get_pcvar_num(cvar_botquota))
  1266. pdata_init(id), g_botclient_pdata = 1
  1267. }
  1268.  
  1269. public infect_user(id)
  1270. {
  1271. if(!is_user_alive(id)) return
  1272.  
  1273. static _msg_scoreattrib
  1274. if(!_msg_scoreattrib) _msg_scoreattrib = get_user_msgid("ScoreAttrib")
  1275.  
  1276. message_begin(MSG_ALL, _msg_scoreattrib)
  1277. write_byte(id)
  1278. write_byte(0)
  1279. message_end()
  1280.  
  1281. static sound; sound = _random(sizeof g_scream_sounds)
  1282. emit_sound(id, CHAN_STATIC, g_scream_sounds[sound], VOL_NORM, ATTN_NONE, 0, PITCH_NORM)
  1283.  
  1284. menu_cancel(id), cs_set_user_team2(id, CS_TEAM_T)
  1285. set_task(0.1, "task_setzombie", TASKID_SETZOMBIE + id)
  1286. }
  1287.  
  1288. public menu_equip(id, menu, item)
  1289. {
  1290. if(item < 0) return PLUGIN_CONTINUE
  1291.  
  1292. static cmd[2], name[64], access, callback, key
  1293. menu_item_getinfo(menu, item, access, cmd, 1, name, 63, callback), key = str_to_num(cmd)
  1294.  
  1295. switch(key)
  1296. {
  1297. case 1: menu_display(id, g_primmenu, 0)
  1298. case 2: (g_weapons[id][0] > 0) ? equipweapon(id, EQUIP_ALL) : menu_display(id, g_primmenu, 0)
  1299. case 3:
  1300. {
  1301. if(g_weapons[id][0] > 0)
  1302. {
  1303. g_showmenu[id] = false
  1304. client_print(id, print_chat, "%L", id, "MENU_CMDENABLE")
  1305. equipweapon(id, EQUIP_ALL)
  1306. }
  1307. else menu_display(id, g_primmenu, 0)
  1308. }
  1309. }
  1310. return PLUGIN_HANDLED
  1311. }
  1312.  
  1313. public menu_prim(id, menu, item)
  1314. {
  1315. if(item < 0) return PLUGIN_HANDLED
  1316.  
  1317. static cmd[6], name[64], access, callback
  1318. menu_item_getinfo(menu, item, access, cmd, 5, name, 63, callback)
  1319.  
  1320. g_weapons[id][0] = str_to_num(cmd)
  1321. equipweapon(id, EQUIP_PRI)
  1322. menu_display(id, g_secmenu, 0)
  1323.  
  1324. return PLUGIN_HANDLED
  1325. }
  1326.  
  1327. public menu_sec(id, menu, item)
  1328. {
  1329. if(item < 0) return PLUGIN_HANDLED
  1330.  
  1331. static cmd[6], name[64], access, callback
  1332. menu_item_getinfo(menu, item, access, cmd, 5, name, 63, callback)
  1333.  
  1334. g_weapons[id][1] = str_to_num(cmd)
  1335. equipweapon(id, EQUIP_SEC)
  1336. equipweapon(id, EQUIP_GREN)
  1337.  
  1338. return PLUGIN_HANDLED
  1339. }
  1340.  
  1341. public randomly_place_everyone()
  1342. {
  1343. if(g_spawncount <= 0) return
  1344.  
  1345. static players[32], num, id, i, CsTeams:team
  1346. get_players(players, num, "a")
  1347.  
  1348. for(i = 0; i < num; i++)
  1349. {
  1350. id = players[i]
  1351. team = cs_get_user_team(id)
  1352.  
  1353. if(team != CS_TEAM_T && team != CS_TEAM_CT || pev(id, pev_iuser1))
  1354. continue
  1355.  
  1356. static spawn_index
  1357. spawn_index = _random(g_spawncount)
  1358.  
  1359. static Float:spawndata[3]
  1360. spawndata[0] = g_spawns[spawn_index][0]
  1361. spawndata[1] = g_spawns[spawn_index][1]
  1362. spawndata[2] = g_spawns[spawn_index][2]
  1363.  
  1364. if(!fm_is_hull_vacant(spawndata, HULL_HUMAN))
  1365. {
  1366. static i
  1367. for(i = spawn_index + 1; i != spawn_index; i++)
  1368. {
  1369. if(i >= g_spawncount) i = 0
  1370.  
  1371. spawndata[0] = g_spawns[i][0]
  1372. spawndata[1] = g_spawns[i][1]
  1373. spawndata[2] = g_spawns[i][2]
  1374.  
  1375. if(fm_is_hull_vacant(spawndata, HULL_HUMAN))
  1376. {
  1377. spawn_index = i
  1378. break
  1379. }
  1380. }
  1381. }
  1382.  
  1383. spawndata[0] = g_spawns[spawn_index][0]
  1384. spawndata[1] = g_spawns[spawn_index][1]
  1385. spawndata[2] = g_spawns[spawn_index][2]
  1386. engfunc(EngFunc_SetOrigin, id, spawndata)
  1387.  
  1388. spawndata[0] = g_spawns[spawn_index][3]
  1389. spawndata[1] = g_spawns[spawn_index][4]
  1390. spawndata[2] = g_spawns[spawn_index][5]
  1391. set_pev(id, pev_angles, spawndata)
  1392.  
  1393. spawndata[0] = g_spawns[spawn_index][6]
  1394. spawndata[1] = g_spawns[spawn_index][7]
  1395. spawndata[2] = g_spawns[spawn_index][8]
  1396. set_pev(id, pev_v_angle, spawndata)
  1397.  
  1398. set_pev(id, pev_fixangle, 1)
  1399. }
  1400. }
  1401.  
  1402. public get_spawnpoints()
  1403. {
  1404. static configdir[32]; get_configsdir(configdir, 31)
  1405. static mapname[32]; get_mapname(mapname, 31)
  1406.  
  1407. static csdmfile[64], line[64], data[10][6]
  1408. formatex(csdmfile, 63, "%s/csdm/%s.spawns.cfg", configdir, mapname)
  1409.  
  1410. if(file_exists(csdmfile))
  1411. {
  1412. static file; file = fopen(csdmfile, "rt")
  1413. while(file && !feof(file))
  1414. {
  1415. fgets(file, line, 63)
  1416. if(!line[0] || str_count(line,' ') < 2) continue
  1417.  
  1418. parse(line, data[0], 5, data[1], 5, data[2], 5, data[3], 5, data[4], 5, data[5], 5, data[6], 5, data[7], 5, data[8], 5, data[9], 5)
  1419.  
  1420. g_spawns[g_spawncount][0] = floatstr(data[0]), g_spawns[g_spawncount][1] = floatstr(data[1])
  1421. g_spawns[g_spawncount][2] = floatstr(data[2]), g_spawns[g_spawncount][3] = floatstr(data[3])
  1422. g_spawns[g_spawncount][4] = floatstr(data[4]), g_spawns[g_spawncount][5] = floatstr(data[5])
  1423. g_spawns[g_spawncount][6] = floatstr(data[7]), g_spawns[g_spawncount][7] = floatstr(data[8])
  1424. g_spawns[g_spawncount][8] = floatstr(data[9])
  1425.  
  1426. if(g_spawncount++ >= MAX_SPAWNS) break
  1427. }
  1428. if(file) fclose(file)
  1429. }
  1430. }
  1431.  
  1432. public native_is_user_zombie(plugin, params)
  1433. {
  1434. if(params != 1) return 0
  1435.  
  1436. static index; index = get_param(1)
  1437. if(!index) return 0
  1438.  
  1439. return g_zombie[index] == true ? 1 : 0
  1440. }
  1441.  
  1442. public native_infect_user(plugin, params)
  1443. {
  1444. if(params != 1) return 0
  1445.  
  1446. static index; index = get_param(1)
  1447. if(is_user_alive(index) && allow_infection() && g_gamestarted)
  1448. {
  1449. infect_user(index)
  1450. return 1
  1451. }
  1452. return 0
  1453. }
  1454.  
  1455. public native_is_user_firstzombie(plugin, params)
  1456. {
  1457. if(params != 1) return 0
  1458.  
  1459. static index; index = get_param(1)
  1460. return index == g_zombieoftheround ? 1 : 0
  1461. }
  1462.  
  1463. public native_first_zombie(plugin)
  1464. return g_zombieoftheround
  1465.  
  1466. public native_game_started(plugin)
  1467. return g_gamestarted
  1468.  
  1469. stock bool:fm_is_hull_vacant(const Float:origin[3], hull)
  1470. {
  1471. static tr; tr = 0; engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, tr)
  1472. return (!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen)) ? true : false
  1473. }
  1474.  
  1475. stock fm_set_kvd(entity, const key[], const value[], const classname[] = "")
  1476. {
  1477. set_kvd(0, KV_ClassName, classname), set_kvd(0, KV_KeyName, key)
  1478. set_kvd(0, KV_Value, value), set_kvd(0, KV_fHandled, 0)
  1479.  
  1480. return dllfunc(DLLFunc_KeyValue, entity, 0)
  1481. }
  1482.  
  1483. stock fm_strip_user_weapons(index)
  1484. {
  1485. static stripent
  1486. if(!pev_valid(stripent))
  1487. {
  1488. stripent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
  1489. dllfunc(DLLFunc_Spawn, stripent)
  1490. set_pev(stripent, pev_solid, SOLID_NOT)
  1491. }
  1492. dllfunc(DLLFunc_Use, stripent, index)
  1493.  
  1494. return 1
  1495. }
  1496.  
  1497. stock fm_set_entity_visibility(index, visible = 1)
  1498. set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
  1499.  
  1500. stock fm_find_ent_by_owner(index, const classname[], owner)
  1501. {
  1502. static ent; ent = index
  1503. while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) && pev(ent, pev_owner) != owner) {}
  1504.  
  1505. return ent
  1506. }
  1507.  
  1508. stock bacon_give_weapon(index, weapon[])
  1509. {
  1510. if(!equal(weapon,"weapon_", 7)) return 0
  1511.  
  1512. static ent; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, weapon))
  1513. if(!pev_valid(ent)) return 0
  1514.  
  1515. set_pev(ent, pev_spawnflags, SF_NORESPAWN)
  1516. dllfunc(DLLFunc_Spawn, ent)
  1517.  
  1518. if(!ExecuteHamB(Ham_AddPlayerItem, index, ent))
  1519. {
  1520. if(pev_valid(ent)) set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME)
  1521. return 0
  1522. }
  1523. ExecuteHamB(Ham_Item_AttachToPlayer, ent, index)
  1524.  
  1525. return 1
  1526. }
  1527.  
  1528. stock cs_set_user_team2(index, {CsTeams,_}:team, update = 1)
  1529. {
  1530. set_pdata_int(index, OFFSET_TEAM, _:team)
  1531. set_pev(index, pev_team, _:team)
  1532.  
  1533. if(update)
  1534. {
  1535. static _msg_teaminfo; if(!_msg_teaminfo) _msg_teaminfo = get_user_msgid("TeamInfo")
  1536. static teaminfo[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
  1537.  
  1538. message_begin(MSG_ALL, _msg_teaminfo)
  1539. write_byte(index)
  1540. write_string(teaminfo[_:team])
  1541. message_end()
  1542. }
  1543. return 1
  1544. }
  1545.  
  1546. stock cs_get_user_armor2(index, &CsArmorType:armortype)
  1547. {
  1548. static armorvalue; pev(index, pev_armorvalue, armorvalue)
  1549. armortype = CsArmorType:get_pdata_int(index, OFFSET_ARMOR)
  1550.  
  1551. return armorvalue
  1552. }
  1553.  
  1554. stock cs_set_user_armor2(index, armorvalue, CsArmorType:armortype)
  1555. {
  1556. set_pev(index, pev_armorvalue, armorvalue)
  1557. set_pdata_int(index, OFFSET_ARMOR, _:armortype)
  1558.  
  1559. return 1
  1560. }
  1561.  
  1562. stock get_weapon_maxclip(weapon)
  1563. {
  1564. static ammo
  1565. switch(weapon)
  1566. {
  1567. case CSW_P228: ammo = 13
  1568. case CSW_GALI: ammo = 35
  1569. case CSW_USP: ammo = 12
  1570. case CSW_M249: ammo = 100
  1571. case CSW_M3: ammo = 8
  1572. case CSW_P90: ammo = 50
  1573. case CSW_SCOUT, CSW_AWP: ammo = 10
  1574. case CSW_XM1014, CSW_DEAGLE: ammo = 7
  1575. case CSW_UMP45, CSW_FAMAS: ammo = 25
  1576. case CSW_FIVESEVEN, CSW_GLOCK18,
  1577. CSW_G3SG1: ammo = 20
  1578. case CSW_KNIFE, CSW_FLASHBANG,
  1579. CSW_SMOKEGRENADE, CSW_HEGRENADE,
  1580. CSW_C4: ammo = 0
  1581. case CSW_SG552, CSW_AK47,
  1582. CSW_MP5NAVY, CSW_M4A1,
  1583. CSW_MAC10, CSW_SG550,
  1584. CSW_AUG, CSW_ELITE, CSW_TMP: ammo = 30
  1585. default: ammo = 0
  1586. }
  1587. return ammo
  1588. }
  1589.  
  1590. stock get_user_bpammo(index, weapon)
  1591. {
  1592. static offset
  1593. switch(weapon)
  1594. {
  1595. case CSW_AWP: offset = OFFSET_AMMO_AWP
  1596. case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = OFFSET_AMMO_SCOUT
  1597. case CSW_M249: offset = OFFSET_AMMO_M249
  1598. case CSW_FAMAS, CSW_M4A1, CSW_AUG,
  1599. CSW_SG550, CSW_GALI, CSW_SG552: offset = OFFSET_AMMO_FAMAS
  1600. case CSW_M3, CSW_XM1014: offset = OFFSET_AMMO_M3
  1601. case CSW_USP, CSW_UMP45, CSW_MAC10: offset = OFFSET_AMMO_USP
  1602. case CSW_FIVESEVEN, CSW_P90: offset = OFFSET_AMMO_FIVESEVEN
  1603. case CSW_DEAGLE: offset = OFFSET_AMMO_DEAGLE
  1604. case CSW_P228: offset = OFFSET_AMMO_P228
  1605. case CSW_GLOCK18, CSW_TMP, CSW_ELITE,
  1606. CSW_MP5NAVY: offset = OFFSET_AMMO_GLOCK18
  1607. default: offset = 0
  1608. }
  1609. return offset ? get_pdata_int(index, offset) : 0
  1610. }
  1611.  
  1612. stock set_user_bpammo(index, weapon, amount)
  1613. {
  1614. static offset
  1615. switch(weapon)
  1616. {
  1617. case CSW_AWP: offset = OFFSET_AMMO_AWP
  1618. case CSW_SCOUT, CSW_AK47, CSW_G3SG1: offset = OFFSET_AMMO_SCOUT
  1619. case CSW_M249: offset = OFFSET_AMMO_M249
  1620. case CSW_FAMAS, CSW_M4A1, CSW_AUG,
  1621. CSW_SG550, CSW_GALI, CSW_SG552: offset = OFFSET_AMMO_FAMAS
  1622. case CSW_M3, CSW_XM1014: offset = OFFSET_AMMO_M3
  1623. case CSW_USP, CSW_UMP45, CSW_MAC10: offset = OFFSET_AMMO_USP
  1624. case CSW_FIVESEVEN, CSW_P90: offset = OFFSET_AMMO_FIVESEVEN
  1625. case CSW_DEAGLE: offset = OFFSET_AMMO_DEAGLE
  1626. case CSW_P228: offset = OFFSET_AMMO_P228
  1627. case CSW_GLOCK18, CSW_TMP, CSW_ELITE,
  1628. CSW_MP5NAVY: offset = OFFSET_AMMO_GLOCK18
  1629. default: offset = 0
  1630. }
  1631.  
  1632. if(offset) set_pdata_int(index, offset, amount)
  1633.  
  1634. return 1
  1635. }
  1636.  
  1637. stock set_user_nvg(index)
  1638. {
  1639. static nvg; nvg = get_pdata_int(index, OFFSET_NVG)
  1640. if(!(nvg & HAS_NVG))
  1641. {
  1642. nvg |= HAS_NVG
  1643. set_pdata_int(index, OFFSET_NVG, nvg)
  1644. }
  1645. return 1
  1646. }
  1647.  
  1648. stock str_count(str[], searchchar)
  1649. {
  1650. static maxlen; maxlen = strlen(str)
  1651. static i, count; count = 0
  1652.  
  1653. for(i = 0; i <= maxlen; i++) if(str[i] == searchchar)
  1654. count++
  1655.  
  1656. return count
  1657. }
  1658.  
  1659. stock reset_user_model(index)
  1660. {
  1661. set_pev(index, pev_rendermode, kRenderNormal)
  1662. set_pev(index, pev_renderamt, 0.0)
  1663.  
  1664. if(pev_valid(g_modelent[index]))
  1665. {
  1666. fm_set_entity_visibility(g_modelent[index], 0)
  1667. set_pev(g_modelent[index], pev_movetype, MOVETYPE_NONE)
  1668. set_pev(g_modelent[index], pev_aiment, 0)
  1669. }
  1670. }
  1671.  
  1672. stock set_zombie_attibutes(index)
  1673. {
  1674. if(!is_user_alive(index)) return
  1675.  
  1676. cs_set_user_armor2(index, 0, CS_ARMOR_NONE), set_pev(index, pev_body, 0), g_zombie[index] = true
  1677.  
  1678. if(!task_exists(TASKID_STRIPNGIVE + index))
  1679. set_task(0.2, "task_stripngive", TASKID_STRIPNGIVE + index)
  1680.  
  1681. if(g_usingplayermodel)
  1682. {
  1683. if(!pev_valid(g_modelent[index]))
  1684. {
  1685. static ent; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  1686. if(pev_valid(ent))
  1687. {
  1688. engfunc(EngFunc_SetModel, ent, g_zombie_model)
  1689. set_pev(ent, pev_classname, MODEL_CLASSNAME)
  1690. set_pev(ent, pev_movetype, MOVETYPE_FOLLOW)
  1691. set_pev(ent, pev_aiment, index)
  1692. set_pev(ent, pev_owner, index)
  1693.  
  1694. g_modelent[index] = ent
  1695. }
  1696. }
  1697. else
  1698. {
  1699. fm_set_entity_visibility(g_modelent[index], 1)
  1700. set_pev(g_modelent[index], pev_movetype, MOVETYPE_FOLLOW)
  1701. set_pev(g_modelent[index], pev_aiment, index)
  1702. }
  1703. }
  1704.  
  1705. static Float:health; health = float(get_pcvar_num(cvar_zombie_hp))
  1706. static Float:bonus; bonus = float(get_pcvar_num(cvar_hpbonus))
  1707. set_pev(index, pev_health, g_zombieoftheround == index ? health + bonus : health)
  1708.  
  1709. set_user_nvg(index)
  1710. if(get_pcvar_num(cvar_autonvg)) engclient_cmd(index, "nightvision")
  1711.  
  1712. static effects; effects = pev(index, pev_effects)
  1713. if(effects & EF_DIMLIGHT)
  1714. {
  1715. static msg_flashlight
  1716. if(!msg_flashlight) msg_flashlight = get_user_msgid("Flashlight")
  1717.  
  1718. message_begin(MSG_ONE, msg_flashlight, _, index)
  1719. write_byte(0)
  1720. write_byte(100)
  1721. message_end()
  1722.  
  1723. set_pev(index, pev_effects, effects & ~EF_DIMLIGHT)
  1724. }
  1725. ExecuteForward(g_fwd_infect2, g_fwd_result, index)
  1726. }
  1727.  
  1728. stock bool:allow_infection()
  1729. {
  1730. static index, count[2], maxzombies; count[0] = 0, count[1] = 0
  1731. for(index = 1; index <= g_maxplayers; index++)
  1732. {
  1733. if(is_user_connected(index) && g_zombie[index]) count[0]++
  1734. else if(is_user_alive(index)) count[1]++
  1735. }
  1736.  
  1737. maxzombies = clamp(get_pcvar_num(cvar_maxzombies), 1, 31)
  1738. return (count[0] < maxzombies && count[1] > 1) ? true : false
  1739. }
  1740.  
  1741. stock randomly_pick_zombie()
  1742. {
  1743. static index, players[2][32], data[4]
  1744. data[0] = 0, data[1] = 0, data[2] = 0, data[3] = 0
  1745.  
  1746. for(index = 1; index <= g_maxplayers; index++)
  1747. {
  1748. if(!is_user_alive(index)) continue
  1749.  
  1750. if(g_zombie[index]) data[0]++, players[0][data[2]++] = index
  1751. else data[1]++, players[1][data[3]++] = index
  1752. }
  1753.  
  1754. if(data[0] > 1 && data[1] < 1) return players[0][_random(data[2])]
  1755. return (data[0] < 1 && data[1] > 1) ? players[1][_random(data[3])] : 0
  1756. }
  1757.  
  1758. stock equipweapon(id, weapon)
  1759. {
  1760. if(!is_user_alive(id)) return
  1761.  
  1762. static weaponid
  1763.  
  1764. if(weapon & EQUIP_PRI)
  1765. {
  1766. fm_strip_user_weapons(id), bacon_give_weapon(id, "weapon_knife")
  1767. bacon_give_weapon(id, g_primweaponnames[g_weapons[id][0]])
  1768.  
  1769. weaponid = get_weaponid(g_primweaponnames[g_weapons[id][0]])
  1770. set_user_bpammo(id, weaponid, MAX_AMMO)
  1771. }
  1772.  
  1773. if(weapon & EQUIP_SEC)
  1774. {
  1775. bacon_give_weapon(id, g_secweaponnames[g_weapons[id][1]])
  1776.  
  1777. weaponid = get_weaponid(g_secweaponnames[g_weapons[id][1]])
  1778. set_user_bpammo(id, weaponid, MAX_AMMO)
  1779. }
  1780.  
  1781. if(weapon & EQUIP_GREN)
  1782. set_task(0.1, "task_givenades", id + TASKID_GIVENADES)
  1783. }