Advertisement
Guest User

NST_Zombie_Mod3.sma

a guest
Sep 2nd, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 113.26 KB | None | 0 0
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4. #include <cstrike>
  5. #include <fakemeta>
  6. #include <hamsandwich>
  7. #include <xs>
  8. #include <engine>
  9.  
  10. #include <nst_player>
  11. #include <nst_wpn>
  12.  
  13.  
  14. #define PLUGIN "NST Zombie Mod3"
  15. #define VERSION "1.0"
  16. #define AUTHOR "NST"
  17.  
  18. // Setting File Name
  19. new const SETTING_FILE[] = "nst_zombie_mod3.ini"
  20. new const CVAR_FILE[] = "nst_zombie_mod3.cfg"
  21. new const LANG_FILE[] = "nst_zombie.txt"
  22. new const ZOMBIE_MOD = 1
  23.  
  24. // Limiters for stuff not worth making dynamic arrays out of (increase if needed)
  25. const MAX_STATS_SAVED = 64
  26. const MAX_SUPPLYBOX = 100
  27. const MAX_SPAWNS = 128
  28. new const SPAWNS_URL[] = "%s/csdm/%s.spawns.cfg"
  29. new const SPAWNS_BOX_URL[] = "%s/nstzb/%s.supplybox_spawns.cfg"
  30.  
  31. // Cvar
  32. new g_maxplayers, g_freezetime, g_endround, g_newround, g_fwSpawn, g_score_human, g_score_zombie, g_zombie_count, g_startcount, g_rount_count
  33.  
  34. new cvar_delay, cvar_wait_time, cvar_glowshell_time, cvar_lighting, cvar_thunder, cvar_randspawn, cvar_remove_weapons_newround,
  35. cvar_time_show_spr, cvar_damage_nade, cvar_damage_grenade, cvar_time_attack_zombie, cvar_nvg_zombie_color[3], cvar_nvg_zombie_give, cvar_nvg_zombie_alpha, cvar_nvg_zombie_size,
  36. cvar_bot_uclip, cvar_recoil, cvar_level_damage, cvar_zombie_weak, cvar_zombie_flash, cvar_zombie_weak_dmg, cvar_zombie_weak_color[3],
  37. cvar_drop_weapons_infected, cvar_icon_deplay, cvar_icon, cvar_icon_light, cvar_icon_size, cvar_level_deplay
  38.  
  39. // available spawn points counter
  40. new g_spawnCount, g_spawnCount2
  41. new Float:g_spawns[MAX_SPAWNS][3], Float:g_spawns2[MAX_SPAWNS][3] // spawn points data
  42. new g_spawnCount_box, g_spawnCount2_box
  43. new Float:g_spawns_box[MAX_SPAWNS][3], Float:g_spawns2_box[MAX_SPAWNS][3] // spawn points data
  44.  
  45. // natives
  46. new g_fwUserInfected, g_fwDummyResult, g_fwUserDamage
  47.  
  48. // Knock back
  49. new cvar_knockback, cvar_knockbackdamage, cvar_knockbackpower, cvar_knockbackzvel,
  50. Float:kb_weapon_power[31] = {-1.0, ... }
  51.  
  52. // Player
  53. new g_level[33], g_zombie[33], g_hero[33], g_evolution[33], g_dmg_attack[33], g_start_health[33], g_star_armor[33],
  54. g_buyammo[33], g_restore_health[33], g_team[33], g_respawning[33], g_zombieclass[33], g_zombie_die[33],
  55. g_victim_time_attack[33], g_victim_damage[33], g_nvg[33], g_supplybox_num, g_supplybox_wait[33], g_zombie_weak[33],
  56. g_level_effect[33], Float:g_icon_delay[33], Float:g_level_delay[33]
  57.  
  58. // Msg
  59. new g_msgBarTime, g_msgDeathMsg, g_msgScoreAttrib, g_msgStatusIcon, g_msgScoreInfo, g_HudMsg_Health, g_HudMsg_Power,
  60. g_msgScenario, g_msgDamage, g_HudMsg_ScoreMatch, g_msgHostagePos, g_msgHostageK, g_msgFlashBat, g_msgNVGToggle, g_msgHudTextArgs,
  61. g_msgWeapPickup, g_msgHealth, g_msgAmmoPickup, g_msgTextMsg, g_msgSendAudio, g_msgTeamScore, g_msgScreenFade, g_msgClCorpse
  62.  
  63. // Customization vars
  64. new Array:lights_thunder, g_lights_i, g_lights_cycle[64], g_lights_cycle_len, Array:sound_thunder, id_sprites_levelup,
  65. g_ambience_rain, g_ambience_snow, g_ambience_fog, g_fog_color[12], g_fog_density[10], g_sky_enable, sprites_effects_levelup[64],
  66. Array:g_sky_names, Array:g_objective_ents, Array:weapons_pri, Array:weapons_pri_name, sound_zombie_count[64], g_blockbuy,
  67. Array:weapons_sec, Array:weapons_sec_name, Array:weapons_nade, Array:sound_zombie_start, Array:supplybox_item, supplybox_count,
  68. supplybox_ent[MAX_SUPPLYBOX], restore_health_spr[64], restore_health_idspr, Array:sound_zombie_attack,
  69. zombie_respawn_spr[64], zombie_respawn_idspr, Array:hero_weapons, sound_win_zombie[64], sound_win_human[64], Array:sound_zombie_hitwall, Array:sound_zombie_swing,
  70. Array:supplybox_models, Array:sound_human_death, Array:sound_female_death, Array:sound_zombie_coming, Array:sound_zombie_comeback, sound_levelup[64]
  71. // class zombie var
  72. new class_count, Array:zombie_name, Array:zombie_gravity, Array:zombie_speed, Array:zombie_knockback, Array:zombie_modelindex,
  73. Array:zombie_sound_death1, Array:zombie_sound_death2, Array:zombie_sound_hurt1, Array:zombie_sound_hurt2, Array:zombie_wpnmodel,
  74. Array:zombie_modelindex_host, Array:zombie_modelindex_origin, Array:zombie_viewmodel_host, Array:zombie_viewmodel_origin,
  75. Array:zombie_sound_heal, Array:zombie_sound_evolution, Array:zombiebom_viewmodel, Array:zombie_sex
  76.  
  77. // Config Value
  78. const MAX_LEVEL_HUMAN = 10
  79. const MAX_LEVEL_ZOMBIE = 3
  80. const MAX_EVOLUTION = 30
  81.  
  82. new MONEY_START, RESPAWN_TIME_WAIT, ZOMBIE_DAMAGE_LEVEL
  83. new MAX_HEALTH_ZOMBIE_RANDOM, MIN_HEALTH_ZOMBIE_RANDOM, LEVEL_ZOMBIE_RANDOM
  84. new HUMAN_HEALTH, HUMAN_ARMOR, Float:HUMAN_GRAVITY
  85. new MIN_HEALTH_ZOMBIE, MIN_ARMOR_ZOMBIE
  86. new RESTORE_HEALTH_TIME, RESTORE_HEALTH_DMG_LV1, RESTORE_HEALTH_DMG_LV2
  87. new Float:SUPPLYBOX_TIME, SUPPLYBOX_NUM, SUPPLYBOX_CLASSNAME[] = "nst_zb3_supplybox", SUPPLYBOX_SOUND_PICKUP[64], SUPPLYBOX_SOUND_DROP[64], SUPPLYBOX_MAX,
  88. SUPPLYBOX_ICON_SPR[64], SUPPLYBOX_ICON_IDSPR, SUPPLYBOX_TOTAL_IN_TIME
  89. new ZOMBIEBOM_MODEL[64], Float:ZOMBIEBOM_RADIUS, Float:ZOMBIEBOM_POWER, ZOMBIEBOM_SPRITES_EXP[64], ZOMBIEBOM_SOUND_EXP[64], ZOMBIEBOM_IDSPRITES_EXP,
  90. ZOMBIEBOM_P_MODEL[64], ZOMBIEBOM_W_MODEL[64]
  91.  
  92. // config level zombie
  93. new ZB_LV2_HEALTH, ZB_LV2_ARMOR
  94. new ZB_LV3_HEALTH, ZB_LV3_ARMOR
  95.  
  96. // config hero
  97. new HERO_MODEL[64], HERO_HEALTH, HERO_ARMOR, Float:HERO_GRAVITY, HERO_ICON_SPR[64], HERO_ICON_IDSPR
  98.  
  99. // Zombie mod
  100. enum
  101. {
  102.     MODE_NONE = 0,
  103.     MODE_RESPAWN,
  104.     MODE_INFECTION
  105. }
  106. // Customization file sections
  107. enum
  108. {
  109.     SECTION_NONE = 0,
  110.     SECTION_CONFIG_VALUE,
  111.     SECTION_HERO,
  112.     SECTION_RESTORE_HEALTH,
  113.     SECTION_SUPPLYBOX,
  114.     SECTION_ZOMBIEBOM,
  115.     SECTION_SOUNDS,
  116.     SECTION_SPRITES,
  117.     SECTION_MENUWEAPONS,
  118.     SECTION_WEATHER_EFFECTS,
  119.     SECTION_SKY,
  120.     SECTION_LIGHTNING,
  121.     SECTION_KNOCKBACK,
  122.     SECTION_OBJECTIVE_ENTS
  123. }
  124. // Task offsets
  125. enum (+= 100)
  126. {
  127.     TASK_TEAM = 2000,
  128.     TASK_MAKEZOMBIE,
  129.     TASK_MAKEHUMAN,
  130.     TASK_WELLCOME,
  131.     TASK_GLOWSHELL,
  132.     TASK_THUNDER_PRE,
  133.     TASK_THUNDER,
  134.     TASK_SPAWN,
  135.     TASK_MENUWPN,
  136.     TASK_SUPPLYBOX,
  137.     TASK_SUPPLYBOX_MODEL,
  138.     TASK_SUPPLYBOX_HELP,
  139.     TASK_SUPPLYBOX_WAIT,
  140.     TASK_ZOMBIE_RESPAWN,
  141.     TASK_ZOMBIE_RESPAWN_EF,
  142.     TASK_STATUSICON,
  143.     TASK_NVISION
  144. }
  145. // IDs inside tasks
  146. #define ID_TEAM (taskid - TASK_TEAM)
  147. #define ID_GLOWSHELL (taskid - TASK_GLOWSHELL)
  148. #define ID_SPAWN (taskid - TASK_SPAWN)
  149. #define ID_MENUWPN (taskid - TASK_MENUWPN)
  150. #define ID_SUPPLYBOX_WAIT (taskid - TASK_SUPPLYBOX_WAIT)
  151. #define ID_ZOMBIE_RESPAWN (taskid - TASK_ZOMBIE_RESPAWN)
  152. #define ID_ZOMBIE_RESPAWN_EF (taskid - TASK_ZOMBIE_RESPAWN_EF)
  153. #define ID_STATUSICON (taskid - TASK_STATUSICON)
  154. #define ID_MAKEHUMAN (taskid - TASK_MAKEHUMAN)
  155. #define ID_NVISION (taskid - TASK_NVISION)
  156.  
  157. // CS Teams
  158. enum
  159. {
  160.     FM_CS_TEAM_UNASSIGNED = 0,
  161.     FM_CS_TEAM_T,
  162.     FM_CS_TEAM_CT,
  163.     FM_CS_TEAM_SPECTATOR
  164. }
  165. // type item weapons
  166. enum
  167. {
  168.     NSTZB_ITEM_WPNDEFAULT = 1,
  169.     NSTZB_ITEM_NSTWPN,
  170.     NSTZB_ITEM_AMMONADE
  171. }
  172.  
  173. // CS Player PData Offsets (win32)
  174. const OFFSET_PAINSHOCK = 108 // ConnorMcLeod
  175. const OFFSET_CSTEAMS = 114
  176. const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
  177. const IMPULSE_FLASHLIGHT = 100
  178. const OFFSET_FLASHLIGHT_BATTERY = 244
  179. const DMG_HEGRENADE = (1<<24)
  180.  
  181. // Weapon bitsums
  182. 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)
  183. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  184. const NADE_WEAPONS_BIT_SUM = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG))
  185. const NOCLIP_WPN_BS = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
  186.  
  187. // Weapon entity names
  188. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  189.             "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  190.             "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  191.             "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  192.             "weapon_ak47", "weapon_knife", "weapon_p90" }
  193. // Max Clip for weapons
  194. new const MAXCLIP[] = { -1, 13, -1, 10, -1, 7, -1, 30, 30, -1, 30, 20, 25, 30, 35, 25, 12, 20,
  195.             10, 30, 100, 8, 30, 30, 20, -1, 7, 30, 30, -1, 50 }
  196. // Ammo IDs for weapons
  197. new const AMMOID[] = { -1, 9, -1, 2, 12, 5, 14, 6, 4, 13, 10, 7, 6, 4, 4, 4, 6, 10,
  198.             1, 10, 3, 5, 4, 10, 2, 11, 8, 4, 2, -1, 7 }
  199.            
  200. // block cmd buy
  201. #define MAXMENUPOS 34
  202. new g_Aliases[MAXMENUPOS][] = {"usp","glock","deagle","p228","elites","fn57","m3","xm1014","mp5","tmp","p90","mac10","ump45","ak47","galil","famas","sg552","m4a1","aug","scout","awp","g3sg1","sg550","m249","vest","vesthelm","flash","hegren","sgren","defuser","nvgs","shield","primammo","secammo"}
  203. new g_Aliases2[MAXMENUPOS][] = {"km45","9x19mm","nighthawk","228compact","elites","fiveseven","12gauge","autoshotgun","smg","mp","c90","mac10","ump45","cv47","defender","clarion","krieg552","m4a1","bullpup","scout","magnum","d3au1","krieg550","m249","vest","vesthelm","flash","hegren","sgren","defuser","nvgs","shield","primammo","secammo"}
  204.  
  205. // HACK: pev_ field used to store additional ammo on weapons
  206. const PEV_ADDITIONAL_AMMO = pev_iuser1
  207.  
  208. // pev_ field used to store custom nade types and their values
  209. const PEV_NADE_TYPE = pev_flTimeStepSound
  210. const NADE_TYPE_INFECTION = 1111
  211.  
  212. // X Damage value
  213. new const XDAMAGE[11][] = {
  214.     "1.0",
  215.     "1.1",
  216.     "1.2",
  217.     "1.3",
  218.     "1.4",
  219.     "1.5",
  220.     "1.6",
  221.     "1.7",
  222.     "1.8",
  223.     "1.9",
  224.     "2.0"
  225. }
  226. // X Recoil value
  227. new const XRECOIL[11][] = {
  228.     "1.0",
  229.     "0.9",
  230.     "0.8",
  231.     "0.7",
  232.     "0.6",
  233.     "0.5",
  234.     "0.4",
  235.     "0.3",
  236.     "0.2",
  237.     "0.1",
  238.     "0.0"
  239. }
  240. new WpnName[32]
  241. new Float:cl_pushangle[33][3]
  242.  
  243. // HUD messages
  244. const Float:HUD_SCORE_X = -1.0
  245. const Float:HUD_SCORE_Y = 0.01
  246. const Float:HUD_HEALTH_X = 0.015
  247. const Float:HUD_HEALTH_Y = 0.92
  248. const Float:HUD_POWER_X = -0.357
  249. const Float:HUD_POWER_Y = 0.907
  250.  
  251. // CS Sound
  252. new const sound_buyammo[] = "items/9mmclip1.wav"
  253. new const sound_nvg[2][] = {"items/nvg_off.wav", "items/nvg_on.wav"}
  254.  
  255. // Some constants
  256. const FFADE_IN = 0x0000
  257. const FFADE_STAYOUT = 0x0004
  258. const UNIT_SECOND = (1<<12)
  259.  
  260. new g_hamczbots, cvar_botquota
  261.  
  262.  
  263. /*================================================================================
  264.  [Natives, Precache and Init]
  265. =================================================================================*/
  266. public plugin_natives()
  267. {
  268.     // Player natives
  269.     register_native("nst_zb_get_mod", "native_get_mod", 1)
  270.     register_native("nst_zb_get_user_sex", "native_get_user_sex", 1)
  271.     register_native("nst_zb_get_user_start_health", "native_get_user_start_health", 1)
  272.     register_native("nst_zb_get_user_level", "native_get_user_level", 1)
  273.     register_native("nst_zb_get_user_zombie", "native_get_user_zombie", 1)
  274.     register_native("nst_zb_get_user_hero", "native_get_user_hero", 1)
  275.     register_native("nst_zb_get_user_zombie_class", "native_get_user_zombie_class", 1)
  276.     register_native("nst_zb_zombie_respawn", "native_zombie_respawn", 1)
  277.     register_native("nst_zb_remove_weapons_newround", "native_remove_weapons_newround", 1)
  278.     register_native("nst_zb_human_kill_zombie", "native_human_kill_zombie", 1)
  279.     register_native("nst_zb_color_saytext", "natives_color_saytext", 1)
  280.     register_native("nst_zb_get_user_damage_attack", "natives_get_user_damage_attack", 1)
  281.     register_native("nst_zb_set_user_damage_attack", "natives_set_user_damage_attack", 1)
  282.     register_native("nst_zb_get_maxlevel_human", "natives_get_maxlevel_human", 1)
  283.     register_native("nst_zb_get_weapons_ammo", "natives_get_weapons_ammo", 1)
  284.     register_native("nst_zb_get_take_damage", "native_get_take_damage", 1)
  285.     register_native("nst_zb_get_damage_nade", "native_get_damage_nade", 1)
  286.  
  287.    
  288.     // External additions natives
  289.     register_native("nst_zb3_register_zombie_class", "native_register_zombie_class", 1)
  290.     register_native("nst_zbu_register_zombie_class", "native_novalue", 1)
  291.     register_native("nst_zbs_register_zombie_class", "native_novalue", 1)
  292.  
  293. }  
  294. public plugin_init()
  295. {
  296.     register_plugin(PLUGIN, VERSION, AUTHOR)
  297.    
  298.     // Language files
  299.     register_dictionary(LANG_FILE)
  300.    
  301.     // Events
  302.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  303.     register_logevent("logevent_round_start",2, "1=Round_Start")
  304.     register_logevent("logevent_round_end", 2, "1=Round_End")
  305.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  306.     register_event("DeathMsg", "Death", "a")
  307.  
  308.     // HAM Forwards
  309.     RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  310.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  311.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  312.     RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
  313.     RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
  314.     RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
  315.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  316.     for(new i=1; i<=CSW_P90; i++)
  317.     {
  318.         if( !(NOCLIP_WPN_BS & (1<<i)) && get_weaponname(i, WpnName, charsmax(WpnName)) )
  319.         {
  320.            
  321.             RegisterHam(Ham_Weapon_PrimaryAttack, WpnName, "fw_primary_attack")
  322.             RegisterHam(Ham_Weapon_PrimaryAttack, WpnName, "fw_primary_attack_post",1)
  323.         }
  324.     }
  325.    
  326.    
  327.     // FM Forwards
  328.     register_forward(FM_CmdStart, "fw_CmdStart")
  329.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  330.     register_forward(FM_EmitSound, "fw_EmitSound")
  331.     register_forward(FM_SetModel, "fw_SetModel")
  332.     register_forward(FM_Touch, "fw_Touch")
  333.     unregister_forward(FM_Spawn, g_fwSpawn)
  334.    
  335.     // Message IDs
  336.     g_msgBarTime = get_user_msgid("BarTime")
  337.     g_msgDeathMsg = get_user_msgid("DeathMsg")
  338.     g_msgScoreAttrib = get_user_msgid("ScoreAttrib")
  339.     g_msgStatusIcon = get_user_msgid("StatusIcon")
  340.     g_msgScoreInfo = get_user_msgid("ScoreInfo")
  341.     g_msgScenario = get_user_msgid("Scenario")
  342.     g_msgDamage = get_user_msgid("Damage")
  343.     g_msgHostagePos = get_user_msgid("HostagePos")
  344.     g_msgHostageK = get_user_msgid("HostageK")
  345.     g_msgFlashBat = get_user_msgid("FlashBat")
  346.     g_msgNVGToggle = get_user_msgid("NVGToggle")
  347.     g_msgWeapPickup = get_user_msgid("WeapPickup")
  348.     g_msgHealth = get_user_msgid("Health")
  349.     g_msgAmmoPickup = get_user_msgid("AmmoPickup")
  350.     g_msgTextMsg = get_user_msgid("TextMsg")
  351.     g_msgSendAudio = get_user_msgid("SendAudio")
  352.     g_msgTeamScore = get_user_msgid("TeamScore")
  353.     g_msgScreenFade = get_user_msgid("ScreenFade");
  354.     g_msgHudTextArgs = get_user_msgid("HudTextArgs")
  355.     g_msgClCorpse = get_user_msgid("ClCorpse")
  356.    
  357.     // Message hooks
  358.     register_message(g_msgHealth, "message_health")
  359.     register_message(g_msgFlashBat, "message_flashbat")
  360.     register_message(g_msgNVGToggle, "message_nvgtoggle")
  361.     register_message(g_msgWeapPickup, "message_weappickup")
  362.     register_message(g_msgAmmoPickup, "message_ammopickup")
  363.     register_message(g_msgScenario, "message_scenario")
  364.     register_message(g_msgHostagePos, "message_hostagepos")
  365.     register_message(g_msgTextMsg, "message_textmsg")
  366.     register_message(g_msgSendAudio, "message_sendaudio")
  367.     register_message(g_msgTeamScore, "message_teamscore")
  368.     register_message(g_msgHudTextArgs, "message_hudtextargs")
  369.     register_message(g_msgClCorpse, "message_msgClCorpse")
  370.    
  371.     // Block msg
  372.     //set_msg_block(g_msgClCorpse, BLOCK_SET)
  373.  
  374.     // Admin commands
  375.     register_concmd("nst_zb3_respawn_zombie", "cmd_respawn_zombie", _, "<target> - Respawn someone as Zombie", 0)
  376.     register_concmd("nst_zb3_respawn_human", "cmd_respawn_human", _, "<target> - Respawn someone as Human", 0)
  377.     register_concmd("nst_zb3_respawn_hero", "cmd_respawn_hero", _, "<target> - Respawn someone as Hero", 0)
  378.     //register_concmd("qq", "qq")
  379.    
  380.     // clie ncommands
  381.     register_clcmd("buyammo1","cmd_buy_ammo")
  382.     register_clcmd("buyammo2","cmd_buy_ammo")
  383.     register_clcmd("primammo","cmd_buy_ammo")
  384.     register_clcmd("secammo","cmd_buy_ammo")
  385.     register_clcmd("nightvision", "cmd_nightvision")
  386.     register_clcmd("cl_autobuy", "cmd_block")
  387.     register_clcmd("cl_rebuy", "cmd_block")
  388.    
  389.     // CVARS Game
  390.     cvar_lighting = register_cvar("nst_zb3_light", "e")
  391.     cvar_thunder = register_cvar("nst_zb3_thunderclap", "90")
  392.     cvar_delay = register_cvar("nst_zb3_delay", "20")
  393.     cvar_glowshell_time = register_cvar("nst_zb3_glowshell_time", "10")
  394.     cvar_randspawn = register_cvar("nst_zb3_random_spawn", "1")
  395.     cvar_remove_weapons_newround = register_cvar("nst_zb3_remove_weapons_newround", "1")
  396.     cvar_time_show_spr = register_cvar("nst_zb3_time_show_spr", "2.0")
  397.     cvar_damage_nade = register_cvar("nst_zb3_damage_nade", "200")
  398.     cvar_damage_grenade = register_cvar("nst_zb3_damage_grenade", "300")
  399.     cvar_time_attack_zombie = register_cvar("nst_zb3_time_attack_zombie", "3")
  400.     cvar_bot_uclip = register_cvar("nst_zb3_bot_uclip", "2")
  401.     cvar_recoil = register_cvar("nst_zb3_level_recoil", "0")
  402.     cvar_level_damage = register_cvar("nst_zb3_level_damage", "0")
  403.     cvar_drop_weapons_infected = register_cvar("nst_zb3_drop_weapons_infected", "0")
  404.    
  405.     // Cvar Zombie Weak
  406.     cvar_zombie_weak = register_cvar("nst_zb3_zombie_weak", "1")
  407.     cvar_zombie_weak_dmg = register_cvar("nst_zb3_zombie_weak_dmg", "1000")
  408.     cvar_zombie_flash = register_cvar("nst_zb3_zombie_weak_flash", "3")
  409.     cvar_zombie_weak_color[0] = register_cvar("nst_zb3_zombie_weak_color_r", "255")
  410.     cvar_zombie_weak_color[1] = register_cvar("nst_zb3_zombie_weak_color_g", "255")
  411.     cvar_zombie_weak_color[2] = register_cvar("nst_zb3_zombie_weak_color_b", "255")
  412.    
  413.     // CVARS - Flashlight and Nightvision
  414.     cvar_nvg_zombie_give = register_cvar("nst_zb3_nvg_zombie_give", "1")
  415.     cvar_nvg_zombie_alpha = register_cvar("nst_zb3_nvg_zombie_alpha", "70")
  416.     cvar_nvg_zombie_size = register_cvar("nst_zb3_nvg_zombie_size", "150")
  417.     cvar_nvg_zombie_color[0] = register_cvar("nst_zb3_nvg_zombie_color_r", "253")
  418.     cvar_nvg_zombie_color[1] = register_cvar("nst_zb3_nvg_zombie_color_g", "110")
  419.     cvar_nvg_zombie_color[2] = register_cvar("nst_zb3_nvg_zombie_color_b", "110")
  420.  
  421.     // CVARS - Knockback
  422.     cvar_knockback = register_cvar("nst_zb3_knockback", "1")
  423.     cvar_knockbackdamage = register_cvar("nst_zb3_knockback_damage", "0")
  424.     cvar_knockbackpower = register_cvar("nst_zb3_knockback_power", "1")
  425.     cvar_knockbackzvel = register_cvar("nst_zb3_knockback_zvel", "0")
  426.    
  427.     // CVARS - Other
  428.     cvar_botquota = get_cvar_pointer("bot_quota")
  429.     cvar_icon = register_cvar("nst_zb3_icon", "1")
  430.     cvar_icon_deplay = register_cvar("nst_zb3_icon_deplay", "0.03")
  431.     cvar_icon_light = register_cvar("nst_zb3_icon_light", "100")
  432.     cvar_icon_size = register_cvar("nst_zb3_icon_size", "2")
  433.     cvar_level_deplay = register_cvar("nst_zb3_level_deplay", "0.1")
  434.    
  435.     // Custom Forwards
  436.     g_fwUserInfected = CreateMultiForward("nst_zb_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
  437.     g_fwUserDamage = CreateMultiForward("nst_zb_human_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  438.    
  439.     // Collect random spawn points
  440.     load_spawns()
  441.     load_spawns_box()
  442.    
  443.     // Set a random skybox?
  444.     if (g_sky_enable)
  445.     {
  446.         new sky[32]
  447.         ArrayGetString(g_sky_names, random_num(0, ArraySize(g_sky_names) - 1), sky, charsmax(sky))
  448.         set_cvar_string("sv_skyname", sky)
  449.     }
  450.    
  451.     // Disable sky lighting so it doesn't mess with our custom lighting
  452.     set_cvar_num("sv_skycolor_r", 0)
  453.     set_cvar_num("sv_skycolor_g", 0)
  454.     set_cvar_num("sv_skycolor_b", 0)
  455.    
  456.     // Create the HUD Sync Objects
  457.     g_HudMsg_Health = CreateHudSyncObj()
  458.     g_HudMsg_ScoreMatch = CreateHudSyncObj()
  459.     g_HudMsg_Power = CreateHudSyncObj()
  460.    
  461.     // Get Max Players
  462.     g_maxplayers = get_maxplayers()
  463.    
  464.     // Task
  465.     set_task(2.0,"radar_scan",_,_,_,"b")
  466.     set_task(1.0, "show_hud_client", _, _, _, "b")
  467. }
  468.  
  469. public plugin_precache()
  470. {
  471.     // Initialize a few dynamically sized arrays (alright, maybe more than just a few...)
  472.     lights_thunder = ArrayCreate(32, 1)
  473.     sound_thunder = ArrayCreate(64, 1)
  474.     g_sky_names = ArrayCreate(32, 1)
  475.     g_objective_ents = ArrayCreate(32, 1)
  476.     weapons_pri = ArrayCreate(64, 1)
  477.     weapons_pri_name = ArrayCreate(64, 1)
  478.     weapons_sec = ArrayCreate(64, 1)
  479.     weapons_sec_name = ArrayCreate(64, 1)
  480.     weapons_nade = ArrayCreate(64, 1)
  481.     supplybox_item = ArrayCreate(64, 1)
  482.     hero_weapons = ArrayCreate(64, 1)
  483.     supplybox_models = ArrayCreate(64, 1)
  484.     sound_human_death = ArrayCreate(64, 1)
  485.     sound_female_death = ArrayCreate(64, 1)
  486.     sound_zombie_coming = ArrayCreate(64, 1)
  487.     sound_zombie_comeback = ArrayCreate(64, 1)
  488.     sound_zombie_attack = ArrayCreate(64, 1)
  489.     sound_zombie_hitwall = ArrayCreate(64, 1)
  490.     sound_zombie_swing = ArrayCreate(64, 1)
  491.     sound_zombie_start = ArrayCreate(64, 1)
  492.    
  493.     // class zombie
  494.     zombie_name = ArrayCreate(64, 1)
  495.     zombie_gravity = ArrayCreate(1, 1)
  496.     zombie_speed = ArrayCreate(1, 1)
  497.     zombie_knockback = ArrayCreate(1, 1)
  498.     zombie_sound_death1 = ArrayCreate(64, 1)
  499.     zombie_sound_death2 = ArrayCreate(64, 1)
  500.     zombie_sound_hurt1 = ArrayCreate(64, 1)
  501.     zombie_sound_hurt2 = ArrayCreate(64, 1)
  502.     zombie_viewmodel_host = ArrayCreate(64, 1)
  503.     zombie_viewmodel_origin = ArrayCreate(64, 1)
  504.     zombie_modelindex_host = ArrayCreate(1, 1)
  505.     zombie_modelindex_origin = ArrayCreate(1, 1)
  506.     zombie_wpnmodel = ArrayCreate(64, 1)
  507.     zombie_sound_heal = ArrayCreate(64, 1)
  508.     zombie_sound_evolution = ArrayCreate(64, 1)
  509.     zombiebom_viewmodel = ArrayCreate(64, 1)
  510.     zombie_sex = ArrayCreate(1, 1)
  511.     zombie_modelindex = ArrayCreate(1, 1)
  512.    
  513.     // Load customization data
  514.     load_customization_from_files()
  515.    
  516.     // CS sounds (just in case)
  517.     engfunc(EngFunc_PrecacheSound, sound_buyammo)
  518.  
  519.    
  520.     new i, buffer[100]
  521.    
  522.     // Model hero
  523.     format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", HERO_MODEL, HERO_MODEL)
  524.     engfunc(EngFunc_PrecacheModel, buffer)
  525.  
  526.     // Custom sounds
  527.     for (i = 0; i < ArraySize(sound_thunder); i++)
  528.     {
  529.         ArrayGetString(sound_thunder, i, buffer, charsmax(buffer))
  530.         //engfunc(EngFunc_PrecacheSound, buffer)
  531.     }
  532.     for (i = 0; i < ArraySize(sound_zombie_coming); i++)
  533.     {
  534.         ArrayGetString(sound_zombie_coming, i, buffer, charsmax(buffer))
  535.         //engfunc(EngFunc_PrecacheSound, buffer)
  536.     }
  537.     for (i = 0; i < ArraySize(sound_zombie_comeback); i++)
  538.     {
  539.         ArrayGetString(sound_zombie_comeback, i, buffer, charsmax(buffer))
  540.         engfunc(EngFunc_PrecacheSound, buffer)
  541.     }
  542.     for (i = 0; i < ArraySize(sound_human_death); i++)
  543.     {
  544.         ArrayGetString(sound_human_death, i, buffer, charsmax(buffer))
  545.         engfunc(EngFunc_PrecacheSound, buffer)
  546.     }
  547.     for (i = 0; i < ArraySize(sound_female_death); i++)
  548.     {
  549.         ArrayGetString(sound_female_death, i, buffer, charsmax(buffer))
  550.         engfunc(EngFunc_PrecacheSound, buffer)
  551.     }
  552.     for (i = 0; i < ArraySize(sound_zombie_attack); i++)
  553.     {
  554.         ArrayGetString(sound_zombie_attack, i, buffer, charsmax(buffer))
  555.         engfunc(EngFunc_PrecacheSound, buffer)
  556.     }
  557.     for (i = 0; i < ArraySize(sound_zombie_hitwall); i++)
  558.     {
  559.         ArrayGetString(sound_zombie_hitwall, i, buffer, charsmax(buffer))
  560.         engfunc(EngFunc_PrecacheSound, buffer)
  561.     }
  562.     for (i = 0; i < ArraySize(sound_zombie_swing); i++)
  563.     {
  564.         ArrayGetString(sound_zombie_swing, i, buffer, charsmax(buffer))
  565.         engfunc(EngFunc_PrecacheSound, buffer)
  566.     }
  567.     for (i = 0; i < ArraySize(sound_zombie_start); i++)
  568.     {
  569.         ArrayGetString(sound_zombie_start, i, buffer, charsmax(buffer))
  570.         //engfunc(EngFunc_PrecacheSound, buffer)
  571.     }
  572.     for (new i = 1; i <= 10; i++)
  573.     {
  574.         new sound_count[64]
  575.         format(sound_count, sizeof sound_count - 1, sound_zombie_count, i)
  576.         //engfunc(EngFunc_PrecacheSound, sound_count)
  577.     }
  578.     precache_sound(SUPPLYBOX_SOUND_PICKUP)
  579.     //precache_sound(SUPPLYBOX_SOUND_DROP)
  580.     //precache_sound(sound_win_zombie)
  581.     //precache_sound(sound_win_human)
  582.    
  583.     // Custom models
  584.     for (i = 0; i < ArraySize(supplybox_models); i++)
  585.     {
  586.         ArrayGetString(supplybox_models, i, buffer, charsmax(buffer))
  587.         engfunc(EngFunc_PrecacheModel, buffer)
  588.     }
  589.    
  590.     // Custom sprites
  591.     id_sprites_levelup = precache_model(sprites_effects_levelup)
  592.     restore_health_idspr = precache_model(restore_health_spr)
  593.     zombie_respawn_idspr = precache_model(zombie_respawn_spr)
  594.     SUPPLYBOX_ICON_IDSPR = precache_model(SUPPLYBOX_ICON_SPR)
  595.     HERO_ICON_IDSPR = precache_model(HERO_ICON_SPR)
  596.    
  597.     // zombie bomb
  598.     engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_P_MODEL)
  599.     engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_W_MODEL)
  600.     ZOMBIEBOM_IDSPRITES_EXP = engfunc(EngFunc_PrecacheModel, ZOMBIEBOM_SPRITES_EXP)
  601.     engfunc(EngFunc_PrecacheSound, ZOMBIEBOM_SOUND_EXP)
  602.    
  603.     new ent
  604.     // Fake Hostage (to force round ending)
  605.     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"))
  606.     if (pev_valid(ent))
  607.     {
  608.         engfunc(EngFunc_SetOrigin, ent, Float:{8192.0,8192.0,8192.0})
  609.         dllfunc(DLLFunc_Spawn, ent)
  610.     }
  611.  
  612.     // Weather/ambience effects
  613.     if (g_ambience_fog)
  614.     {
  615.         ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
  616.         if (pev_valid(ent))
  617.         {
  618.             fm_set_kvd(ent, "density", g_fog_density, "env_fog")
  619.             fm_set_kvd(ent, "rendercolor", g_fog_color, "env_fog")
  620.         }
  621.     }
  622.     if (g_ambience_rain) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_rain"))
  623.     if (g_ambience_snow) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_snow"))
  624.  
  625.     // Prevent some entities from spawning
  626.     g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  627.    
  628. }
  629. public plugin_cfg()
  630. {
  631.     // Get configs dir
  632.     new cfgdir[32]
  633.     get_configsdir(cfgdir, charsmax(cfgdir))
  634.    
  635.     // Execute config file (zombieplague.cfg)
  636.     server_cmd("exec %s/%s", cfgdir, CVAR_FILE)
  637.  
  638.     // Lighting task
  639.     set_task(5.0, "lighting_effects", _, _, _, "b")
  640.    
  641.     // Cache CVARs after configs are loaded / call roundstart manually
  642.     set_task(0.5, "event_round_start")
  643.     set_task(0.5, "logevent_round_start")
  644. }
  645. /*================================================================================
  646.  [Main Events]
  647. =================================================================================*/
  648. // Event Round Start
  649. public event_round_start()
  650. {
  651.     // set value
  652.     g_freezetime = 1
  653.     g_newround = 1
  654.     g_endround = 0
  655.     supplybox_count = 0
  656.     if (g_startcount) g_rount_count += 1
  657.    
  658.     if (g_rount_count)
  659.     {
  660.         // play sound start
  661.         static sound[64]
  662.         ArrayGetString(sound_zombie_start, random(ArraySize(sound_zombie_start)), sound, charsmax(sound))
  663.         PlaySound(0, sound)
  664.        
  665.         // reset value
  666.         for (new id = 1; id <= g_maxplayers; id++)
  667.         {
  668.             if (!is_user_connected(id)) continue;
  669.            
  670.             if (g_zombie[id]) reset_wpnmodel(id)
  671.             reset_value(id)
  672.    
  673.             // menu wpn
  674.             if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
  675.             set_task(0.5, "menu_wpn", id+TASK_MENUWPN)
  676.         }
  677.    
  678.         // wellcome
  679.         if (task_exists(TASK_WELLCOME)) remove_task(TASK_WELLCOME)
  680.         set_task(5.0, "wellcome", TASK_WELLCOME)
  681.     }
  682. }
  683. // Log Event Round Start
  684. public logevent_round_start()
  685. {
  686.     // remove freezetime
  687.     g_freezetime = 0
  688.  
  689.     if (g_rount_count)
  690.     {
  691.         // start zombie count
  692.         g_zombie_count = get_pcvar_num(cvar_delay)
  693.         task_zombie_count()
  694.         if (task_exists(TASK_MAKEZOMBIE)) remove_task(TASK_MAKEZOMBIE)
  695.         set_task(1.0, "task_zombie_count", TASK_MAKEZOMBIE, _, _, "b")
  696.     }
  697. }
  698. public task_zombie_count()
  699. {
  700.     new message[64], sound_count[64]
  701.     if (!g_zombie_count)
  702.     {
  703.         g_newround = 0
  704.         make_random_zombie()
  705.         format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_APPEAR")
  706.         remove_task(TASK_MAKEZOMBIE)
  707.     }
  708.     else
  709.     {
  710.         if (g_zombie_count<=10)
  711.         {
  712.             format(sound_count, charsmax(sound_count), sound_zombie_count, g_zombie_count)
  713.             PlaySound(0, sound_count)
  714.         }
  715.         format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_COUNT", g_zombie_count)
  716.     }
  717.     SendCenterText(0, message)
  718.    
  719.     g_zombie_count -= 1
  720. }
  721. // Log Event Round End
  722. public logevent_round_end()
  723. {
  724.     // set score team
  725.     if (g_rount_count)
  726.     {
  727.         new humans = GetTotalPlayer(4, 1)
  728.         new zombie = GetTotalPlayer(3, 1)
  729.         new message[64]
  730.         if (humans)
  731.         {
  732.             g_score_human += 1
  733.             PlaySound(0, sound_win_human)
  734.             format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_HUMAN")
  735.         }
  736.         else if (zombie && !humans)
  737.         {
  738.             g_score_zombie += 1
  739.             PlaySound(0, sound_win_zombie)
  740.             format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_ZOMBIE")
  741.         }
  742.         else
  743.         {
  744.             format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_WIN_NO_ONE")
  745.         }
  746.        
  747.         // show hud msg
  748.         SendCenterText(0, message)
  749.  
  750.         // show score match
  751.         //ShowScoreMatch()
  752.     }
  753.    
  754.     // reset
  755.     g_endround = 1
  756.     reset_teams()
  757.     remove_supplybox()
  758. }
  759. public wellcome()
  760. {
  761.     color_saytext(0, "^x03-=[^x04NST Zombie Mod3^x03]=-")
  762.     if (task_exists(TASK_WELLCOME)) remove_task(TASK_WELLCOME)
  763.     set_task(60.0, "wellcome", TASK_WELLCOME)
  764. }
  765.  
  766. /*================================================================================
  767.  [Clien Public]
  768. =================================================================================*/
  769. // Client joins the game
  770. public client_putinserver(id)
  771. {
  772.     // reset value
  773.     reset_value(id)
  774.    
  775.     // Reg Ham Zbot
  776.     if (is_user_bot(id) && !g_hamczbots && cvar_botquota)
  777.     {
  778.         set_task(0.1, "register_ham_czbots", id)
  779.     }
  780. }
  781. // Client leaving
  782. public fw_ClientDisconnect(id)
  783. {
  784.     reset_value(id)
  785. }
  786. // make human if client joins match
  787. public TaskMakeHuman(taskid)
  788. {
  789.     new id = ID_MAKEHUMAN
  790.    
  791.     // make_human
  792.     make_human(id)
  793.  
  794.     // show menu weapons
  795.     if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
  796.     set_task(0.1, "menu_wpn", id+TASK_MENUWPN)
  797.    
  798.     // give nade
  799.     give_nade(id)
  800.    
  801.     //remove task
  802.     if (task_exists(id+TASK_MAKEHUMAN)) remove_task(id+TASK_MAKEHUMAN)
  803. }
  804. public client_command(id)
  805. {
  806.     new arg[13]
  807.     if (read_argv(0, arg, 12) > 11)
  808.     {
  809.         return PLUGIN_CONTINUE
  810.     }
  811.    
  812.     // block cmd buy
  813.     if (g_blockbuy)
  814.     {
  815.         new a = 0
  816.         do {
  817.             if (equali(g_Aliases[a], arg) || equali(g_Aliases2[a], arg))
  818.             {
  819.                 return PLUGIN_HANDLED
  820.             }
  821.         } while(++a < MAXMENUPOS)
  822.     }
  823.  
  824.    
  825.     return PLUGIN_CONTINUE
  826. }
  827. public cmd_block(id)
  828. {
  829.     return PLUGIN_CONTINUE
  830. }
  831. public Death()
  832. {
  833.     new killer = read_data(1)
  834.     new victim = read_data(2)  
  835.     new headshot = read_data(3)
  836.    
  837.     new weaponid = get_user_weapon(killer)
  838.     // Zombie Die
  839.     if (g_zombie[victim])
  840.     {
  841.         human_kill_zombie(killer, victim, weaponid)
  842.     }
  843.    
  844.     // reset value victim
  845.     turn_off_nvg(victim)
  846.     fm_set_rendering(victim)
  847.     //hide_level(victim)
  848. }
  849. public client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
  850. {
  851.     // check
  852.     if (attacker == victim || g_zombie[attacker] || !g_zombie[victim]) return;
  853.  
  854.     // get damage attack
  855.     new damage_victim = get_user_health(victim)+damage
  856.     new damage_fire = min(damage_victim, damage)
  857.    
  858.     // update level of human for damage
  859.     UpdateLevelHumanDamage(attacker, damage_fire)
  860.  
  861.     // damage victim
  862.     UpdateEvolutionDamage(victim, damage_fire)
  863.  
  864.     //client_print(attacker, print_chat, "%i", g_dmg_attack[attacker])
  865. }
  866.  
  867.  
  868. /*================================================================================
  869.  [Main Forwards]
  870. =================================================================================*/
  871. public client_PostThink(id)
  872. {
  873.     show_hud_icon(id)
  874.     show_player_level(id)
  875. }
  876. // Entity Spawn Forward
  877. public fw_Spawn(entity)
  878. {
  879.     // Invalid entity
  880.     if (!pev_valid(entity)) return FMRES_IGNORED;
  881.    
  882.     // Get classname
  883.     new classname[32], objective[32], size = ArraySize(g_objective_ents)
  884.     pev(entity, pev_classname, classname, charsmax(classname))
  885.    
  886.     // Check whether it needs to be removed
  887.     for (new i = 0; i < size; i++)
  888.     {
  889.         ArrayGetString(g_objective_ents, i, objective, charsmax(objective))
  890.        
  891.         if (equal(classname, objective))
  892.         {
  893.             engfunc(EngFunc_RemoveEntity, entity)
  894.             return FMRES_SUPERCEDE;
  895.         }
  896.     }
  897.    
  898.     return FMRES_IGNORED;
  899. }
  900. // Ham Player Spawn Post Forward
  901. public fw_PlayerSpawn_Post(id)
  902. {
  903.     // Not alive or didn't join a team yet
  904.     if (!is_user_alive(id) || !fm_cs_get_user_team(id))
  905.         return;
  906.  
  907.     // Remove previous tasks
  908.     if (task_exists(id+TASK_SPAWN)) remove_task(id+TASK_SPAWN)
  909.     if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
  910.    
  911.     // remove glow
  912.     fm_set_rendering(id)
  913.    
  914.     // remove weapons in new round
  915.     if (get_pcvar_num(cvar_remove_weapons_newround) && !is_user_bot(id))
  916.     {
  917.         fm_strip_user_weapons(id)
  918.         fm_give_item(id, "weapon_knife")
  919.     }
  920.    
  921.     // Spawn at a random location?
  922.     if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
  923.    
  924.     // set money
  925.     fm_cs_set_user_money(id, MONEY_START)
  926. }
  927. // Ham Take Damage Forward
  928. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  929. {
  930.     // Non-player damage or self damage
  931.     if (victim == attacker)
  932.         return HAM_IGNORED;
  933.  
  934.     // Fix bug player not connect
  935.     if (!is_user_connected(victim) || !is_user_connected(attacker))
  936.         return HAM_IGNORED;
  937.  
  938.     // Remove Damage when Freetime
  939.     if (g_newround || g_endround)
  940.         return HAM_SUPERCEDE;
  941.        
  942.     // attacker is zombie
  943.     if (g_zombie[attacker] && !g_zombie[victim])
  944.     {
  945.         // Fix Bug zombie has weapons # knife
  946.         if (get_user_weapon(attacker) != CSW_KNIFE) return HAM_SUPERCEDE;
  947.        
  948.         // infection
  949.         new human_alive = GetTotalPlayer(4, 1)
  950.         if (human_alive>1)
  951.         {
  952.             zombie_infection_human(attacker,  victim)
  953.             return HAM_SUPERCEDE;
  954.         }
  955.         else
  956.         {
  957.             SetHamParamFloat(4, float(get_user_health(victim)*2))
  958.             return HAM_IGNORED
  959.         }
  960.     }
  961.     // attacker is human
  962.     else if (!g_zombie[attacker] && g_zombie[victim])
  963.     {
  964.         // remove restore health of zombie
  965.         g_restore_health[victim] = 0
  966.        
  967.         // he xdamage
  968.         if ( (damage_type & DMG_HEGRENADE) && !g_zombie[attacker] )
  969.         {
  970.             new Float: hedmg = get_pcvar_float(cvar_damage_nade)+get_pcvar_float(cvar_damage_grenade)
  971.             if (damage < hedmg) damage += hedmg
  972.         }
  973.         // X Damage
  974.         else if (g_level[attacker])
  975.         {
  976.             new Float: xdmg = str_to_float(XDAMAGE[g_level[attacker]])
  977.             damage *= xdmg
  978.         }
  979.        
  980.         SetHamParamFloat(4, damage)
  981.         return HAM_IGNORED
  982.     }
  983.     // fix bug
  984.     else return HAM_SUPERCEDE;
  985.  
  986.    
  987.     return HAM_IGNORED
  988. }
  989. // Ham Weapon Touch Forward
  990. public fw_TouchWeapon(weapon, id)
  991. {
  992.     // Not a player
  993.     if (!is_user_connected(id))
  994.         return HAM_IGNORED;
  995.    
  996.     // Dont pickup weapons if zombie or survivor (+PODBot MM fix)
  997.     if (g_zombie[id])
  998.         return HAM_SUPERCEDE;
  999.    
  1000.     return HAM_IGNORED;
  1001. }
  1002. // FW CmdStart
  1003. public fw_CmdStart(id, uc_handle, seed)
  1004. {          
  1005.     if (!is_user_alive(id))
  1006.     {
  1007.         //hide_level(id)
  1008.         return FMRES_IGNORED
  1009.     }
  1010.  
  1011.     // restore health
  1012.     zombie_restore_health(id)
  1013.  
  1014.     // zombie weak
  1015.     zombie_weak(id)
  1016.  
  1017.     //client_print(id, print_chat, "L[%i] E[%i]", g_level[id], g_evolution[id])
  1018.     return FMRES_IGNORED
  1019. }
  1020. public fw_PlayerPreThink(id)
  1021. {
  1022.     if (!is_user_alive(id) || g_freezetime) return;
  1023.    
  1024.     // Set Player MaxSpeed
  1025.     if (g_zombie[id])
  1026.     {
  1027.         new Float:maxspeed
  1028.         maxspeed = ArrayGetCell(zombie_speed, g_zombieclass[id])
  1029.         set_pev(id, pev_maxspeed, maxspeed)
  1030.     }
  1031. }  
  1032. // Ham Trace Attack Forward
  1033. public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
  1034. {
  1035.     // Non-player damage or self damage
  1036.     if (victim == attacker || !is_user_connected(attacker))
  1037.         return HAM_IGNORED;
  1038.    
  1039.     // New round starting or round ended
  1040.     if (g_newround || g_endround)
  1041.         return HAM_SUPERCEDE;
  1042.  
  1043.     // Prevent friendly fire
  1044.     if (g_zombie[attacker] == g_zombie[victim])
  1045.         return HAM_SUPERCEDE;
  1046.    
  1047.     // Victim isn't a zombie or not bullet damage, nothing else to do here
  1048.     if (!g_zombie[victim] || !(damage_type & DMG_BULLET))
  1049.         return HAM_IGNORED;
  1050.  
  1051.     // Knockback disabled, nothing else to do here
  1052.     if (!get_pcvar_num(cvar_knockback))
  1053.         return HAM_IGNORED;
  1054.  
  1055.     // Get distance between players
  1056.     static origin1[3], origin2[3]
  1057.     get_user_origin(victim, origin1)
  1058.     get_user_origin(attacker, origin2)
  1059.    
  1060.     // Get victim's velocity
  1061.     static Float:velocity[3]
  1062.     pev(victim, pev_velocity, velocity)
  1063.  
  1064.     // Use damage on knockback calculation
  1065.     if (get_pcvar_num(cvar_knockbackdamage))
  1066.         xs_vec_mul_scalar(direction, damage, direction)
  1067.  
  1068.     // Use weapon power on knockback calculation
  1069.     if (get_pcvar_num(cvar_knockbackpower))
  1070.     {
  1071.         new Float:weapon_knockback
  1072.         weapon_knockback = kb_weapon_power[get_user_weapon(attacker)]
  1073.         xs_vec_mul_scalar(direction, weapon_knockback, direction)
  1074.     }
  1075.        
  1076.     // Apply zombie class knockback multiplier
  1077.     if (g_zombie[victim])
  1078.     {
  1079.         new Float:classzb_knockback
  1080.         classzb_knockback = ArrayGetCell(zombie_knockback, g_zombieclass[victim])
  1081.         xs_vec_mul_scalar(direction, classzb_knockback, direction)
  1082.     }
  1083.        
  1084.     // Add up the new vector
  1085.     xs_vec_add(velocity, direction, direction)
  1086.    
  1087.     // Should knockback also affect vertical velocity?
  1088.     if (!get_pcvar_num(cvar_knockbackzvel))
  1089.         direction[2] = velocity[2]
  1090.    
  1091.     // Set the knockback'd victim's velocity
  1092.     set_pev(victim, pev_velocity, direction)
  1093.    
  1094.     //client_print(attacker, print_chat, "[%i][%i]", victim_kb, class_kb)
  1095.     return HAM_IGNORED;
  1096. }
  1097. // Emit Sound Forward
  1098. public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
  1099. {
  1100.     //client_print(id, print_chat, "[%s]", sample)
  1101.    
  1102.     // Block all those unneeeded hostage sounds
  1103.     if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
  1104.         return FMRES_SUPERCEDE;
  1105.    
  1106.     // Replace these next sounds for zombies only
  1107.     if (!is_user_connected(id) || !g_zombie[id])
  1108.         return FMRES_IGNORED;
  1109.    
  1110.     static sound[64]
  1111.    
  1112.     // Zombie being hit
  1113.     if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' ||
  1114.     sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
  1115.     {
  1116.         if (g_level[id]==1) ArrayGetString(zombie_sound_hurt1, g_zombieclass[id], sound, charsmax(sound))
  1117.         else ArrayGetString(zombie_sound_hurt2, g_zombieclass[id], sound, charsmax(sound))
  1118.         emit_sound(id, channel, sound, volume, attn, flags, pitch)
  1119.         return FMRES_SUPERCEDE;
  1120.     }
  1121.    
  1122.     // Zombie dies
  1123.     if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
  1124.     {
  1125.         if (g_level[id]==1) ArrayGetString(zombie_sound_death1, g_zombieclass[id], sound, charsmax(sound))
  1126.         else ArrayGetString(zombie_sound_death2, g_zombieclass[id], sound, charsmax(sound))
  1127.         emit_sound(id, channel, sound, volume, attn, flags, pitch)
  1128.         return FMRES_SUPERCEDE;
  1129.     }
  1130.  
  1131.     // Zombie Attack
  1132.     new attack_type
  1133.     if (equal(sample,"weapons/knife_hitwall1.wav")) attack_type = 1
  1134.     else if (equal(sample,"weapons/knife_hit1.wav") ||
  1135.     equal(sample,"weapons/knife_hit3.wav") ||
  1136.     equal(sample,"weapons/knife_hit2.wav") ||
  1137.     equal(sample,"weapons/knife_hit4.wav") ||
  1138.     equal(sample,"weapons/knife_stab.wav")) attack_type = 2
  1139.     else if(equal(sample,"weapons/knife_slash1.wav") ||
  1140.     equal(sample,"weapons/knife_slash2.wav")) attack_type = 3
  1141.     if (attack_type)
  1142.     {
  1143.         new sound[64]
  1144.         if (attack_type == 1) ArrayGetString(sound_zombie_hitwall, random(ArraySize(sound_zombie_hitwall)), sound, charsmax(sound))
  1145.         else if (attack_type == 2) ArrayGetString(sound_zombie_attack, random(ArraySize(sound_zombie_attack)), sound, charsmax(sound))
  1146.         else if (attack_type == 3) ArrayGetString(sound_zombie_swing, random(ArraySize(sound_zombie_swing)), sound, charsmax(sound))
  1147.         emit_sound(id, channel, sound, volume, attn, flags, pitch)
  1148.         return FMRES_SUPERCEDE;
  1149.     }
  1150.  
  1151.    
  1152.     return FMRES_IGNORED;
  1153. }
  1154. // Forward Set Model
  1155. public fw_SetModel(entity, const model[])
  1156. {
  1157.     // We don't care
  1158.     if (strlen(model) < 8)
  1159.         return FMRES_IGNORED;
  1160.  
  1161.     // Narrow down our matches a bit
  1162.     //if (model[7] != 'w' || model[8] != '_')
  1163.     //  return FMRES_IGNORED;
  1164.    
  1165.     // Get damage time of grenade
  1166.     static Float:dmgtime
  1167.     pev(entity, pev_dmgtime, dmgtime)
  1168.    
  1169.     // Grenade not yet thrown
  1170.     if (dmgtime == 0.0)
  1171.         return FMRES_IGNORED;
  1172.    
  1173.     // Get attacker
  1174.     static attacker
  1175.     attacker = pev(entity, pev_owner)
  1176.    
  1177.     // Get whether grenade's owner is a zombie
  1178.     if (g_zombie[attacker])
  1179.     {
  1180.         if (model[9] == 'h' && model[10] == 'e') // Zombie Bomb
  1181.         {
  1182.             // Set grenade type on the thrown grenade entity
  1183.             set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  1184.             engfunc(EngFunc_SetModel, entity, ZOMBIEBOM_W_MODEL)
  1185.        
  1186.             return FMRES_SUPERCEDE
  1187.         }
  1188.     }
  1189.  
  1190.    
  1191.     return FMRES_IGNORED
  1192. }
  1193. // Ham Grenade Think Forward
  1194. public fw_ThinkGrenade(entity)
  1195. {
  1196.     // Invalid entity
  1197.     if (!pev_valid(entity)) return FMRES_IGNORED;
  1198.    
  1199.     // Get damage time of grenade
  1200.     static Float:dmgtime
  1201.     pev(entity, pev_dmgtime, dmgtime)
  1202.    
  1203.     // Check if it's time to go off
  1204.     if (dmgtime > get_gametime())
  1205.         return HAM_IGNORED;
  1206.    
  1207.     // Check if it's one of our custom nades
  1208.     switch (pev(entity, PEV_NADE_TYPE))
  1209.     {
  1210.         case NADE_TYPE_INFECTION:
  1211.         {
  1212.             zombiebom_explode(entity)
  1213.         }
  1214.         default: return HAM_IGNORED;
  1215.     }
  1216.    
  1217.     return HAM_SUPERCEDE;
  1218. }
  1219. public fw_primary_attack(ent)
  1220. {
  1221.     new id = pev(ent,pev_owner)
  1222.     pev(id,pev_punchangle,cl_pushangle[id])
  1223.    
  1224.     return HAM_IGNORED
  1225. }
  1226. public fw_primary_attack_post(ent)
  1227. {
  1228.     new id = pev(ent,pev_owner)
  1229.     if (!g_zombie[id] && g_level[id] && get_pcvar_num(cvar_recoil))
  1230.     {
  1231.         //Recoil Wpn
  1232.         new Float: xrecoil = str_to_float(XRECOIL[g_level[id]])
  1233.         new Float:push[3]
  1234.         pev(id,pev_punchangle,push)
  1235.         xs_vec_sub(push,cl_pushangle[id],push)
  1236.         xs_vec_mul_scalar(push,xrecoil,push)
  1237.         xs_vec_add(push,cl_pushangle[id],push)
  1238.         set_pev(id,pev_punchangle,push)
  1239.     }
  1240.    
  1241.     return HAM_IGNORED
  1242. }
  1243.  
  1244. /*================================================================================
  1245.  [Main Public]
  1246. =================================================================================*/
  1247. // Menu Weapons
  1248. public menu_wpn(taskid)
  1249. {
  1250.     new id = ID_MENUWPN
  1251.     if (!is_user_alive(id)) return PLUGIN_HANDLED
  1252.    
  1253.     menu_wpn_item(id, 1)
  1254.     give_weapons_bot(id)
  1255.     make_human_firt(id)
  1256.    
  1257.     if (task_exists(taskid)) remove_task(taskid)
  1258.     return PLUGIN_HANDLED
  1259. }
  1260. public menu_wpn_item(id, type)
  1261. {
  1262.     if (g_zombie[id]) return PLUGIN_HANDLED
  1263.    
  1264.     // check size
  1265.     new size_id, size_name, fun_run[32]
  1266.     new size_pri = ArraySize(weapons_pri)
  1267.     new size_pri_name = ArraySize(weapons_pri_name)
  1268.     new size_sec = ArraySize(weapons_sec)
  1269.     new size_sec_name = ArraySize(weapons_sec_name)
  1270.     if (type == 1)
  1271.     {
  1272.         size_id = size_pri
  1273.         size_name = size_pri_name
  1274.         format(fun_run, 31, "menu_wpn_pri_handler")
  1275.     }
  1276.     else
  1277.     {
  1278.         size_id = size_sec
  1279.         size_name = size_sec_name
  1280.         format(fun_run, 31, "menu_wpn_sec_handler")
  1281.     }
  1282.    
  1283.     // create menu wpn
  1284.     new menuwpn_title[64]
  1285.     format(menuwpn_title, 63, "[NST Zombie] %L:", LANG_PLAYER, "ZB3_MENU_WPN_TITLE")
  1286.     new mHandleID = menu_create(menuwpn_title, fun_run)
  1287.     new item_id[32], item_name[32]
  1288.     for (new i = 0; i < size_id && i < size_name; i++)
  1289.     {
  1290.         if (type == 1)
  1291.         {
  1292.             ArrayGetString(weapons_pri, i, item_id, charsmax(item_id))
  1293.             ArrayGetString(weapons_pri_name, i, item_name, charsmax(item_name))
  1294.         }
  1295.         else
  1296.         {
  1297.             ArrayGetString(weapons_sec, i, item_id, charsmax(item_id))
  1298.             ArrayGetString(weapons_sec_name, i, item_name, charsmax(item_name))
  1299.         }
  1300.         menu_additem(mHandleID, item_name, item_id, 0)
  1301.     }
  1302.     menu_display(id, mHandleID, 0)
  1303.    
  1304.    
  1305.     return PLUGIN_HANDLED
  1306. }
  1307. public menu_wpn_pri_handler(id, menu, item)
  1308. {
  1309.     if (item == MENU_EXIT)
  1310.     {
  1311.         menu_destroy(menu)
  1312.         return PLUGIN_HANDLED
  1313.     }
  1314.     new idwpn[32], name[32], access
  1315.     menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
  1316.  
  1317.     new idweapon = csw_name_to_id(idwpn)
  1318.     drop_weapons(id, 1)
  1319.     give_weapon(id, idweapon)
  1320.    
  1321.     menu_destroy(menu)
  1322.    
  1323.     // show menu wpn sec
  1324.     menu_wpn_item(id, 2)
  1325.    
  1326.     return PLUGIN_HANDLED
  1327. }
  1328. public menu_wpn_sec_handler(id, menu, item)
  1329. {
  1330.     if (item == MENU_EXIT)
  1331.     {
  1332.         menu_destroy(menu)
  1333.         return PLUGIN_HANDLED
  1334.     }
  1335.     new idwpn[32], name[32], access
  1336.     menu_item_getinfo(menu, item, access, idwpn, 31, name, 31, access)
  1337.  
  1338.     new idweapon = csw_name_to_id(idwpn)
  1339.     drop_weapons(id, 2)
  1340.     give_weapon(id, idweapon)
  1341.    
  1342.     menu_destroy(menu)
  1343.  
  1344.     return PLUGIN_HANDLED
  1345. }
  1346. // Buy ammo
  1347. public cmd_buy_ammo(id)
  1348. {
  1349.     return PLUGIN_HANDLED
  1350. }
  1351. // Current Weapon
  1352. public CurrentWeapon(id)
  1353. {
  1354.     if (!is_user_alive(id)) return;
  1355.  
  1356.     // check weapons
  1357.     CheckWeapon(id)
  1358.    
  1359.     // Uclip
  1360.     new bot_uclip = get_pcvar_num(cvar_bot_uclip)
  1361.     if (is_user_bot(id) && bot_uclip && !g_zombie[id])
  1362.     {
  1363.         new WpnName[64]
  1364.         new idwpn = get_user_weapon(id)
  1365.         if ( idwpn && !(NOCLIP_WPN_BS & (1<<idwpn)) && get_weaponname(idwpn, WpnName, charsmax(WpnName)) )
  1366.         {
  1367.             if (bot_uclip == 1)
  1368.             {
  1369.                 new ent = get_weapon_ent(id, idwpn)
  1370.                 new uclip = max(1, MAXCLIP[idwpn])
  1371.                 if (ent) cs_set_weapon_ammo(ent, uclip)
  1372.                 //client_print(0, print_chat, "[%i]", ent)
  1373.             }
  1374.             else cs_set_user_bpammo(id, idwpn, 150)
  1375.         }
  1376.     }
  1377.    
  1378.     return;
  1379. }
  1380. //get weapon ent
  1381. get_weapon_ent(id, weaponid)
  1382. {
  1383.     static wname[32], weapon_ent
  1384.     get_weaponname(weaponid, wname, charsmax(wname))
  1385.     weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  1386.     return weapon_ent
  1387. }
  1388. CheckWeapon(id)
  1389. {
  1390.     if (!is_user_alive(id)) return;
  1391.    
  1392.     // zombie weapons
  1393.     new current_weapon = get_user_weapon(id)
  1394.     if (g_zombie[id] && current_weapon)
  1395.     {
  1396.         // remove weapon # knife & he
  1397.         if (current_weapon != CSW_KNIFE && current_weapon != CSW_HEGRENADE)
  1398.         {
  1399.             drop_weapons(id, get_weapon_type(current_weapon), 1)
  1400.         }
  1401.         // set model zonbie bom
  1402.         else if (current_weapon == CSW_HEGRENADE)
  1403.         {
  1404.             new idclass, v_model[64]
  1405.             idclass = g_zombieclass[id]
  1406.             ArrayGetString(zombiebom_viewmodel, idclass, v_model, charsmax(v_model))
  1407.             set_pev(id, pev_viewmodel2, v_model)
  1408.             set_pev(id, pev_weaponmodel2, ZOMBIEBOM_P_MODEL)
  1409.         }
  1410.         // set model knife zombie
  1411.         else
  1412.         {
  1413.             new model_wpn[64], idclass
  1414.             idclass = g_zombieclass[id]
  1415.             ArrayGetString(zombie_wpnmodel, idclass, model_wpn, charsmax(model_wpn))
  1416.  
  1417.             set_pev(id, pev_viewmodel2, model_wpn)
  1418.             set_pev(id, pev_weaponmodel2, "")
  1419.         }
  1420.  
  1421.     }
  1422. }
  1423.  
  1424. public reset_wpnmodel(id)
  1425. {
  1426.     if (get_user_weapon(id) == CSW_KNIFE)
  1427.     {
  1428.         set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
  1429.         set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
  1430.     }
  1431. }
  1432.  
  1433. // Make Zombie Random
  1434. public make_random_zombie()
  1435. {
  1436. // Give Team player
  1437.     give_team_player()
  1438.    
  1439. // check total player
  1440.     static total_players
  1441.     total_players = GetTotalPlayer(0, 1)
  1442.     if (!total_players) return;
  1443.    
  1444. // Ramdom zombie
  1445.     static total_zombie, zombie_random, num_a, size_zb = 8
  1446.     num_a = total_players % size_zb
  1447.     total_zombie = (total_players-num_a)/size_zb
  1448.     if (num_a) total_zombie += 1
  1449.     if (!total_zombie) total_zombie = 1
  1450.    
  1451.     // get damage for zombie random
  1452.     new humans = total_players - total_zombie
  1453.     new zombie_random_dmg = (humans*1000)/total_zombie
  1454.     if (zombie_random_dmg < MIN_HEALTH_ZOMBIE_RANDOM) zombie_random_dmg = MIN_HEALTH_ZOMBIE_RANDOM
  1455.     else if (zombie_random_dmg > MAX_HEALTH_ZOMBIE_RANDOM) zombie_random_dmg = MAX_HEALTH_ZOMBIE_RANDOM
  1456.    
  1457.     // make random
  1458.     new zombies_name[64]
  1459.     for (new i = 1; i <= total_zombie; i++)
  1460.     {
  1461.         // get id zombie random
  1462.         zombie_random = fnGetRandomPlayer()
  1463.         //zombie_random = 1
  1464.        
  1465.         // set star health armor od random zombie
  1466.         g_level[zombie_random] = LEVEL_ZOMBIE_RANDOM
  1467.        
  1468.         // make zombie
  1469.         g_zombieclass[zombie_random] = random(class_count)
  1470.         make_zombie(zombie_random)
  1471.        
  1472.         // show menu class zombie
  1473.         show_menu_class_zombie(zombie_random)
  1474.        
  1475.         // give health
  1476.         g_start_health[zombie_random] = zombie_random_dmg
  1477.         g_star_armor[zombie_random] = zombie_random_dmg/2
  1478.         fm_set_user_health(zombie_random, g_start_health[zombie_random])
  1479.         fm_set_user_armor(zombie_random, g_star_armor[zombie_random])
  1480.        
  1481.         // play sound human death
  1482.         new sound[64], sex
  1483.         sex = nst_get_user_sex(zombie_random)
  1484.         if (sex == 2) ArrayGetString(sound_female_death, random(ArraySize(sound_female_death)), sound, charsmax(sound))
  1485.         else ArrayGetString(sound_human_death, random(ArraySize(sound_human_death)), sound, charsmax(sound))
  1486.         PlayEmitSound(zombie_random, CHAN_VOICE, sound)
  1487.        
  1488.         // play sound zombie coming
  1489.         ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
  1490.         PlaySound(0, sound)
  1491.        
  1492.         // Post user infect forward
  1493.         ExecuteForward(g_fwUserInfected, g_fwDummyResult, zombie_random, 0)
  1494.        
  1495.         // get hud msg zombies
  1496.         new zombie_name[32]
  1497.         get_user_name(zombie_random, zombie_name, 31)
  1498.         if (i==1) format(zombies_name, charsmax(zombies_name), "%s", zombie_name)
  1499.         else format(zombies_name, charsmax(zombies_name), "%s - %s", zombies_name, zombie_name)
  1500.     }
  1501.        
  1502. // random hero
  1503.     // get hero random
  1504.     static num_aa, total_hero, total_human, hero_random, size_hero = 10
  1505.     total_human = GetTotalPlayer(4, 1)
  1506.     num_aa = total_human % size_hero
  1507.     total_hero = (total_human-num_aa)/size_hero
  1508.     if (num_aa>=(size_hero/2)) total_hero += 1
  1509.  
  1510.     // make hero random
  1511.     new heros_name[64]
  1512.     for (new i = 1; i <= total_hero; i++)
  1513.     {
  1514.         // get id hero random
  1515.         hero_random = fnGetRandomPlayer()
  1516.         //hero_random = 1
  1517.        
  1518.         // make hero
  1519.         make_hero(hero_random)
  1520.        
  1521.         // give nade
  1522.         give_nade(hero_random)
  1523.        
  1524.         // create effect
  1525.         EffectLevelUp(hero_random)
  1526.        
  1527.         // get hud msg
  1528.         new hero_name[32]
  1529.         get_user_name(hero_random, hero_name, 31)
  1530.         if (i==1) format(heros_name, charsmax(heros_name), "%s", hero_name)
  1531.         else format(heros_name, charsmax(heros_name), "%s - %s", heros_name, hero_name)
  1532.     }
  1533.    
  1534. // make human
  1535.     make_human_team()
  1536.  
  1537. // Hud Msg
  1538.     format(zombies_name, charsmax(zombies_name), "%L", LANG_PLAYER, "ZB3_NOTICE_FIRST_ZOMBIE", zombies_name)
  1539.     format(heros_name, charsmax(heros_name), "%L", LANG_PLAYER, "ZB3_NOTICE_FIRST_HERO", heros_name)
  1540.  
  1541.     new msg[100]
  1542.     format(msg, charsmax(msg), "%L", LANG_PLAYER, "ZB3_NOTICE_APPEAR")
  1543.     SendCenterText(0, msg)
  1544.     //set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 0.2, 0.2, -1)
  1545.     //ShowSyncHudMsg(0, g_HudMsg_Event, "%s", msg)
  1546.  
  1547. // make supply box
  1548.     if (task_exists(TASK_SUPPLYBOX)) remove_task(TASK_SUPPLYBOX)
  1549.     set_task(SUPPLYBOX_TIME, "create_supply_box", TASK_SUPPLYBOX)
  1550.    
  1551. // thong bao
  1552.     //client_print(0, print_chat, "Z[%i] H[%i] HU[%i]", total_zombie, total_hero, total_human)
  1553.    
  1554.     if (task_exists(TASK_MAKEZOMBIE)) remove_task(TASK_MAKEZOMBIE)
  1555. }
  1556. // menu class zombie
  1557. public show_menu_class_zombie(id)
  1558. {
  1559.     if (!g_zombie[id]) return PLUGIN_HANDLED
  1560.    
  1561.     // create menu wpn
  1562.     new menuwpn_title[64]
  1563.     format(menuwpn_title, 63, "[NST Zombie] %L:", LANG_PLAYER, "ZB3_MENU_CLASSZOMBIE_TITLE")
  1564.     new mHandleID = menu_create(menuwpn_title, "select_class_zombie")
  1565.     new class_name[32], class_id[32]
  1566.    
  1567.     for (new i = 0; i < class_count; i++)
  1568.     {
  1569.         ArrayGetString(zombie_name, i, class_name, charsmax(class_name))
  1570.         formatex(class_id, charsmax(class_name), "%i", i)
  1571.         menu_additem(mHandleID, class_name, class_id, 0)
  1572.     }
  1573.     menu_display(id, mHandleID, 0)
  1574.    
  1575.     return PLUGIN_HANDLED
  1576. }
  1577. public select_class_zombie(id, menu, item)
  1578. {
  1579.     if (!g_zombie[id]) return PLUGIN_HANDLED
  1580.    
  1581.     if (item == MENU_EXIT)
  1582.     {
  1583.         menu_destroy(menu)
  1584.         give_zombiebom(id)
  1585.        
  1586.         return PLUGIN_HANDLED
  1587.     }
  1588.     new idclass[32], name[32], access
  1589.     menu_item_getinfo(menu, item, access, idclass, 31, name, 31, access)
  1590.    
  1591.     // set class zombie
  1592.     g_zombieclass[id] = str_to_num(idclass)
  1593.     make_zombie(id)
  1594.     give_zombiebom(id)
  1595.    
  1596.     menu_destroy(menu)
  1597.     //client_print(id, print_chat, "item: %i - id: %s", name, idclass)
  1598.    
  1599.     return PLUGIN_HANDLED
  1600. }
  1601.  
  1602. // Spawn a player [admin cmd]
  1603. public cmd_respawn_hero(id, level, cid)
  1604. {
  1605.     if (!cmd_access(id, level, cid, 2))
  1606.         return PLUGIN_HANDLED
  1607.  
  1608.     // Retrieve arguments
  1609.     static arg[32], player
  1610.     read_argv(1, arg, charsmax(arg))
  1611.     player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  1612.    
  1613.     // Remove Respawn when Freetime
  1614.     if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
  1615.  
  1616.     reset_value(player)
  1617.     respawn_player_manually(player)
  1618.     make_hero(player)
  1619.    
  1620.     // give nade
  1621.     give_nade(player)
  1622.    
  1623.     return PLUGIN_HANDLED
  1624. }
  1625. // Spawn a player [admin cmd]
  1626. public cmd_respawn_human(id, level, cid)
  1627. {
  1628.     if (!cmd_access(id, level, cid, 2))
  1629.         return PLUGIN_HANDLED
  1630.  
  1631.     // Retrieve arguments
  1632.     static arg[32], player
  1633.     read_argv(1, arg, charsmax(arg))
  1634.     player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  1635.    
  1636.     // Remove Respawn when Freetime
  1637.     if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
  1638.  
  1639.     reset_value(player)
  1640.     respawn_player_manually(player)
  1641.     make_human(player)
  1642.  
  1643.     // show menu weapons
  1644.     if (task_exists(player+TASK_MENUWPN)) remove_task(player+TASK_MENUWPN)
  1645.     set_task(0.1, "menu_wpn", player+TASK_MENUWPN)
  1646.    
  1647.     // give nade
  1648.     give_nade(player)
  1649.  
  1650.     return PLUGIN_HANDLED
  1651. }
  1652. // Spawn a player [admin cmd]
  1653. public cmd_respawn_zombie(id, level, cid)
  1654. {
  1655.     if (!cmd_access(id, level, cid, 2))
  1656.         return PLUGIN_HANDLED
  1657.  
  1658.     // Retrieve arguments
  1659.     static arg[32], player
  1660.     read_argv(1, arg, charsmax(arg))
  1661.     player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF)
  1662.    
  1663.     // Remove Respawn when Freetime
  1664.     if (g_newround || g_endround || !is_user_connected(player)) return PLUGIN_HANDLED
  1665.  
  1666.     reset_value(player)
  1667.     respawn_player_manually(player)
  1668.    
  1669.     // make zombie
  1670.     g_zombieclass[player] = random(class_count)
  1671.     make_zombie(player)
  1672.    
  1673.     // show menu class zombie
  1674.     show_menu_class_zombie(player)
  1675.  
  1676.     // play sound zombie coming
  1677.     new sound[64]
  1678.     ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
  1679.     PlaySound(0, sound)
  1680.    
  1681.     // Post user infect forward
  1682.     ExecuteForward(g_fwUserInfected, g_fwDummyResult, player, 0)
  1683.  
  1684.    
  1685.     return PLUGIN_HANDLED
  1686. }
  1687. // Zombie Respawn
  1688. public zombie_respawn(taskid)
  1689. {
  1690.     new id = ID_ZOMBIE_RESPAWN
  1691.    
  1692.     // Remove Respawn when Freetime
  1693.     if (g_newround || g_endround || !is_user_connected(id)) return PLUGIN_HANDLED
  1694.    
  1695.     g_respawning[id] = 0
  1696.     respawn_player_manually(id)
  1697.     make_zombie(id)
  1698.  
  1699.     // play sound zombie comback
  1700.     new sound[64]
  1701.     ArrayGetString(sound_zombie_comeback, random(ArraySize(sound_zombie_comeback)), sound, charsmax(sound))
  1702.     PlayEmitSound(id, CHAN_VOICE, sound)
  1703.  
  1704.     // Post user infect forward
  1705.     ExecuteForward(g_fwUserInfected, g_fwDummyResult, id, 0)
  1706.    
  1707.     if (task_exists(taskid)) remove_task(taskid)
  1708.  
  1709.     return PLUGIN_HANDLED
  1710. }
  1711. public zombie_respawn_effect(taskid)
  1712. {
  1713.     new id = ID_ZOMBIE_RESPAWN_EF
  1714.  
  1715.     // Remove Respawn when Freetime
  1716.     if (g_newround || g_endround || !is_user_connected(id) || is_user_alive(id)) return;
  1717.  
  1718.     EffectZombieRespawn(id)
  1719.     if (task_exists(id+TASK_ZOMBIE_RESPAWN_EF)) remove_task(id+TASK_ZOMBIE_RESPAWN_EF)
  1720.     set_task(2.0, "zombie_respawn_effect", id+TASK_ZOMBIE_RESPAWN_EF)
  1721.    
  1722.     return;
  1723. }
  1724. public show_hud_client()
  1725. {
  1726.     new message[101]
  1727.    
  1728.     // show score match
  1729.     new humans[32], zombies[32], humans_alive[32], zombies_alive[32], match_count[32]
  1730.     format(humans, 31, "%s", FixNumber(g_score_human))
  1731.     format(zombies, 31, "%s", FixNumber(g_score_zombie))
  1732.     format(humans_alive, 31, "%s", FixNumber(GetTotalPlayer(4, 1)))
  1733.     format(zombies_alive, 31, "%s", FixNumber(GetTotalPlayer(3, 1)))
  1734.     format(match_count, 31, "%s", FixNumber( g_score_human+g_score_zombie ))
  1735.    
  1736.     format(message, 100, "%L", LANG_PLAYER, "ZB3_HUD_SCORE_MATCH", humans, match_count, zombies, humans_alive, zombies_alive)
  1737.     set_hudmessage(255, 255, 255, HUD_SCORE_X, HUD_SCORE_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  1738.     ShowSyncHudMsg(0, g_HudMsg_ScoreMatch, "%s", message)
  1739.    
  1740.     // show health & level
  1741.     for (new id = 1; id <= g_maxplayers; id++)
  1742.     {
  1743.         if (!is_user_alive(id)) continue;
  1744.    
  1745.         // show health
  1746.         if (g_zombie[id]) format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_HUD_ZOMBIE_HEALTH", get_user_health(id), g_level[id])
  1747.         else format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_HUD_HUMAN_HEALTH", get_user_health(id), g_level[id])
  1748.         set_hudmessage(0, 125, 0, HUD_HEALTH_X, HUD_HEALTH_Y, 0, 6.0, 2.0, 0.0, 0.0, -1)
  1749.         ShowSyncHudMsg(id, g_HudMsg_Health, "%s", message)
  1750.        
  1751.         if (!g_zombie[id])
  1752.         {
  1753.             new message_power[128], color[3]
  1754.             color[0] = get_color_level(id, 0)
  1755.             color[1] = get_color_level(id, 1)
  1756.             color[2] = get_color_level(id, 2)
  1757.             format(message_power, charsmax(message_power), "%L", LANG_PLAYER, "ZB3_HUD_HUMAN_POWER", g_level[id]*10+100)
  1758.             set_hudmessage(color[0], color[1], color[2], HUD_POWER_X, HUD_POWER_Y, 0, 6.0, 2.0, 0.0, 0.0, -1)
  1759.             ShowSyncHudMsg(id, g_HudMsg_Power, "%s", message_power)
  1760.         }
  1761.     }
  1762. }
  1763. // HUD LEVEL SCREENT
  1764. show_player_level(id)
  1765. {
  1766.     if (!is_user_alive(id)) return;
  1767.  
  1768.     if ((g_level_delay[id] + get_pcvar_float(cvar_level_deplay)) > get_gametime()) return;
  1769.     g_level_delay[id] = get_gametime()
  1770.    
  1771.  
  1772.     g_level_effect[id] += 1
  1773.     if (g_level_effect[id]>8) g_level_effect[id] = 1
  1774.    
  1775.     new level, sprname[64]
  1776.     if (g_zombie[id])
  1777.     {
  1778.         new MaxEvo = MAX_EVOLUTION/MAX_LEVEL_ZOMBIE
  1779.         level = min(g_evolution[id], MaxEvo)
  1780.         if (level) format(sprname, charsmax(sprname), "zombie_level_%i%i", level, g_level_effect[id])
  1781.         else format(sprname, charsmax(sprname), "zombie_level_%i", level)
  1782.     }
  1783.     else
  1784.     {
  1785.         level = min(g_level[id], MAX_LEVEL_HUMAN)
  1786.         format(sprname, charsmax(sprname), "human_level_%i", level)
  1787.     }
  1788.    
  1789.     message_begin(MSG_ONE, g_msgScenario, _, id)
  1790.     write_byte(1)//  Active
  1791.     write_string(sprname)//  Sprite
  1792.     write_byte(1000)//  Alpha
  1793.     write_short(3)//  FlashRate
  1794.     write_short(0)//  Unknown
  1795.     message_end()
  1796. }
  1797. // HUD ICON
  1798. show_hud_icon(id)
  1799. {
  1800.     if (!get_pcvar_num(cvar_icon) || !is_user_alive(id) || g_zombie[id]) return;
  1801.    
  1802.     if ((g_icon_delay[id] + get_pcvar_float(cvar_icon_deplay)) > get_gametime()) return;
  1803.     g_icon_delay[id] = get_gametime()
  1804.    
  1805.     // Hud Icon Suppplybox
  1806.     if (supplybox_count)
  1807.     {
  1808.         new i = 1, box_ent
  1809.         while (i<=supplybox_count)
  1810.         {
  1811.             box_ent = supplybox_ent[i]
  1812.             create_icon_origin(id, box_ent, SUPPLYBOX_ICON_IDSPR)
  1813.             i++
  1814.         }
  1815.     }
  1816.    
  1817.     // Hud Icon Hero
  1818.     static Players[32], iNum
  1819.     get_players(Players, iNum, "a")
  1820.     for (new i = 0; i < iNum; ++i) if(id != Players[i])
  1821.     {
  1822.         new hero = Players[i]
  1823.         if (!g_hero[hero]) continue;
  1824.         create_icon_origin(id, hero, HERO_ICON_IDSPR)
  1825.     }
  1826. }
  1827. stock create_icon_origin(id, ent, sprite)
  1828. {
  1829.     if (!pev_valid(ent)) return;
  1830.    
  1831.     new Float:fMyOrigin[3]
  1832.     entity_get_vector(id, EV_VEC_origin, fMyOrigin)
  1833.    
  1834.     new target = ent
  1835.     new Float:fTargetOrigin[3]
  1836.     entity_get_vector(target, EV_VEC_origin, fTargetOrigin)
  1837.     fTargetOrigin[2] += 40.0
  1838.    
  1839.     if (!is_in_viewcone(id, fTargetOrigin)) return;
  1840.  
  1841.     new Float:fMiddle[3], Float:fHitPoint[3]
  1842.     xs_vec_sub(fTargetOrigin, fMyOrigin, fMiddle)
  1843.     trace_line(-1, fMyOrigin, fTargetOrigin, fHitPoint)
  1844.                            
  1845.     new Float:fWallOffset[3], Float:fDistanceToWall
  1846.     fDistanceToWall = vector_distance(fMyOrigin, fHitPoint) - 10.0
  1847.     normalize(fMiddle, fWallOffset, fDistanceToWall)
  1848.    
  1849.     new Float:fSpriteOffset[3]
  1850.     xs_vec_add(fWallOffset, fMyOrigin, fSpriteOffset)
  1851.     new Float:fScale, Float:fDistanceToTarget = vector_distance(fMyOrigin, fTargetOrigin)
  1852.     fScale = 0.01 * fDistanceToWall
  1853.    
  1854.     new scale = floatround(fScale)
  1855.     scale = max(scale, 1)
  1856.     scale = min(scale, get_pcvar_num(cvar_icon_size))
  1857.     scale = max(scale, 1)
  1858.  
  1859.     if (is_user_alive(ent) && g_hero[ent] && (floatround(fDistanceToWall)+10) == floatround(fDistanceToTarget)) return;
  1860.    
  1861.     te_sprite(id, fSpriteOffset, sprite, scale, get_pcvar_num(cvar_icon_light))
  1862.    
  1863.     //client_print(id, print_chat, "W[%i]P[%i]S[%i]", floatround(fDistanceToWall), floatround(fDistanceToTarget), scale)
  1864. }
  1865. stock te_sprite(id, Float:origin[3], sprite, scale, brightness)
  1866. {  
  1867.     message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
  1868.     write_byte(TE_SPRITE)
  1869.     write_coord(floatround(origin[0]))
  1870.     write_coord(floatround(origin[1]))
  1871.     write_coord(floatround(origin[2]))
  1872.     write_short(sprite)
  1873.     write_byte(scale)
  1874.     write_byte(brightness)
  1875.     message_end()
  1876. }
  1877. stock normalize(Float:fIn[3], Float:fOut[3], Float:fMul)
  1878. {
  1879.     new Float:fLen = xs_vec_len(fIn)
  1880.     xs_vec_copy(fIn, fOut)
  1881.    
  1882.     fOut[0] /= fLen, fOut[1] /= fLen, fOut[2] /= fLen
  1883.     fOut[0] *= fMul, fOut[1] *= fMul, fOut[2] *= fMul
  1884. }
  1885. // Nightvision toggle
  1886. public cmd_nightvision(id)
  1887. {
  1888.     if (!is_user_alive(id)) return PLUGIN_HANDLED;
  1889.  
  1890.     if (!g_nvg[id])
  1891.     {
  1892.         g_nvg[id] = 1
  1893.         if (g_zombie[id])
  1894.         {
  1895.             remove_task(id+TASK_NVISION)
  1896.             set_task(0.1, "set_user_nvision", id+TASK_NVISION, _, _, "b")
  1897.         }
  1898.         else  set_user_gnvision(id, g_nvg[id])
  1899.         PlaySound(id, sound_nvg[1])
  1900.     }
  1901.     else
  1902.     {
  1903.         g_nvg[id] = 0
  1904.         if (g_zombie[id])
  1905.         {
  1906.             remove_task(id+TASK_NVISION)
  1907.             set_user_screen_fade(id)
  1908.         }
  1909.         else  set_user_gnvision(id, g_nvg[id])
  1910.         PlaySound(id, sound_nvg[0])
  1911.     }
  1912.    
  1913.     return PLUGIN_HANDLED;
  1914. }
  1915. turn_off_nvg(id)
  1916. {
  1917.     if (!is_user_connected(id)) return;
  1918.    
  1919.     g_nvg[id] = 0
  1920.     remove_task(id+TASK_NVISION)
  1921.     set_user_screen_fade(id)
  1922.     set_user_gnvision(id, 0)
  1923. }
  1924.  
  1925.  
  1926. // Custom Night Vision
  1927. public set_user_nvision(taskid)
  1928. {
  1929.     new id = ID_NVISION
  1930.    
  1931.     if (!is_user_alive(id)) return;
  1932.  
  1933.     // Get player's origin
  1934.     static origin[3]
  1935.     get_user_origin(id, origin)
  1936.    
  1937.     // Nightvision message
  1938.     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  1939.     write_byte(TE_DLIGHT) // TE id
  1940.     write_coord(origin[0]) // x
  1941.     write_coord(origin[1]) // y
  1942.     write_coord(origin[2]) // z
  1943.     write_byte(get_pcvar_num(cvar_nvg_zombie_size)) // radius
  1944.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[0])) // r
  1945.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[1])) // g
  1946.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[2])) // b
  1947.     write_byte(2) // life
  1948.     write_byte(0) // decay rate
  1949.     message_end()
  1950.  
  1951.     // screen_fade
  1952.     set_user_screen_fade(id)
  1953. }
  1954. set_user_gnvision(id, toggle)
  1955. {
  1956.     // Toggle NVG message
  1957.     message_begin(MSG_ONE, g_msgNVGToggle, _, id)
  1958.     write_byte(toggle) // toggle
  1959.     message_end()
  1960. }
  1961. set_user_screen_fade(id)
  1962. {
  1963.     if (!is_user_connected(id)) return;
  1964.    
  1965.     new alpha
  1966.     if (g_nvg[id]) alpha = get_pcvar_num(cvar_nvg_zombie_alpha)
  1967.     else alpha = 0
  1968.    
  1969.     message_begin(MSG_ONE, g_msgScreenFade, _, id)
  1970.     write_short(0) // duration
  1971.     write_short(0) // hold time
  1972.     write_short(FFADE_STAYOUT) // fade type
  1973.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[0])) // r
  1974.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[1])) // g
  1975.     write_byte(get_pcvar_num(cvar_nvg_zombie_color[2])) // b
  1976.     write_byte(alpha) // alpha
  1977.     message_end()
  1978. }
  1979.  
  1980.  
  1981. // Other
  1982. public qq(id)
  1983. {
  1984.     client_print(id, print_chat, "L[%i]", ArrayGetCell(zombie_modelindex, get_pcvar_num(cvar_knockback)))
  1985. }
  1986.  
  1987. // ##################### SupplyBox #####################
  1988. // SupplyBox Pickup
  1989. public fw_Touch(ent, id)
  1990. {
  1991.     if (!pev_valid(ent) || !is_user_alive(id) || g_zombie[id] || g_supplybox_wait[id]) return FMRES_IGNORED
  1992.    
  1993.     new classname[32]
  1994.     entity_get_string(ent,EV_SZ_classname,classname,31)
  1995.     //client_print(id, print_chat, "[%s][%i]", classname, ent)
  1996.    
  1997.     if (equal(classname, SUPPLYBOX_CLASSNAME))
  1998.     {
  1999.         // get item from supply pickup
  2000.         new item_id, item[64]
  2001.         item_id = entity_get_int(ent, EV_INT_iuser1)
  2002.         ArrayGetString(supplybox_item, item_id, item, charsmax(item))
  2003.        
  2004.         // give item for player
  2005.         give_weapons_item(id, item)
  2006.        
  2007.         // play sound
  2008.         PlayEmitSound(id, CHAN_VOICE, SUPPLYBOX_SOUND_PICKUP)
  2009.  
  2010.         // remove ent in supplybox_ent
  2011.         new num_box = entity_get_int(ent, EV_INT_iuser2)
  2012.         supplybox_ent[num_box] = 0
  2013.         remove_entity(ent)
  2014.        
  2015.         // waiting
  2016.         g_supplybox_wait[id] = 1
  2017.         if (task_exists(id+TASK_SUPPLYBOX_WAIT)) remove_task(id+TASK_SUPPLYBOX_WAIT)
  2018.         set_task(2.0, "remove_supplybox_wait", id+TASK_SUPPLYBOX_WAIT)
  2019.     }
  2020.    
  2021.     return FMRES_IGNORED
  2022. }
  2023. public remove_supplybox_wait(taskid)
  2024. {
  2025.     new id = ID_SUPPLYBOX_WAIT
  2026.     g_supplybox_wait[id] = 0
  2027.     if (task_exists(taskid)) remove_task(taskid)
  2028. }
  2029. give_weapons_item(id, item[])
  2030. {
  2031.     new item_type = supplybox_get_type_item(item)
  2032.    
  2033.     // give cs weapons default
  2034.     if (item_type == NSTZB_ITEM_WPNDEFAULT)
  2035.     {
  2036.         new idweapon = csw_name_to_id(item)
  2037.         new wpn_type = get_weapon_type(idweapon)
  2038.         if (wpn_type==1 || wpn_type==2) drop_weapons(id, wpn_type)
  2039.         give_weapon(id, idweapon)
  2040.     }
  2041.     // give weapon mod nst wpn
  2042.     else if (item_type == NSTZB_ITEM_NSTWPN)
  2043.     {
  2044.         replace(item, 32, "nst_", "")
  2045.         nst_wpn_give_weapon(id, item)
  2046.     }
  2047.     // give nade
  2048.     else if (item_type == NSTZB_ITEM_AMMONADE)
  2049.     {
  2050.         give_nade(id)
  2051.         give_ammo(id)
  2052.     }
  2053.    
  2054.     //client_print(0, print_chat, "[%i]", item_type)
  2055. }
  2056. supplybox_get_type_item(item[])
  2057. {
  2058.     new left[64], right[64], type
  2059.     strbreak(item, left, 4, right, 63)
  2060.     if (equali(left, "csw_")) type = NSTZB_ITEM_WPNDEFAULT
  2061.     else if (equali(left, "nst_")) type = NSTZB_ITEM_NSTWPN
  2062.     else if (equali(item, "item_ammonade")) type = NSTZB_ITEM_AMMONADE
  2063.    
  2064.     return type
  2065. }
  2066. // Create SupplyBox
  2067. public create_supply_box()
  2068. {
  2069.     // check max supplybox
  2070.     if (supplybox_count>=SUPPLYBOX_MAX || g_newround || g_endround) return;
  2071.  
  2072.     // continue create supply
  2073.     if (task_exists(TASK_SUPPLYBOX)) remove_task(TASK_SUPPLYBOX)
  2074.     set_task(SUPPLYBOX_TIME, "create_supply_box", TASK_SUPPLYBOX)
  2075.    
  2076.     if (get_total_supplybox()>=SUPPLYBOX_TOTAL_IN_TIME) return;
  2077.    
  2078.     // create model
  2079.     g_supplybox_num = 0
  2080.     create_supply_box_model()
  2081.    
  2082.     // play sound
  2083.     PlaySound(0, SUPPLYBOX_SOUND_DROP)
  2084.    
  2085.     // show hudtext
  2086.     new message[100]
  2087.     format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_SUPPLYBOX")
  2088.     SendCenterText(0, message)
  2089.    
  2090.     // show text help
  2091.     if (task_exists(TASK_SUPPLYBOX_HELP)) remove_task(TASK_SUPPLYBOX_HELP)
  2092.     set_task(2.0, "supply_box_help", TASK_SUPPLYBOX_HELP)
  2093.  
  2094.     // create 2 supply box
  2095.     if (task_exists(TASK_SUPPLYBOX_MODEL)) remove_task(TASK_SUPPLYBOX_MODEL)
  2096.     set_task(0.5, "create_supply_box_model", TASK_SUPPLYBOX_MODEL, _, _, "b")
  2097. }
  2098. get_total_supplybox()
  2099. {
  2100.     new total
  2101.     for (new i=1; i<=supplybox_count; i++)
  2102.     {
  2103.         if (supplybox_ent[i]) total += 1
  2104.     }
  2105.     return total;
  2106. }
  2107. public create_supply_box_model()
  2108. {
  2109.     // check max supplybox
  2110.     if (supplybox_count>=SUPPLYBOX_MAX || get_total_supplybox()>=SUPPLYBOX_TOTAL_IN_TIME || g_newround || g_endround)
  2111.     {
  2112.         remove_task(TASK_SUPPLYBOX_MODEL)
  2113.         return;
  2114.     }
  2115.    
  2116.     // supply box count
  2117.     supplybox_count += 1
  2118.     g_supplybox_num += 1
  2119.  
  2120.     // get item in SupplyBox
  2121.     new item = random(ArraySize(supplybox_item))
  2122.    
  2123.     // get random model supplybox
  2124.     static model_w[64]
  2125.     ArrayGetString(supplybox_models, random(ArraySize(supplybox_models)), model_w, charsmax(model_w))
  2126.  
  2127.     // create supply box
  2128.     new ent_box = create_entity("info_target")
  2129.     entity_set_string(ent_box, EV_SZ_classname, SUPPLYBOX_CLASSNAME)
  2130.     entity_set_model(ent_box,model_w)  
  2131.     entity_set_size(ent_box,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
  2132.     entity_set_int(ent_box,EV_INT_solid,1)
  2133.     entity_set_int(ent_box,EV_INT_movetype,6)
  2134.     entity_set_int(ent_box, EV_INT_iuser1, item)
  2135.     entity_set_int(ent_box, EV_INT_iuser2, supplybox_count)
  2136.     //entity_set_vector(ent_box,EV_VEC_origin,origin)
  2137.    
  2138.     // set origin
  2139.     if (g_spawnCount_box) do_random_spawn_box(ent_box)
  2140.     else if (g_spawnCount) do_random_spawn(ent_box)
  2141.    
  2142.     // give ent SupplyBox
  2143.     supplybox_ent[supplybox_count] = ent_box
  2144.  
  2145.     // remove task
  2146.     if ((g_supplybox_num>=SUPPLYBOX_NUM) && task_exists(TASK_SUPPLYBOX_MODEL)) remove_task(TASK_SUPPLYBOX_MODEL)
  2147.  
  2148. }
  2149. // SupplyBox Help
  2150. public supply_box_help()
  2151. {
  2152.     new message[100]
  2153.     format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_SUPPLYBOX_HELP")
  2154.     SendCenterText(0, message)
  2155. }
  2156. // Remove SupplyBox
  2157. remove_supplybox()
  2158. {
  2159.     remove_ent_by_class(SUPPLYBOX_CLASSNAME)
  2160.     new supplybox_ent_reset[MAX_SUPPLYBOX]
  2161.     supplybox_ent = supplybox_ent_reset
  2162. }
  2163.  
  2164. // ##################### RADAR SCAN #####################
  2165. public radar_scan()
  2166. {  
  2167.     for (new id=1; id<=g_maxplayers; id++)
  2168.     {
  2169.         if (!is_user_alive(id)) continue;
  2170.        
  2171.         // scan supply box
  2172.         if (!supplybox_count) continue;
  2173.         if (g_zombie[id]) continue;
  2174.        
  2175.         new i = 1, next_ent
  2176.         while(i<=supplybox_count)
  2177.         {
  2178.             next_ent = supplybox_ent[i]
  2179.             if (next_ent)
  2180.             {
  2181.                 static Float:origin[3]
  2182.                 pev(next_ent, pev_origin, origin)
  2183.                
  2184.                 message_begin(MSG_ONE_UNRELIABLE, g_msgHostagePos, {0,0,0}, id)
  2185.                 write_byte(id)
  2186.                 write_byte(i)      
  2187.                 write_coord(fnFloatToNum(origin[0]))
  2188.                 write_coord(fnFloatToNum(origin[1]))
  2189.                 write_coord(fnFloatToNum(origin[2]))
  2190.                 message_end()
  2191.            
  2192.                 message_begin(MSG_ONE_UNRELIABLE, g_msgHostageK, {0,0,0}, id)
  2193.                 write_byte(i)
  2194.                 message_end()
  2195.                 //client_print(id, print_chat, "[%i] [%i] [%i] [%i]", next_ent, origin[0], origin[1], origin[2])
  2196.             }
  2197.  
  2198.             i++
  2199.         }
  2200.         //client_print(id, print_chat, "[%i][%i]", supplybox_count, i)
  2201.     }
  2202. }
  2203. // Register Ham Forwards for CZ bots
  2204. public register_ham_czbots(id)
  2205. {
  2206.     // Make sure it's a CZ bot and it's still connected
  2207.     if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))
  2208.         return;
  2209.            
  2210.     RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
  2211.     RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  2212.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
  2213.    
  2214.     // Ham forwards for CZ bots succesfully registered
  2215.     g_hamczbots = true
  2216.    
  2217.     // If the bot has already spawned, call the forward manually for him
  2218.     if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
  2219. }
  2220.  
  2221.  
  2222. /*================================================================================
  2223.  [Main Function]
  2224. =================================================================================*/
  2225. // Make Human Function
  2226. make_human_firt(id)
  2227. {
  2228.     if (!is_user_alive(id)) return;
  2229.    
  2230.     fm_set_user_health(id, HUMAN_HEALTH)
  2231.     fm_set_user_armor(id, HUMAN_ARMOR)
  2232.     set_pev(id, pev_gravity, HUMAN_GRAVITY)
  2233.    
  2234.     //show_level(id)
  2235.     turn_off_nvg(id)
  2236. }
  2237. make_human(id)
  2238. {
  2239.     if (!is_user_alive(id)) return;
  2240.    
  2241.     // set value
  2242.     g_zombie[id] = 0
  2243.     g_hero[id] = 0
  2244.    
  2245.     fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  2246.     fm_set_user_health(id, HUMAN_HEALTH)
  2247.     fm_set_user_armor(id, HUMAN_ARMOR)
  2248.     set_pev(id, pev_gravity, HUMAN_GRAVITY)
  2249.    
  2250.     // set model
  2251.     set_model_for_player(id)
  2252.    
  2253.     //show_level(id)
  2254.     turn_off_nvg(id)
  2255. }
  2256. // Make Hero Function
  2257. make_hero(id)
  2258. {
  2259.     if (!is_user_alive(id)) return;
  2260.  
  2261.     // set value
  2262.     g_zombie[id] = 0
  2263.     g_hero[id] = 1
  2264.        
  2265.     // set info
  2266.     fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  2267.     fm_set_user_health(id, HERO_HEALTH)
  2268.     fm_set_user_armor(id, HERO_ARMOR)
  2269.     set_pev(id, pev_gravity, HERO_GRAVITY)
  2270.     nst_set_user_sex(id, 1)
  2271.     nst_set_user_hand(id, 0)
  2272.    
  2273.     // set model
  2274.     set_model_for_player(id)
  2275.    
  2276.     // Drop previous weapons
  2277.     drop_weapons(id, 1)
  2278.     drop_weapons(id, 2)
  2279.    
  2280.     // give weapons
  2281.     new weapon[32]
  2282.     for (new i = 0; i < ArraySize(hero_weapons); i++)
  2283.     {
  2284.         ArrayGetString(hero_weapons, i, weapon, charsmax(weapon))
  2285.         give_weapons_item(id, weapon)
  2286.     }
  2287.    
  2288.     // show spr
  2289.     ShowStatusIcon(id, 1)
  2290.     if (task_exists(id+TASK_STATUSICON)) remove_task(id+TASK_STATUSICON)
  2291.     set_task(get_pcvar_float(cvar_time_show_spr), "Task_HideStatusIcon", id+TASK_STATUSICON)
  2292.    
  2293.     //show_level(id)
  2294.     turn_off_nvg(id)
  2295. }
  2296. // Make a Zombie Function
  2297. make_zombie(id)
  2298. {
  2299.     if (!is_user_alive(id)) return;
  2300.  
  2301.     // set value
  2302.     g_hero[id] = 0
  2303.     g_zombie[id] = 1
  2304.     if (!g_level[id]) g_level[id] = 1
  2305.    
  2306.     // Remove survivor's aura (bugfix)
  2307.     set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_BRIGHTLIGHT)
  2308.        
  2309.     // Remove spawn protection (bugfix)
  2310.     set_pev(id, pev_effects, pev(id, pev_effects) &~ EF_NODRAW)
  2311.  
  2312.     // Remove any zoom (bugfix)
  2313.     cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  2314.        
  2315.     // Remove armor
  2316.     set_pev(id, pev_armorvalue, 0.0)
  2317.        
  2318.     // Drop previous weapons
  2319.     if (get_pcvar_num(cvar_drop_weapons_infected))
  2320.     {  
  2321.         drop_weapons(id, 1)
  2322.         drop_weapons(id, 2)
  2323.     }
  2324.     else
  2325.     {  
  2326.         drop_weapons(id, 1, 1)
  2327.         drop_weapons(id, 2, 1)
  2328.     }
  2329.    
  2330.     // Strip off from weapons
  2331.     fm_strip_user_weapons(id)
  2332.     fm_give_item(id, "weapon_knife")
  2333.    
  2334.     // give zombie bom
  2335.     //give_zombiebom(id)
  2336.  
  2337.     // set team
  2338.     fm_cs_set_user_team(id, FM_CS_TEAM_T)
  2339.  
  2340.     // give info zombie
  2341.     new Float:gravity, Float:speed
  2342.     gravity = ArrayGetCell(zombie_gravity, g_zombieclass[id])
  2343.     speed = ArrayGetCell(zombie_speed, g_zombieclass[id])
  2344.     set_pev(id, pev_gravity, gravity)
  2345.     set_pev(id, pev_maxspeed, speed)
  2346.     UpdateHealthZombie(id)
  2347.    
  2348.     // set model
  2349.     set_model_for_player(id)
  2350.    
  2351.     // create effects
  2352.     infection_effects(id)
  2353.    
  2354.     // show level
  2355.     //show_level(id)
  2356.    
  2357.     // check model
  2358.     CurrentWeapon(id)
  2359.    
  2360.     // Show Score of Match
  2361.     //ShowScoreMatch()
  2362.  
  2363.     // turn off flashlight
  2364.     turn_off_flashlight(id)
  2365.    
  2366.     // nvg
  2367.     turn_off_nvg(id)
  2368.     if (get_pcvar_num(cvar_nvg_zombie_give)) cmd_nightvision(id)
  2369. }
  2370. set_model_for_player(id)
  2371. {  
  2372.     if (!is_user_connected(id)) return;
  2373.    
  2374.     if (g_zombie[id])
  2375.     {
  2376.         // set model player
  2377.         new model_view[64], model_index, idclass
  2378.         idclass = g_zombieclass[id]
  2379.         if (g_level[id]==1)
  2380.         {
  2381.             ArrayGetString(zombie_viewmodel_host, idclass, model_view, charsmax(model_view))
  2382.             model_index = ArrayGetCell(zombie_modelindex_host, idclass)
  2383.         }
  2384.         else
  2385.         {
  2386.             ArrayGetString(zombie_viewmodel_origin, idclass, model_view, charsmax(model_view))
  2387.             model_index = ArrayGetCell(zombie_modelindex_origin, idclass)
  2388.         }
  2389.         nst_set_user_model(id, model_view)
  2390.         if (get_zombie_set_modelindex(id)) nst_set_user_model_index(id, model_index)
  2391.         else nst_reset_user_model_index(id)
  2392.        
  2393.         //client_print(id, print_chat, "[%s][%s]", model_view, model_wpn)
  2394.     }
  2395.     else if (g_hero[id])
  2396.     {
  2397.         nst_set_user_model(id, HERO_MODEL)
  2398.     }
  2399.     else
  2400.     {
  2401.         nst_reset_user_model(id)
  2402.     }
  2403.    
  2404. }
  2405. get_zombie_set_modelindex(id)
  2406. {
  2407.     if (!g_zombie[id]) return 0;
  2408.    
  2409.     new modelindex = ArrayGetCell(zombie_modelindex, g_zombieclass[id])
  2410.     if ( (modelindex==3) || (modelindex==2 && g_level[id]>1) || (modelindex==1 && g_level[id]==1) ) return 1;
  2411.     else return 0;
  2412.    
  2413.     return 0;
  2414. }
  2415. zombie_infection_human(attacker, victim)
  2416. {
  2417.     // show Msg Death
  2418.     SendDeathMsg(attacker, victim)
  2419.     FixDeadAttrib(victim)
  2420.    
  2421.     // update frags of attacker and deaths of victim
  2422.     UpdateFrags(attacker, 1)
  2423.     UpdateDeaths(victim, 1)
  2424.    
  2425.     // update evolution of zombie attacker
  2426.     new xlevel, evo_up
  2427.     if (g_hero[victim]) xlevel = 4
  2428.     else xlevel = 1
  2429.    
  2430.     if (g_level[attacker]==1)  evo_up = xlevel*3
  2431.     else if (g_level[attacker]==2)  evo_up = xlevel*2
  2432.     UpdateEvolution(attacker, evo_up)
  2433.  
  2434.    
  2435.     // make zombie infection
  2436.     g_evolution[victim] = 0
  2437.     g_level[victim] = 1
  2438.     g_start_health[victim] = get_user_health(attacker)*1/2
  2439.     g_star_armor[victim] = get_user_armor(attacker)*1/2
  2440.    
  2441.     // make zombie
  2442.     g_zombieclass[victim] = random(class_count)
  2443.     make_zombie(victim)
  2444.    
  2445.     // show menu class zombie
  2446.     show_menu_class_zombie(victim)
  2447.    
  2448.     // remove glow of victim
  2449.     fm_set_rendering(victim)
  2450.  
  2451.     // play sound human death
  2452.     new sound[64], sex
  2453.     sex = nst_get_user_sex(victim)
  2454.     if (sex == 2) ArrayGetString(sound_female_death, random(ArraySize(sound_female_death)), sound, charsmax(sound))
  2455.     else ArrayGetString(sound_human_death, random(ArraySize(sound_human_death)), sound, charsmax(sound))
  2456.     PlayEmitSound(victim, CHAN_VOICE, sound)
  2457.    
  2458.     // play sound zombie coming
  2459.     ArrayGetString(sound_zombie_coming, random(ArraySize(sound_zombie_coming)), sound, charsmax(sound))
  2460.     PlaySound(0, sound)
  2461.    
  2462.     // Post user infect forward
  2463.     ExecuteForward(g_fwUserInfected, g_fwDummyResult, victim, attacker)
  2464.    
  2465.     //client_print(attacker, print_chat, "L[%i] E[%i]", g_level[attacker], g_evolution[attacker])
  2466.     //client_print(victim, print_chat, "DA[%i] DV[%i]", get_user_health(attacker), g_start_health[victim])
  2467.     //client_print(victim, print_chat, "AA[%i] AV[%i]", get_user_armor(attacker), g_star_armor[victim])
  2468. }
  2469. human_kill_zombie(killer, victim, weaponid)
  2470. {  
  2471.     // update zombie die
  2472.     g_zombie_die[victim] ++
  2473.        
  2474.     // check killer is human
  2475.     new human
  2476.     if (is_user_connected(killer) && killer!=victim) human = killer
  2477.    
  2478.     // respawn zombie if not headshot
  2479.     if (weaponid != CSW_KNIFE)
  2480.     {
  2481.         g_respawning[victim] = 1
  2482.        
  2483.         // Set time respawn zombie
  2484.         if (task_exists(victim+TASK_ZOMBIE_RESPAWN)) remove_task(victim+TASK_ZOMBIE_RESPAWN)
  2485.         set_task(float(RESPAWN_TIME_WAIT), "zombie_respawn", victim+TASK_ZOMBIE_RESPAWN)
  2486.        
  2487.         // effect
  2488.         if (task_exists(victim+TASK_ZOMBIE_RESPAWN_EF)) remove_task(victim+TASK_ZOMBIE_RESPAWN_EF)
  2489.         set_task(0.5, "zombie_respawn_effect", victim+TASK_ZOMBIE_RESPAWN_EF)
  2490.    
  2491.         // Run BarTime
  2492.         run_bartime(victim, RESPAWN_TIME_WAIT)
  2493.        
  2494.         // fix frags of human & deaths of zombie
  2495.         if (human)
  2496.         {
  2497.             //UpdateFrags(killer, -1)
  2498.             UpdateDeaths(victim, -1)
  2499.         }
  2500.     }
  2501.     // else zombie is death
  2502.     else
  2503.     {
  2504.         // Show Score of Match
  2505.         //ShowScoreMatch()
  2506.     }
  2507.    
  2508.     // update level of human and show effect
  2509.     if (human)
  2510.     {
  2511.         UpdateLevelTeamHuman()
  2512.     }
  2513.  
  2514.     //client_print(killer, print_chat, "L[%i]", g_level[killer])
  2515. }
  2516. // reset value of player
  2517. reset_value(id)
  2518. {
  2519.     if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
  2520.     if (task_exists(id+TASK_SPAWN)) remove_task(id+TASK_SPAWN)
  2521.     if (task_exists(id+TASK_MENUWPN)) remove_task(id+TASK_MENUWPN)
  2522.     if (task_exists(id+TASK_ZOMBIE_RESPAWN)) remove_task(id+TASK_ZOMBIE_RESPAWN)
  2523.     if (task_exists(id+TASK_ZOMBIE_RESPAWN_EF)) remove_task(id+TASK_ZOMBIE_RESPAWN_EF)
  2524.     if (task_exists(id+TASK_NVISION)) remove_task(id+TASK_NVISION)
  2525.    
  2526.     g_level[id] = 0
  2527.     g_zombie[id] = 0
  2528.     g_hero[id] = 0
  2529.     g_evolution[id] = 0
  2530.     g_dmg_attack[id] = 0
  2531.     g_start_health[id] = 0
  2532.     g_star_armor[id] = 0
  2533.     g_buyammo[id] = 0
  2534.     g_restore_health[id] = 0
  2535.     g_respawning[id] = 0
  2536.     g_nvg[id] = 0
  2537.     g_supplybox_wait[id] = 0
  2538.     g_zombie_weak[id] = 0
  2539.     g_zombie_die[id] = 0
  2540.    
  2541.     if (is_user_alive(id))
  2542.     {
  2543.         fm_set_rendering(id)
  2544.         set_pev(id, pev_gravity, 1.0)
  2545.     }
  2546. }
  2547. // Restore health for zombie
  2548. zombie_restore_health(id)
  2549. {
  2550.     if (!g_zombie[id] || g_newround || g_endround) return;
  2551.    
  2552.     static Float:velocity[3]
  2553.     pev(id, pev_velocity, velocity)
  2554.    
  2555.     if (!velocity[0] && !velocity[1] && !velocity[2])
  2556.     {
  2557.         if (!g_restore_health[id]) g_restore_health[id] = get_systime()
  2558.     }
  2559.     else g_restore_health[id] = 0
  2560.    
  2561.     if (g_restore_health[id])
  2562.     {
  2563.         new rh_time = get_systime() - g_restore_health[id]
  2564.         if (rh_time == RESTORE_HEALTH_TIME+1 && get_user_health(id) < g_start_health[id])
  2565.         {
  2566.             // get health add
  2567.             new health_add
  2568.             if (g_level[id]==1) health_add = RESTORE_HEALTH_DMG_LV1
  2569.             else health_add = RESTORE_HEALTH_DMG_LV2
  2570.            
  2571.             // get health new
  2572.             new health_new = get_user_health(id)+health_add
  2573.             health_new = min(health_new, g_start_health[id])
  2574.            
  2575.             // set health
  2576.             fm_set_user_health(id, health_new)
  2577.             g_restore_health[id] += 1
  2578.            
  2579.             // effect
  2580.             SendMsgDamage(id)
  2581.             EffectRestoreHealth(id)
  2582.            
  2583.             // play sound heal
  2584.             new sound_heal[64]
  2585.             ArrayGetString(zombie_sound_heal, g_zombieclass[id], sound_heal, charsmax(sound_heal))
  2586.             PlaySound(id, sound_heal)
  2587.         }
  2588.     }
  2589. }
  2590. // Zombie Weak
  2591. zombie_weak(id)
  2592. {
  2593.     // check value
  2594.     if (!g_zombie[id] || !get_pcvar_num(cvar_zombie_weak)) return;
  2595.  
  2596.     // set zombie Weak
  2597.     if (get_user_health(id)<=get_pcvar_num(cvar_zombie_weak_dmg) && !g_zombie_weak[id])
  2598.     {
  2599.         g_zombie_weak[id] = 1
  2600.     }
  2601.     else if (get_user_health(id)>get_pcvar_num(cvar_zombie_weak_dmg) && g_zombie_weak[id])
  2602.     {
  2603.         fm_set_rendering(id)
  2604.         g_zombie_weak[id] = 0
  2605.     }
  2606.    
  2607.     // repeat glow
  2608.     if (g_zombie_weak[id])
  2609.     {
  2610.         g_zombie_weak[id] += 1
  2611.         new glow_num = g_zombie_weak[id] % max(2, get_pcvar_num(cvar_zombie_flash))
  2612.         if (glow_num) zombie_weak_create_glow(id)
  2613.         else fm_set_rendering(id)
  2614.         //client_print(0, print_chat, "AT[%i]", glow_num)
  2615.     }
  2616.    
  2617. }
  2618. zombie_weak_create_glow(id)
  2619. {
  2620.     new color[3]
  2621.     color[0] = get_pcvar_num(cvar_zombie_weak_color[0])
  2622.     color[1] = get_pcvar_num(cvar_zombie_weak_color[1])
  2623.     color[2] = get_pcvar_num(cvar_zombie_weak_color[2])
  2624.     fm_set_rendering(id, kRenderFxGlowShell, color[0], color[1], color[2], kRenderNormal, 0)
  2625. }
  2626.  
  2627. // ZombieBom Grenade Explosion
  2628. zombiebom_explode(ent)
  2629. {
  2630.     // Round ended (bugfix)
  2631.     if (g_newround || g_endround) return;
  2632.    
  2633.     // Get origin
  2634.     static Float:originF[3]
  2635.     pev(ent, pev_origin, originF)
  2636.    
  2637.     // Make the explosion
  2638.     EffectZombieBomExp(ent)
  2639.    
  2640.     // explode sound
  2641.     engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, ZOMBIEBOM_SOUND_EXP, 1.0, ATTN_NORM, 0, PITCH_NORM)
  2642.    
  2643.     // Get attacker
  2644.     //static attacker
  2645.     //attacker = pev(ent, pev_owner)
  2646.    
  2647.     // Collisions
  2648.     static victim
  2649.     victim = -1
  2650.    
  2651.     new Float:fOrigin[3],Float:fDistance,Float:fDamage
  2652.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, ZOMBIEBOM_RADIUS)) != 0)
  2653.     {
  2654.         // Only effect alive non-spawnprotected humans
  2655.         if (!is_user_alive(victim))
  2656.             continue;
  2657.        
  2658.         // get value
  2659.         pev(victim, pev_origin, fOrigin)
  2660.         fDistance = get_distance_f(fOrigin, originF)
  2661.         fDamage = ZOMBIEBOM_POWER - floatmul(ZOMBIEBOM_POWER, floatdiv(fDistance, ZOMBIEBOM_RADIUS))//get the damage value
  2662.         fDamage *= estimate_take_hurt(originF, victim, 0)//adjust
  2663.         if ( fDamage < 0 )
  2664.             continue
  2665.  
  2666.         // create effect
  2667.         manage_effect_action(victim, fOrigin, originF, fDistance, fDamage * 8.0)
  2668.         continue;
  2669.     }
  2670.    
  2671.     // Get rid of the grenade
  2672.     engfunc(EngFunc_RemoveEntity, ent)
  2673.    
  2674.     //client_print(0, print_chat, "AT[%i]", attacker)
  2675. }
  2676. EffectZombieBomExp(id)
  2677. {
  2678.     static Float:origin[3];
  2679.     pev(id,pev_origin,origin);
  2680.    
  2681.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  2682.     write_byte(TE_EXPLOSION); // TE_EXPLOSION
  2683.     write_coord(floatround(origin[0])); // origin x
  2684.     write_coord(floatround(origin[1])); // origin y
  2685.     write_coord(floatround(origin[2])); // origin z
  2686.     write_short(ZOMBIEBOM_IDSPRITES_EXP); // sprites
  2687.     write_byte(40); // scale in 0.1's
  2688.     write_byte(30); // framerate
  2689.     write_byte(14); // flags
  2690.     message_end(); // message end
  2691. }
  2692. manage_effect_action(iEnt, Float:fEntOrigin[3], Float:fPoint[3], Float:fDistance, Float:fDamage)
  2693. {
  2694.     //return 1
  2695.     new Float:Velocity[3]
  2696.     pev(iEnt, pev_velocity, Velocity)
  2697.    
  2698.     new Float:fTime = floatdiv(fDistance, fDamage)
  2699.     new Float:fVelocity[3]
  2700.     fVelocity[0] = floatdiv((fEntOrigin[0] - fPoint[0]), fTime) + Velocity[0]*0.5
  2701.     fVelocity[1] = floatdiv((fEntOrigin[1] - fPoint[1]), fTime) + Velocity[1]*0.5
  2702.     fVelocity[2] = floatdiv((fEntOrigin[2] - fPoint[2]), fTime) + Velocity[2]*0.5
  2703.     set_pev(iEnt, pev_velocity, fVelocity)
  2704.     return 1
  2705. }
  2706. give_ammo(id)
  2707. {
  2708.     new weapons[32], num, i, idwpn, ammo
  2709.     num = 0
  2710.     get_user_weapons(id, weapons, num)
  2711.  
  2712.     for (i = 0; i < num; i++)
  2713.     {
  2714.         idwpn = weapons[i]
  2715.         ammo = get_ammo_buywpn(idwpn)
  2716.         if (ammo>2)
  2717.         {
  2718.             show_hud_ammo(id, idwpn, ammo)
  2719.             cs_set_user_bpammo(id, idwpn, ammo)
  2720.         }
  2721.     }
  2722.    
  2723.     // set full ammo for nst wpn
  2724.     nst_wpn_set_fullammo(id)
  2725. }
  2726. // Give Nade for player
  2727. give_nade(id)
  2728. {
  2729.     // Get user weapons
  2730.     new weapons[32], num, i, weaponid
  2731.     num = 0 // reset passed weapons count (bugfix)
  2732.     get_user_weapons(id, weapons, num)
  2733.    
  2734.     // Loop through them and drop primaries or secondaries
  2735.     for (i = 0; i < num; i++)
  2736.     {
  2737.         // Prevent re-indexing the array
  2738.         weaponid = weapons[i]
  2739.        
  2740.         new idnade_str[32], idnade_num
  2741.         for (new i = 0; i < ArraySize(weapons_nade); i++)
  2742.         {
  2743.             ArrayGetString(weapons_nade, i, idnade_str, charsmax(idnade_str))
  2744.             idnade_num = csw_name_to_id(idnade_str)
  2745.             if (weaponid != idnade_num) give_weapon(id, idnade_num)
  2746.         }
  2747.     }
  2748. }
  2749. give_zombiebom(id)
  2750. {
  2751.     // Get user weapons
  2752.     new weapons[32], num, i, weaponid
  2753.     num = 0 // reset passed weapons count (bugfix)
  2754.     get_user_weapons(id, weapons, num)
  2755.    
  2756.     // Loop through them and drop primaries or secondaries
  2757.     for (i = 0; i < num; i++)
  2758.     {
  2759.         weaponid = weapons[i]
  2760.         if (weaponid != CSW_HEGRENADE) fm_give_item(id, WEAPONENTNAMES[CSW_HEGRENADE])
  2761.     }
  2762. }
  2763. // StatusIcon
  2764. ShowStatusIcon(id, idspr)
  2765. {  
  2766.     StatusIcon(id, idspr, 1)
  2767. }
  2768. HideStatusIcon(id)
  2769. {  
  2770.     for (new i = 1; i <= 1; i++)
  2771.     {
  2772.         StatusIcon(id, i, 0)
  2773.     }
  2774.  
  2775. }
  2776. StatusIcon(id, idspr, run)
  2777. {  
  2778.     message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
  2779.     write_byte(run); // status (0=hide, 1=show, 2=flash)
  2780.     write_string(GetStatusIconName(idspr)); // sprite name
  2781.     message_end();
  2782.  
  2783. }
  2784. GetStatusIconName(idspr)
  2785. {
  2786.     new spr_name[33]
  2787.     switch (idspr)
  2788.     {
  2789.         case 1: spr_name = "g_hero"
  2790.     }
  2791.     return spr_name
  2792. }
  2793. public Task_HideStatusIcon(taskid)
  2794. {
  2795.     new id = ID_STATUSICON
  2796.     HideStatusIcon(id)
  2797.     if (task_exists(taskid)) remove_task(taskid)
  2798. }
  2799.  
  2800. // Infection special effects
  2801. infection_effects(id)
  2802. {
  2803.     // Get player's origin
  2804.     static origin[3]
  2805.     get_user_origin(id, origin)
  2806.  
  2807.     // Tracers?
  2808.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  2809.     write_byte(TE_IMPLOSION) // TE id
  2810.     write_coord(origin[0]) // x
  2811.     write_coord(origin[1]) // y
  2812.     write_coord(origin[2]) // z
  2813.     write_byte(128) // radius
  2814.     write_byte(20) // count
  2815.     write_byte(3) // duration
  2816.     message_end()
  2817.        
  2818.     // Particle burst?
  2819.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  2820.     write_byte(TE_PARTICLEBURST) // TE id
  2821.     write_coord(origin[0]) // x
  2822.     write_coord(origin[1]) // y
  2823.     write_coord(origin[2]) // z
  2824.     write_short(50) // radius
  2825.     write_byte(70) // color
  2826.     write_byte(3) // duration (will be randomized a bit)
  2827.     message_end()
  2828.    
  2829.     // Light sparkle?
  2830.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  2831.     write_byte(TE_DLIGHT) // TE id
  2832.     write_coord(origin[0]) // x
  2833.     write_coord(origin[1]) // y
  2834.     write_coord(origin[2]) // z
  2835.     write_byte(20) // radius
  2836.     write_byte(0) // r
  2837.     write_byte(150) // g
  2838.     write_byte(0) // b
  2839.     write_byte(2) // life
  2840.     write_byte(0) // decay rate
  2841.     message_end()
  2842.    
  2843. }
  2844. // Respawn Player Manually (called after respawn checks are done)
  2845. respawn_player_manually(id)
  2846. {
  2847.     if (is_user_connected(id))
  2848.     {
  2849.         fm_cs_set_user_team(id, FM_CS_TEAM_T)
  2850.         ExecuteHamB(Ham_CS_RoundRespawn, id)
  2851.     }  
  2852. }
  2853. make_human_team()
  2854. {
  2855.     static id
  2856.     for (id = 1; id <= g_maxplayers; id++)
  2857.     {
  2858.         if (is_user_connected(id) && !g_zombie[id] && !g_hero[id])
  2859.         {
  2860.             make_human(id)
  2861.             give_nade(id)
  2862.             nst_reset_user_model(id)
  2863.         }
  2864.     }
  2865. }
  2866. give_team_player()
  2867. {
  2868.     // Get amount of users playing
  2869.     static iPlayersnum
  2870.     iPlayersnum = fnGetPlaying()
  2871.    
  2872.     // No players, don't bother
  2873.     if (iPlayersnum < 1) return;
  2874.  
  2875.     // reset team
  2876.     for (new id = 1; id <= g_maxplayers; id++)
  2877.     {
  2878.         // Skip if not connected
  2879.         if (!is_user_connected(id)) continue;
  2880.        
  2881.         g_team[id] = fm_cs_get_user_team(id)
  2882.     }
  2883. }
  2884. reset_teams()
  2885. {
  2886.     // Get amount of users playing
  2887.     static iPlayersnum
  2888.     iPlayersnum = fnGetPlaying()
  2889.    
  2890.     // No players, don't bother
  2891.     if (iPlayersnum < 1) return;
  2892.  
  2893.     // reset team
  2894.     for (new id = 1; id <= g_maxplayers; id++)
  2895.     {
  2896.         // Skip if not connected
  2897.         if (!is_user_connected(id)) continue;
  2898.        
  2899.         // get model
  2900.         new model[32]
  2901.         cs_get_user_model(id, model, charsmax(model))
  2902.  
  2903.         // reset teams
  2904.         new team = g_team[id]
  2905.         if (team == 1) fm_cs_set_user_team(id, FM_CS_TEAM_T)
  2906.         else if (team == 2) fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  2907.        
  2908.         // set model
  2909.         nst_set_user_model(id, model)
  2910.     }
  2911.    
  2912.     /*
  2913.     // Get amount of users playing
  2914.     static iPlayersnum
  2915.     iPlayersnum = fnGetPlaying()
  2916.    
  2917.     // No players, don't bother
  2918.     if (iPlayersnum < 1) return;
  2919.    
  2920.     // Split players evenly
  2921.     static iTerrors, iMaxTerrors, id, team[33]
  2922.     iMaxTerrors = iPlayersnum/2
  2923.     iTerrors = 0
  2924.    
  2925.     // First, set everyone to CT
  2926.     for (id = 1; id <= g_maxplayers; id++)
  2927.     {
  2928.         // Skip if not connected
  2929.         if (!is_user_connected(id))
  2930.             continue;
  2931.        
  2932.         team[id] = fm_cs_get_user_team(id)
  2933.        
  2934.         // Skip if not playing
  2935.         if (team[id] == FM_CS_TEAM_SPECTATOR || team[id] == FM_CS_TEAM_UNASSIGNED)
  2936.             continue;
  2937.        
  2938.         // Set team
  2939.         if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
  2940.         fm_cs_set_user_team(id, FM_CS_TEAM_CT)
  2941.         team[id] = FM_CS_TEAM_CT
  2942.     }
  2943.    
  2944.     // Then randomly set half of the players to Terrorists
  2945.     while (iTerrors < iMaxTerrors)
  2946.     {
  2947.         // Keep looping through all players
  2948.         if (++id > g_maxplayers) id = 1
  2949.        
  2950.         // Skip if not connected
  2951.         if (!is_user_connected(id))
  2952.             continue;
  2953.        
  2954.         // Skip if not playing or already a Terrorist
  2955.         if (team[id] != FM_CS_TEAM_CT)
  2956.             continue;
  2957.        
  2958.         // Random chance
  2959.         if (random_num(0, 1))
  2960.         {
  2961.             fm_cs_set_user_team(id, FM_CS_TEAM_T)
  2962.             team[id] = FM_CS_TEAM_T
  2963.             iTerrors++
  2964.         }
  2965.     }
  2966.     */
  2967. }
  2968.  
  2969. // Get Playing -returns number of users playing-
  2970. fnGetPlaying()
  2971. {
  2972.     static iPlaying, id, team
  2973.     iPlaying = 0
  2974.    
  2975.     for (id = 1; id <= g_maxplayers; id++)
  2976.     {
  2977.         if (is_user_connected(id))
  2978.         {
  2979.             team = fm_cs_get_user_team(id)
  2980.            
  2981.             if (team != FM_CS_TEAM_SPECTATOR && team != FM_CS_TEAM_UNASSIGNED)
  2982.                 iPlaying++
  2983.         }
  2984.     }
  2985.    
  2986.     return iPlaying;
  2987. }
  2988. // Get Random Player
  2989. fnGetRandomPlayer()
  2990. {
  2991.     new id, check_vl
  2992.     while (!check_vl)
  2993.     {
  2994.         id = random_num(1, g_maxplayers)
  2995.         if (is_user_alive(id) && !g_zombie[id] && !g_hero[id]) check_vl = 1
  2996.     }
  2997.    
  2998.     return id
  2999. }
  3000.  
  3001. // get total player
  3002. GetTotalPlayer(team, alive)
  3003. {
  3004.     // team: 1 is TE, 2 is CT, 3 is Zombie, 4 is Human, 0 is all
  3005.     // alive: 0 is death and alive, 1 is alive
  3006.     static total, id
  3007.     total = 0
  3008.    
  3009.     for (id = 1; id <= g_maxplayers; id++)
  3010.     {
  3011.         if ( (alive && is_user_alive(id)) || (!alive && is_user_connected(id)) )
  3012.         {
  3013.             if (
  3014.             team == 1 && fm_cs_get_user_team(id) == FM_CS_TEAM_T ||
  3015.             team == 2 && fm_cs_get_user_team(id) == FM_CS_TEAM_CT ||
  3016.             team == 3 && g_zombie[id] ||
  3017.             team == 4 && !g_zombie[id] ||
  3018.             team == 0
  3019.             ) total++
  3020.         }
  3021.     }
  3022.    
  3023.     return total;
  3024. }
  3025. // bartime
  3026. run_bartime(id, wait_time)
  3027. {
  3028.     message_begin(MSG_ONE, g_msgBarTime, _, id)
  3029.     write_short(wait_time)
  3030.     message_end()
  3031. }
  3032. // Send Death Message for infections
  3033. SendDeathMsg(attacker, victim)
  3034. {
  3035.     message_begin(MSG_BROADCAST, g_msgDeathMsg)
  3036.     write_byte(attacker) // killer
  3037.     write_byte(victim) // victim
  3038.     write_byte(0) // headshot flag
  3039.     write_string("knife") // killer's weapon
  3040.     message_end()
  3041. }
  3042. // Fix Dead Attrib on scoreboard
  3043. FixDeadAttrib(id)
  3044. {
  3045.     message_begin(MSG_BROADCAST, g_msgScoreAttrib)
  3046.     write_byte(id) // id
  3047.     write_byte(0) // attrib
  3048.     message_end()
  3049. }
  3050. // Plays a sound on clients
  3051. PlaySound(id, const sound[])
  3052. {
  3053.     client_cmd(id, "spk ^"%s^"", sound)
  3054. }
  3055. // Plays Emit sound
  3056. PlayEmitSound(id, type, const sound[])
  3057. {
  3058.     emit_sound(id, type, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  3059. }
  3060.  
  3061. // Effect level up
  3062. EffectLevelUp(id)
  3063. {
  3064.     if (!is_user_alive(id)) return;
  3065.    
  3066.     // get origin
  3067.     static Float:origin[3]
  3068.     pev(id, pev_origin, origin)
  3069.    
  3070.     // set color
  3071.     new color[3]
  3072.     color[0] = get_color_level(id, 0)
  3073.     color[1] = get_color_level(id, 1)
  3074.     color[2] = get_color_level(id, 2)
  3075.  
  3076.     // create effect
  3077.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  3078.     write_byte(TE_BEAMCYLINDER) // TE id
  3079.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  3080.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  3081.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  3082.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  3083.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  3084.     engfunc(EngFunc_WriteCoord, origin[2]+100.0) // z axis
  3085.     write_short(id_sprites_levelup) // sprite
  3086.     write_byte(0) // startframe
  3087.     write_byte(0) // framerate
  3088.     write_byte(4) // life
  3089.     write_byte(60) // width
  3090.     write_byte(0) // noise
  3091.     write_byte(color[0]) // red
  3092.     write_byte(color[1]) // green
  3093.     write_byte(color[2]) // blue
  3094.     write_byte(200) // brightness
  3095.     write_byte(0) // speed
  3096.     message_end()
  3097.    
  3098.     // create glow shell
  3099.     fm_set_rendering(id)
  3100.     fm_set_rendering(id, kRenderFxGlowShell, color[0], color[1], color[2], kRenderNormal, 0)
  3101.     if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
  3102.     set_task(get_pcvar_float(cvar_glowshell_time), "RemoveGlowShell", id+TASK_GLOWSHELL)
  3103. }
  3104. get_color_level(id, num)
  3105. {
  3106.     new color[3]
  3107.     if (g_zombie[id])
  3108.     {
  3109.         switch (g_level[id])
  3110.         {
  3111.             case 2: color = {251,168,0}
  3112.             case 3: color = {255,10,0}
  3113.             default: color = {41,138,255}
  3114.         }
  3115.     }
  3116.     else
  3117.     {
  3118.         switch (g_level[id])
  3119.         {
  3120.             case 1: color = {0,177,0}
  3121.             case 2: color = {0,177,0}
  3122.             case 3: color = {0,177,0}
  3123.             case 4: color = {137,191,20}
  3124.             case 5: color = {137,191,20}
  3125.             case 6: color = {250,229,0}
  3126.             case 7: color = {250,229,0}
  3127.             case 8: color = {243,127,1}
  3128.             case 9: color = {243,127,1}
  3129.             case 10: color = {255,3,0}
  3130.             case 11: color = {127,40,208}
  3131.             case 12: color = {127,40,208}
  3132.             case 13: color = {127,40,208}
  3133.             default: color = {0,177,0}
  3134.         }
  3135.     }
  3136.    
  3137.     return color[num];
  3138. }
  3139. // Effect
  3140. EffectRestoreHealth(id)
  3141. {
  3142.     if (!is_user_alive(id)) return;
  3143.    
  3144.     static Float:origin[3];
  3145.     pev(id,pev_origin,origin);
  3146.    
  3147.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  3148.     write_byte(TE_EXPLOSION); // TE_EXPLOSION
  3149.     write_coord(floatround(origin[0])); // origin x
  3150.     write_coord(floatround(origin[1])); // origin y
  3151.     write_coord(floatround(origin[2])); // origin z
  3152.     write_short(restore_health_idspr); // sprites
  3153.     write_byte(15); // scale in 0.1's
  3154.     write_byte(12); // framerate
  3155.     write_byte(14); // flags
  3156.     message_end(); // message end
  3157.    
  3158.     message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade , _, id);
  3159.     write_short(1<<10);
  3160.     write_short(1<<10);
  3161.     write_short(0x0000);
  3162.     write_byte(255);//r
  3163.     write_byte(0);  //g
  3164.     write_byte(0);  //b
  3165.     write_byte(75);
  3166.     message_end();
  3167. }
  3168. EffectZombieRespawn(id)
  3169. {
  3170.     static Float:origin[3];
  3171.     pev(id,pev_origin,origin);
  3172.    
  3173.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  3174.     write_byte(TE_EXPLOSION); // TE_EXPLOSION
  3175.     write_coord(floatround(origin[0])); // origin x
  3176.     write_coord(floatround(origin[1])); // origin y
  3177.     write_coord(floatround(origin[2])); // origin z
  3178.     write_short(zombie_respawn_idspr); // sprites
  3179.     write_byte(10); // scale in 0.1's
  3180.     write_byte(20); // framerate
  3181.     write_byte(14); // flags
  3182.     message_end(); // message end
  3183. }
  3184. public RemoveGlowShell(taskid)
  3185. {
  3186.     fm_set_rendering(ID_GLOWSHELL)
  3187.     if (task_exists(taskid)) remove_task(taskid)
  3188. }
  3189. UpdateLevelZombie(id, num)
  3190. {
  3191.     // give level
  3192.     g_level[id] += num
  3193.     if (g_level[id] > MAX_LEVEL_ZOMBIE) g_level[id] = MAX_LEVEL_ZOMBIE
  3194.    
  3195.     // check model
  3196.     CurrentWeapon(id)
  3197.        
  3198.     //client_print(id, print_chat, "L[%i]", g_level[id])
  3199. }
  3200. UpdateEvolutionDamage(id, damageup)
  3201. {
  3202.     // check zombie
  3203.     if (!g_zombie[id]) return;
  3204.    
  3205.     // get damage
  3206.     new damage
  3207.     new sec_c = get_systime()
  3208.     new time_attack_zombie = get_pcvar_num(cvar_time_attack_zombie)
  3209.     new timeleft = sec_c - g_victim_time_attack[id]
  3210.     g_victim_time_attack[id] = sec_c
  3211.    
  3212.     if (timeleft <= time_attack_zombie) damage = g_victim_damage[id]+damageup
  3213.     else damage = damageup
  3214.    
  3215.     // Update Evolution
  3216.     new evo_dmg = damage % (ZOMBIE_DAMAGE_LEVEL*g_level[id])
  3217.     new evo_up = (damage - evo_dmg)/(ZOMBIE_DAMAGE_LEVEL*g_level[id])
  3218.     UpdateEvolution(id, evo_up)
  3219.     g_victim_damage[id] = evo_dmg
  3220.  
  3221.     //client_print(id, print_chat, "[%i][%i]", g_victim_damage[id], evo_up)
  3222. }
  3223. UpdateEvolution(id, num)
  3224. {
  3225.     if (!num || !g_zombie[id]) return;
  3226.    
  3227.     // update Evolution of zombie
  3228.     g_evolution[id] += num
  3229.     if (g_evolution[id] > MAX_EVOLUTION) g_evolution[id] = MAX_EVOLUTION
  3230.  
  3231.     // update level of zombie
  3232.     new evolution_zb = g_evolution[id] % 10
  3233.     new levelup = (g_evolution[id]-evolution_zb)/10
  3234.     if (levelup && g_level[id]<MAX_LEVEL_ZOMBIE)
  3235.     {
  3236.         // reset zombie die
  3237.         g_zombie_die[id] = 0
  3238.         // update level
  3239.         UpdateLevelZombie(id, levelup)
  3240.         // set health & armor
  3241.         UpdateHealthZombie(id)
  3242.         // create effect
  3243.         EffectLevelUp(id)
  3244.         // play sound evolution
  3245.         new sound_ev[64]
  3246.         ArrayGetString(zombie_sound_evolution, g_zombieclass[id], sound_ev, charsmax(sound_ev))
  3247.         PlayEmitSound(id, CHAN_VOICE, sound_ev)
  3248.     }
  3249.    
  3250.     // max level zombie
  3251.     g_evolution[id] = evolution_zb
  3252.     if (g_level[id] >= MAX_LEVEL_ZOMBIE) g_evolution[id] = MAX_EVOLUTION
  3253.  
  3254.     // show Evolution
  3255.     //show_level(id)
  3256.    
  3257.     //client_print(id, print_chat, "E[%i]", g_evolution[id])
  3258. }
  3259. UpdateHealthZombie(id)
  3260. {
  3261.     if (!g_zombie[id]) return;
  3262.    
  3263.     // set value
  3264.     new health, armor
  3265.     if (g_level[id]==2)
  3266.     {
  3267.         health = ZB_LV2_HEALTH
  3268.         armor = ZB_LV2_ARMOR
  3269.  
  3270.     }
  3271.     else if (g_level[id]==3)
  3272.     {
  3273.         health = ZB_LV3_HEALTH
  3274.         armor = ZB_LV3_ARMOR
  3275.     }
  3276.     else
  3277.     {
  3278.         health = g_start_health[id]
  3279.         armor = g_star_armor[id]
  3280.     }
  3281.    
  3282.     // zombie has 1/2 health if die
  3283.     if (g_zombie_die[id])
  3284.     {
  3285.         if (g_level[id]==1) health = health/2
  3286.         else health = health/(g_zombie_die[id]*2)
  3287.     }
  3288.    
  3289.     // check value
  3290.     health = max(MIN_HEALTH_ZOMBIE, health)
  3291.     armor = max(MIN_ARMOR_ZOMBIE, armor)
  3292.    
  3293.     // set again start value
  3294.     g_start_health[id] = health
  3295.     g_star_armor[id] = armor
  3296.  
  3297.     // give health
  3298.     fm_set_user_health(id, health)
  3299.     fm_set_user_armor(id, armor)
  3300. }
  3301. UpdateLevelTeamHuman()
  3302. {
  3303.     static id
  3304.     for (id = 1; id <= g_maxplayers; id++)
  3305.     {
  3306.         if (is_user_alive(id) && !g_zombie[id])
  3307.         {
  3308.             UpdateLevelHuman(id, 1)
  3309.         }
  3310.     }
  3311.    
  3312.     return 1
  3313. }
  3314. UpdateLevelHuman(id, num)
  3315. {
  3316.     // update level
  3317.     g_level[id] += num
  3318.     if (g_level[id] > MAX_LEVEL_HUMAN) g_level[id] = MAX_LEVEL_HUMAN
  3319.     else
  3320.     {
  3321.         // show level
  3322.         //show_level(id)
  3323.        
  3324.         // play sound
  3325.         PlaySound(id, sound_levelup)
  3326.        
  3327.         // Effect
  3328.         EffectLevelUp(id)
  3329.  
  3330.         // show hudtext
  3331.         new message[100]
  3332.         format(message, charsmax(message), "%L", LANG_PLAYER, "ZB3_NOTICE_HUMAN_LEVELUP", g_level[id])
  3333.         SendCenterText(id, message)
  3334.     }
  3335.    
  3336.     //client_print(id, print_chat, "L[%i]", g_level[id])
  3337. }
  3338. UpdateLevelHumanDamage(id, damageup)
  3339. {
  3340.     new level_damage = get_pcvar_num(cvar_level_damage)
  3341.     if (!level_damage) return;
  3342.  
  3343.     // ExecuteForward
  3344.     ExecuteForward(g_fwUserDamage, g_fwDummyResult, id, damageup, level_damage)
  3345.  
  3346.     // get value
  3347.     new k_old = get_k(g_dmg_attack[id])
  3348.     new k_new = get_k(g_dmg_attack[id]+damageup)
  3349.     new level_up = k_new - k_old
  3350.    
  3351.     // if human attack 1000 dmg of zombie then level up
  3352.     if (level_damage==1)
  3353.     {
  3354.         if (level_up && g_level[id]<MAX_LEVEL_HUMAN)
  3355.         {
  3356.             UpdateLevelHuman(id, level_up)
  3357.         }
  3358.     }
  3359.     // if human attack 1000 dmg of zombie then frags up
  3360.     else
  3361.     {
  3362.         if (level_up) UpdateFrags(id, level_up)
  3363.     }
  3364.    
  3365.     // update dmg attack
  3366.     g_dmg_attack[id] += damageup
  3367. }
  3368. get_k(num)
  3369. {
  3370.     new aaa,aaaa
  3371.     if (num >= 1000)
  3372.     {
  3373.         aaa = num % 1000
  3374.         aaaa = (num - aaa)/1000
  3375.     }
  3376.     else aaaa = 0
  3377.    
  3378.     return aaaa
  3379. }
  3380. UpdateFrags(player, num)
  3381. {
  3382.     if (!is_user_connected(player)) return;
  3383.    
  3384.     set_pev(player, pev_frags, float(pev(player, pev_frags) + num))
  3385.     message_begin(MSG_BROADCAST, g_msgScoreInfo)
  3386.     write_byte(player) // id
  3387.     write_short(pev(player, pev_frags)) // frags
  3388.     write_short(get_user_deaths(player)) // deaths
  3389.     write_short(0) // class?
  3390.     write_short(get_user_team(player)) // team
  3391.     message_end()
  3392. }
  3393. UpdateDeaths(player, num)
  3394. {
  3395.     if (!is_user_connected(player)) return;
  3396.    
  3397.     new deaths = get_user_deaths(player) + num
  3398.     cs_set_user_deaths(player, deaths)
  3399.     message_begin(MSG_BROADCAST, g_msgScoreInfo)
  3400.     write_byte(player) // id
  3401.     write_short(pev(player, pev_frags)) // frags
  3402.     write_short(deaths) // deaths
  3403.     write_short(0) // class?
  3404.     write_short(get_user_team(player)) // team
  3405.     message_end()
  3406. }
  3407. give_weapons_bot(id)
  3408. {
  3409.     if (!is_user_bot(id)) return;
  3410.  
  3411.     static wpn_pri[32], wpn_sec[32]
  3412.     ArrayGetString(weapons_pri, random(ArraySize(weapons_pri)), wpn_pri, charsmax(wpn_pri))
  3413.     ArrayGetString(weapons_sec, random(ArraySize(weapons_sec)), wpn_sec, charsmax(wpn_sec))
  3414.     new idwpn_pri = csw_name_to_id(wpn_pri)
  3415.     new idwpn_sec = csw_name_to_id(wpn_sec)
  3416.     give_weapon(id, idwpn_pri)
  3417.     give_weapon(id, idwpn_sec)
  3418. }
  3419.  
  3420. // Place user at a random spawn
  3421. do_random_spawn(id, regularspawns = 0)
  3422. {
  3423.     static hull, sp_index, i
  3424.    
  3425.     // Get whether the player is crouching
  3426.     hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  3427.    
  3428.     // Use regular spawns?
  3429.     if (!regularspawns)
  3430.     {
  3431.         // No spawns?
  3432.         if (!g_spawnCount)
  3433.             return;
  3434.        
  3435.         // Choose random spawn to start looping at
  3436.         sp_index = random_num(0, g_spawnCount - 1)
  3437.        
  3438.         // Try to find a clear spawn
  3439.         for (i = sp_index + 1; /*no condition*/; i++)
  3440.         {
  3441.             // Start over when we reach the end
  3442.             if (i >= g_spawnCount) i = 0
  3443.            
  3444.             // Free spawn space?
  3445.             if (is_hull_vacant(g_spawns[i], hull))
  3446.             {
  3447.                 // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  3448.                 engfunc(EngFunc_SetOrigin, id, g_spawns[i])
  3449.                 break;
  3450.             }
  3451.            
  3452.             // Loop completed, no free space found
  3453.             if (i == sp_index) break;
  3454.         }
  3455.     }
  3456.     else
  3457.     {
  3458.         // No spawns?
  3459.         if (!g_spawnCount2)
  3460.             return;
  3461.        
  3462.         // Choose random spawn to start looping at
  3463.         sp_index = random_num(0, g_spawnCount2 - 1)
  3464.        
  3465.         // Try to find a clear spawn
  3466.         for (i = sp_index + 1; /*no condition*/; i++)
  3467.         {
  3468.             // Start over when we reach the end
  3469.             if (i >= g_spawnCount2) i = 0
  3470.            
  3471.             // Free spawn space?
  3472.             if (is_hull_vacant(g_spawns2[i], hull))
  3473.             {
  3474.                 // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  3475.                 engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
  3476.                 break;
  3477.             }
  3478.            
  3479.             // Loop completed, no free space found
  3480.             if (i == sp_index) break;
  3481.         }
  3482.     }
  3483. }
  3484. do_random_spawn_box(id, regularspawns = 0)
  3485. {
  3486.     static hull, sp_index, i
  3487.    
  3488.     // Get whether the player is crouching
  3489.     hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  3490.    
  3491.     // Use regular spawns?
  3492.     if (!regularspawns)
  3493.     {
  3494.         // No spawns?
  3495.         if (!g_spawnCount_box)
  3496.             return;
  3497.        
  3498.         // Choose random spawn to start looping at
  3499.         sp_index = random_num(0, g_spawnCount_box - 1)
  3500.        
  3501.         // Try to find a clear spawn
  3502.         for (i = sp_index + 1; /*no condition*/; i++)
  3503.         {
  3504.             // Start over when we reach the end
  3505.             if (i >= g_spawnCount_box) i = 0
  3506.            
  3507.             // Free spawn space?
  3508.             if (is_hull_vacant(g_spawns_box[i], hull))
  3509.             {
  3510.                 // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  3511.                 engfunc(EngFunc_SetOrigin, id, g_spawns_box[i])
  3512.                 break;
  3513.             }
  3514.            
  3515.             // Loop completed, no free space found
  3516.             if (i == sp_index) break;
  3517.         }
  3518.     }
  3519.     else
  3520.     {
  3521.         // No spawns?
  3522.         if (!g_spawnCount2_box)
  3523.             return;
  3524.        
  3525.         // Choose random spawn to start looping at
  3526.         sp_index = random_num(0, g_spawnCount2_box - 1)
  3527.        
  3528.         // Try to find a clear spawn
  3529.         for (i = sp_index + 1; /*no condition*/; i++)
  3530.         {
  3531.             // Start over when we reach the end
  3532.             if (i >= g_spawnCount2_box) i = 0
  3533.            
  3534.             // Free spawn space?
  3535.             if (is_hull_vacant(g_spawns2[i], hull))
  3536.             {
  3537.                 // Engfunc_SetOrigin is used so ent's mins and maxs get updated instantly
  3538.                 engfunc(EngFunc_SetOrigin, id, g_spawns2[i])
  3539.                 break;
  3540.             }
  3541.            
  3542.             // Loop completed, no free space found
  3543.             if (i == sp_index) break;
  3544.         }
  3545.     }
  3546. }
  3547.  
  3548.  
  3549. csw_name_to_id(wpn[])
  3550. {
  3551.     new weapons[32]
  3552.     format(weapons, charsmax(weapons), "weapon_%s", wpn)
  3553.     replace(weapons, charsmax(weapons), "csw_", "")
  3554.    
  3555.     return cs_weapon_name_to_id(weapons)
  3556. }
  3557. give_weapon(id, idwpn)
  3558. {
  3559.     if (g_zombie[id]) return;
  3560.    
  3561.     fm_give_item(id, WEAPONENTNAMES[idwpn])
  3562.     new ammo = get_ammo_buywpn(idwpn)
  3563.     if (ammo > 2)
  3564.     {
  3565.         cs_set_user_bpammo(id, idwpn, ammo)
  3566.         show_hud_ammo(id, idwpn, ammo)
  3567.     }
  3568. }
  3569. show_hud_ammo(id, weapon, ammo)
  3570. {
  3571.     message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  3572.     write_byte(AMMOID[weapon]) // ammo id
  3573.     write_byte(ammo) // ammo amount
  3574.     message_end()
  3575.    
  3576.     PlayEmitSound(id, CHAN_ITEM, sound_buyammo)
  3577. }
  3578. get_ammo_buywpn(wpn)
  3579. {
  3580.     new ammo = 1
  3581.     if (wpn == CSW_P228 || wpn == CSW_ELITE || wpn == CSW_FIVESEVEN || wpn == CSW_USP || wpn == CSW_GLOCK18)
  3582.     {
  3583.         ammo = 200
  3584.     }
  3585.     else if (wpn == CSW_DEAGLE)
  3586.     {
  3587.         ammo = 70
  3588.     }
  3589.     else if (wpn == CSW_M3 || wpn == CSW_XM1014)
  3590.     {
  3591.         ammo = 64
  3592.     }
  3593.     else if (wpn == CSW_MAC10 || wpn == CSW_UMP45 || wpn == CSW_MP5NAVY || wpn == CSW_TMP || wpn == CSW_P90)
  3594.     {
  3595.         ammo = 180
  3596.     }
  3597.     else if (wpn == CSW_AUG || wpn == CSW_FAMAS || wpn == CSW_GALIL || wpn == CSW_M4A1 || wpn == CSW_SG552 || wpn == CSW_AK47 || wpn == CSW_SCOUT || wpn == CSW_G3SG1 || wpn == CSW_SG550)
  3598.     {
  3599.         ammo = 180
  3600.     }
  3601.     else if (wpn == CSW_M249)
  3602.     {
  3603.         ammo = 200
  3604.     }
  3605.     else if (wpn == CSW_AWP)
  3606.     {
  3607.         ammo = 30
  3608.     }
  3609.     else if (wpn == CSW_HEGRENADE || wpn == CSW_SMOKEGRENADE || wpn == CSW_FLASHBANG)
  3610.     {
  3611.         ammo = 1
  3612.     }
  3613.     return ammo;
  3614. }
  3615.  
  3616. SendMsgDamage(id)
  3617. {
  3618.     message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
  3619.     write_byte(0) // damage save
  3620.     write_byte(0) // damage take
  3621.     write_long(DMG_NERVEGAS) // damage type - DMG_RADIATION
  3622.     write_coord(0) // x
  3623.     write_coord(0) // y
  3624.     write_coord(0) // z
  3625.     message_end()
  3626. }
  3627.  
  3628. FixNumber(number)
  3629. {
  3630.     new numstr[32]
  3631.     if (number<0) format(numstr, 31, "0")
  3632.     else if (number<10) format(numstr, 31, "0%i", number)
  3633.     else format(numstr, 31, "%i", number)
  3634.    
  3635.     return numstr
  3636. }
  3637. fnFloatToNum(Float:floatn)
  3638. {
  3639.     new str[64], num
  3640.     float_to_str(floatn, str, 63)
  3641.     num = str_to_num(str)
  3642.    
  3643.     return num
  3644. }
  3645. // Turn Off Flashlight and Restore Batteries
  3646. turn_off_flashlight(id)
  3647. {
  3648.     // Restore batteries for the next use
  3649.     fm_cs_set_user_batteries(id, 100)
  3650.    
  3651.     // Check if flashlight is on
  3652.     if (pev(id, pev_effects) & EF_DIMLIGHT)
  3653.     {
  3654.         // Turn it off
  3655.         set_pev(id, pev_impulse, IMPULSE_FLASHLIGHT)
  3656.     }
  3657.     else
  3658.     {
  3659.         // Clear any stored flashlight impulse (bugfix)
  3660.         set_pev(id, pev_impulse, 0)
  3661.     }
  3662.    
  3663.     // Update flashlight HUD
  3664.     message_begin(MSG_ONE, get_user_msgid("Flashlight"), _, id)
  3665.     write_byte(0) // toggle
  3666.     write_byte(100) // battery
  3667.     message_end()
  3668. }
  3669. color_saytext(player, const message[], any:...)
  3670. {
  3671.     new text[301]
  3672.     format(text, 300, "%s", message)
  3673.  
  3674.     new dest
  3675.     if (player) dest = MSG_ONE
  3676.     else dest = MSG_ALL
  3677.    
  3678.     message_begin(dest, get_user_msgid("SayText"), {0,0,0}, player)
  3679.     write_byte(1)
  3680.     write_string(check_text(text))
  3681.     return message_end()
  3682. }
  3683. check_text(text1[])
  3684. {
  3685.     new text[301]
  3686.     format(text, 300, "%s", text1)
  3687.     replace(text, 300, ">x04", "^x04")
  3688.     replace(text, 300, ">x03", "^x03")
  3689.     replace(text, 300, ">x01", "^x01")
  3690.     return text
  3691. }
  3692. SendCenterText(id, message[])
  3693. {
  3694.     new dest
  3695.     if (id) dest = MSG_ONE
  3696.     else dest = MSG_ALL
  3697.    
  3698.     message_begin(dest, g_msgTextMsg, {0,0,0}, id)
  3699.     write_byte(4)
  3700.     write_string(message)
  3701.     message_end()
  3702. }
  3703. get_weapon_type(weaponid)
  3704. {
  3705.     new type_wpn = 0
  3706.     if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM) type_wpn = 1
  3707.     else if ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM) type_wpn = 2
  3708.     else if ((1<<weaponid) & NADE_WEAPONS_BIT_SUM) type_wpn = 4
  3709.     return type_wpn
  3710. }
  3711. remove_ent_by_class(classname[])
  3712. {
  3713.     new nextitem  = find_ent_by_class(-1, classname)
  3714.     while(nextitem)
  3715.     {
  3716.         remove_entity(nextitem)
  3717.         nextitem = find_ent_by_class(-1, classname)
  3718.     }
  3719. }
  3720.  
  3721.  
  3722. // ##################### Lighting Effects #####################
  3723. // Lighting Effects Task
  3724. public lighting_effects()
  3725. {
  3726.     // Get lighting style
  3727.     static lighting[2]
  3728.     get_pcvar_string(cvar_lighting, lighting, charsmax(lighting))
  3729.     strtolower(lighting)
  3730.    
  3731.     // Lighting disabled? ["0"]
  3732.     if (lighting[0] == '0')
  3733.         return;
  3734.    
  3735.     // Darkest light settings?
  3736.     if (lighting[0] >= 'a' && lighting[0] <= 'd')
  3737.     {
  3738.         static thunderclap_in_progress, Float:thunder
  3739.         thunderclap_in_progress = task_exists(TASK_THUNDER)
  3740.         thunder = get_pcvar_float(cvar_thunder)
  3741.        
  3742.         // Set thunderclap tasks if not existant
  3743.         if (thunder > 0.0 && !task_exists(TASK_THUNDER_PRE) && !thunderclap_in_progress)
  3744.         {
  3745.             g_lights_i = 0
  3746.             ArrayGetString(lights_thunder, random_num(0, ArraySize(lights_thunder) - 1), g_lights_cycle, charsmax(g_lights_cycle))
  3747.             g_lights_cycle_len = strlen(g_lights_cycle)
  3748.             //set_task(thunder, "thunderclap", TASK_THUNDER_PRE)
  3749.         }
  3750.        
  3751.         // Set lighting only when no thunderclaps are going on
  3752.         if (!thunderclap_in_progress) engfunc(EngFunc_LightStyle, 0, lighting)
  3753.     }
  3754.     else
  3755.     {
  3756.         // Remove thunderclap tasks
  3757.         if (task_exists(TASK_THUNDER_PRE)) remove_task(TASK_THUNDER_PRE)
  3758.         if (task_exists(TASK_THUNDER)) remove_task(TASK_THUNDER)
  3759.        
  3760.         // Set lighting
  3761.         engfunc(EngFunc_LightStyle, 0, lighting)
  3762.     }
  3763. }
  3764. // Thunderclap task
  3765. public thunderclap()
  3766. {
  3767.     // Play thunder sound
  3768.     if (g_lights_i == 0)
  3769.     {
  3770.         static sound[64]
  3771.         ArrayGetString(sound_thunder, random_num(0, ArraySize(sound_thunder) - 1), sound, charsmax(sound))
  3772.         PlaySound(0, sound)
  3773.     }
  3774.    
  3775.     // Set lighting
  3776.     static light[2]
  3777.     light[0] = g_lights_cycle[g_lights_i]
  3778.     engfunc(EngFunc_LightStyle, 0, light)
  3779.    
  3780.     g_lights_i++
  3781.    
  3782.     // Lighting cycle end?
  3783.     if (g_lights_i >= g_lights_cycle_len)
  3784.     {
  3785.         if (task_exists(TASK_THUNDER)) remove_task(TASK_THUNDER)
  3786.         lighting_effects()
  3787.     }
  3788.     // Lighting cycle start?
  3789.     else if (!task_exists(TASK_THUNDER))
  3790.         set_task(0.1, "thunderclap", TASK_THUNDER, _, _, "b")
  3791. }
  3792.  
  3793.  
  3794. /*================================================================================
  3795.  [Message Hooks]
  3796. =================================================================================*/
  3797. // Fix for the HL engine bug when HP is multiples of 256
  3798. public message_health(msg_id, msg_dest, msg_entity)
  3799. {
  3800.     // Get player's health
  3801.     static health
  3802.     health = get_msg_arg_int(1)
  3803.    
  3804.     // Don't bother
  3805.     if (health < 256) return;
  3806.    
  3807.     // Check if we need to fix it
  3808.     if (health % 256 == 0)
  3809.         fm_set_user_health(msg_entity, pev(msg_entity, pev_health) + 1)
  3810.    
  3811.     // HUD can only show as much as 255 hp
  3812.     set_msg_arg_int(1, get_msg_argtype(1), 255)
  3813. }
  3814. // Block flashlight battery messages if custom flashlight is enabled instead
  3815. public message_flashbat()
  3816. {
  3817.     return PLUGIN_HANDLED;
  3818. }
  3819. // Prevent spectators' nightvision from being turned off when switching targets, etc.
  3820. public message_nvgtoggle()
  3821. {
  3822.     return PLUGIN_HANDLED;
  3823. }
  3824. // Prevent zombies from seeing any weapon pickup icon
  3825. public message_weappickup(msg_id, msg_dest, msg_entity)
  3826. {
  3827.     if (g_zombie[msg_entity])
  3828.         return PLUGIN_HANDLED;
  3829.    
  3830.     return PLUGIN_CONTINUE;
  3831. }
  3832. // Prevent zombies from seeing any ammo pickup icon
  3833. public message_ammopickup(msg_id, msg_dest, msg_entity)
  3834. {
  3835.     if (g_zombie[msg_entity])
  3836.         return PLUGIN_HANDLED;
  3837.    
  3838.     return PLUGIN_CONTINUE;
  3839. }
  3840. // Block hostage HUD display
  3841. public message_scenario()
  3842. {
  3843.     if (get_msg_args() > 1)
  3844.     {
  3845.         static sprite[8]
  3846.         get_msg_arg_string(2, sprite, charsmax(sprite))
  3847.        
  3848.         if (equal(sprite, "hostage"))
  3849.             return PLUGIN_HANDLED;
  3850.     }
  3851.    
  3852.     return PLUGIN_CONTINUE;
  3853. }
  3854. // Block hostages from appearing on radar
  3855. public message_hostagepos()
  3856. {
  3857.     return PLUGIN_HANDLED;
  3858. }
  3859. // Block some text messages
  3860. public message_textmsg()
  3861. {
  3862.     static textmsg[22]
  3863.     get_msg_arg_string(2, textmsg, charsmax(textmsg))
  3864.    
  3865.     // Game restarting, reset scores and call round end to balance the teams
  3866.     if (equal(textmsg, "#Game_will_restart_in"))
  3867.     {
  3868.         g_score_human = 0
  3869.         g_score_zombie = 0
  3870.         logevent_round_end()
  3871.     }
  3872.     else if (equal(textmsg, "#Game_Commencing"))
  3873.     {
  3874.         g_startcount = 1
  3875.     }
  3876.     // Block round end related messages
  3877.     else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
  3878.     {
  3879.         return PLUGIN_HANDLED;
  3880.     }
  3881.    
  3882.     return PLUGIN_CONTINUE;
  3883. }
  3884. // Block CS round win audio messages, since we're playing our own instead
  3885. public message_sendaudio()
  3886. {
  3887.     static audio[17]
  3888.     get_msg_arg_string(2, audio, charsmax(audio))
  3889.    
  3890.     if(equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
  3891.         return PLUGIN_HANDLED;
  3892.    
  3893.     return PLUGIN_CONTINUE;
  3894. }
  3895. // Send actual team scores (T = zombies // CT = humans)
  3896. public message_teamscore()
  3897. {
  3898.     static team[2]
  3899.     get_msg_arg_string(1, team, charsmax(team))
  3900.    
  3901.     switch (team[0])
  3902.     {
  3903.         // CT
  3904.         case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_score_human)
  3905.         // Terrorist
  3906.         case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_score_zombie)
  3907.     }
  3908. }
  3909. public message_hudtextargs()
  3910. {
  3911.     return PLUGIN_HANDLED;
  3912. }
  3913. public message_msgClCorpse()
  3914. {
  3915.     new victim = get_msg_arg_int(12)
  3916.     if (g_respawning[victim] || is_user_alive(victim)) return PLUGIN_HANDLED;
  3917.    
  3918.     return PLUGIN_CONTINUE
  3919. }
  3920.    
  3921.  
  3922. /*================================================================================
  3923.  [Main Stock]
  3924. =================================================================================*/
  3925.  
  3926. // Set a Player's Team
  3927. stock fm_cs_set_user_team(id, team)
  3928. {
  3929.     // Our task params
  3930.     static params[1]
  3931.     params[0] = team
  3932.     if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
  3933.     set_task(0.1, "task_set_user_team", id+TASK_TEAM, params, sizeof params)
  3934.    
  3935. }
  3936. // Task Set Model
  3937. public task_set_user_team(params[1], taskid)
  3938. {
  3939.     new id = ID_TEAM
  3940.     new team = params[0]
  3941.     cs_set_user_team(id, team, 0)
  3942.     set_model_for_player(id)
  3943.     if (task_exists(id+TASK_TEAM)) remove_task(id+TASK_TEAM)
  3944. }
  3945. // Set user money
  3946. stock fm_cs_set_user_money(id, money)
  3947. {
  3948.     cs_set_user_money(id, money, 1)
  3949. }
  3950. // Set player's health (from fakemeta_util)
  3951. stock fm_set_user_health(id, health)
  3952. {
  3953.     (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  3954. }
  3955. // Drop primary/secondary weapons
  3956. stock drop_weapons(id, dropwhat, type=0)
  3957. {
  3958.     // Get user weapons
  3959.     static weapons[32], num, i, weaponid
  3960.     num = 0 // reset passed weapons count (bugfix)
  3961.     get_user_weapons(id, weapons, num)
  3962.    
  3963.     // Loop through them and drop primaries or secondaries
  3964.     for (i = 0; i < num; i++)
  3965.     {
  3966.         // Prevent re-indexing the array
  3967.         weaponid = weapons[i]
  3968.        
  3969.         if (get_weapon_type(weaponid) == dropwhat)
  3970.         {
  3971.             if (type==1)
  3972.             {
  3973.                 fm_strip_user_gun(id, weaponid)
  3974.             }
  3975.             else
  3976.             {
  3977.                 // Get weapon entity
  3978.                 static wname[32], weapon_ent
  3979.                 get_weaponname(weaponid, wname, charsmax(wname))
  3980.                 weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  3981.                
  3982.                 // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
  3983.                 set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
  3984.                
  3985.                 // Player drops the weapon and looses his bpammo
  3986.                 engclient_cmd(id, "drop", wname)
  3987.             }
  3988.         }
  3989.     }
  3990. }
  3991. // Find entity by its owner (from fakemeta_util)
  3992. stock fm_find_ent_by_owner(entity, const classname[], owner)
  3993. {
  3994.     while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  3995.     return entity;
  3996. }
  3997. // Get User Team
  3998. stock fm_set_user_armor(id, armor)
  3999. {
  4000.     set_pev(id, pev_armorvalue, float(min(armor, 999)))
  4001. }
  4002. // Get User Team
  4003. stock fm_cs_get_user_team(id)
  4004. {
  4005.     return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
  4006. }
  4007. // Set entity's rendering type (from fakemeta_util)
  4008. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  4009. {
  4010.     static Float:color[3]
  4011.     color[0] = float(r)
  4012.     color[1] = float(g)
  4013.     color[2] = float(b)
  4014.    
  4015.     set_pev(entity, pev_renderfx, fx)
  4016.     set_pev(entity, pev_rendercolor, color)
  4017.     set_pev(entity, pev_rendermode, render)
  4018.     set_pev(entity, pev_renderamt, float(amount))
  4019. }
  4020. // only weapon index or its name can be passed, if neither is passed then the current gun will be stripped
  4021. stock fm_strip_user_gun(index, wid = 0, const wname[] = "") {
  4022.     new ent_class[32];
  4023.     if (!wid && wname[0])
  4024.         copy(ent_class, sizeof ent_class - 1, wname);
  4025.     else {
  4026.         new weapon = wid, clip, ammo;
  4027.         if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
  4028.             return false;
  4029.        
  4030.         get_weaponname(weapon, ent_class, sizeof ent_class - 1);
  4031.     }
  4032.  
  4033.     new ent_weap = fm_find_ent_by_owner(-1, ent_class, index);
  4034.     if (!ent_weap)
  4035.         return false;
  4036.  
  4037.     engclient_cmd(index, "drop", ent_class);
  4038.  
  4039.     new ent_box = pev(ent_weap, pev_owner);
  4040.     if (!ent_box || ent_box == index)
  4041.         return false;
  4042.  
  4043.     dllfunc(DLLFunc_Think, ent_box);
  4044.  
  4045.     return true;
  4046. }
  4047.  
  4048. // Simplified get_weaponid (CS only)
  4049. stock cs_weapon_name_to_id(const weapon[])
  4050. {
  4051.     static i
  4052.     for (i = 0; i < sizeof WEAPONENTNAMES; i++)
  4053.     {
  4054.         if (equal(weapon, WEAPONENTNAMES[i]))
  4055.             return i;
  4056.     }
  4057.    
  4058.     return 0;
  4059. }
  4060.  
  4061. // Give an item to a player (from fakemeta_util)
  4062. stock fm_give_item(id, const item[])
  4063. {
  4064.     static ent
  4065.     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  4066.     if (!pev_valid(ent)) return;
  4067.    
  4068.     static Float:originF[3]
  4069.     pev(id, pev_origin, originF)
  4070.     set_pev(ent, pev_origin, originF)
  4071.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  4072.     dllfunc(DLLFunc_Spawn, ent)
  4073.    
  4074.     static save
  4075.     save = pev(ent, pev_solid)
  4076.     dllfunc(DLLFunc_Touch, ent, id)
  4077.     if (pev(ent, pev_solid) != save)
  4078.         return;
  4079.    
  4080.     engfunc(EngFunc_RemoveEntity, ent)
  4081. }
  4082. // Set an entity's key value (from fakemeta_util)
  4083. stock fm_set_kvd(entity, const key[], const value[], const classname[])
  4084. {
  4085.     set_kvd(0, KV_ClassName, classname)
  4086.     set_kvd(0, KV_KeyName, key)
  4087.     set_kvd(0, KV_Value, value)
  4088.     set_kvd(0, KV_fHandled, 0)
  4089.  
  4090.     dllfunc(DLLFunc_KeyValue, entity, 0)
  4091. }
  4092. // Checks if a space is vacant (credits to VEN)
  4093. stock is_hull_vacant(Float:origin[3], hull)
  4094. {
  4095.     engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
  4096.    
  4097.     if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
  4098.         return true;
  4099.    
  4100.     return false;
  4101. }
  4102. // Collect random spawn points
  4103. stock load_spawns()
  4104. {
  4105.     // Check for CSDM spawns of the current map
  4106.     new cfgdir[32], mapname[32], filepath[100], linedata[64]
  4107.     get_configsdir(cfgdir, charsmax(cfgdir))
  4108.     get_mapname(mapname, charsmax(mapname))
  4109.     formatex(filepath, charsmax(filepath), SPAWNS_URL, cfgdir, mapname)
  4110.    
  4111.     // Load CSDM spawns if present
  4112.     if (file_exists(filepath))
  4113.     {
  4114.         new csdmdata[10][6], file = fopen(filepath,"rt")
  4115.        
  4116.         while (file && !feof(file))
  4117.         {
  4118.             fgets(file, linedata, charsmax(linedata))
  4119.            
  4120.             // invalid spawn
  4121.             if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  4122.            
  4123.             // get spawn point data
  4124.             parse(linedata,csdmdata[0],5,csdmdata[1],5,csdmdata[2],5,csdmdata[3],5,csdmdata[4],5,csdmdata[5],5,csdmdata[6],5,csdmdata[7],5,csdmdata[8],5,csdmdata[9],5)
  4125.            
  4126.             // origin
  4127.             g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
  4128.             g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
  4129.             g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
  4130.            
  4131.             // increase spawn count
  4132.             g_spawn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement