помогите пожалуйста

Сообщения
107
Реакции
10
Berkulech, может прикрепишь видео что конкретно не так? у тебя дроны просто в начальной анимации находятся. Явно плагин юзает еще следующие анимации где модель выглядит нормально
 
Сообщения
107
Реакции
10
Berkulech, Не уверен, но проверь
Код:
#include <amxmodx>
#include <fakemeta_util>
#include <hamsandwich>
#include <zombieplague>

#define CustomItem(%0) (pev(%0, pev_impulse) == WEAPON_SPECIAL_CODE)
#define Sprite_SetScale(%0,%1) set_pev(%0, pev_scale, %1)   
#define get_WeaponState(%0) (get_pdata_int(%0, m_iWeaponState, linux_diff_weapon))
#define set_WeaponState(%0,%1) (set_pdata_int(%0, m_iWeaponState, %1, linux_diff_weapon))
#define MDLL_Touch(%0,%1)            dllfunc(DLLFunc_Touch, %0, %1)
#define MDLL_Spawn(%0)                dllfunc(DLLFunc_Spawn, %0)

#define WEAPON_ANIM_IDLE1 0
#define WEAPON_ANIM_IDLE2 1
#define WEAPON_ANIM_PATROL 2
#define WEAPON_ANIM_DRAW 3
#define WEAPON_ANIM_THROW 4
#define WEAPON_ANIM_RETURN 5

// From model: Frames/FPS
#define WEAPON_ANIM_IDLE1_TIME         46.0/15.0
#define WEAPON_ANIM_IDLE2_TIME         155.0/30.0
#define WEAPON_ANIM_SHOOT_TIME        26.0/30.0
#define WEAPON_ANIM_DRAW_TIME         31.0/30.0

#define WEAPON_SPECIAL_CODE     05022022001
#define WEAPON_REFERENCE     "weapon_hegrenade"
#define CSW_BASE        CSW_HEGRENADE
#define WEAPON_ITEM_NAME     "Patrol Drone"
#define WEAPON_ITEM_COST     0
#define WEAPON_ANIM_EXTENSION    "knife"

#define WEAPON_MODEL_VIEW1         "models/v_patroldrone2.mdl"
#define WEAPON_MODEL_VIEW         "models/v_patroldrone.mdl"
#define WEAPON_MODEL_PLAYER         "models/p_patroldrone.mdl"
#define WEAPON_MODEL_WORLD        "models/w_patroldrone.mdl"
#define LIGHT                "sprites/ef_droneattacklightning.spr"
#define EXPLOSION_DRONE            "sprites/ef_droneexplosion.spr"

// Linux extra offsets
#define linux_diff_weapon 4
#define linux_diff_player 5

// CWeaponBox
#define m_rgpPlayerItems_CWeaponBox 34

// CBaseAnimating
#define m_maxFrame 35
#define m_flLastEventCheck 38

// CBasePlayerItem
#define m_pPlayer 41
#define m_pNext 42
#define m_iId 43

// CBasePlayerWeapon
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
#define m_flTimeWeaponIdle 48
#define m_iPrimaryAmmoType 49
#define m_iClip 51
#define m_fInReload 54
#define m_IdleMode 72
#define m_iWeaponState 74
#define m_LastHitGroup 75

// CBaseMonster
#define m_flNextAttack 83

// CBasePlayer
#define m_iFOV 363
#define m_rpgPlayerItems 367
#define m_pActiveItem 373
#define m_rgAmmo 376
#define OFFSET_AMMO_HEGRENADE 388
#define m_szAnimExtention 492

#define BEAM_CLASSNAME2            "szBeamDrone1"
#define BEAM_SCROLLRATE            40.0
#define BEAM_NOISE            0
#define BEAM_WEIGHT            150.0   
#define BEAM_FRAMECHANGETIME        0.05

new const iWeaponList[] =             { 12,  1, -1, -1, 3, 1, 4, 24  };
new const WEAPONLIST[][] = { "weapon_patroldrone" };
new const WEAPON_SPRITES[][] =
{
    "sprites/muzzleflash105.spr",
    "sprites/patroldrone_bg.spr",
    "sprites/patroldrone_mark.spr",
    "sprites/patroldrone_ammo0.spr",    //3
    "sprites/patroldrone_ammo1.spr",
    "sprites/patroldrone_ammo2.spr",    //5
    "sprites/patroldrone_ammo3.spr",
    "sprites/patroldrone_ammo4.spr"        //7
}

new const Sounds[][]=
{
    "weapons/patroldrone_patrol.wav",//0
    "weapons/patroldrone_throw.wav",//1
    "weapons/patroldrone_throw_exp2.wav",//2
    "weapons/patroldrone_attack_loop.wav",//3
    "weapons/patroldrone_power_on.wav",//4
    "weapons/patroldrone_power_off.wav",//5
    "weapons/patroldrone_spin1.wav",//6
    "weapons/patroldrone_spin2.wav"//7
    
}
//settings balls
#define MOVEMENT_MAX_FORWARD        random_float(-50.0,80.0)    //pos forward balls
#define MOVEMENT_MAX_RIGHT_OR_LEFT    random_float(-80.0,80.0)    //pos right balls
#define MOVEMENT_MAX_UP            random_float(16.0,40.0)        //pos up balls
#define TIME_CHECK_POSITION        random_float(0.3,0.7)        //time check position
#define COEF_SPEED_POWER        1.5                //Drone momentum ratio (speed)
#define DISTANCE_DRONE             500.0                //drone range
#define WEAPON_DEFAULT_AMMO         4                //default ammo(dont change)
#define RADIUS_EXPLODE            150.0                //radius explode damage
#define DAMAGE_EXPLODE            random_float(500.0,1500.0)    //damage explode
#define TIME_DAMAGE            random_float(0.3,0.5)        //frequency of lightning damage to zombies over a given period of time
#define DAMAGE_LIGHT            random_float(20.0,40.0)        //damage from lightning
#define SPEED_COMEBACK            900.0                //drone return speed

new     g_iszAllocString_Entity,
    g_iItemID,
    g_iszAllocString_ModelView,
    g_iszAllocString_ModelView1,
    g_iszAllocString_ModelPlayer,
    gl_iMsgID_Weaponlist,
    gl_iszAllocString_Muzzleflash,
    gl_iszAllocString_BackGround,
    gl_iszAllocString_BackGround1,
    gl_iszAllocString_Balls,
    g_ball_1,
    g_ball_2,
    g_ball_3,
    g_ball_4,
    gl_iszModelIndex_BloodSpray,
    gl_iszModelIndex_BloodDrop,
    g_isBeam2,
    g_exp,
    g_mode[33],
    g_background,
    g_enemy[33];

public plugin_init()
{
    register_plugin("[ZP] Weapon: Drone", "1.51", "PeTRoX");
    register_event("HLTV", "EV_RoundStart", "a", "1=0", "2=0");
    register_forward(FM_UpdateClientData,        "FM_Hook_UpdateClientData_Post", true);
    register_forward(FM_SetModel,             "FM_Hook_SetModel_Pre", false);
    register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
    RegisterHam(Ham_Spawn,                "player",            "CPlayer__Spawn_Post", true);
    RegisterHam(Ham_Item_Holster,            WEAPON_REFERENCE,    "CWeapon__Holster_Post", true);
    RegisterHam(Ham_Item_Deploy,            WEAPON_REFERENCE,    "CWeapon__Deploy_Post", true);
    RegisterHam(Ham_Weapon_Reload,            WEAPON_REFERENCE,    "CWeapon__Reload_Pre", false);
    RegisterHam(Ham_Weapon_WeaponIdle,        WEAPON_REFERENCE,    "CWeapon__PrimaryAttack_Pre", false);
    RegisterHam(Ham_Weapon_PrimaryAttack,        WEAPON_REFERENCE,    "CWeapon__PrimaryAttack_Pre", false);
    RegisterHam(Ham_Item_PostFrame,            WEAPON_REFERENCE,     "CWeapon__Item_PostFrame", false);
    RegisterHam(Ham_Item_AddToPlayer,        WEAPON_REFERENCE,    "CWeapon__AddToPlayer_Post", true);
    RegisterHam(Ham_Think,                 "env_sprite",         "CEntity__Think_Pre", false);
    RegisterHam(Ham_Think,                 "info_target",         "CEntity__Think_Pre_In", false);   
    RegisterHam(Ham_Think,                 "beam",         "CWeapon__Think_Beam", false);
    
    g_iItemID = zp_register_extra_item(WEAPON_ITEM_NAME, WEAPON_ITEM_COST, ZP_TEAM_HUMAN);
    gl_iMsgID_Weaponlist = get_user_msgid("WeaponList");
    
    gl_iszAllocString_Muzzleflash = engfunc(EngFunc_AllocString, "ent_muzzlepatrol1");
    gl_iszAllocString_BackGround = engfunc(EngFunc_AllocString, "ent_backgrpatrol1");
    gl_iszAllocString_BackGround1 = engfunc(EngFunc_AllocString, "ent_backgrpatrol2");
    gl_iszAllocString_Balls = engfunc(EngFunc_AllocString, "ent_ballspatrol1");
    g_ball_1 = engfunc(EngFunc_AllocString, "ent_ballsentpatrol1");
    g_ball_2 = engfunc(EngFunc_AllocString, "ent_ballsentpatrol2");
    g_ball_3 = engfunc(EngFunc_AllocString, "ent_ballsentpatrol3");
    g_ball_4 = engfunc(EngFunc_AllocString, "ent_ballsentpatrol4");
    g_isBeam2 = engfunc(EngFunc_AllocString, "ent_beampatrol1");     
    
}

public plugin_precache()
{
    engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_VIEW);
    engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_VIEW1);
    engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_PLAYER);
    engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_WORLD);
    
    new i;
    
    for(i = 0; i < sizeof WEAPON_SPRITES; i++)
        engfunc(EngFunc_PrecacheModel, WEAPON_SPRITES[i]);
        
    for(i = 0; i < sizeof Sounds; i++)
    {
        precache_sound(Sounds[i]);
    }
    UTIL_PrecacheSpritesFromTxt(WEAPONLIST[0]);
    UTIL_PrecacheSoundsFromModel(WEAPON_MODEL_VIEW1);
    UTIL_PrecacheSoundsFromModel(WEAPON_MODEL_WORLD);
    g_iszAllocString_Entity = engfunc(EngFunc_AllocString, WEAPON_REFERENCE);
    g_iszAllocString_ModelView = engfunc(EngFunc_AllocString, WEAPON_MODEL_VIEW);
    g_iszAllocString_ModelView1 = engfunc(EngFunc_AllocString, WEAPON_MODEL_VIEW1);
    g_iszAllocString_ModelPlayer = engfunc(EngFunc_AllocString, WEAPON_MODEL_PLAYER);
    gl_iszModelIndex_BloodSpray = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr");
    gl_iszModelIndex_BloodDrop = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr");   
    register_clcmd(WEAPONLIST[0], "Command_HookWeapon");
    engfunc(EngFunc_PrecacheModel, LIGHT);
    
    g_exp = engfunc(EngFunc_PrecacheModel, EXPLOSION_DRONE);
}
public fw_AddToFullPack_Post(es, e, user, host, host_flags, player, p_set)
{
    if(player) return FMRES_IGNORED
    if(!is_user_alive(host)) return FMRES_IGNORED
    new classname[33];
    pev(user, pev_classname, classname, 32);
    if(equal(classname, "ent_backgrpatrol1")||equal(classname, "ent_backgrpatrol2")||equal(classname, "ent_ballspatrol1"))
    {
        new id = pev(user, pev_owner)
        
        if(id==host&&get_es(es, ES_Effects)!=0)
        {
            set_es(es, ES_Effects, 0)
        }
        if(id!=host&&get_es(es, ES_Effects)==0)
        {
            set_es(es, ES_Effects, EF_NODRAW)
        }
    }
    return FMRES_HANDLED
    
}
public EV_RoundStart()
{
    static iEntity; iEntity = FM_NULLENT;
    while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", "ent_ballsentpatrol1")))
    {
        if(pev_valid(iEntity)==2)
        {
            static iPlayer; iPlayer = pev(iEntity, pev_owner);
            if(user_has_weapon(iPlayer, CSW_BASE))
            {   
                ham_strip_weapon_name(iPlayer, WEAPON_REFERENCE)
            }
            set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);
        }
    }
        
    static iEntity1; iEntity1 = FM_NULLENT;
    while((iEntity1 = engfunc(EngFunc_FindEntityByString, iEntity1, "classname", "ent_ballsentpatrol2")))
    {
        if(pev_valid(iEntity1)==2)
        {
            static iPlayer; iPlayer = pev(iEntity1, pev_owner);
            if(user_has_weapon(iPlayer, CSW_BASE))
            {   
                ham_strip_weapon_name(iPlayer, WEAPON_REFERENCE)
            }
            set_pev(iEntity1, pev_flags, pev(iEntity1, pev_flags)|FL_KILLME);
        }
    }   
    static iEntity2; iEntity2 = FM_NULLENT;
    while((iEntity2 = engfunc(EngFunc_FindEntityByString, iEntity2, "classname", "ent_ballsentpatrol3")))
    {
        if(pev_valid(iEntity2)==2)
        {
            static iPlayer; iPlayer = pev(iEntity2, pev_owner);
            if(user_has_weapon(iPlayer, CSW_BASE))
            {   
                ham_strip_weapon_name(iPlayer, WEAPON_REFERENCE)
            }
            set_pev(iEntity2, pev_flags, pev(iEntity2, pev_flags)|FL_KILLME);
        }
    }           
    static iEntity3; iEntity3 = FM_NULLENT;
    while((iEntity3 = engfunc(EngFunc_FindEntityByString, iEntity3, "classname", "ent_ballsentpatrol4")))
    {
        if(pev_valid(iEntity3)==2)
        {
            static iPlayer; iPlayer = pev(iEntity3, pev_owner);
            if(user_has_weapon(iPlayer, CSW_BASE))
            {   
                ham_strip_weapon_name(iPlayer, WEAPON_REFERENCE)
            }
            set_pev(iEntity3, pev_flags, pev(iEntity3, pev_flags)|FL_KILLME);
        }
    }       
}
public CWeapon__Item_PostFrame(iItem)
{
    if(!CustomItem(iItem)) return HAM_IGNORED;
    fw_Weapon_SecondaryAttack(iItem);

    return HAM_IGNORED;
}
public fw_Weapon_SecondaryAttack(iItem)
{

    static iPlayer,iButton,iShoots;
    iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
    iButton = pev(iPlayer,pev_button);
    iShoots = get_pdata_int(iPlayer,388,linux_diff_player)
    if(!iShoots)
    {
        iButton &= ~IN_ATTACK2
        
    }       
    
    if(iButton & IN_ATTACK2)
    {
        if(get_pdata_float(iItem, m_flNextPrimaryAttack, linux_diff_weapon) > 0.0 || get_pdata_float(iItem, m_flNextSecondaryAttack, linux_diff_weapon) > 0.0) return

        new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol1", iPlayer)
        if(pev_valid(spr1)==2)
        {
            exp(spr1, iPlayer, iShoots, iItem)
        }
        else if(!spr1)
        {
            new spr2 = fm_find_ent_by_owner(spr2, "ent_ballsentpatrol2", iPlayer)
            if(pev_valid(spr2)==2)
            {
                exp(spr2, iPlayer, iShoots, iItem)
            }
            else if(!spr2)
            {
                new spr3 = fm_find_ent_by_owner(spr3, "ent_ballsentpatrol3", iPlayer)
                if(pev_valid(spr3)==2)
                {
                    exp(spr3, iPlayer, iShoots, iItem)
                }
                else if(!spr3)
                {
                    new spr4 = fm_find_ent_by_owner(spr4, "ent_ballsentpatrol4", iPlayer)
                    if(pev_valid(spr4)==2)
                    {
                        exp(spr4, iPlayer, iShoots, iItem)
                    }
                }
            }
        }

        iButton &= ~IN_ATTACK2;
        set_pev(iPlayer, pev_button, iButton);
    }
    return
}
public exp(iEntity, iPlayer, iShoots, iItem)
{
    if(!pev(iEntity, pev_iuser4)) return
    set_pdata_int(iPlayer,388,iShoots-1,linux_diff_player)
    static Float: Orig[3];
    pev(iEntity, pev_origin, Orig);
    set_pdata_float(iItem, m_flNextPrimaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
    set_pdata_float(iItem, m_flNextSecondaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
    set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_SHOOT_TIME+0.5, linux_diff_weapon);
    set_pdata_float(iPlayer, m_flNextAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_player);
    engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, iEntity, 0);
    write_byte(TE_EXPLOSION);
    engfunc(EngFunc_WriteCoord, Orig[0]);
    engfunc(EngFunc_WriteCoord, Orig[1]);
    engfunc(EngFunc_WriteCoord, Orig[2]-3.0);
    write_short(g_exp);
    write_byte(10);
    write_byte(20);
    write_byte(TE_EXPLFLAG_NODLIGHTS|TE_EXPLFLAG_NOSOUND|TE_EXPLFLAG_NOPARTICLES);
    message_end();   
    UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_THROW )
    static iVictim; iVictim = FM_NULLENT;
    while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, Orig, RADIUS_EXPLODE)))
    {
        if(is_user_alive(iVictim) && zp_get_user_zombie(iVictim))
        {
            static Float: flDamage1;
                        
            flDamage1 = DAMAGE_EXPLODE;
            static Float:OrigVic[3];pev(iVictim,pev_origin, OrigVic);
            set_pdata_int(iVictim, m_LastHitGroup, HIT_GENERIC, linux_diff_player);
                                
            ExecuteHamB(Ham_TakeDamage, iVictim, iPlayer, iPlayer, flDamage1, DMG_BULLET);
            UTIL_BloodDrips(OrigVic, iVictim, floatround(flDamage1));
        }
    }
    new spr_hud = fm_find_ent_by_owner(spr_hud, "ent_ballspatrol1", iPlayer);
    if(pev_valid(spr_hud)==2)
    {
        set_pev(spr_hud, pev_flags, pev(spr_hud, pev_flags)|FL_KILLME);
    }
    emit_sound(iEntity, CHAN_WEAPON, Sounds[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    balls_muzzle(iPlayer, WEAPON_SPRITES[3+(iShoots-1)], 0.0, 255.0, 4)
    set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);
    
    if(g_mode[iPlayer])
    {
        new szAnimation[64]
        formatex(szAnimation, charsmax(szAnimation), pev(iPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION)
        Send_PlayerAnimation(iPlayer, szAnimation)
    }
}
public CWeapon__Think_Beam(iSprite)
{
    if (pev_valid(iSprite)!=2)
    {
        return HAM_IGNORED;
    }
    if(pev(iSprite, pev_classname) != g_isBeam2) return HAM_IGNORED;
    static Float:amt; pev(iSprite, pev_renderamt, amt)
    amt -= 255.0
    set_pev(iSprite, pev_renderamt, amt)
    
    if(amt <= 0.0)
    {
        set_pev(iSprite, pev_flags, pev(iSprite,pev_flags) | FL_KILLME)
        return HAM_IGNORED;
    }
    set_pev(iSprite, pev_nextthink, get_gametime() + BEAM_FRAMECHANGETIME);
    return HAM_IGNORED;
}
// [ Amxx ]
#if AMXX_VERSION_NUM < 183
    public client_disconnect(iPlayer)
#else
    public client_disconnected(iPlayer)
#endif
{
    UTIL_SetRendering(iPlayer);
    set_pev(iPlayer, pev_iuser2, 0);
    /*new spr1 = fm_find_ent_by_owner(-1, "", iPlayer)
    while(spr1>0)
    {
        set_pev(spr1, pev_flags, pev(spr1, pev_flags)|FL_KILLME);
    }*/
}
public zp_user_infected_pre(iPlayer)
{
    new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol1", iPlayer);
    if(pev_valid(spr1)==2)
    {
        set_pev(spr1, pev_flags, pev(spr1, pev_flags)|FL_KILLME);
    }   
    new spr2 = fm_find_ent_by_owner(spr2, "ent_ballsentpatrol2", iPlayer);
    if(pev_valid(spr2)==2)
    {
        set_pev(spr2, pev_flags, pev(spr2, pev_flags)|FL_KILLME);
    }   
    new spr3 = fm_find_ent_by_owner(spr3, "ent_ballsentpatrol3", iPlayer);
    if(pev_valid(spr3)==2)
    {
        set_pev(spr3, pev_flags, pev(spr3, pev_flags)|FL_KILLME);
    }   
    new spr4 = fm_find_ent_by_owner(spr4, "ent_ballsentpatrol4", iPlayer);
    if(pev_valid(spr4)==2)
    {
        set_pev(spr4, pev_flags, pev(spr4, pev_flags)|FL_KILLME);
    }   
}
public Command_HookWeapon(iPlayer)
{
    engclient_cmd(iPlayer, WEAPON_REFERENCE);
    return PLUGIN_HANDLED;
}
public zp_extra_item_selected(iPlayer, iItem)
{
    if(iItem == g_iItemID)
        Command_GiveWeapon(iPlayer);

}

public Command_GiveWeapon(iPlayer)
{
    static iEntity; iEntity = engfunc(EngFunc_CreateNamedEntity, g_iszAllocString_Entity);
    if(iEntity <= 0) return 0;
    if(user_has_weapon(iPlayer, CSW_BASE)||CustomItem(iEntity))
    {   
        ham_strip_weapon_name(iPlayer, WEAPON_REFERENCE)
    }
    set_pev(iEntity, pev_impulse, WEAPON_SPECIAL_CODE);
    ExecuteHam(Ham_Spawn, iEntity);
    
    if(!ExecuteHamB(Ham_AddPlayerItem, iPlayer, iEntity))
    {
        set_pev(iEntity, pev_flags, pev(iEntity, pev_flags) | FL_KILLME);
        return 0;
    }
    new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol1", iPlayer);
    if(pev_valid(spr1)==2)
    {
        set_pev(spr1, pev_flags, pev(spr1, pev_flags)|FL_KILLME);
    }   
    new spr2 = fm_find_ent_by_owner(spr2, "ent_ballsentpatrol2", iPlayer);
    if(pev_valid(spr2)==2)
    {
        set_pev(spr2, pev_flags, pev(spr2, pev_flags)|FL_KILLME);
    }   
    new spr3 = fm_find_ent_by_owner(spr3, "ent_ballsentpatrol3", iPlayer);
    if(pev_valid(spr3)==2)
    {
        set_pev(spr3, pev_flags, pev(spr3, pev_flags)|FL_KILLME);
    }   
    new spr4 = fm_find_ent_by_owner(spr4, "ent_ballsentpatrol4", iPlayer);
    if(pev_valid(spr4)==2)
    {
        set_pev(spr4, pev_flags, pev(spr4, pev_flags)|FL_KILLME);
    }
    UTIL_SendWeaponAnim(iPlayer,WEAPON_ANIM_DRAW);
    set_pdata_float(iPlayer, m_flNextAttack, WEAPON_ANIM_DRAW_TIME, linux_diff_player);
    ExecuteHamB(Ham_Item_AttachToPlayer, iEntity, iPlayer);
    emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    g_mode[iPlayer]=0
    new iAmmoType = m_rgAmmo + get_pdata_int(iEntity, m_iPrimaryAmmoType, linux_diff_weapon);
    if(get_pdata_int(iPlayer, m_rgAmmo, linux_diff_player) < WEAPON_DEFAULT_AMMO)
        set_pdata_int(iPlayer, iAmmoType, WEAPON_DEFAULT_AMMO, linux_diff_player);

    return FM_NULLENT;
}
stock ham_strip_weapon_name(pPlayer, const szWeaponName[])
{
    static iEntity;
    while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", szWeaponName)) && pev(iEntity, pev_owner) != pPlayer) {}
    if(!iEntity) return 0;
    static iWeaponId;iWeaponId = get_weaponid(szWeaponName);
    if(get_user_weapon(pPlayer) == iWeaponId) ExecuteHamB(Ham_Weapon_RetireWeapon, iEntity);
    if(!ExecuteHamB(Ham_RemovePlayerItem, pPlayer, iEntity)) return 0;
    ExecuteHamB(Ham_Item_Kill, iEntity);
    set_pev(pPlayer, pev_weapons, pev(pPlayer, pev_weapons) & ~(1<<iWeaponId));
    return 1;
}
// [ Fakemeta ]
public FM_Hook_UpdateClientData_Post(iPlayer, SendWeapons, CD_Handle)
{
    if(!is_user_alive(iPlayer)) return;

    static iItem; iItem = get_pdata_cbase(iPlayer, m_pActiveItem, linux_diff_player);
    if(pev_valid(iItem) != 2 || !CustomItem(iItem)) return;

    set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001);
}

public FM_Hook_SetModel_Pre(iEntity)
{
    static i, szClassName[32], iItem;
    pev(iEntity, pev_classname, szClassName, charsmax(szClassName));

    if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED;

    for(i = 0; i < 6; i++)
    {
        iItem = get_pdata_cbase(iEntity, m_rgpPlayerItems_CWeaponBox + i, linux_diff_weapon);

        if(iItem > 0 && CustomItem(iItem))
        {
            engfunc(EngFunc_SetModel, iEntity, WEAPON_MODEL_WORLD);
            set_pev(iEntity, pev_body, 1);
            
            set_pev(iItem, pev_iuser2, GetAmmoInventory(pev(iEntity,pev_owner), PrimaryAmmoIndex(iItem)))
            return FMRES_SUPERCEDE;
        }
    }

    return FMRES_IGNORED;
}
// [ HamSandwich ]
public CPlayer__Spawn_Post(iPlayer)
{
    if(!is_user_connected(iPlayer)) return;

    UTIL_SetRendering(iPlayer);
    set_pev(iPlayer, pev_iuser2, 0);
}

public CWeapon__AddToPlayer_Post(iItem, iPlayer)
{
    if(CustomItem(iItem)){
        SetAmmoInventory(iPlayer, PrimaryAmmoIndex(iItem), pev(iItem, pev_iuser2));
        UTIL_WeaponList(iPlayer, true);
    }
    else if(pev(iItem, pev_impulse) == 0) UTIL_WeaponList(iPlayer, false);
}

public CWeapon__Holster_Post(iItem)
{
    if(!CustomItem(iItem)) return HAM_IGNORED;
    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
    
    set_pdata_float(iItem, m_flNextPrimaryAttack, 0.0, linux_diff_weapon);
    set_pdata_float(iItem, m_flNextSecondaryAttack, 0.0, linux_diff_weapon);
    set_pdata_float(iItem, m_flTimeWeaponIdle, 0.0, linux_diff_weapon);
    set_pdata_float(iPlayer, m_flNextAttack, 0.0, linux_diff_player);
    set_pev(iItem, pev_iuser1, 0) ;
    message_begin(MSG_ONE, get_user_msgid("HideWeapon"), _, iPlayer);
           write_byte(0);
    message_end();
    new spr1 = fm_find_ent_by_owner(spr1, "ent_backgrpatrol1", iPlayer)
    if(pev_valid(spr1)==2)
    {
        set_pev(spr1, pev_flags, pev(spr1, pev_flags)|FL_KILLME);
    }
    new spr2 = fm_find_ent_by_owner(spr2, "ent_backgrpatrol2", iPlayer)
    if(pev_valid(spr2)==2)
    {
        set_pev(spr2, pev_flags, pev(spr2, pev_flags)|FL_KILLME);
    }
    new spr3 = fm_find_ent_by_owner(spr3, "ent_ballspatrol1", iPlayer)
    if(pev_valid(spr3)==2)
    {
        set_pev(spr3, pev_flags, pev(spr3, pev_flags)|FL_KILLME);
    }   
    return HAM_IGNORED;
}

public CWeapon__Deploy_Post(iItem)
{
    if(!CustomItem(iItem)) return HAM_IGNORED;
    
    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);

    set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView1);

    
    set_pev_string(iPlayer, pev_weaponmodel2,g_iszAllocString_ModelPlayer);
    set_pdata_string(iPlayer, m_szAnimExtention * 4, WEAPON_ANIM_EXTENSION, -1, linux_diff_player * 4)
    UTIL_SendWeaponAnim(iPlayer,WEAPON_ANIM_DRAW);
    set_pdata_float(iPlayer, m_flNextAttack, WEAPON_ANIM_DRAW_TIME, linux_diff_player);
    set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_DRAW_TIME, linux_diff_weapon);
    UTIL_CreateMuzzleFlash_bg(iPlayer, WEAPON_SPRITES[1], 0.0, 255.0, 4)
    set_pdata_int(iItem, m_IdleMode, 0, 4);
    UTIL_CreateMuzzleFlash_bg1(iPlayer, WEAPON_SPRITES[2], 0.0, 255.0, 4)
    message_begin(MSG_ONE, get_user_msgid("HideWeapon"), _, iPlayer);
           write_byte(1 << 6);
    message_end();
    new bpammo = get_pdata_int(iPlayer,388,5)
    balls_muzzle(iPlayer, WEAPON_SPRITES[3+bpammo], 0.0, 255.0, 4)
    return HAM_IGNORED;
}

public CWeapon__Reload_Pre(iItem)
{
    if(CustomItem(iItem)) return HAM_SUPERCEDE;
    return HAM_IGNORED;
}
public CWeapon__WeaponIdle_Post(iItem)
{
    if(!CustomItem(iItem)) return HAM_IGNORED;
    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);

    if(get_pdata_float(iItem, m_flTimeWeaponIdle, linux_diff_weapon) < 0.0)
    {
        static IdleMode; IdleMode = get_pdata_int(iItem, m_IdleMode, linux_diff_weapon)
        switch(IdleMode)
        {
            case 0:
            {
                set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_IDLE1_TIME, linux_diff_weapon);
                UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_IDLE2 )
                set_pdata_int(iItem, m_IdleMode, 1, linux_diff_weapon)
                
            }
            case 1:
            {
                set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_IDLE1_TIME, linux_diff_weapon);
                UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_IDLE2 )
                set_pdata_int(iItem, m_IdleMode, 2, linux_diff_weapon)
                
            }
            case 2:
            {
                set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_IDLE1_TIME, linux_diff_weapon);
                UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_IDLE2 )
                set_pdata_int(iItem, m_IdleMode, 3, linux_diff_weapon)
                
            }           
            case 3:
            {
                set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_IDLE2_TIME, linux_diff_weapon);
                UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_IDLE2 )
                set_pdata_int(iItem, m_IdleMode, 0, linux_diff_weapon)
            }
        }
    }
    return HAM_IGNORED;
}

public CWeapon__PrimaryAttack_Pre(iItem)
{
    if(!CustomItem(iItem)) return HAM_IGNORED;
    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
    new bpammo = get_pdata_int(iPlayer,388,5)
    if(get_pdata_float(iItem, m_flNextPrimaryAttack, linux_diff_weapon) > 0.0) return HAM_IGNORED
    if(!bpammo)
    {
        ExecuteHam(Ham_Weapon_PlayEmptySound, iItem);
        set_pdata_float(iItem, m_flNextPrimaryAttack, 0.2, linux_diff_weapon);
        return HAM_SUPERCEDE;
    }   
    switch(g_mode[iPlayer])
    {
        case 0:
        {
            UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_PATROL)
            
            new b = bpammo
            if(b==1)
            {
                
                start_seach1(iPlayer);
            }
            if(b==2)
            {
                start_seach2(iPlayer);
                start_seach1(iPlayer);
            }   
            if(b==3)
            {
                start_seach3(iPlayer);
                start_seach2(iPlayer);
                start_seach1(iPlayer);
            }   
            if(b==4)
            {
                start_seach4(iPlayer);
                start_seach3(iPlayer);
                start_seach2(iPlayer);
                start_seach1(iPlayer);
            }   
            new szAnimation[64]
            formatex(szAnimation, charsmax(szAnimation), pev(iPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION)
            Send_PlayerAnimation(iPlayer, szAnimation)
            set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView);
            set_task(10.0/30.0, "vmodel_2", iItem, _,_,"a",1)
            UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 1)
            UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 2)
            set_pdata_float(iItem, m_flNextPrimaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
            set_pdata_float(iItem, m_flNextSecondaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
            set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_SHOOT_TIME+0.5, linux_diff_weapon);
            set_pdata_float(iPlayer, m_flNextAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_player);
            g_mode[iPlayer]=1
            
            
            
        }
        case 1:
        {
            //set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView);
            set_pdata_float(iItem, m_flNextPrimaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
            set_pdata_float(iItem, m_flNextSecondaryAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_weapon);
            set_pdata_float(iItem, m_flTimeWeaponIdle, WEAPON_ANIM_SHOOT_TIME+0.5, linux_diff_weapon);
            set_pdata_float(iPlayer, m_flNextAttack, WEAPON_ANIM_SHOOT_TIME, linux_diff_player);
            UTIL_SendWeaponAnim(iPlayer, WEAPON_ANIM_RETURN)
            emit_sound(iPlayer, CHAN_WEAPON, Sounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 1)
            UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 2)
            UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 3)
            set_task(12.0/30.0, "vmodel_1", iItem, _,_,"a",1)
            
            g_mode[iPlayer]=0
            new szAnimation[64]
            formatex(szAnimation, charsmax(szAnimation), pev(iPlayer, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", WEAPON_ANIM_EXTENSION)
            Send_PlayerAnimation(iPlayer, szAnimation)           
        }
    }
    return HAM_SUPERCEDE;
}
public vmodel_1(iItem)
{

    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
    if(!is_user_connected(iPlayer)||!pev_valid(iPlayer))
    {
        remove_task(iItem)
        return;
    }   
    if(get_user_weapon(iPlayer)!= CSW_BASE||pev_valid(iItem)!=2||!CustomItem(iItem))
    {
        remove_task(iItem)
        return;
    }
    
    if(task_exists(iItem))
    {
        remove_task(iItem)
    }
    if(pev_valid(iPlayer)!=2)
    {
        remove_task(iItem)
        return
    }
    
    if(is_user_connected(iPlayer)&&is_user_alive(iPlayer)&&!zp_get_user_zombie(iPlayer))
    {
        
        set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView1);
        //client_print(iPlayer, print_chat, "mode off");
    }
    else
    {
        remove_task(iItem);
    }
}
public vmodel_2(iItem)
{
    static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, linux_diff_weapon);
    if(!is_user_connected(iPlayer)||!pev_valid(iPlayer))
    {
        remove_task(iItem)
        return;
    }
    if(get_user_weapon(iPlayer)!= CSW_BASE||pev_valid(iItem)!=2||!CustomItem(iItem))
    {
        remove_task(iItem)
        return;
    }
    
    if(task_exists(iItem))
    {
        remove_task(iItem)
    }
    if(pev_valid(iPlayer)!=2)
    {
        remove_task(iItem)
        return
    }
    
    if(is_user_connected(iPlayer)&&is_user_alive(iPlayer)&&!zp_get_user_zombie(iPlayer))
    {
        UTIL_CreateMuzzleFlash(iPlayer, WEAPON_SPRITES[0], 0.05, 255.0, 3)
        //client_print(iPlayer, print_chat, "mode on");
        set_pev_string(iPlayer, pev_viewmodel2, g_iszAllocString_ModelView1);
    }
    else
    {
        remove_task(iItem);
    }   
}
public start_seach4(iPlayer)
{
    new spr4 = fm_find_ent_by_owner(spr4, "ent_ballsentpatrol4", iPlayer);
    if(pev_valid(spr4)==2)
    {
        set_pev(spr4, pev_flags, pev(spr4, pev_flags)|FL_KILLME);
    }
    static iEntity, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "info_target")))
    {
        iEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }   
    
    if(!pev_valid(iEntity)) return FM_NULLENT;

    new Float: vecOrigin[3]; pev(iPlayer, pev_origin, vecOrigin);
    engfunc(EngFunc_SetModel, iEntity, WEAPON_MODEL_WORLD);
    set_pev_string(iEntity, pev_classname, g_ball_4);
    Stock_Get_Postion(iPlayer,random_float(-10.0,10.0),random_float(-10.0,10.0),random_float(0.0,10.0),vecOrigin)
    set_pev(iEntity, pev_movetype, MOVETYPE_NOCLIP);
    set_pev(iEntity, pev_owner, iPlayer);
    set_anim(iEntity, 0)
    engfunc(EngFunc_SetOrigin, iEntity, vecOrigin);
    set_pev(iEntity, pev_fuser3, get_gametime())
    set_pev(iEntity, pev_nextthink, get_gametime());

    return iEntity;
}
public start_seach3(iPlayer)
{
    new spr3 = fm_find_ent_by_owner(spr3, "ent_ballsentpatrol3", iPlayer);
    if(pev_valid(spr3)==2)
    {
        set_pev(spr3, pev_flags, pev(spr3, pev_flags)|FL_KILLME);
    }
    static iEntity, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "info_target")))
    {
        iEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }   
    
    if(!pev_valid(iEntity)) return FM_NULLENT;

    new Float: vecOrigin[3]; pev(iPlayer, pev_origin, vecOrigin);
    engfunc(EngFunc_SetModel, iEntity, WEAPON_MODEL_WORLD);
    set_pev_string(iEntity, pev_classname, g_ball_3);
    Stock_Get_Postion(iPlayer,random_float(-10.0,10.0),random_float(-10.0,10.0),random_float(0.0,10.0),vecOrigin)
    set_pev(iEntity, pev_movetype, MOVETYPE_NOCLIP);
    set_pev(iEntity, pev_owner, iPlayer);
    set_anim(iEntity, 0)
    engfunc(EngFunc_SetOrigin, iEntity, vecOrigin);
    set_pev(iEntity, pev_fuser3, get_gametime())
    set_pev(iEntity, pev_nextthink, get_gametime());
    return iEntity;
}
public start_seach2(iPlayer)
{
    new spr2 = fm_find_ent_by_owner(spr2, "ent_ballsentpatrol2", iPlayer);
    if(pev_valid(spr2)==2)
    {
        set_pev(spr2, pev_flags, pev(spr2, pev_flags)|FL_KILLME);
    }
    static iEntity, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "info_target")))
    {
        iEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }   
    
    if(!pev_valid(iEntity)) return FM_NULLENT;

    new Float: vecOrigin[3]; pev(iPlayer, pev_origin, vecOrigin);
    engfunc(EngFunc_SetModel, iEntity, WEAPON_MODEL_WORLD);
    set_pev_string(iEntity, pev_classname, g_ball_2);
    Stock_Get_Postion(iPlayer,random_float(-10.0,10.0),random_float(-10.0,10.0),random_float(0.0,10.0),vecOrigin)
    set_pev(iEntity, pev_movetype, MOVETYPE_NOCLIP);
    set_pev(iEntity, pev_owner, iPlayer);
    set_anim(iEntity, 0)
    engfunc(EngFunc_SetOrigin, iEntity, vecOrigin);
    set_pev(iEntity, pev_fuser3, get_gametime())
    set_pev(iEntity, pev_nextthink, get_gametime());
    return iEntity;
}
public start_seach1(iPlayer)
{
    new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol1", iPlayer);
    if(pev_valid(spr1)==2)
    {
        set_pev(spr1, pev_flags, pev(spr1, pev_flags)|FL_KILLME);
    }   
    static iEntity, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "info_target")))
    {
        iEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }   
    
    if(!pev_valid(iEntity)) return FM_NULLENT;

    new Float: vecOrigin[3]; pev(iPlayer, pev_origin, vecOrigin);
    engfunc(EngFunc_SetModel, iEntity, WEAPON_MODEL_WORLD);
    set_pev_string(iEntity, pev_classname, g_ball_1);
    Stock_Get_Postion(iPlayer,random_float(-10.0,10.0),random_float(-10.0,10.0),random_float(0.0,10.0),vecOrigin)
    set_pev(iEntity, pev_movetype, MOVETYPE_NOCLIP);
    set_pev(iEntity, pev_owner, iPlayer);
    engfunc(EngFunc_SetOrigin, iEntity, vecOrigin);
    set_pev(iEntity, pev_fuser3, get_gametime())
    set_pev(iEntity, pev_nextthink, get_gametime());
    emit_sound(iEntity, CHAN_STATIC, Sounds[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    return iEntity;
}

public CEntity__Think_Pre_In(iEntity)
{
    if (pev_valid(iEntity) != 2)
    {
        return HAM_IGNORED;
    }   
    if(pev(iEntity, pev_classname) == g_ball_1)
    {   
        
        static iPlayer; iPlayer = pev(iEntity, pev_owner);
        if(is_user_connected(iPlayer)&&zp_get_user_zombie(iPlayer))
        {
            set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
        }
        if(g_mode[iPlayer]==0)
        {
            static Float: EntOrig[3];
            pev(iEntity, pev_origin, EntOrig)
            static Float: PlayerOrig[3]; pev(iPlayer, pev_origin, PlayerOrig);
            new Float: distance = get_distance_f(EntOrig, PlayerOrig);
            static Float: velocity[3];   
            if(distance>30.0)
            {                   
                get_speed_vector(EntOrig, PlayerOrig, SPEED_COMEBACK, velocity);
                set_pev(iEntity, pev_velocity, velocity);
                                
            }
            else
            {
                emit_sound(iEntity, CHAN_STATIC, Sounds[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
                set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
            }
        }

        else if(g_mode[iPlayer]==1)
        {
            static Float:vecEnt[3];pev(iEntity,pev_origin,vecEnt);
            static Float:velocity[3];
            
            static Float:fTimeNewEn
            static Float:vecOrigin[3];pev(iPlayer, pev_origin, vecOrigin);       
            static Float:vecEnd[3];
            static iVictim; iVictim = FM_NULLENT;
            new i=0;
            
            while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
            {
                if(is_user_connected(iVictim) && is_user_alive(iVictim))
                {
                    if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                            
                    pev(iVictim, pev_origin, vecEnd);
                                
                    new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                    if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                    {
                        
                        i++
    
                    }
                }
                if(i<1)
                {
                    for(new u=0;u<=get_maxplayers();u++)
                    {
                        if(!is_user_alive(u)||!is_user_connected(u)||zp_get_user_zombie(u)||u!=iPlayer) continue
                        
                        set_pev(iEntity, pev_iuser4, 0)
                        pev(iEntity, pev_fuser3, fTimeNewEn);//time to change pos
                        if(!fTimeNewEn)
                        {
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                        }
                        static Float:PlayOrig[3];
                        if(get_gametime() >= fTimeNewEn)
                        {
                            Stock_Get_Postion(iPlayer, MOVEMENT_MAX_FORWARD,MOVEMENT_MAX_RIGHT_OR_LEFT,MOVEMENT_MAX_UP,PlayOrig);
                            set_anim(iEntity, 0)
                            set_pev(iEntity, pev_fuser1, get_gametime()+random_float(21.0/30.0,60.0/30.0))
                            set_pev(iEntity, pev_frame, random_float(1.0,3.0));
    
                                                                
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                            new Float: distance = get_distance_f(vecEnt, PlayOrig)
                            if(distance>5.0)
                            {
                                get_speed_vector(vecEnt, PlayOrig, distance*COEF_SPEED_POWER, velocity);
                                set_pev(iEntity, pev_velocity, velocity);
                                                            
                            }
                            else
                            {
                                set_pev(iEntity, pev_velocity, 0.0);               
                            }
                        }
                                                        

                    }
                    g_enemy[iPlayer]=0
                }
            }

            if(i>=1)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                                
                            
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim))
                            {       
                                    
                                Stock_Get_Postion(iVictim, 20.0,20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                            
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {           
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
    

        }
        new fTime3 = pev(iEntity, pev_fuser1)   
        if(get_gametime() >= fTime3&&fTime3!=0.0&&g_enemy[iPlayer]==0)
        {   
            emit_sound(iEntity, CHAN_STATIC, Sounds[random_num(6,7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            set_pev(iEntity, pev_fuser1, 0.0);
        }   
                        
        set_pev(iEntity, pev_nextthink, get_gametime());
        
    }
    if(pev(iEntity, pev_classname) == g_ball_2)
    {   
        static iPlayer; iPlayer = pev(iEntity, pev_owner);
        if(is_user_connected(iPlayer)&&zp_get_user_zombie(iPlayer))
        {
            set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
        }
        if(g_mode[iPlayer]==0)
        {
            static Float: EntOrig[3];
            pev(iEntity, pev_origin, EntOrig)
            static Float: PlayerOrig[3]; pev(iPlayer, pev_origin, PlayerOrig);
            new Float: distance = get_distance_f(EntOrig, PlayerOrig);
            static Float: velocity[3];   
            if(distance>30.0)
            {                   
                get_speed_vector(EntOrig, PlayerOrig, SPEED_COMEBACK, velocity);
                set_pev(iEntity, pev_velocity, velocity);
                                
            }
            else
            {
                set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
            }
        }
        else if(g_mode[iPlayer]==1)
        {
        
            static Float:vecEnt[3];pev(iEntity,pev_origin,vecEnt);
            static Float:velocity[3];
            
            static Float:fTimeNewEn
            static Float:vecOrigin[3];pev(iPlayer, pev_origin, vecOrigin);       
            static Float:vecEnd[3];
            static iVictim; iVictim = FM_NULLENT;
            new i=0;
            
            while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
            {
                if(is_user_connected(iVictim) && is_user_alive(iVictim))
                {
                    if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                            
                    pev(iVictim, pev_origin, vecEnd);
                                
                    new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                    if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                    {
                        
                        i++
    
                    }
                }
                if(i<1)
                {
                    for(new u=0;u<=get_maxplayers();u++)
                    {
                        if(!is_user_alive(u)||!is_user_connected(u)||zp_get_user_zombie(u)||u!=iPlayer) continue
                        
                        set_pev(iEntity, pev_iuser4, 0)
                        pev(iEntity, pev_fuser3, fTimeNewEn);//time to change pos
                        if(!fTimeNewEn)
                        {
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                        }
                        static Float:PlayOrig[3];
                        if(get_gametime() >= fTimeNewEn)
                        {
                            Stock_Get_Postion(iPlayer, MOVEMENT_MAX_FORWARD,MOVEMENT_MAX_RIGHT_OR_LEFT,MOVEMENT_MAX_UP,PlayOrig);
                            set_anim(iEntity, 0);
                            set_pev(iEntity, pev_fuser1, get_gametime()+random_float(21.0/30.0,60.0/30.0))
                            set_pev(iEntity, pev_animtime, get_gametime());
                            set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                            set_pev(iEntity, pev_framerate, 1.0);
            
                            
                                                                
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                            new Float: distance = get_distance_f(vecEnt, PlayOrig)
                            if(distance>0.0)
                            {
                                get_speed_vector(vecEnt, PlayOrig, distance*COEF_SPEED_POWER, velocity);
                                set_pev(iEntity, pev_velocity, velocity);
                                                            
                            }
                            else
                            {
                                set_pev(iEntity, pev_velocity, 0.0);               
                            }
                        }
                                                        

                    }
                    g_enemy[iPlayer]=0
                }
            }

            if(i>=1)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                                
                            
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {       
                                    
                                Stock_Get_Postion(iVictim, 20.0,-20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_pev(iEntity, pev_sequence, 1);
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {
                                            
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i>=2)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            new sprxd = fm_find_ent_by_owner(sprxd, "ent_ballsentpatrol1", iPlayer)
                            if(pev_valid(sprxd))
                            {
                                new iVictim1 = pev(sprxd, pev_iuser4)
                                if(iVictim == iVictim1) continue
                            }   
                            set_pev(iEntity, pev_iuser4, iVictim)
                            
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            
                            if(is_user_alive(iVictim))
                            {       
                                Stock_Get_Postion(iVictim, 20.0,-20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {                   
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
        }
        new fTime3 = pev(iEntity, pev_fuser1)   
        if(get_gametime() >= fTime3&&fTime3!=0.0&&g_enemy[iPlayer]==0)
        {   
            emit_sound(iEntity, CHAN_STATIC, Sounds[random_num(6,7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            set_pev(iEntity, pev_fuser1, 0.0);
        }           
                        
        set_pev(iEntity, pev_nextthink, get_gametime());
        
    }
    if(pev(iEntity, pev_classname) == g_ball_3)
    {   
        static iPlayer; iPlayer = pev(iEntity, pev_owner);
        if(is_user_connected(iPlayer)&&zp_get_user_zombie(iPlayer))
        {
            set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
        }
        if(g_mode[iPlayer]==0)
        {
            static Float: EntOrig[3];
            pev(iEntity, pev_origin, EntOrig)
            static Float: PlayerOrig[3]; pev(iPlayer, pev_origin, PlayerOrig);
            new Float: distance = get_distance_f(EntOrig, PlayerOrig);
            static Float: velocity[3];   
            if(distance>30.0)
            {                   
                get_speed_vector(EntOrig, PlayerOrig, SPEED_COMEBACK, velocity);
                set_pev(iEntity, pev_velocity, velocity);
                                
            }
            else
            {
                set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
            }
        }
        else if(g_mode[iPlayer]==1)
        {
        
            static Float:vecEnt[3];pev(iEntity,pev_origin,vecEnt);
            static Float:velocity[3];
            
            static Float:fTimeNewEn
            static Float:vecOrigin[3];pev(iPlayer, pev_origin, vecOrigin);       
            static Float:vecEnd[3];
            static iVictim; iVictim = FM_NULLENT;
            new i=0;
            
            while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
            {
                if(is_user_connected(iVictim) && is_user_alive(iVictim))
                {
                    if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                            
                    pev(iVictim, pev_origin, vecEnd);
                                
                    new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                    if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                    {
                        
                        i++
    
                    }
                }
                if(i<1)
                {
                    for(new u=0;u<=get_maxplayers();u++)
                    {
                        if(!is_user_alive(u)||!is_user_connected(u)||zp_get_user_zombie(u)||u!=iPlayer) continue
                        
                        set_pev(iEntity, pev_iuser4, 0)
                        pev(iEntity, pev_fuser3, fTimeNewEn);//time to change pos
                        if(!fTimeNewEn)
                        {
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                        }
                        static Float:PlayOrig[3];
                        if(get_gametime() >= fTimeNewEn)
                        {
                            Stock_Get_Postion(iPlayer, MOVEMENT_MAX_FORWARD,MOVEMENT_MAX_RIGHT_OR_LEFT,MOVEMENT_MAX_UP,PlayOrig);
                            set_anim(iEntity, 0)
                            set_pev(iEntity, pev_fuser1, get_gametime()+random_float(21.0/30.0,60.0/30.0))
                            set_pev(iEntity, pev_animtime, get_gametime());
                            set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                            set_pev(iEntity, pev_framerate, 1.0);
            

                                                                
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                            new Float: distance = get_distance_f(vecEnt, PlayOrig)
                            if(distance>0.0)
                            {
                                get_speed_vector(vecEnt, PlayOrig, distance*COEF_SPEED_POWER, velocity);
                                set_pev(iEntity, pev_velocity, velocity);
                                                            
                            }
                            else
                            {
                                set_pev(iEntity, pev_velocity, 0.0);               
                            }
                        }
                                                        

                    }
                    g_enemy[iPlayer]=0
                }
            }
            if(i==1)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                                
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {       
                                    
                                Stock_Get_Postion(iVictim, -20.0,-20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {               
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i==2)//prig na 2
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            
                            new spr5 = fm_find_ent_by_owner(spr5, "ent_ballsentpatrol2", iPlayer)
                            if(pev_valid(spr5))
                            {
                                new iVictim5 = pev(spr5, pev_iuser4)
                                if(iVictim == iVictim5) continue
                            }
                            set_pev(iEntity, pev_iuser4, iVictim)
                            
                            
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            
                            if(is_user_alive(iVictim))
                            {       
                                static Float:newVic[3];pev(iVictim, pev_origin, newVic);       
                                    
                                Stock_Get_Postion(iVictim, -20.0,-20.0,10.0,newVic);
                                    
                                new Float: distance = get_distance_f(vecEnt, newVic)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, newVic, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {                   
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i>=3) //na 3
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            new spr = fm_find_ent_by_owner(spr, "ent_ballsentpatrol1", iPlayer)
                            if(pev_valid(spr))
                            {
                                new iVictim1 = pev(spr, pev_iuser4)
                                if(iVictim == iVictim1) continue
                            }
                            new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol2", iPlayer)
                            if(pev_valid(spr1))
                            {
                                new iVictim2 = pev(spr1, pev_iuser4)
                                if(iVictim == iVictim2) continue
                            }                       
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {       
                                    
                                Stock_Get_Postion(iVictim, -20.0,-20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {
                                            
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
        }
            
        new fTime3 = pev(iEntity, pev_fuser1)   
        if(get_gametime() >= fTime3&&fTime3!=0.0&&g_enemy[iPlayer]==0)
        {   
            emit_sound(iEntity, CHAN_STATIC, Sounds[random_num(6,7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            set_pev(iEntity, pev_fuser1, 0.0);
        }                       
        set_pev(iEntity, pev_nextthink, get_gametime());
        
    }
    if(pev(iEntity, pev_classname) == g_ball_4)
    {   
        static iPlayer; iPlayer = pev(iEntity, pev_owner);
        if(is_user_connected(iPlayer)&&zp_get_user_zombie(iPlayer))
        {
            set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
        }
        if(g_mode[iPlayer]==0)
        {
            static Float: EntOrig[3];
            pev(iEntity, pev_origin, EntOrig)
            static Float: PlayerOrig[3]; pev(iPlayer, pev_origin, PlayerOrig);
            new Float: distance = get_distance_f(EntOrig, PlayerOrig);
            static Float: velocity[3];   
            if(distance>30.0)
            {   
                get_speed_vector(EntOrig, PlayerOrig, SPEED_COMEBACK, velocity);
                set_pev(iEntity, pev_velocity, velocity);
                                
            }
            else
            {
                set_pev(iEntity, pev_flags, pev(iEntity, pev_flags)|FL_KILLME);   
            }
        }
        else if(g_mode[iPlayer]==1)
        {
            static Float:vecEnt[3];pev(iEntity,pev_origin,vecEnt);
            static Float:velocity[3];
            
            static Float:fTimeNewEn
            static Float:vecOrigin[3];pev(iPlayer, pev_origin, vecOrigin);       
            static Float:vecEnd[3];
            static iVictim; iVictim = FM_NULLENT;
            new i=0;
            
            while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
            {
                if(is_user_connected(iVictim) && is_user_alive(iVictim))
                {
                    if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                            
                    pev(iVictim, pev_origin, vecEnd);
                                
                    new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                    if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                    {
                        
                        i++
    
                    }
                }
                if(i<1)
                {
                    for(new u=0;u<=get_maxplayers();u++)
                    {
                        if(!is_user_alive(u)||!is_user_connected(u)||zp_get_user_zombie(u)||u!=iPlayer) continue
                        
                        set_pev(iEntity, pev_iuser4, 0)
                        pev(iEntity, pev_fuser3, fTimeNewEn);//time to change pos
                        if(!fTimeNewEn)
                        {
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                        }
                        static Float:PlayOrig[3];
                        if(get_gametime() >= fTimeNewEn)
                        {
                            Stock_Get_Postion(iPlayer, MOVEMENT_MAX_FORWARD,MOVEMENT_MAX_RIGHT_OR_LEFT,MOVEMENT_MAX_UP,PlayOrig);
                            set_anim(iEntity, 0)
                            set_pev(iEntity, pev_fuser1, get_gametime()+random_float(21.0/30.0,60.0/30.0))
                            set_pev(iEntity, pev_animtime, get_gametime());
                            set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                            set_pev(iEntity, pev_framerate, 1.0);
            
                            
                                                                
                            set_pev(iEntity, pev_fuser3, get_gametime()+TIME_CHECK_POSITION);
                            new Float: distance = get_distance_f(vecEnt, PlayOrig)
                            if(distance>0.0)
                            {
                                get_speed_vector(vecEnt, PlayOrig, distance*COEF_SPEED_POWER, velocity);
                                set_pev(iEntity, pev_velocity, velocity);
                                                            
                            }
                            else
                            {
                                set_pev(iEntity, pev_velocity, 0.0);               
                            }
                        }
                                                        

                    }
                    g_enemy[iPlayer]=0
                }               
            }
            if(i==1)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                                
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {                   
                                Stock_Get_Postion(iVictim, -20.0,20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {               
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i==2)//prig na esli na 1 esni net to 2
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            new spr = fm_find_ent_by_owner(spr, "ent_ballsentpatrol1", iPlayer)
                            if(pev_valid(spr))
                            {
                                new iVictim1 = pev(spr, pev_iuser4)
                                if(iVictim ==iVictim1) continue
                            }       
                            set_pev(iEntity, pev_iuser4, iVictim)
                                        
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {       
                                Stock_Get_Postion(iVictim, -20.0,20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                        
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i==3)
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            new spr = fm_find_ent_by_owner(spr, "ent_ballsentpatrol1", iPlayer)
                            if(pev_valid(spr))
                            {
                                new iVictim1 = pev(spr, pev_iuser4)
                                
                                set_pev(iEntity, pev_iuser4, iVictim1)
                            }       
                            else
                            {
                                set_pev(iEntity, pev_iuser4, iVictim)

                            }
                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            
                            if(is_user_alive(iVictim))
                            {       
                                Stock_Get_Postion(iVictim, -20.0,20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {       
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }           
            if(i>=4)//prigau 4
            {
                while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 99999.9)))
                {
                    if(is_user_connected(iVictim) && is_user_alive(iVictim))
                    {
                        if(iVictim == iPlayer || !zp_get_user_zombie(iVictim) ||!is_user_alive(iVictim)) continue;
                                    
                        pev(iVictim, pev_origin, vecEnd);
                                        
                        new Float:distance1 = get_distance_f(vecOrigin, vecEnd);
                        if(distance1<DISTANCE_DRONE&&!IsWallBetweenPoints(vecOrigin, vecEnd, iPlayer))
                        {
                                
                            new spr = fm_find_ent_by_owner(spr, "ent_ballsentpatrol1", iPlayer)
                            if(pev_valid(spr))
                            {
                                new iVictim1 = pev(spr, pev_iuser4)
                                if(iVictim == iVictim1) continue
                            }
                            new spr1 = fm_find_ent_by_owner(spr1, "ent_ballsentpatrol2", iPlayer)
                            if(pev_valid(spr1))
                            {
                                new iVictim2 = pev(spr1, pev_iuser4)
                                if(iVictim == iVictim2) continue
                            }
                            new spr2 = fm_find_ent_by_owner(spr2, "ent_ballsentpatrol3", iPlayer)
                            if(pev_valid(spr2))
                            {
                                new iVictim3 = pev(spr2, pev_iuser4)
                                if(iVictim == iVictim3) continue
                            }                       

                            set_task(TIME_DAMAGE,"damage_task", iEntity,_,_,"a",1)
                            set_pev(iEntity, pev_iuser4, iVictim)
                            if(is_user_alive(iVictim)&&pev(iEntity, pev_iuser4))
                            {       
                                Stock_Get_Postion(iVictim, -20.0,20.0,10.0,vecEnd);
                                    
                                new Float: distance = get_distance_f(vecEnt, vecEnd)
            
                                set_anim(iEntity, 1)
                                        
                                if(distance>0.0)
                                {
                                            
                                    get_speed_vector(vecEnt, vecEnd, distance*3.0, velocity);
                                    set_pev(iEntity, pev_velocity, velocity);
                                    
                                }
                                else
                                {                           
                                    set_pev(iEntity, pev_animtime, get_gametime());
                                    set_pev(iEntity, pev_frame, random_float(1.0,3.0));
                                    set_pev(iEntity, pev_framerate, 1.0);
                                    set_pev(iEntity, pev_velocity, 0.0);   
            
                                }
                            }
        
                        }
                    }   
                }
                g_enemy[iPlayer]=1
            }

        }
        new fTime3 = pev(iEntity, pev_fuser1)   
        if(get_gametime() >= fTime3&&fTime3!=0.0&&g_enemy[iPlayer]==0)
        {   
            emit_sound(iEntity, CHAN_STATIC, Sounds[random_num(6,7)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            set_pev(iEntity, pev_fuser1, 0.0);
        }                   
        set_pev(iEntity, pev_nextthink, get_gametime());
        
    }
    return HAM_IGNORED;
}
public damage_task(iEntity)
{
    if(task_exists ( iEntity ))
    {
        remove_task(iEntity)
    }
    if(pev_valid(iEntity)!=2)
    {
        emit_sound(iEntity, CHAN_STATIC, Sounds[3], VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM);
        remove_task(iEntity)
        return
    }
    new iVic=pev(iEntity, pev_iuser4);
    new iPlayer=pev(iEntity, pev_owner);
    
    if(is_user_connected(iVic)&&is_user_alive(iVic)&&zp_get_user_zombie(iVic)&&is_user_connected(iPlayer)&&is_user_alive(iPlayer)&&!zp_get_user_zombie(iPlayer))
    {
        
        new Float:flDamage=DAMAGE_LIGHT;
        static Float:OrigVic[3];pev(iVic, pev_origin, OrigVic);
        set_pdata_int(iVic, m_LastHitGroup, HIT_GENERIC, 5);
        ExecuteHamB(Ham_TakeDamage, iVic, iPlayer, iPlayer, flDamage, DMG_GENERIC);
        UTIL_BloodDrips(OrigVic, iVic, floatround(flDamage));
        Weapon_DrawBeam2(iEntity, OrigVic)
        emit_sound(iEntity, CHAN_STATIC, Sounds[3], 0.4, ATTN_NORM, 0, PITCH_NORM);
        
        
    }
    else
    {
        remove_task(iEntity);
    }
}

public CEntity__Think_Pre(iSprite)
{
    if (pev_valid(iSprite) != 2)
    {
        return HAM_IGNORED;
    }
    
    if(pev(iSprite, pev_classname) == gl_iszAllocString_Muzzleflash)
    {
        new iOwner = pev(iSprite, pev_owner);       
        if(!is_user_connected(iOwner)||!is_user_alive(iOwner) || zp_get_user_zombie(iOwner)||get_user_weapon(iOwner)!=CSW_BASE)
        {
            set_pev(iSprite, pev_flags, pev(iSprite,pev_flags)|FL_KILLME);
            return HAM_IGNORED;
        }

        static Float: flFrame;
        if (pev(iSprite, pev_frame, flFrame) && ++flFrame - 1.0 < get_pdata_float(iSprite, m_maxFrame, 4))
        {
            set_pev(iSprite, pev_frame, flFrame);
            set_pev(iSprite, pev_nextthink, get_gametime() + 0.01);
            return HAM_SUPERCEDE
        }

        set_pev(iSprite, pev_flags, pev(iSprite,pev_flags)|FL_KILLME);
    }
    if(pev(iSprite, pev_classname) == gl_iszAllocString_BackGround)
    {
        new iOwner = pev(iSprite, pev_owner);   
        if(!is_user_connected(iOwner)||!is_user_alive(iOwner) || zp_get_user_zombie(iOwner)||get_user_weapon(iOwner)!=CSW_BASE)
        {
            set_pev(iSprite, pev_flags, pev(iSprite,pev_flags)|FL_KILLME);
            return HAM_IGNORED;
        }
        static Float: flScale; pev(iSprite, pev_scale, flScale);
        if(flScale < 0.08)
        {
            flScale+=0.01;
            set_pev(iSprite, pev_scale, flScale);
            

        }
        set_pev(iSprite, pev_nextthink, get_gametime() + 0.08);
        
        
    }
    if(pev(iSprite, pev_classname) == gl_iszAllocString_BackGround1)
    {
        new iOwner = pev(iSprite, pev_owner);   
        if(!is_user_connected(iOwner)||!is_user_alive(iOwner) || zp_get_user_zombie(iOwner)||get_user_weapon(iOwner)!=CSW_BASE)
        {
            set_pev(iSprite, pev_flags, pev(iSprite,pev_flags)|FL_KILLME);
            return HAM_IGNORED;
        }
        static Float: flScale; pev(iSprite, pev_scale, flScale);
        if(flScale < 0.015)
        {
            flScale+=0.005;
        }

        set_pev(iSprite, pev_scale, flScale);
        set_pev(iSprite, pev_nextthink, get_gametime() + 0.1);
    }   
    if(pev(iSprite, pev_classname) == gl_iszAllocString_Balls)
    {
        new iOwner = pev(iSprite, pev_owner);   
        if(!is_user_connected(iOwner)||!is_user_alive(iOwner) || zp_get_user_zombie(iOwner)||get_user_weapon(iOwner)!=CSW_BASE)
        {
            set_pev(iSprite, pev_flags, pev(iSprite,pev_flags)|FL_KILLME);
            return HAM_IGNORED;
        }
        static Float: flScale; pev(iSprite, pev_scale, flScale);
        if(flScale < 0.02)
        {
            flScale+=0.01;
            set_pev(iSprite, pev_scale, flScale);
            

        }
        set_pev(iSprite, pev_nextthink, get_gametime() + 0.08);
        
        
    }
    return HAM_IGNORED;
}

// [ Stocks ]
stock Send_PlayerAnimation(const iPlayer, const szAnim[])
{
    new iAnimDesired, Float:flFrameRate, Float:flGroundSpeed, bool:bLoops
    
    if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
    {
        iAnimDesired = 0
    }
    set_pev(iPlayer, pev_frame,0.0)
    set_pev(iPlayer, pev_framerate, 1.0)
    set_pev(iPlayer, pev_animtime , get_gametime())
    set_pev(iPlayer, pev_sequence , iAnimDesired)
    set_pdata_int(iPlayer, 40, bLoops)
    set_pdata_int(iPlayer, 39, 0)
    set_pdata_float(iPlayer, 36, flFrameRate)
    set_pdata_float(iPlayer, 37, flGroundSpeed)
    set_pdata_float(iPlayer, 38, get_gametime())
    set_pdata_int(iPlayer, 73,28 )
    set_pdata_int(iPlayer, 74, 28)
    set_pdata_float(iPlayer, 220, get_gametime())

}
stock Weapon_DrawBeam2(iPlayer, Float: vecEnd[3])
{
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecEnd, 0)
    write_byte(TE_SPARKS) // TE
    engfunc(EngFunc_WriteCoord, vecEnd[0]) // x
    engfunc(EngFunc_WriteCoord, vecEnd[1]) // y
    engfunc(EngFunc_WriteCoord, vecEnd[2]) // z
    message_end()
    
    static iBeamEntity, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "beam")))
    {
        iBeamEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }
    if(pev_valid(iBeamEntity)!=2) return FM_NULLENT;
    set_pev(iBeamEntity, pev_flags, pev(iBeamEntity, pev_flags) | FL_CUSTOMENTITY);
    set_pev(iBeamEntity, pev_rendercolor, Float: {255.0, 255.0, 255.0})
    set_pev(iBeamEntity, pev_renderamt, 255.0)
    set_pev(iBeamEntity, pev_body, 0)
    set_pev(iBeamEntity, pev_frame, 0.0)
    set_pev(iBeamEntity, pev_animtime, 0.0)
    set_pev(iBeamEntity, pev_scale, BEAM_WEIGHT)
        
    engfunc(EngFunc_SetModel, iBeamEntity, LIGHT);
        
    set_pev(iBeamEntity, pev_skin, 0);
    set_pev(iBeamEntity, pev_sequence, 0);
    set_pev(iBeamEntity, pev_rendermode, 0);     
    static Float:Origp[3];pev(iPlayer, pev_origin, Origp);
    set_pev(iBeamEntity, pev_origin, vecEnd) 
    set_pev(iBeamEntity, pev_angles, Origp)
    set_pev(iBeamEntity, pev_sequence, (pev(iBeamEntity, pev_sequence) & 0x0FFF) | ((0 & 0xF) << 12))
    set_pev(iBeamEntity, pev_skin, (pev(iBeamEntity, pev_skin) & 0x0FFF) | ((0 & 0xF) << 12))
    static Float: vecMins[3];
    static Float: vecMaxs[3];
    
    static Float: vecOrigin[3];
    static Float: vecEndPos[3];
    static Float: vecStartPos[3];
    
    pev(iBeamEntity, pev_origin, vecOrigin);
    
    pev(iBeamEntity, pev_origin, vecStartPos);
    pev(iBeamEntity, pev_angles, vecEndPos);
    
    vecMins[0] = floatmin(vecStartPos[0], vecEndPos[0]);
    vecMins[1] = floatmin(vecStartPos[1], vecEndPos[1]);
    vecMins[2] = floatmin(vecStartPos[2], vecEndPos[2]);
    
    vecMaxs[0] = floatmax(vecStartPos[0], vecEndPos[0]);
    vecMaxs[1] = floatmax(vecStartPos[1], vecEndPos[1]);
    vecMaxs[2] = floatmax(vecStartPos[2], vecEndPos[2]);
    
    xs_vec_sub(vecMins, vecOrigin, vecMins);
    xs_vec_sub(vecMaxs, vecOrigin, vecMaxs);
    
    set_pev(iBeamEntity, pev_mins, vecMins);
    set_pev(iBeamEntity, pev_maxs, vecMaxs);
    
    engfunc(EngFunc_SetSize, iBeamEntity, vecMins, vecMaxs);
    engfunc(EngFunc_SetOrigin, iBeamEntity, vecOrigin);     
        
    set_pev(iBeamEntity, pev_skin, (pev(iBeamEntity, pev_skin) & 0x0FFF) | ((0 & 0xF) << 12))
    set_pev(iBeamEntity, pev_sequence, (pev(iBeamEntity, pev_sequence) & 0x0FFF) | ((0 & 0xF) << 12))
    set_pev(iBeamEntity, pev_renderamt, 255.0)
    set_pev(iBeamEntity, pev_animtime, BEAM_SCROLLRATE)
    set_pev(iBeamEntity, pev_rendercolor, Float: {255.0, 255.0, 255.0})
    set_pev(iBeamEntity, pev_body, BEAM_NOISE)
    
    set_pev(iBeamEntity, pev_nextthink, get_gametime() + 0.25);
    set_pev_string(iBeamEntity, pev_classname, g_isBeam2);
    set_pev(iBeamEntity, pev_owner, iPlayer);
    return iBeamEntity;
}
stock Sprite_SetTransparency(iSprite, iRendermode, Float: flAmt, iFx = kRenderFxNone)
{
    set_pev(iSprite, pev_rendermode, iRendermode);
    set_pev(iSprite, pev_renderamt, flAmt);
    set_pev(iSprite, pev_renderfx, iFx);
}
stock UTIL_SendWeaponAnim(iPlayer, iAnim)
{
    set_pev(iPlayer, pev_weaponanim, iAnim);

    message_begin(MSG_ONE, SVC_WEAPONANIM, _, iPlayer);
    write_byte(iAnim);
    write_byte(0);
    message_end();
}


stock UTIL_PrecacheSoundsFromModel(const szModelPath[])
{
    new iFile;
    
    if((iFile = fopen(szModelPath, "rt")))
    {
        new szSoundPath[64];
        
        new iNumSeq, iSeqIndex;
        new iEvent, iNumEvents, iEventIndex;
        
        fseek(iFile, 164, SEEK_SET);
        fread(iFile, iNumSeq, BLOCK_INT);
        fread(iFile, iSeqIndex, BLOCK_INT);
        
        for(new k, i = 0; i < iNumSeq; i++)
        {
            fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
            fread(iFile, iNumEvents, BLOCK_INT);
            fread(iFile, iEventIndex, BLOCK_INT);
            fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
            
            for(k = 0; k < iNumEvents; k++)
            {
                fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
                fread(iFile, iEvent, BLOCK_INT);
                fseek(iFile, 4, SEEK_CUR);
                
                if(iEvent != 5004)
                    continue;
                
                fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
                
                if(strlen(szSoundPath))
                {
                    strtolower(szSoundPath);
                    engfunc(EngFunc_PrecacheSound, szSoundPath);
                }
            }
        }
    }
    
    fclose(iFile);
}

stock UTIL_WeaponList(iPlayer, bool: bEnabled)
{
    message_begin(MSG_ONE, gl_iMsgID_Weaponlist, _, iPlayer);
    write_string(bEnabled ? WEAPONLIST[0] : WEAPON_REFERENCE);
    write_byte(iWeaponList[0]);
    write_byte(bEnabled ? WEAPON_DEFAULT_AMMO : iWeaponList[1]);
    write_byte(iWeaponList[2]);
    write_byte(iWeaponList[3]);
    write_byte(iWeaponList[4]);
    write_byte(iWeaponList[5]);
    write_byte(iWeaponList[6]);
    write_byte(iWeaponList[7]);
    message_end();
}
stock UTIL_PrecacheSpritesFromTxt(const szWeaponList[])
{
    new szTxtDir[64], szSprDir[64];
    new szFileData[128], szSprName[48], temp[1];

    format(szTxtDir, charsmax(szTxtDir), "sprites/%s.txt", szWeaponList);
    engfunc(EngFunc_PrecacheGeneric, szTxtDir);

    new iFile = fopen(szTxtDir, "rb");
    while(iFile && !feof(iFile))
    {
        fgets(iFile, szFileData, charsmax(szFileData));
        trim(szFileData);

        if(!strlen(szFileData))
            continue;

        new pos = containi(szFileData, "640");   
            
        if(pos == -1)
            continue;
            
        format(szFileData, charsmax(szFileData), "%s", szFileData[pos+3]);       
        trim(szFileData);

        strtok(szFileData, szSprName, charsmax(szSprName), temp, charsmax(temp), ' ', 1);
        trim(szSprName);
        
        format(szSprDir, charsmax(szSprDir), "sprites/%s.spr", szSprName);
        engfunc(EngFunc_PrecacheGeneric, szSprDir);
    }

    if(iFile) fclose(iFile);
}
PrimaryAmmoIndex(iItem)
{
    return get_pdata_int(iItem, m_iPrimaryAmmoType, 4);
}

GetAmmoInventory(iPlayer, iAmmoIndex)
{
    if (iAmmoIndex == -1)
    {
        return -1;
    }

    return get_pdata_int(iPlayer, m_rgAmmo + iAmmoIndex, 5);
}
SetAmmoInventory(iPlayer, iAmmoIndex, iAmount)
{
    if (iAmmoIndex == -1)
    {
        return 0;
    }

    set_pdata_int(iPlayer, m_rgAmmo + iAmmoIndex, iAmount, 5);
    return 1;
}
stock IsWallBetweenPoints(Float: vecStart[3], Float: vecEnd[3], PlayerEnt)
{
    static iTrace;iTrace = create_tr2();
    static Float: vecEndPos[3];
    engfunc(EngFunc_TraceLine, vecStart, vecEnd, IGNORE_MONSTERS, PlayerEnt, iTrace);
    get_tr2(iTrace, TR_vecEndPos, vecEndPos);
    free_tr2(iTrace);
    return floatround(get_distance_f(vecEnd, vecEndPos));
}
stock UTIL_SetRendering(iPlayer, iFx = 0, iRed = 255, iGreen = 255, iBlue = 255, iRender = 0, Float: flAmount = 16.0)
{
    static Float: flColor[3];
    
    flColor[0] = float(iRed);
    flColor[1] = float(iGreen);
    flColor[2] = float(iBlue);
    
    set_pev(iPlayer, pev_renderfx, iFx);
    set_pev(iPlayer, pev_rendercolor, flColor);
    set_pev(iPlayer, pev_rendermode, iRender);
    set_pev(iPlayer, pev_renderamt, flAmount);
}

stock UTIL_CreateMuzzleFlash(iPlayer, szMuzzleSprite[], Float: flScale, Float: flBrightness, iAttachment)
{
    if (global_get(glb_maxEntities) - engfunc(EngFunc_NumberOfEntities) < 100)
    {
        return FM_NULLENT;
    }
    static iSprite, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "env_sprite")))
    {
        iSprite = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }
    if(!pev_valid(iSprite)) return FM_NULLENT;

    set_pev(iSprite, pev_model, szMuzzleSprite);
    set_pev(iSprite, pev_owner, iPlayer);
    set_pev(iSprite, pev_aiment, iPlayer);
    set_pev(iSprite, pev_body, iAttachment);
    set_pev(iSprite, pev_frame, 0.0);
    set_pev_string(iSprite, pev_classname, gl_iszAllocString_Muzzleflash);
    set_pev(iSprite, pev_spawnflags, SF_SPRITE_ONCE);       
    Sprite_SetTransparency(iSprite, kRenderTransAdd, flBrightness);
    Sprite_SetScale(iSprite, flScale);
    set_pev(iSprite, pev_nextthink, get_gametime()+0.01);
    dllfunc(DLLFunc_Spawn, iSprite)

    return iSprite;
}
stock UTIL_CreateMuzzleFlash_bg(iPlayer, szMuzzleSprite[], Float: flScale, Float: flBrightness, iAttachment)
{
    if (global_get(glb_maxEntities) - engfunc(EngFunc_NumberOfEntities) < 100)
    {
        return FM_NULLENT;
    }
    static iSprite, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "env_sprite")))
    {
        iSprite = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }
    if(!pev_valid(iSprite)) return FM_NULLENT;

    set_pev(iSprite, pev_model, szMuzzleSprite);
    set_pev(iSprite, pev_owner, iPlayer);
    set_pev(iSprite, pev_aiment, iPlayer);
    set_pev(iSprite, pev_body, iAttachment);
    set_pev(iSprite, pev_frame, 0.0);
    set_pev_string(iSprite, pev_classname, gl_iszAllocString_BackGround);
    set_pev(iSprite, pev_spawnflags, SF_SPRITE_ONCE);       
    set_pev(iSprite, pev_nextthink, get_gametime()+0.1);
    Sprite_SetTransparency(iSprite, kRenderTransAdd, flBrightness);
    Sprite_SetScale(iSprite, flScale);
    
    dllfunc(DLLFunc_Spawn, iSprite)

    return iSprite;
}
stock UTIL_CreateMuzzleFlash_bg1(iPlayer, szMuzzleSprite[], Float: flScale, Float: flBrightness, iAttachment)
{
    if (global_get(glb_maxEntities) - engfunc(EngFunc_NumberOfEntities) < 100)
    {
        return FM_NULLENT;
    }
    static iSprite, iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "env_sprite")))
    {
        iSprite = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }
    if(!pev_valid(iSprite)) return FM_NULLENT;

    set_pev(iSprite, pev_model, szMuzzleSprite);
    set_pev(iSprite, pev_owner, iPlayer);
    set_pev(iSprite, pev_aiment, iPlayer);
    set_pev(iSprite, pev_body, iAttachment);
    set_pev(iSprite, pev_frame, 0.0);
    set_pev_string(iSprite, pev_classname, gl_iszAllocString_BackGround1);
    set_pev(iSprite, pev_spawnflags, SF_SPRITE_ONCE);       
    set_pev(iSprite, pev_nextthink, get_gametime()+0.1);
    Sprite_SetTransparency(iSprite, kRenderTransAdd, flBrightness);
    Sprite_SetScale(iSprite, flScale);
    
    dllfunc(DLLFunc_Spawn, iSprite)

    return iSprite;
}
stock balls_muzzle(iPlayer, szMuzzleSprite[], Float: flScale, Float: flBrightness, iAttachment)
{
    if (global_get(glb_maxEntities) - engfunc(EngFunc_NumberOfEntities) < 100)
    {
        return FM_NULLENT;
    }
    static iszAllocStringCached;
    if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, "env_sprite")))
    {
        g_background = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached);
    }
    if(!pev_valid(g_background)) return FM_NULLENT;
    set_pev(g_background, pev_model, szMuzzleSprite);
    set_pev(g_background, pev_owner, iPlayer);
    set_pev(g_background, pev_aiment, iPlayer);
    set_pev(g_background, pev_body, iAttachment);
    set_pev(g_background, pev_frame, 10.0);
    set_pev_string(g_background, pev_classname, gl_iszAllocString_Balls);
    set_pev(g_background, pev_spawnflags, SF_SPRITE_ONCE);       
    set_pev(g_background, pev_nextthink, get_gametime()+0.1);
    Sprite_SetTransparency(g_background, kRenderTransAdd, flBrightness);
    Sprite_SetScale(g_background, flScale);
    
    dllfunc(DLLFunc_Spawn, g_background)

    return g_background;
}
public UTIL_BloodDrips(Float: vecOrigin[3], iVictim, iAmount)
{
    if(iAmount > 255) iAmount = 255;
    engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, vecOrigin, 0);
    write_byte(TE_BLOODSPRITE);
    engfunc(EngFunc_WriteCoord, vecOrigin[0]);
    engfunc(EngFunc_WriteCoord, vecOrigin[1]);
    engfunc(EngFunc_WriteCoord, vecOrigin[2]);
    write_short(gl_iszModelIndex_BloodSpray);
    write_short(gl_iszModelIndex_BloodDrop);
    write_byte(ExecuteHamB(Ham_BloodColor, iVictim));
    write_byte(min(max(3, iAmount / 10), 16));
    message_end();
}
stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
    new_velocity[0] = origin2[0] - origin1[0]
    new_velocity[1] = origin2[1] - origin1[1]
    new_velocity[2] = origin2[2] - origin1[2]
    new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    new_velocity[0] *= num
    new_velocity[1] *= num
    return 1;
}

stock set_anim(Model, sequence)
{
    if(pev(Model,pev_sequence)!=sequence)
    {
        set_pev(Model, pev_animtime, get_gametime());
        set_pev(Model, pev_framerate,1.0);
        set_pev(Model, pev_frame,0.0);
        set_pev(Model, pev_sequence,sequence);
    }
}
stock Stock_Get_Postion(id,Float:forw,Float:right,Float:up,Float:vStart[])
{
    static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    pev(id, pev_origin, vOrigin)
    pev(id, pev_view_ofs, vUp)
    xs_vec_add(vOrigin, vUp, vOrigin)
    pev(id, pev_v_angle, vAngle)
    
    engfunc(EngFunc_AngleVectors, vAngle, vForward, vRight, vUp)
    vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}

Я правильно понял, если ты покупаешь дрона в спец. магазине и у тебя они спавнятся в первой анимации?
 
Сообщения
3,020
Реакции
1,731
Помог
79 раз(а)
Berkulech, это нормально, так как у тебя не было попыток решить проблему, советую разместить тему в разделе "покупка"
 
Сообщения
107
Реакции
10
Berkulech, Я пытался тебе помочь, но ты даже ответа не дал на, то что я тебе скинул. Тебе просто при покупке нужно выставить анимацию #4
 
Сообщения
9
Реакции
0
Kulogram, пробовал не работает (
18 Авг 2024
когда дроны летят анимация просто не красиво
 
Сообщения
9
Реакции
1
вашему коду нужна анимация простоя? потому что по мне это нет и достаточно поменять эти анимации
 

Вложения

Сообщения
9
Реакции
0
сейчас покажу как они работает
18 Авг 2024
viper367, вы можете мне сказать как изменить анимации в исходнике ?
 
Сообщения
9
Реакции
1
В файле, который я вам отправил, нет анимации простоя.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу