Плагин, зомби класс " Толстяк " [ zp_class_heavy ], для зомби сервера [ ZP 5.0.8 ]. Не работает " Пассивная способность - Ослепление ".

Сообщения
15
Реакции
9
Баллы
3
Ошибка
bla_bla_bla\amxmodx\scripting\zp_class_heavy.sma(100) : warning 204: symbol is assigned a value that is never used: "cvar_TrapAffectTime"
AMX Mod X
Amx Mod X version 1.9.0.5294
Билд сервера
Protocol version 48
Exe version 1.6.3.7/Stdio (cstrike)
ReHLDS version: 3.14.0.857-dev
Build date: 19:53:00 Mar 27 2025 (4002)
ReGameDLL
ReGameDLL version: 5.28.0.756-dev
Build date: 19:20:12 Mar 27 2025
Metamod версия
Metamod-r v1.3.0.149, API (5:13)
Metamod-r build: 11:31:13 Apr 23 2024
Metamod плагины
SafeNameAndChat   RUN   -    safenameandchat.dll    v1.1         ini  ANY   ANY  
Reunion RUN - reunion_mm.dll v0.1.0.92c ini Start Never
Rechecker RUN - rechecker_mm.dll v2.5 ini Chlvl ANY
ReAuthCheck RUN - reauthcheck_mm.dll v0.1.6 ini Start Never
VoiceTranscoder RUN - voicetranscoder.dll v2017RC5 ini ANY ANY
AMX Mod X RUN - amxmodx_mm.dll v1.9.0.5294 ini Start ANY
Print Center Fix RUN - printcenterfix_mm.dll v2.0.1 ini ANY ANY
YaPB RUN - yapb.dll v4.5.1170 ini Chlvl ANY
ReSemiclip RUN - resemiclip_mm.dll v2.4.3 ini Chlvl ANY
HitBox Fix RUN - hitbox_fix_mm.dll v1.1.5 ini Start ANY
Hide Cvars RUN - hidecvars_amxx.dll v1.0 pl6 ANY ANY
FakeMeta RUN - fakemeta_amxx.dll v1.9.0.5294 pl6 ANY ANY
whois RUN - whois_amxx.dll v0.2.270 pl6 ANY ANY
Ham Sandwich RUN - hamsandwich_amxx.dll v1.9.0.5294 pl6 ANY ANY
Fun RUN - fun_amxx.dll v1.9.0.5294 pl6 ANY ANY
CStrike RUN - cstrike_amxx.dll v1.9.0.5294 pl6 ANY ANY
Engine RUN - engine_amxx.dll v1.9.0.5294 pl6 ANY ANY
Список плагинов
AMXX BanCfg             0.95        Safety1st         amx_bancfg.amxx  running  
SubnetBan 2.2 Lev subnetban.amxx running
Admin Base 1.9.0.5294 AMXX Dev Team admin.amxx running
Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running
Menus Front-End 1.9.0.5294 AMXX Dev Team menufront.amxx running
Commands Menu 1.9.0.5294 AMXX Dev Team cmdmenu.amxx running
Players Menu 1.9.0.5294 AMXX Dev Team plmenu.amxx running
Maps Menu 1.9.0.5294 AMXX Dev Team mapsmenu.amxx running
Plugin Menu 1.9.0.5294 AMXX Dev Team pluginmenu.amxx running
Anti Flood 1.9.0.5294 AMXX Dev Team antiflood.amxx running
Admin Votes 1.9.0.5294 AMXX Dev Team adminvote.amxx running
NextMap 1.9.0.5294 AMXX Dev Team nextmap.amxx running
Nextmap Chooser 1.9.0.5294 AMXX Dev Team mapchooser.amxx running
TimeLeft 1.9.0.5294 AMXX Dev Team timeleft.amxx running
Pause Plugins 1.9.0.5294 AMXX Dev Team pausecfg.amxx running
Stats Configuration 1.9.0.5294 AMXX Dev Team statscfg.amxx running
Models Replacement 0.0.2 ConnorMcLeod | V models_replacem running
[ZP] Can Auto Save Amm 0.1.0 ZombArena.Ru zp_save.amxx running
[ZP]knife Menu 2.2 Mr.H zp_addon_knife. running
[ZP] Countdown 1.0 Lacosta zp_countdown.am running
[ZP] Addon: Auto Healt 1.1 Dias ZP_Addon_Auto_H running
[ZP] DHUD Informer 0.0.0.1 Andrei zp_score.amxx running
Block grande info 1.0 neygomon BlockGrenadeInf running
[ZP] Buy Health New 2.0 FINAL xrekuy zp_extra_health running
[ZP] Extra: Anti-Infec 1.0 MeRcyLeZZ zp_extra_human_ running
[ZP] Kill Rewards 1.0 Doomsday zp_kill_reward. running
[ ZP ] Nemesis skill Shurik07 0.1 zp_nemskill.amx running
[ZP]: Zombie Health 1.0 Yakess ZP_Zombie_Healt running
[ZP] LaserMine 2.8.2 SandStriker / Sh zp_lasermine_28 debug
WinTeam Sprite 0.0.8 Some Scripter WinTeam_Sprite. running
[ZP] Addon : No Engine 1.1.0 schmurgel1983 OT6POC.amxx running
[ZP] Survivor HP 1.0 ASSOM zp_addons_survi debug
[ZP] ZP++ Ice Cube 1.0 Dare(Gyiove) zp50_ice_cube.a running
Hide Status Icons on H 0.0 Leo_[BH] hide_hud_status running
The Smartest 1.0 BaHeK The_Smartest.am running
[DF] Plague: Emotions 1.0 DARKFEAL DF_emotions.amx running
[ZP] Addon: Death Spri 1.4 eXcalibur.007 zp_addon_death_ running
[ZP] Core/Engine ZP Dev Team zp50_core.amxx running
[AMXX] Settings API 1.0 MeRcyLeZZ amx_settings_ap running
[CS] Player Models API 1.2 WiLS cs_player_model running
[CS] Teams API 1.2 WiLS cs_teams_api.am running
[CS] MaxSpeed API 1.0 WiLS cs_maxspeed_api running
[CS] Weapon Models API 1.1 WiLS cs_weap_models_ running
[CS] Weapons Restrict 0.4 WiLS cs_weap_restric running
[CS] Ham Hooks for Bot 1.0 WiLS cs_ham_bots_api running
[ZP] Class: Zombie ZP Dev Team zp50_class_zomb running
[ZP] Class: Human ZP Dev Team zp50_class_huma running
[ZP] Class: Nemesis ZP Dev Team zp50_class_neme running
[ZP] Class: Survivor Leo_[BH] & ZP De zp50_class_surv running
[CSO:Ghost Zombie] 1.4 HoRRoR, Fry!,tER cso_zclass_ghos running
[CSO:Shaman Zombie] 0.1 meTaLiCroSS cso_shaman_v1.a running
[ZP] Class: Big 1.0 :) / Slimes zp_class_heavy. debug
[ZP] Class: Human: Cla ZP Dev Team zp50_class_huma running
[ZP] Class: Human: Rap ZP Dev Team zp50_class_huma running
[ZP] Human Armor ZP Dev Team zp50_human_armo running
[ZP] Game Modes Manage ZP Dev Team zp50_gamemodes. running
[ZP] Game Mode: Infect ZP Dev Team zp50_gamemode_i paused
[ZP] Game Mode: Multip ZP Dev Team zp50_gamemode_m paused
[ZP] Game Mode: Swarm ZP Dev Team zp50_gamemode_s running
[ZP] Game Mode: Nemesi ZP Dev Team zp50_gamemode_n paused
[ZP] Game Mode: Surviv ZP Dev Team zp50_gamemode_s paused
[ZP] Game Mode: Plague ZP Dev Team zp50_gamemode_p paused
[ZP] Items Manager ZP Dev Team zp50_items.amxx running
[ZP] Items Manager: Am ZP Dev Team zp50_items_ammo running
[ZP] Item: Weapons ZP Dev Team zp50_item_weapo running
[ZP] Item: Antidote ZP Dev Team zp50_item_antid running
[ZP] Item: Zombie Madn ZP Dev Team zp50_item_zombi running
[ZP] Admin Commands ZP Dev Team zp50_admin_comm running
[ZP] Admin Menus ZP Dev Team zp50_admin_menu running
[ZP] Admin Models ZP Dev Team zp50_admin_mode running
[ZP] Custom Buy Menus ZP Dev Team zp50_buy_menus. running
[ZP] Buyzones ZP Dev Team zp50_buy_zones. running
[ZP] Rewards: Ammo Pac ZP Dev Team zp50_rewards_am running
[ZP] Rewards: Frags & Leo_[BH] & ZP De zp50_rewards_fr running
[ZP] Zombie Features ZP Dev Team zp50_zombie_fea running
[ZP] Zombie Sounds ZP Dev Team zp50_zombie_sou running
[ZP] Zombie Damage ZP Dev Team zp50_zombie_dam running
[ZP] Human Unlimited A ZP Dev Team zp50_human_ammo running
[ZP] Flashlight ZP Dev Team zp50_flashlight running
[ZP] Nightvision Leo_[BH] & ZP De zp50_nightvisio running
[ZP] Leap/Longjump ZP Dev Team zp50_leap.amxx running
[ZP] Pain Shock Free ZP Dev Team zp50_painshockf running
[ZP] Knockback ZP Dev Team zp50_knockback. running
[ZP] Weapon Drop/Strip ZP Dev Team zp50_weapon_dro running
[ZP] Effects: Infect ZP Dev Team zp50_effects_in running
[ZP] Effects: Cure ZP Dev Team zp50_effects_cu running
[ZP] Effects: Lighting ZP Dev Team zp50_effects_li running
[ZP] Ambience Effects ZP Dev Team zp50_ambience_e running
[ZP] Ambience Sonds ZP Dev Team zp50_ambience_s running
[ZP] Main Menu ZP Dev Team zp50_main_menu. running
[ZP] Objective Remover ZP Dev Team zp50_objective_ running
[ZP] Gameplay Fixes ZP Dev Team zp50_gameplay_f running
[ZP] Team Scoring ZP Dev Team zp50_team_scori running
[ZP] HUD Information ZP Dev Team zp50_hud_info.a running
[ZP] Server Browser In ZP Dev Team zp50_serverbrow running
[ZP] Ammo Packs ZP Dev Team zp50_ammopacks. running
[ZP] Grenade: Fire Leo_[BH] & ZP De zp50_grenade_fi running
[ZP] Grenade: Frost Leo_[BH] & ZP De zp50_grenade_fr running
[ZP] Grenade: Flare Leo_[BH] & ZP De zp50_grenade_fl running
[ZP] ZP 4.3 Subplugin ZP Dev Team zp50_zp43_compa running
Исходный код плагина
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <xs>
#include <hamsandwich>
#include <zombieplague>

#define SUPPORT_BOT_TO_USE
#define TASK_SET_TRAP 1234
#define TASK_REMOVE_TRAP 4321

#define TIME_CATCHED 4.0

new const zclass4_name[] = { "Heavy" }
new const zclass4_info[] = { "\y[ Ловушки на \rR \y]" }
new const zclass4_model[] = {"Heavy"}
new const zclass4_clawmodel[] = { "Bla_Bla/v_knife_heavy.mdl" }
const zclass4_health = 4200
const zclass4_speed = 235
const Float:zclass4_gravity = 0.85
const Float:zclass4_knockback = 0.25

new g_chance[33]
new g_msgScreenFade
const FFADE_IN = 0x0000
const FFADE_STAYOUT = 0x0004
const UNIT_SECOND = (1<<12)

new is_cooldown_time[33] = 0
new is_cooldown[33] = 0
new g_MsgSync

new const Trap_Model[] = { "models/Bla_Bla/w_trap.mdl" }

new const TrapTrigger_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_trigger.wav" }
new const PlayerCatched_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_cathed.wav" }
new const CantPlantTrap_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_cant_plant.wav" }
const Max_Traps = 5

enum (+= 100)
{
TASK_COOLDOWN,
TASK_ABILITY
}

const OFFSET_flNextPrimaryAttack = 46
const OFFSET_flNextSecondaryAttack = 47
const OFFSET_flTimeWeaponIdle = 48

const OFFSET_LINUX_WEAPONS = 4

new g_zclass_heavy

new Float:g_revenge_cooldown = 30.0

new g_chance_to_cast = 25
new cvar_TrapAffectTime

#define SET_TIME 1.0

new g_maxplayers
new user_has_traps[33]
new user_traps_ent[33][Max_Traps]
new g_TrapPromptSpr, g_PlayerCatchedSpr
new g_msgScreenShake, g_msgBarTime
new bool:user_set_trap[33], set_trap_ent[33], Float:set_trap_origin[33][3]
new bool:user_be_catched[33], catched_trap_ent[33]

new const sound_sleep[] = "Bla_Bla/ZP_class/sleep_impact.wav"

#if defined SUPPORT_BOT_TO_USE
new Float:bot_next_check_time[33]
#endif

public plugin_init()
{
register_plugin("[ZP] Class: Big", "1.0", ":) / Slimes")

g_msgScreenFade = get_user_msgid("ScreenFade")
g_maxplayers = get_maxplayers()

register_logevent("roundStart", 2, "1=Round_Start")
register_forward(FM_CmdStart, "fw_CmdStart")
register_forward(FM_StartFrame, "fw_StartFrame")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_Touch, "fw_Touch")
register_forward(FM_Think, "fw_Think")

register_event("ResetHUD", "event_NewSpawn", "be")
register_event("DeathMsg", "event_Death", "a")
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")

#if defined SUPPORT_BOT_TO_USE
register_event("Damage", "event_Damage", "be", "2>0")
#endif

cvar_TrapAffectTime = register_cvar("zp_heavy_trap_affecttime", "10.0")

g_msgScreenShake = get_user_msgid("ScreenShake")
g_msgBarTime = get_user_msgid("BarTime")
g_maxplayers = get_maxplayers()
g_MsgSync = CreateHudSyncObj()
}

public plugin_precache()
{
precache_sound(sound_sleep)
precache_model(Trap_Model)

precache_sound(TrapTrigger_Sound)
precache_sound(PlayerCatched_Sound)
precache_sound(CantPlantTrap_Sound)

g_TrapPromptSpr = precache_model("sprites/Bla_Bla/ZP_class/zombie_trap_prompt.spr")
g_PlayerCatchedSpr = precache_model("sprites/Bla_Bla/ZP_class/zombie_trap_notice.spr")

g_zclass_heavy = zp_register_zombie_class(zclass4_name, zclass4_info, zclass4_model, zclass4_clawmodel, zclass4_health, zclass4_speed, zclass4_gravity, zclass4_knockback)
}

public client_damage(attacker,victim)
{
if ((zp_get_user_zombie_class(victim) == g_zclass_heavy) && zp_get_user_zombie(victim) && !zp_get_user_nemesis(victim) && (is_cooldown[victim] == 0))
{
g_chance[victim] = random_num(0,999)
if (g_chance[victim] < g_chance_to_cast)
{
message_begin(MSG_ONE, g_msgScreenFade, _, attacker)
write_short(4)
write_short(4)
write_short(FFADE_STAYOUT)
write_byte(0)
write_byte(0)
write_byte(0)
write_byte(255)
message_end()

set_user_health(victim, get_user_health(victim) + ( get_user_health(victim) / 10 ) )

set_task(4.0,"wake_up",attacker)
set_task(1.0, "RemoveCooldown", victim+TASK_COOLDOWN, _, _, "a",is_cooldown_time[victim])

emit_sound(attacker, CHAN_STREAM, sound_sleep, 1.0, ATTN_NORM, 0, PITCH_NORM);

is_cooldown[victim] = 1
}
}
}

public Ability(taskid)
{
new id = taskid - TASK_ABILITY

if(is_user_alive(id))
{
if (is_cooldown_time[id] == 0)
{
set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(id, g_MsgSync, "Ловушка - [R]^nОслепление - Пассивная способность!")
}
}
else remove_task(id+TASK_ABILITY)
}

public RemoveCooldown(taskid)
{
new id = taskid - TASK_COOLDOWN

if(is_user_alive(id))
{
is_cooldown_time[id]--
if (is_cooldown_time[id] == 0)
{
set_task(2.5, "Ability", id+TASK_ABILITY)
remove_task(id+TASK_COOLDOWN)
}
set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(id, g_MsgSync, "Ловушка - [R]^nОслепление - Перезарядка: %d",is_cooldown_time[id])
}
else remove_task(id+TASK_COOLDOWN)
}

public wake_up(id)
{
message_begin(MSG_ONE, g_msgScreenFade, _, id)
write_short(UNIT_SECOND)
write_short(0)
write_short(FFADE_IN)
write_byte(0)
write_byte(0)
write_byte(0)
write_byte(255)
message_end()
}

public zp_user_infected_post(id, infector)
{
if (user_be_catched[id])
{
clear_user_sprite(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}

reset_vars(id)

if (zp_get_user_zombie_class(id) == g_zclass_heavy && !zp_get_user_nemesis(id))
{
is_cooldown[id] = 0
is_cooldown_time[id] = 0
set_task(1.0, "Ability", id+TASK_ABILITY, _, _, "b")

user_has_traps[id] = Max_Traps
}

remove_task(id)
is_cooldown[id] = 0
}

public fw_CmdStart(id, uc_handle, seed)
{
if (!is_user_alive(id))
return FMRES_IGNORED;

if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
return FMRES_IGNORED;

#if defined SUPPORT_BOT_TO_USE
if (is_user_bot(id))
{
bot_use_traps(id)
return FMRES_IGNORED;
}
#endif

static button, oldbutton
button = get_uc(uc_handle, UC_Buttons)
oldbutton = pev(id, pev_oldbuttons)

if (!user_set_trap[id])
{
if ((button & IN_RELOAD) && !(oldbutton & IN_RELOAD))
{
do_set_trap(id)
}
}
else
{
static user_flags, Float:user_origin[3], Float:fdistance
user_flags = pev(id, pev_flags)
pev(id, pev_origin, user_origin)
user_origin[2] -= (user_flags & FL_DUCKING) ? 18.0 : 36.0
fdistance = get_distance_f(user_origin, set_trap_origin[id])

if (!(button & IN_RELOAD) || fdistance > 18.0)
{
stop_set_trap(id)
}
}

return FMRES_HANDLED;
}

public fw_StartFrame()
{
static Float:time, Float:next_check_time, id, i, classname[32], Float:origin1[3], Float:origin2[3]

time = get_gametime()

if (time >= next_check_time)
{
for (id = 1; id <= g_maxplayers; id++)
{
if (!is_user_connected(id) || !is_user_alive(id))
continue;

if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
continue;

for (i = 0; i < Max_Traps; i++)
{
if (user_traps_ent[id][i] <= 0)
continue;

if (!pev_valid(user_traps_ent[id][i]))
{
user_traps_ent[id][i] = 0
continue;
}

pev(user_traps_ent[id][i], pev_classname, classname, charsmax(classname))
if (!equal(classname, "ZOMBIE_TRAP_ENT"))
{
user_traps_ent[id][i] = 0
continue;
}

if (pev(user_traps_ent[id][i], pev_iuser3) == 1)
continue;

pev(user_traps_ent[id][i], pev_origin, origin1)
xs_vec_copy(origin1, origin2)
origin2[2] += 30.0
if (fm_is_point_visible(id, origin1, 1) || fm_is_point_visible(id, origin2, 1))
{
origin1[2] += 30.0
create_user_sprite(id, origin1, g_TrapPromptSpr, 5)
}
}
}

next_check_time = time + 0.1
}

return FMRES_IGNORED;
}

public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED;

if (zp_get_user_zombie(id))
{
if (zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
return FMRES_IGNORED;

if (user_set_trap[id])
{
freeze_user_attack(id)
}
}
else
{
if (user_be_catched[id] && pev_valid(catched_trap_ent[id]))
{
static classname[32]
pev(catched_trap_ent[id], pev_classname, classname, charsmax(classname))
if (!equal(classname, "ZOMBIE_TRAP_ENT"))
return FMRES_IGNORED;

set_pev(id, pev_velocity, Float:{ 0.0, 0.0, -200.0 })
set_pev(id, pev_maxspeed, 1.0)

static Float:user_origin[3], Float:ent_origin[3], Float:temp_origin[3]
pev(id, pev_origin, user_origin)
pev(catched_trap_ent[id], pev_origin, ent_origin)
xs_vec_copy(ent_origin, temp_origin)
temp_origin[2] += 18.0
if (get_distance_f(user_origin, temp_origin) > 18.0)
{
temp_origin[2] += ((pev(id, pev_flags) & FL_DUCKING) ? 0.0 : 18.0)
set_pev(id, pev_origin, temp_origin)
}
}
}

return FMRES_IGNORED;
}

public fw_Touch(ptr, ptd)
{
if (!pev_valid(ptr) || !pev_valid(ptd))
return FMRES_IGNORED;

static classname[32]
pev(ptr, pev_classname, classname, charsmax(classname))
if (!equal(classname, "ZOMBIE_TRAP_ENT"))
return FMRES_IGNORED;

if (!(1 <= ptd <= g_maxplayers) || !is_user_alive(ptd) || zp_get_user_zombie(ptd))
return FMRES_IGNORED;

if (pev(ptr, pev_iuser2) == 0)
return FMRES_IGNORED;

if (pev(ptr, pev_iuser3) == 0 && !user_be_catched[ptd])
{
PlaySound(ptd, TrapTrigger_Sound)
engfunc(EngFunc_EmitSound, ptd, CHAN_VOICE, PlayerCatched_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
user_screen_shake(ptd, 4, 2, 5)
show_user_sprite(ptd, g_PlayerCatchedSpr)

static Float:origin[3]
pev(ptr, pev_origin, origin)
origin[2] += ((pev(ptd, pev_flags) & FL_DUCKING) ? 18.0 : 36.0)
set_pev(ptd, pev_origin, origin)
set_pev(ptd, pev_velocity, Float:{ 0.0, 0.0, 0.0 })
new name[32]
get_user_name(ptd, name, 31)
client_print(ptd, print_center, "Вы пойманы в ловушку!")

set_pev(ptr, pev_iuser3, 1)
set_pev(ptr, pev_iuser4, ptd)
user_be_catched[ptd] = true
catched_trap_ent[ptd] = ptr
fm_set_rendering(ptr, kRenderFxNone, 0,0,0, kRenderNormal, 255)
set_pev(ptr, pev_nextthink, get_gametime() + 0.05)

static owner
owner = pev(ptr, pev_iuser1)
if (1 <= owner <= g_maxplayers)
client_print(owner, print_center, "Игрок %s попал в ловушку!", name)

static Float:trap_affect_time
trap_affect_time = TIME_CATCHED
if (trap_affect_time > 0.0)
{
static args[1]
args[0] = ptr
set_task(trap_affect_time, "remove_trap", TASK_REMOVE_TRAP, args, 1)
}
}

return FMRES_IGNORED;
}

public fw_Think(ent)
{
if (pev_valid(ent))
{
static classname[32]
pev(ent, pev_classname, classname, charsmax(classname))
if (equal(classname, "ZOMBIE_TRAP_ENT"))
{
if (pev(ent, pev_sequence) != 1)
{
set_pev(ent, pev_sequence, 1)
set_pev(ent, pev_frame, 0.0)
}
else
{
if (pev(ent, pev_frame) > 241.0)
set_pev(ent, pev_frame, 20.0)
else
set_pev(ent, pev_frame, pev(ent, pev_frame) + 1.0)
}

static catched_player
catched_player = pev(ent, pev_iuser4)
if (!user_be_catched[catched_player] || catched_trap_ent[catched_player] != ent)
{
engfunc(EngFunc_RemoveEntity, ent)
return FMRES_IGNORED;
}

set_pev(ent, pev_nextthink, get_gametime() + 0.05)
}
}

return FMRES_IGNORED;
}

freeze_user_attack(id)
{
new weapon, weapon_name[32], weapon_ent
weapon = get_user_weapon(id)
get_weaponname(weapon, weapon_name, charsmax(weapon_name))
weapon_ent = fm_find_ent_by_owner(-1, weapon_name, id)

if (get_weapon_next_pri_attack(weapon_ent) <= 0.1)
set_weapon_next_pri_attack(weapon_ent, 0.5)

if (get_weapon_next_sec_attack(weapon_ent) <= 0.1)
set_weapon_next_sec_attack(weapon_ent, 0.5)

if (weapon == CSW_XM1014 || weapon == CSW_M3)
{
if (get_weapon_idle_time(weapon_ent) <= 0.1)
set_weapon_idle_time(weapon_ent, 0.5)
}
}

do_set_trap(id)
{
if (!user_set_trap[id])
{
if (set_a_trap(id, set_trap_ent[id], set_trap_origin[id]) == 1)
{
user_set_trap[id] = true

new Float:velocity[3]
pev(id, pev_velocity, velocity)
velocity[0] = velocity[1] = 0.0
set_pev(id, pev_velocity, velocity)

new Float:set_trap_time, task_time
set_trap_time = SET_TIME
task_time = floatround(set_trap_time, floatround_floor) + (floatfract(set_trap_time) >= 0.5 ? 1 : 0)
set_task(set_trap_time, "trap_complete", (id + TASK_SET_TRAP))
show_user_taskbar(id, task_time)

client_print(id, print_center, "Установка ловушки...")
return 1;
}
}

return 0;
}

stop_set_trap(id)
{
if (user_set_trap[id])
{
client_print(id, print_center, "")

if (pev_valid(set_trap_ent[id]))
engfunc(EngFunc_RemoveEntity, set_trap_ent[id])

user_set_trap[id] = false
set_trap_ent[id] = 0
remove_task(id + TASK_SET_TRAP)
show_user_taskbar(id, 0)
}
}

set_a_trap(id, &trap_entity, Float:trap_origin[3])
{
if (user_has_traps[id] <= 0)
{
engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "У вас не осталось ловушек!")
return 0;
}

new user_flags = pev(id, pev_flags)
if (!(user_flags & FL_ONGROUND))
{
engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Отмена установки")
return 0;
}

new Float:origin[3]
pev(id, pev_origin, origin)
origin[2] -= (user_flags & FL_DUCKING) ? 18.0 : 36.0

if (get_too_close_traps(origin))
{
engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Отмена установки")
return 0;
}

client_print(id, print_center, "")

engfunc(EngFunc_EmitSound, id, CHAN_ITEM, TrapTrigger_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)

new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if (!ent) return -1;

set_pev(ent, pev_classname, "ZOMBIE_TRAP_ENT")
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_movetype, MOVETYPE_FLY)
set_pev(ent, pev_sequence, 0)
set_pev(ent, pev_frame, 0.0)
set_pev(ent, pev_iuser1, id)
set_pev(ent, pev_iuser2, 0)
set_pev(ent, pev_iuser3, 0)
set_pev(ent, pev_iuser4, 0)

new Float:mins[3] = { -20.0, -20.0, 0.0 }
new Float:maxs[3] = { 20.0, 20.0, 30.0 }
engfunc(EngFunc_SetSize, ent, mins, maxs)

engfunc(EngFunc_SetModel, ent, Trap_Model)

fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)

set_pev(ent, pev_origin, origin)

trap_entity = ent

xs_vec_copy(origin, trap_origin)

return 1;
}

public trap_complete(taskid)
{
new id = taskid - TASK_SET_TRAP

show_user_taskbar(id, 0)

if (pev_valid(set_trap_ent[id]))
{
set_pev(set_trap_ent[id], pev_iuser2, 1)
user_has_traps[id]--
set_user_traps_data(id, set_trap_ent[id])

client_print(id, print_center, "Ловушка установлена")
}

if (user_has_traps[id] > 0)
ChatColor(id, "!g[ZP] !yУ вас осталось !team%i !yловушек!", user_has_traps[id])
else
ChatColor(id, "!g[ZP] !yУ вас не осталось !gловушек!")

#if defined SUPPORT_BOT_TO_USE
if (is_user_bot(id))
{
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
bot_next_check_time[id] = get_gametime() + 10.0
}
#endif

user_set_trap[id] = false
set_trap_ent[id] = 0
}

public remove_trap(args[1])
{
new ent = args[0]

if (pev_valid(ent))
{
new classname[32]
pev(ent, pev_classname, classname, charsmax(classname))
if (!equal(classname, "ZOMBIE_TRAP_ENT"))
return;

new catched_player = pev(ent, pev_iuser4)
if (user_be_catched[catched_player] && catched_trap_ent[catched_player] == ent)
{
clear_user_sprite(catched_player)
ExecuteHamB(Ham_Item_PreFrame, catched_player)
set_pev(catched_player, pev_flags, (pev(catched_player, pev_flags) & ~FL_FROZEN))
user_be_catched[catched_player] = false
catched_trap_ent[catched_player] = 0
}

engfunc(EngFunc_RemoveEntity, ent)
}
}

public zp_user_humanized_post(id)
{
if (user_set_trap[id])
{
stop_set_trap(id)

#if defined SUPPORT_BOT_TO_USE
if (pev(id, pev_flags) & FL_FROZEN)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
#endif
}

remove_task(id+TASK_ABILITY)
remove_task(id+TASK_COOLDOWN)
remove_task(id)
reset_traps_owner(id)
reset_vars(id)

}

public client_connect(id)
{
reset_vars(id)
}

public client_disconnected(id)
{
if (user_set_trap[id])
{
stop_set_trap(id)

#if defined SUPPORT_BOT_TO_USE
if (pev(id, pev_flags) & FL_FROZEN)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
#endif
}

if (user_be_catched[id])
{
clear_user_sprite(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}

reset_vars(id)
}

public event_NewSpawn(id)
{
if (user_set_trap[id])
{
stop_set_trap(id)

#if defined SUPPORT_BOT_TO_USE
if (pev(id, pev_flags) & FL_FROZEN)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
#endif
}

if (user_be_catched[id])
{
clear_user_sprite(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}

reset_vars(id)
}

public event_Death()
{
new id = read_data(2)
if (!(1 <= id <= g_maxplayers))
return;

if (user_set_trap[id])
{
stop_set_trap(id)

#if defined SUPPORT_BOT_TO_USE
if (pev(id, pev_flags) & FL_FROZEN)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
#endif
}

if (user_be_catched[id])
{
clear_user_sprite(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}

reset_traps_owner(id)
reset_vars(id)
}

public event_RoundStart()
{
remove_task(TASK_REMOVE_TRAP)
remove_all_traps()
}

get_too_close_traps(const Float:origin[3])
{
new bool:find, ent, Float:ent_origin[3]
find = false
ent = -1
while ((ent = fm_find_ent_by_class(ent, "ZOMBIE_TRAP_ENT")))
{
if (pev(ent, pev_iuser2) == 1)
{
pev(ent, pev_origin, ent_origin)
if (get_distance_f(origin, ent_origin) <= 50.0)
find = true
}
}

if (!find) return 0;

return 1;
}

set_user_traps_data(id, trap_ent)
{
new bool:find = false

for (new i = 0; i < Max_Traps; i++)
{
if (user_traps_ent[id][i] == 0)
{
user_traps_ent[id][i] = trap_ent
find = true
break;
}
}

if (!find) return 0;

return 1;
}

reset_traps_owner(id)
{
new classname[32], owner
for (new i = 0; i < Max_Traps; i++)
{
if (user_traps_ent[id][i] > 0 && pev_valid(user_traps_ent[id][i]))
{
pev(user_traps_ent[id][i], pev_classname, classname, charsmax(classname))
owner = pev(user_traps_ent[id][i], pev_iuser1)

if (equal(classname, "ZOMBIE_TRAP_ENT") && owner == id)
set_pev(user_traps_ent[id][i], pev_iuser1, 0)
}
}
}

remove_all_traps()
{
new ent = -1
while ((ent = fm_find_ent_by_class(ent, "ZOMBIE_TRAP_ENT")))
{
engfunc(EngFunc_RemoveEntity, ent)
}
}

reset_vars(id)
{
user_has_traps[id] = 0
user_set_trap[id] = false
set_trap_ent[id] = 0
user_be_catched[id] = false
catched_trap_ent[id] = 0

for (new i = 0; i < Max_Traps; i++)
user_traps_ent[id][i] = 0
}

stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);

set_pev(entity, pev_renderfx, fx);
set_pev(entity, pev_rendercolor, RenderColor);
set_pev(entity, pev_rendermode, render);
set_pev(entity, pev_renderamt, float(amount));

return 1;
}

stock fm_find_ent_by_class(index, const classname[])
{
return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
}

stock PlaySound(id, const sound[])
{
if (equal(sound[strlen(sound)-4], ".mp3"))
client_cmd(id, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(id, "spk ^"%s^"", sound)
}

stock user_screen_shake(id, amplitude = 4, duration = 2, frequency = 10)
{
message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
write_short((1<<12)*amplitude)
write_short((1<<12)*duration)
write_short((1<<12)*frequency)
message_end()
}

stock show_user_taskbar(id, time)
{
message_begin(MSG_ONE_UNRELIABLE, g_msgBarTime, _, id)
write_short(time)
message_end()
}

stock show_user_sprite(id, const sprite_index)
{
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_PLAYERATTACHMENT)
write_byte(id)
write_coord(45)
write_short(sprite_index)
write_short(32767)
message_end()
}

stock clear_user_sprite(id)
{
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_KILLPLAYERATTACHMENTS)
write_byte(id)
message_end()
}

stock bool:fm_is_point_visible(index, const Float:point[3], ignoremonsters = 1)
{
new Float:start[3], Float:dest[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, dest);
xs_vec_add(start, dest, start);

engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0);

new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (fraction == 1.0)
return true;

get_tr2(0, TR_vecEndPos, dest);
if ((dest[0] == point[0]) && (dest[1] == point[1]) && (dest[2] == point[2]))
return true;

return false;
}

stock create_user_sprite(id, const Float:originF[3], sprite_index, scale)
{
message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
write_byte(TE_SPRITE)
engfunc(EngFunc_WriteCoord, originF[0])
engfunc(EngFunc_WriteCoord, originF[1])
engfunc(EngFunc_WriteCoord, originF[2])
write_short(sprite_index)
write_byte(scale)
write_byte(200)
message_end()
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}

return entity;
}

stock Float:get_weapon_next_pri_attack(entity)
{
return get_pdata_float(entity, OFFSET_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_next_pri_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
}

stock Float:get_weapon_next_sec_attack(entity)
{
return get_pdata_float(entity, OFFSET_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_next_sec_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flNextSecondaryAttack, time, OFFSET_LINUX_WEAPONS)
}

stock Float:get_weapon_idle_time(entity)
{
return get_pdata_float(entity, OFFSET_flTimeWeaponIdle, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_idle_time(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flTimeWeaponIdle, time, OFFSET_LINUX_WEAPONS)
}

#if defined SUPPORT_BOT_TO_USE
public bot_use_traps(id)
{
static target, hitzone, distance
target = get_valid_aim_target(id, hitzone, distance)

if (!user_set_trap[id])
{
static Float:time
time = get_gametime()

if (target > 0 && (500 <= distance <= 1000) && time >= bot_next_check_time[id])
{
if (random_num(1, 100) > 85)
{
if (do_set_trap(id))
set_pev(id, pev_flags, (pev(id, pev_flags) | FL_FROZEN))
}

bot_next_check_time[id] = time + 1.0
}
}
else
{
static Float:user_origin[3], Float:fdistance
pev(id, pev_origin, user_origin)
user_origin[2] = set_trap_origin[id][2]
fdistance = get_distance_f(user_origin, set_trap_origin[id])

if ((target > 0 && distance <= 200) || fdistance > 18.0)
{
stop_set_trap(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}
}
}

public event_Damage(id)
{
new attacker, weapon, hitzone
attacker = get_user_attacker(id, weapon, hitzone)

if (!(1 <= attacker <= g_maxplayers) || !is_user_connected(attacker) || !is_user_alive(attacker)
|| attacker == id)
return;

new damage = read_data(2)

if (is_user_bot(id) && damage > 0)
{
new Float:origin1[3], Float:origin2[3], distance
pev(id, pev_origin, origin1)
pev(attacker, pev_origin, origin2)
distance = floatround(get_distance_f(origin1, origin2))

if (distance < 500 || damage > 100)
{
if (user_set_trap[id])
{
stop_set_trap(id)
set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
}
}
}
}

get_valid_aim_target(id, &hitzone, &distance)
{
new target, aim_hitzone
get_user_aiming(id, target, aim_hitzone)
if (!(1 <= target <= g_maxplayers) || !is_user_alive(target) || zp_get_user_zombie(target))
return 0;

hitzone = aim_hitzone
new Float:origin1[3], Float:origin2[3]
pev(id, pev_origin, origin1)
pev(target, pev_origin, origin2)
distance = floatround(get_distance_f(origin1, origin2), floatround_round)

return target;
}
#endif

public roundStart()
{
for (new i = 1; i <= g_maxplayers; i++)
{
is_cooldown[i] = 0
is_cooldown_time[i] = floatround(g_revenge_cooldown)
remove_task(i)
}
}

stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!team", "^3")

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
Данный плагин добавляет на ваш сервер зомби класс " Толстяк ". Этот класс может ставить ловушки и ослеплять людей на определенное время когда те атакуют. Первая способность " Ловушки " работает без нареканий, даже боты могут её использовать. Но вторая пассивная способность " Ослепление " как буд-то даже не присутствует, не активна. Плагин компилируется без ошибок. Присутствует один варнинг. В чем может быть проблема? Почему не активна вторая способность?
 
По логике я вижу что это рандом (псевдо-шанс), шанс срабатывание: 2.5%.

Исходя из предоставленного кода:
  • g_chance_to_cast = 25
  • g_chance[victim] = random_num(0, 999) — генерируется случайное целое число от 0 до 999 включительно.
  • Условие g_chance[victim] < g_chance_to_cast означает, что успех наступает, если выпало число от 0 до 24 включительно.
Количество благоприятных исходов: 25 (числа 0, 1, 2, …, 24).
Общее количество исходов: 1000 (числа 0, 1, 2, …, 999).

Вероятность = 25\1000=0.025 = 2.5%
для проверки измени g_chance_to_cast вместо 25 на 998 (это 100%), если работает, значит дело в % шанса
 
@Limbooc,
C-подобный:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <xs>
#include <hamsandwich>
#include <zombieplague>

#define SUPPORT_BOT_TO_USE
#define TASK_SET_TRAP        1234
#define TASK_REMOVE_TRAP        4321

#define TIME_CATCHED 4.0

new const zclass4_name[] = { "Heavy" }   
new const zclass4_info[] = { "\y[ Ловушки на \rR \y]" }   
new const zclass4_model[] = {"Heavy"}       
new const zclass4_clawmodel[] = { "Bla_Bla/v_knife_heavy.mdl" }   
const zclass4_health = 4200       
const zclass4_speed = 235       
const Float:zclass4_gravity = 0.85       
const Float:zclass4_knockback = 0.25       

new g_chance[33]
new g_msgScreenFade
const FFADE_IN = 0x0000
const FFADE_STAYOUT = 0x0004
const UNIT_SECOND = (1<<12)

new is_cooldown_time[33] = 0
new is_cooldown[33] = 0
new g_MsgSync

new const Trap_Model[] = { "models/Bla_Bla/w_trap.mdl" }

new const TrapTrigger_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_trigger.wav" }
new const PlayerCatched_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_cathed.wav" }
new const CantPlantTrap_Sound[] = { "Bla_Bla/ZP_class/zombie_trap_cant_plant.wav" }
const Max_Traps = 5   

enum (+= 100)
{
    TASK_COOLDOWN,
    TASK_ABILITY
}

const OFFSET_flNextPrimaryAttack = 46
const OFFSET_flNextSecondaryAttack = 47
const OFFSET_flTimeWeaponIdle = 48

const OFFSET_LINUX_WEAPONS = 4

new g_zclass_heavy

new Float:g_revenge_cooldown = 30.0

new g_chance_to_cast = 998
new cvar_TrapAffectTime

#define SET_TIME 1.0

new g_maxplayers
new user_has_traps[33]
new user_traps_ent[33][Max_Traps]
new g_TrapPromptSpr, g_PlayerCatchedSpr
new g_msgScreenShake, g_msgBarTime
new bool:user_set_trap[33], set_trap_ent[33], Float:set_trap_origin[33][3]
new bool:user_be_catched[33], catched_trap_ent[33]

new const sound_sleep[] = "Bla_Bla/ZP_class/sleep_impact.wav"

#if defined SUPPORT_BOT_TO_USE
new Float:bot_next_check_time[33]
#endif

public plugin_init()
{
    register_plugin("[ZP] Class: Big", "1.0", ":) / Slimes")

    g_msgScreenFade = get_user_msgid("ScreenFade")
    g_maxplayers = get_maxplayers()

    register_logevent("roundStart", 2, "1=Round_Start")
    register_forward(FM_CmdStart, "fw_CmdStart")
    register_forward(FM_StartFrame, "fw_StartFrame")
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
    register_forward(FM_Touch, "fw_Touch")
    register_forward(FM_Think, "fw_Think")
    
    register_event("ResetHUD", "event_NewSpawn", "be")
    register_event("DeathMsg", "event_Death", "a")
    register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
    
    #if defined SUPPORT_BOT_TO_USE
    register_event("Damage", "event_Damage", "be", "2>0")
    #endif
    
    cvar_TrapAffectTime = register_cvar("zp_heavy_trap_affecttime", "10.0")

    g_msgScreenShake = get_user_msgid("ScreenShake")
    g_msgBarTime = get_user_msgid("BarTime")
    g_maxplayers = get_maxplayers()
    g_MsgSync = CreateHudSyncObj()
}

public plugin_precache()
{
    precache_sound(sound_sleep)
    precache_model(Trap_Model)
    
    precache_sound(TrapTrigger_Sound)
    precache_sound(PlayerCatched_Sound)
    precache_sound(CantPlantTrap_Sound)
    
    g_TrapPromptSpr = precache_model("sprites/Bla_Bla/ZP_class/zombie_trap_prompt.spr")
    g_PlayerCatchedSpr = precache_model("sprites/Bla_Bla/ZP_class/zombie_trap_notice.spr")
    
    g_zclass_heavy = zp_register_zombie_class(zclass4_name, zclass4_info, zclass4_model, zclass4_clawmodel, zclass4_health, zclass4_speed, zclass4_gravity, zclass4_knockback)
}

public client_damage(attacker,victim)
{
    if ((zp_get_user_zombie_class(victim) == g_zclass_heavy) && zp_get_user_zombie(victim) && !zp_get_user_nemesis(victim) && (is_cooldown[victim] == 0))
    {
        g_chance[victim] = random_num(0,999)
        if (g_chance[victim] < g_chance_to_cast)
        {
            message_begin(MSG_ONE, g_msgScreenFade, _, attacker)
            write_short(4)
            write_short(4)
            write_short(FFADE_STAYOUT)
            write_byte(0)
            write_byte(0)
            write_byte(0)
            write_byte(255)
            message_end()
            
            set_user_health(victim, get_user_health(victim) + ( get_user_health(victim) / 10 ) )
            
            set_task(4.0,"wake_up",attacker)
            set_task(1.0, "RemoveCooldown", victim+TASK_COOLDOWN, _, _, "a",is_cooldown_time[victim])   
            
            emit_sound(attacker, CHAN_STREAM, sound_sleep, 1.0, ATTN_NORM, 0, PITCH_NORM);
            
            is_cooldown[victim] = 1
        }
    }
}

public Ability(taskid)
{
    new id = taskid - TASK_ABILITY
    
    if(is_user_alive(id))
    {
        if (is_cooldown_time[id] == 0)
        {
        set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
        ShowSyncHudMsg(id, g_MsgSync, "Ловушка - [R]^nОслепление - Пассивная способность!")
        }
    }
    else remove_task(id+TASK_ABILITY)
}

public RemoveCooldown(taskid)
{
    new id = taskid - TASK_COOLDOWN
    
    if(is_user_alive(id))
    {
        is_cooldown_time[id]--
        if (is_cooldown_time[id] == 0)
        {
        set_task(2.5, "Ability", id+TASK_ABILITY)
        remove_task(id+TASK_COOLDOWN)
        }
        set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
        ShowSyncHudMsg(id, g_MsgSync, "Ловушка - [R]^nОслепление - Перезарядка: %d",is_cooldown_time[id])
    }
    else remove_task(id+TASK_COOLDOWN)
}

public wake_up(id)
{
    message_begin(MSG_ONE, g_msgScreenFade, _, id)
    write_short(UNIT_SECOND)
    write_short(0)
    write_short(FFADE_IN)
    write_byte(0)
    write_byte(0)
    write_byte(0)
    write_byte(255)
    message_end()
}

public zp_user_infected_post(id, infector)
{
    if (user_be_catched[id])
    {
        clear_user_sprite(id)
        set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
    }
    
    reset_vars(id)
    
    if (zp_get_user_zombie_class(id) == g_zclass_heavy && !zp_get_user_nemesis(id))
    {   
        is_cooldown[id] = 0
        is_cooldown_time[id] = 0
        set_task(1.0, "Ability", id+TASK_ABILITY, _, _, "b")   

        user_has_traps[id] = Max_Traps
    }

    remove_task(id)
    is_cooldown[id] = 0
}

public fw_CmdStart(id, uc_handle, seed)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
    
    if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
        return FMRES_IGNORED;
    
    #if defined SUPPORT_BOT_TO_USE
    if (is_user_bot(id))
    {
        bot_use_traps(id)
        return FMRES_IGNORED;
    }
    #endif
    
    static button, oldbutton
    button = get_uc(uc_handle, UC_Buttons)
    oldbutton = pev(id, pev_oldbuttons)
    
    if (!user_set_trap[id])
    {
        if ((button & IN_RELOAD) && !(oldbutton & IN_RELOAD))
        {
            do_set_trap(id)
        }
    }
    else
    {
        static user_flags, Float:user_origin[3], Float:fdistance
        user_flags = pev(id, pev_flags)
        pev(id, pev_origin, user_origin)
        user_origin[2] -= (user_flags & FL_DUCKING) ? 18.0 : 36.0
        fdistance = get_distance_f(user_origin, set_trap_origin[id])
        
        if (!(button & IN_RELOAD) || fdistance > 18.0)
        {
            stop_set_trap(id)
        }
    }
    
    return FMRES_HANDLED;
}

public fw_StartFrame()
{
    static Float:time, Float:next_check_time, id, i, classname[32], Float:origin1[3], Float:origin2[3]
    
    time = get_gametime()
    
    if (time >= next_check_time)
    {
        for (id = 1; id <= g_maxplayers; id++)
        {
            if (!is_user_connected(id) || !is_user_alive(id))
                continue;
            
            if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
                continue;
            
            for (i = 0; i < Max_Traps; i++)
            {
                if (user_traps_ent[id][i] <= 0)
                    continue;
                
                if (!pev_valid(user_traps_ent[id][i]))
                {
                    user_traps_ent[id][i] = 0
                    continue;
                }
                
                pev(user_traps_ent[id][i], pev_classname, classname, charsmax(classname))
                if (!equal(classname, "ZOMBIE_TRAP_ENT"))
                {
                    user_traps_ent[id][i] = 0
                    continue;
                }
                
                if (pev(user_traps_ent[id][i], pev_iuser3) == 1)
                    continue;
                
                pev(user_traps_ent[id][i], pev_origin, origin1)
                xs_vec_copy(origin1, origin2)
                origin2[2] += 30.0
                if (fm_is_point_visible(id, origin1, 1) || fm_is_point_visible(id, origin2, 1))
                {
                    origin1[2] += 30.0
                    create_user_sprite(id, origin1, g_TrapPromptSpr, 5)
                }
            }
        }
        
        next_check_time = time + 0.1
    }
    
    return FMRES_IGNORED;
}

public fw_PlayerPreThink(id)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED;
    
    if (zp_get_user_zombie(id))
    {
        if (zp_get_user_zombie_class(id) != g_zclass_heavy || zp_get_user_nemesis(id))
            return FMRES_IGNORED;
        
        if (user_set_trap[id])
        {
            freeze_user_attack(id)
        }
    }
    else
    {
        if (user_be_catched[id] && pev_valid(catched_trap_ent[id]))
        {
            static classname[32]
            pev(catched_trap_ent[id], pev_classname, classname, charsmax(classname))
            if (!equal(classname, "ZOMBIE_TRAP_ENT"))
                return FMRES_IGNORED;
            
            set_pev(id, pev_velocity, Float:{ 0.0, 0.0, -200.0 })
            set_pev(id, pev_maxspeed, 1.0)
            
            static Float:user_origin[3], Float:ent_origin[3], Float:temp_origin[3]
            pev(id, pev_origin, user_origin)
            pev(catched_trap_ent[id], pev_origin, ent_origin)
            xs_vec_copy(ent_origin, temp_origin)
            temp_origin[2] += 18.0
            if (get_distance_f(user_origin, temp_origin) > 18.0)
            {
                temp_origin[2] += ((pev(id, pev_flags) & FL_DUCKING) ? 0.0 : 18.0)
                set_pev(id, pev_origin, temp_origin)
            }
        }
    }
    
    return FMRES_IGNORED;
}

public fw_Touch(ptr, ptd)
{
    if (!pev_valid(ptr) || !pev_valid(ptd))
        return FMRES_IGNORED;
    
    static classname[32]
    pev(ptr, pev_classname, classname, charsmax(classname))
    if (!equal(classname, "ZOMBIE_TRAP_ENT"))
        return FMRES_IGNORED;
    
    if (!(1 <= ptd <= g_maxplayers) || !is_user_alive(ptd) || zp_get_user_zombie(ptd))
        return FMRES_IGNORED;
    
    if (pev(ptr, pev_iuser2) == 0)
        return FMRES_IGNORED;

    if (pev(ptr, pev_iuser3) == 0 && !user_be_catched[ptd])
    {
        PlaySound(ptd, TrapTrigger_Sound)
        engfunc(EngFunc_EmitSound, ptd, CHAN_VOICE, PlayerCatched_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
        user_screen_shake(ptd, 4, 2, 5)
        show_user_sprite(ptd, g_PlayerCatchedSpr)
        
        static Float:origin[3]
        pev(ptr, pev_origin, origin)
        origin[2] += ((pev(ptd, pev_flags) & FL_DUCKING) ? 18.0 : 36.0)
        set_pev(ptd, pev_origin, origin)
        set_pev(ptd, pev_velocity, Float:{ 0.0, 0.0, 0.0 })
                new name[32]
                get_user_name(ptd, name, 31)
                client_print(ptd, print_center, "Вы пойманы в ловушку!")
        
        set_pev(ptr, pev_iuser3, 1)
        set_pev(ptr, pev_iuser4, ptd)
        user_be_catched[ptd] = true
        catched_trap_ent[ptd] = ptr
        fm_set_rendering(ptr, kRenderFxNone, 0,0,0, kRenderNormal, 255)
        set_pev(ptr, pev_nextthink, get_gametime() + 0.05)
        
        static owner
        owner = pev(ptr, pev_iuser1)
        if (1 <= owner <= g_maxplayers)
                        client_print(owner, print_center, "Игрок %s попал в ловушку!", name)
        
        static Float:trap_affect_time
        trap_affect_time = TIME_CATCHED
        if (trap_affect_time > 0.0)
        {
            static args[1]
            args[0] = ptr
            set_task(trap_affect_time, "remove_trap", TASK_REMOVE_TRAP, args, 1)
        }
    }
    
    return FMRES_IGNORED;
}

public fw_Think(ent)
{
    if (pev_valid(ent))
    {
        static classname[32]
        pev(ent, pev_classname, classname, charsmax(classname))
        if (equal(classname, "ZOMBIE_TRAP_ENT"))
        {
            if (pev(ent, pev_sequence) != 1)
            {
                set_pev(ent, pev_sequence, 1)
                set_pev(ent, pev_frame, 0.0)
            }
            else
            {
                if (pev(ent, pev_frame) > 241.0)
                    set_pev(ent, pev_frame, 20.0)
                else
                    set_pev(ent, pev_frame, pev(ent, pev_frame) + 1.0)
            }
            
            static catched_player
            catched_player = pev(ent, pev_iuser4)
            if (!user_be_catched[catched_player] || catched_trap_ent[catched_player] != ent)
            {
                engfunc(EngFunc_RemoveEntity, ent)
                return FMRES_IGNORED;
            }
            
            set_pev(ent, pev_nextthink, get_gametime() + 0.05)
        }
    }
    
    return FMRES_IGNORED;
}

freeze_user_attack(id)
{
    new weapon, weapon_name[32], weapon_ent
    weapon = get_user_weapon(id)
    get_weaponname(weapon, weapon_name, charsmax(weapon_name))
    weapon_ent = fm_find_ent_by_owner(-1, weapon_name, id)
    
    if (get_weapon_next_pri_attack(weapon_ent) <= 0.1)
        set_weapon_next_pri_attack(weapon_ent, 0.5)
    
    if (get_weapon_next_sec_attack(weapon_ent) <= 0.1)
        set_weapon_next_sec_attack(weapon_ent, 0.5)
    
    if (weapon == CSW_XM1014 || weapon == CSW_M3)
    {
        if (get_weapon_idle_time(weapon_ent) <= 0.1)
            set_weapon_idle_time(weapon_ent, 0.5)
    }
}

do_set_trap(id)
{
    if (!user_set_trap[id])
    {
        if (set_a_trap(id, set_trap_ent[id], set_trap_origin[id]) == 1)
        {
            user_set_trap[id] = true
            
            new Float:velocity[3]
            pev(id, pev_velocity, velocity)
            velocity[0] = velocity[1] = 0.0
            set_pev(id, pev_velocity, velocity)
            
            new Float:set_trap_time, task_time
            set_trap_time = SET_TIME
            task_time = floatround(set_trap_time, floatround_floor) + (floatfract(set_trap_time) >= 0.5 ? 1 : 0)
            set_task(set_trap_time, "trap_complete", (id + TASK_SET_TRAP))
            show_user_taskbar(id, task_time)
            
                        client_print(id, print_center, "Установка ловушки...")
            return 1;
        }
    }
    
    return 0;
}

stop_set_trap(id)
{
    if (user_set_trap[id])
    {
        client_print(id, print_center, "")
        
        if (pev_valid(set_trap_ent[id]))
            engfunc(EngFunc_RemoveEntity, set_trap_ent[id])
        
        user_set_trap[id] = false
        set_trap_ent[id] = 0
        remove_task(id + TASK_SET_TRAP)
        show_user_taskbar(id, 0)
    }
}

set_a_trap(id, &trap_entity, Float:trap_origin[3])
{
    if (user_has_traps[id] <= 0)
    {
        engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
                client_print(id, print_center, "У вас не осталось ловушек!")
        return 0;
    }
    
    new user_flags = pev(id, pev_flags)
    if (!(user_flags & FL_ONGROUND))
    {
        engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
                client_print(id, print_center, "Отмена установки")
        return 0;
    }
    
    new Float:origin[3]
    pev(id, pev_origin, origin)
    origin[2] -= (user_flags & FL_DUCKING) ? 18.0 : 36.0
    
    if (get_too_close_traps(origin))
    {
        engfunc(EngFunc_EmitSound, id, CHAN_ITEM, CantPlantTrap_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
                client_print(id, print_center, "Отмена установки")
        return 0;
    }
    
    client_print(id, print_center, "")
    
    engfunc(EngFunc_EmitSound, id, CHAN_ITEM, TrapTrigger_Sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    
    new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if (!ent) return -1;
    
    set_pev(ent, pev_classname, "ZOMBIE_TRAP_ENT")
    set_pev(ent, pev_solid, SOLID_TRIGGER)
    set_pev(ent, pev_movetype, MOVETYPE_FLY)
    set_pev(ent, pev_sequence, 0)
    set_pev(ent, pev_frame, 0.0)
    set_pev(ent, pev_iuser1, id)
    set_pev(ent, pev_iuser2, 0)
    set_pev(ent, pev_iuser3, 0)
    set_pev(ent, pev_iuser4, 0)
    
    new Float:mins[3] = { -20.0, -20.0, 0.0 }
    new Float:maxs[3] = { 20.0, 20.0, 30.0 }
    engfunc(EngFunc_SetSize, ent, mins, maxs)
    
    engfunc(EngFunc_SetModel, ent, Trap_Model)
    
    fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
    
    set_pev(ent, pev_origin, origin)
    
    trap_entity = ent
    
    xs_vec_copy(origin, trap_origin)
    
    return 1;
}

public trap_complete(taskid)
{
    new id = taskid - TASK_SET_TRAP
    
    show_user_taskbar(id, 0)
    
    if (pev_valid(set_trap_ent[id]))
    {
        set_pev(set_trap_ent[id], pev_iuser2, 1)
        user_has_traps[id]--
        set_user_traps_data(id, set_trap_ent[id])
        
        client_print(id, print_center, "Ловушка установлена")
    }

        if (user_has_traps[id] > 0)
               ChatColor(id, "!g[ZP] !yУ вас осталось !team%i !yловушек!", user_has_traps[id])
    else
              ChatColor(id, "!g[ZP] !yУ вас не осталось !gловушек!")
    
    #if defined SUPPORT_BOT_TO_USE
    if (is_user_bot(id))
    {
        set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        bot_next_check_time[id] = get_gametime() + 10.0
    }
    #endif
    
    user_set_trap[id] = false
    set_trap_ent[id] = 0
}

public remove_trap(args[1])
{
    new ent = args[0]
    
    if (pev_valid(ent))
    {
        new classname[32]
        pev(ent, pev_classname, classname, charsmax(classname))
        if (!equal(classname, "ZOMBIE_TRAP_ENT"))
            return;
        
        new catched_player = pev(ent, pev_iuser4)
        if (user_be_catched[catched_player] && catched_trap_ent[catched_player] == ent)
        {
            clear_user_sprite(catched_player)
            ExecuteHamB(Ham_Item_PreFrame, catched_player)
            set_pev(catched_player, pev_flags, (pev(catched_player, pev_flags) & ~FL_FROZEN))
            user_be_catched[catched_player] = false
            catched_trap_ent[catched_player] = 0
        }
        
        engfunc(EngFunc_RemoveEntity, ent)
    }
}

public zp_user_humanized_post(id)
{
    if (user_set_trap[id])
    {
        stop_set_trap(id)
        
        #if defined SUPPORT_BOT_TO_USE
        if (pev(id, pev_flags) & FL_FROZEN)
            set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        #endif
    }
    
    remove_task(id+TASK_ABILITY)
    remove_task(id+TASK_COOLDOWN)
    remove_task(id)
    reset_traps_owner(id)
    reset_vars(id)

}

public client_connect(id)
{
    reset_vars(id)
}

public client_disconnected(id)
{
    if (user_set_trap[id])
    {
        stop_set_trap(id)
        
        #if defined SUPPORT_BOT_TO_USE
        if (pev(id, pev_flags) & FL_FROZEN)
            set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        #endif
    }
    
    if (user_be_catched[id])
    {
        clear_user_sprite(id)
        set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
    }
    
    reset_vars(id)
}

public event_NewSpawn(id)
{
    if (user_set_trap[id])
    {
        stop_set_trap(id)
        
        #if defined SUPPORT_BOT_TO_USE
        if (pev(id, pev_flags) & FL_FROZEN)
            set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        #endif
    }
    
    if (user_be_catched[id])
    {
        clear_user_sprite(id)
        set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
    }
    
    reset_vars(id)
}

public event_Death()
{
    new id = read_data(2)
    if (!(1 <= id <= g_maxplayers))
        return;
    
    if (user_set_trap[id])
    {
        stop_set_trap(id)
        
        #if defined SUPPORT_BOT_TO_USE
        if (pev(id, pev_flags) & FL_FROZEN)
            set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        #endif
    }
    
    if (user_be_catched[id])
    {
        clear_user_sprite(id)
        set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
    }
    
    reset_traps_owner(id)
    reset_vars(id)
}

public event_RoundStart()
{
    remove_task(TASK_REMOVE_TRAP)
    remove_all_traps()
}

get_too_close_traps(const Float:origin[3])
{
    new bool:find, ent, Float:ent_origin[3]
    find = false
    ent = -1
    while ((ent = fm_find_ent_by_class(ent, "ZOMBIE_TRAP_ENT")))
    {
        if (pev(ent, pev_iuser2) == 1)
        {
            pev(ent, pev_origin, ent_origin)
            if (get_distance_f(origin, ent_origin) <= 50.0)
                find = true
        }
    }
    
    if (!find) return 0;
    
    return 1;
}

set_user_traps_data(id, trap_ent)
{
    new bool:find = false
    
    for (new i = 0; i < Max_Traps; i++)
    {
        if (user_traps_ent[id][i] == 0)
        {
            user_traps_ent[id][i] = trap_ent
            find = true
            break;
        }
    }
    
    if (!find) return 0;
    
    return 1;
}

reset_traps_owner(id)
{
    new classname[32], owner
    for (new i = 0; i < Max_Traps; i++)
    {
        if (user_traps_ent[id][i] > 0 && pev_valid(user_traps_ent[id][i]))
        {
            pev(user_traps_ent[id][i], pev_classname, classname, charsmax(classname))
            owner = pev(user_traps_ent[id][i], pev_iuser1)
            
            if (equal(classname, "ZOMBIE_TRAP_ENT") && owner == id)
                set_pev(user_traps_ent[id][i], pev_iuser1, 0)
        }
    }
}

remove_all_traps()
{
    new ent = -1
    while ((ent = fm_find_ent_by_class(ent, "ZOMBIE_TRAP_ENT")))
    {
        engfunc(EngFunc_RemoveEntity, ent)
    }
}

reset_vars(id)
{
    user_has_traps[id] = 0
    user_set_trap[id] = false
    set_trap_ent[id] = 0
    user_be_catched[id] = false
    catched_trap_ent[id] = 0
    
    for (new i = 0; i < Max_Traps; i++)
        user_traps_ent[id][i] = 0
}

stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
    new Float:RenderColor[3];
    RenderColor[0] = float(r);
    RenderColor[1] = float(g);
    RenderColor[2] = float(b);
    
    set_pev(entity, pev_renderfx, fx);
    set_pev(entity, pev_rendercolor, RenderColor);
    set_pev(entity, pev_rendermode, render);
    set_pev(entity, pev_renderamt, float(amount));
    
    return 1;
}

stock fm_find_ent_by_class(index, const classname[])
{
    return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
}

stock PlaySound(id, const sound[])
{
    if (equal(sound[strlen(sound)-4], ".mp3"))
        client_cmd(id, "mp3 play ^"sound/%s^"", sound)
    else
        client_cmd(id, "spk ^"%s^"", sound)
}

stock user_screen_shake(id, amplitude = 4, duration = 2, frequency = 10)
{
    message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
    write_short((1<<12)*amplitude)
    write_short((1<<12)*duration)
    write_short((1<<12)*frequency)
    message_end()
}

stock show_user_taskbar(id, time)
{
    message_begin(MSG_ONE_UNRELIABLE, g_msgBarTime, _, id)
    write_short(time)
    message_end()
}

stock show_user_sprite(id, const sprite_index)
{
    message_begin(MSG_ALL, SVC_TEMPENTITY)
    write_byte(TE_PLAYERATTACHMENT)
    write_byte(id)
    write_coord(45)
    write_short(sprite_index)
    write_short(32767)
    message_end()
}

stock clear_user_sprite(id)
{
    message_begin(MSG_ALL, SVC_TEMPENTITY)
    write_byte(TE_KILLPLAYERATTACHMENTS)
    write_byte(id)
    message_end()
}

stock bool:fm_is_point_visible(index, const Float:point[3], ignoremonsters = 1)
{
    new Float:start[3], Float:dest[3];
    pev(index, pev_origin, start);
    pev(index, pev_view_ofs, dest);
    xs_vec_add(start, dest, start);
    
    engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0);
    
    new Float:fraction;
    get_tr2(0, TR_flFraction, fraction);
    if (fraction == 1.0)
        return true;
    
    get_tr2(0, TR_vecEndPos, dest);
    if ((dest[0] == point[0]) && (dest[1] == point[1]) && (dest[2] == point[2]))
        return true;
    
    return false;
}

stock create_user_sprite(id, const Float:originF[3], sprite_index, scale)
{
    message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, originF[0])
    engfunc(EngFunc_WriteCoord, originF[1])
    engfunc(EngFunc_WriteCoord, originF[2])
    write_short(sprite_index)
    write_byte(scale)
    write_byte(200)
    message_end()
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}
    
    return entity;
}

stock Float:get_weapon_next_pri_attack(entity)
{
    return get_pdata_float(entity, OFFSET_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_next_pri_attack(entity, Float:time)
{
    set_pdata_float(entity, OFFSET_flNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
}

stock Float:get_weapon_next_sec_attack(entity)
{
    return get_pdata_float(entity, OFFSET_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_next_sec_attack(entity, Float:time)
{
    set_pdata_float(entity, OFFSET_flNextSecondaryAttack, time, OFFSET_LINUX_WEAPONS)
}

stock Float:get_weapon_idle_time(entity)
{
    return get_pdata_float(entity, OFFSET_flTimeWeaponIdle, OFFSET_LINUX_WEAPONS)
}

stock set_weapon_idle_time(entity, Float:time)
{
    set_pdata_float(entity, OFFSET_flTimeWeaponIdle, time, OFFSET_LINUX_WEAPONS)
}

#if defined SUPPORT_BOT_TO_USE
public bot_use_traps(id)
{
    static target, hitzone, distance
    target = get_valid_aim_target(id, hitzone, distance)
    
    if (!user_set_trap[id])
    {
        static Float:time
        time = get_gametime()
        
        if (target > 0 && (500 <= distance <= 1000) && time >= bot_next_check_time[id])
        {
            if (random_num(1, 100) > 85)
            {
                if (do_set_trap(id))
                    set_pev(id, pev_flags, (pev(id, pev_flags) | FL_FROZEN))
            }
            
            bot_next_check_time[id] = time + 1.0
        }
    }
    else
    {
        static Float:user_origin[3], Float:fdistance
        pev(id, pev_origin, user_origin)
        user_origin[2] = set_trap_origin[id][2]
        fdistance = get_distance_f(user_origin, set_trap_origin[id])
        
        if ((target > 0 && distance <= 200) || fdistance > 18.0)
        {
            stop_set_trap(id)
            set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
        }
    }
}

public event_Damage(id)
{
    new attacker, weapon, hitzone
    attacker = get_user_attacker(id, weapon, hitzone)
    
    if (!(1 <= attacker <= g_maxplayers) || !is_user_connected(attacker) || !is_user_alive(attacker)
    || attacker == id)
        return;
    
    new damage = read_data(2)
    
    if (is_user_bot(id) && damage > 0)
    {
        new Float:origin1[3], Float:origin2[3], distance
        pev(id, pev_origin, origin1)
        pev(attacker, pev_origin, origin2)
        distance = floatround(get_distance_f(origin1, origin2))
        
        if (distance < 500 || damage > 100)
        {
            if (user_set_trap[id])
            {
                stop_set_trap(id)
                set_pev(id, pev_flags, (pev(id, pev_flags) & ~FL_FROZEN))
            }
        }
    }
}

get_valid_aim_target(id, &hitzone, &distance)
{
    new target, aim_hitzone
    get_user_aiming(id, target, aim_hitzone)
    if (!(1 <= target <= g_maxplayers) || !is_user_alive(target) || zp_get_user_zombie(target))
        return 0;
    
    hitzone = aim_hitzone
    new Float:origin1[3], Float:origin2[3]
    pev(id, pev_origin, origin1)
    pev(target, pev_origin, origin2)
    distance = floatround(get_distance_f(origin1, origin2), floatround_round)
    
    return target;
}
#endif

public roundStart()
{
    for (new i = 1; i <= g_maxplayers; i++)
    {
        is_cooldown[i] = 0
        is_cooldown_time[i] = floatround(g_revenge_cooldown)
        remove_task(i)
    }
}

stock ChatColor(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
    
    replace_all(msg, 190, "!g", "^4")
    replace_all(msg, 190, "!y", "^1")
    replace_all(msg, 190, "!team", "^3")
    
    if (id) players[0] = id; else get_players(players, count, "ch")
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}
Благодарю за вариант, но всё осталось без изменений. Сам побегал за этого зомби, боты за него побегали, способность ослепления так и не робит.
 
на самом деле я также не понимаю зачем поставили is_cooldown[victim] = 1

правильно будет
C-подобный:
public client_damage(attacker,victim)
{
    log_amx("PRE: %d",is_cooldown_time[victim]) // добавил дэбаг в консоль
    if ((zp_get_user_zombie_class(victim) == g_zclass_heavy) && zp_get_user_zombie(victim) && !zp_get_user_nemesis(victim) && (is_cooldown[victim] == 0))
    {
        g_chance[victim] = random_num(0,999)
        if (g_chance[victim] < g_chance_to_cast)
        {
            message_begin(MSG_ONE, g_msgScreenFade, _, attacker)
            write_short(4)
            write_short(4)
            write_short(FFADE_STAYOUT)
            write_byte(0)
            write_byte(0)
            write_byte(0)
            write_byte(255)
            message_end()
            
            set_user_health(victim, get_user_health(victim) + ( get_user_health(victim) / 10 ) )
            
            set_task(4.0,"wake_up",attacker)
            set_task(1.0, "RemoveCooldown", victim+TASK_COOLDOWN, _, _, "a",is_cooldown_time[victim])    
            
            emit_sound(attacker, CHAN_STREAM, sound_sleep, 1.0, ATTN_NORM, 0, PITCH_NORM);
            
            is_cooldown[victim] = floatround(g_revenge_cooldown) // берем из квара секунды
            log_amx("POST: %d",is_cooldown_time[victim])  // добавил дэбаг в консоль
        }
    }
}

Ослепление будет работать "только" когда is_cooldown_time будет равно 0, далее сбрасывается у жертвы
добавил дэбаг в консоль, чекни вот это,
 

Кто просматривает тему

Назад
Верх