Плагин CSDM Poison Launcher

Статус
В этой теме нельзя размещать новые ответы.

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Доброй ночи всем.
Ребят помогите пожалуйста с плагином.
Проблема заключается в том, что:
... купил оружие (в чат: /pl) - выстреливаешь всю обойму - перезаряжаешься ... и вот когда у тебя уже вторая обойма, после каждого выстрела, начинает перезаряжаться.
Но, если зажать кнопку, будет стрелять пока не закончится обойма.

PHP:
#include <amxmodx>
#include <fakemeta_util>
#include <engine>
#include <cstrike>
#include <hamsandwich>
#include <xs>

const UNIT_SECOND = (1<<12)

#define ENG_NULLENT            -1
#define EV_INT_WEAPONKEY    EV_INT_impulse
#define POISON_WEAPONKEY        233
#define WEAP_LINUX_XTRA_OFF            4
#define m_fKnown                44
#define m_flNextPrimaryAttack             46
#define m_flTimeWeaponIdle            48
#define m_iClip                    51
#define m_fInReload                54
#define PLAYER_LINUX_XTRA_OFF            5
#define m_flNextAttack                83
#define TIME_POISON                5.0
#define CSW_WPN_POISON        CSW_M3
#define OFFSET_TIME_ATTACK 0.6
#define WPN_RELOAD_TIME 3.0

new const gWeapon[] = "weapon_m3"

#define PLUGIN "CSDM Poison Launcher"
#define VERSION "1.8.6"
#define AUTHOR "Re.Act!ve"

#define RED 60
#define GREEN 250
#define BLUE 0
#define PEV_ENT_TIME pev_fuser1

// Precahce files
new const fire_model_name[] =     "models/sevcs/spore.mdl"
new const fire_poison[] =         "models/spore_poison.mdl"
new const fire_spr_name[] =         "sprites/laserbeam.spr"
new const fire_sprite[] =         "sprites/poison.spr"
new const spr_poison_flare[] =     "sprites/poison_flare.spr"

new fire_sound[] = "weapons/plauncher-1.wav"
new g_sound[][] = {
    "weapons/plauncher_draw.wav",
    "weapons/plaunch_clipin.wav",
    "weapons/plaunch_clipout.wav",
    "weapons/plauncher_explode.wav"
}

new const v_model[] = "models/v_plaunch.mdl"
new const p_model[] = "models/p_plaunch.mdl"
new const w_model[] = "models/w_plaunch.mdl"

// classname
new const fire_classname[] = "poison_fire"
new const poison_classname[] = "posion_spore"
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
enum
{
    IDLE_ANIM = 0,
    DRAW_ANIM = 2,
    RELOAD_ANIM = 1,
    SHOOT_ANIM = 3,
    SHOOT_ANIM1 = 4,
    SHOOT_ANIM2 = 5
}

new sprite_ability, fire_spr_id, fire_spr_nameid, g_IsInPrimaryAttack, cvar_start_damage, cvar_end_damage, cvar_clip, cvar_maxclip, cvar_shot_speed, cvar_cost_poison, cvar_movetype
new g_orig_event, Float:g_poison_touch[33], oldweap[33], g_TmpClip[33], Float:gPoisonGlow[33], bool:gGlowPlayer[33], g_msgScreenShake
new bool:g_has_item[33], bool:disc_opened[33]

new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
            "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
            "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
            "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
            "weapon_ak47", "weapon_knife", "weapon_p90" }

public plugin_precache()
{
    precache_model(v_model)
    precache_model(p_model)
    precache_model(w_model)

    for(new i=0;i<sizeof g_sound;i++) precache_sound(g_sound[i])

    precache_sound(fire_sound)

    precache_model(fire_model_name)
    precache_model(fire_poison)
    sprite_ability = engfunc(EngFunc_PrecacheModel, spr_poison_flare)   
    fire_spr_id = precache_model(fire_sprite)
    fire_spr_nameid = precache_model(fire_spr_name)
}

public plugin_init()
{
    register_plugin ( PLUGIN, VERSION, AUTHOR )

        cvar_cost_poison = register_cvar("pl_bulletcost", "3000") // cost
    cvar_shot_speed = register_cvar("pl_bulletspeed", "80")    // Speed shot
    cvar_movetype = register_cvar("pl_movetype", "0")    // 0 - Line, 1 - Toss
    cvar_start_damage = register_cvar("pl_startdamage", "50.0")    // Урон
    cvar_end_damage = register_cvar("pl_enddamage", "60.0")    // Урон
    cvar_clip = register_cvar("pl_clip", "15")        // Основ. патроны
    cvar_maxclip = register_cvar("pl_ammo", "60")        // Запас. патроны
    g_msgScreenShake = get_user_msgid("ScreenShake")
    set_cvar_num("sv_maxvelocity", 8000)

    RegisterHam(Ham_Weapon_PrimaryAttack, gWeapon, "fw_PrimaryAttack")
    RegisterHam(Ham_Weapon_PrimaryAttack, gWeapon, "fw_PrimaryAttack_Post", 1)
    RegisterHam(Ham_Item_PostFrame, gWeapon, "plasma_ItemPostFrame")
    RegisterHam(Ham_Weapon_Reload, gWeapon, "fw_Reload")
    RegisterHam(Ham_Weapon_Reload, gWeapon, "Reload_Post", 1)
    RegisterHam(Ham_Item_AddToPlayer, gWeapon, "fw_item_addtoplayer", 1)
    
    register_forward(FM_SetModel, "fw_SetModel")
    register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
    register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
    register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    
    register_touch(fire_classname, "*", "fw_touch_shot")
    register_think(fire_classname, "fw_think")
    register_touch(poison_classname, "*", "fw_touch_poison")

        register_clcmd("say /pl", "give_poison")
    
    for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
    if (WEAPONENTNAMES[i][0])
        RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
}

public fwPrecacheEvent_Post(type, const name[])
{
    if (equal("events/m3.sc", name))
    {
        g_orig_event = get_orig_retval()
        return FMRES_HANDLED
    }
    return FMRES_IGNORED
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{   
    if(get_user_weapon(id) != CSW_WPN_POISON || !g_has_item[id])
        return FMRES_IGNORED
        
    set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001) 

    return FMRES_HANDLED
}

public fw_item_addtoplayer(ent, id)
{
    if(!is_valid_ent(ent))
        return HAM_IGNORED
            
    if(entity_get_int(ent, EV_INT_WEAPONKEY) == POISON_WEAPONKEY)
    {
        g_has_item[id] = true;
        entity_set_int(id, EV_INT_impulse, 0)

        replace_weapon_models(id, ent)
        return HAM_HANDLED
    }

    return HAM_HANDLED
}

public client_connect(id)
    g_has_item[id] = false

public client_disconnect(id)
    g_has_item[id] = false

public give_poison(id, itemid)
{
        new money = cs_get_user_money(id)   
        if(money >= get_pcvar_num(cvar_cost_poison))
    {
        drop_weapons(id,1)
        new iWep2 = fm_give_item(id,gWeapon)
        if( iWep2 > 0 )
        {
                        cs_set_user_money(id, money - get_pcvar_num(cvar_cost_poison))
            cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip))
            cs_set_user_bpammo (id, CSW_WPN_POISON, get_pcvar_num(cvar_maxclip))   
        }
        UTIL_PlayWeaponAnimation (id, DRAW_ANIM)
        emit_sound(id, CHAN_WEAPON, g_sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
        g_has_item[id] = true;
    }
}

public fw_PrimaryAttack(Weapon)
{
    if (g_has_item[pev( Weapon, pev_owner )])
    {
        g_IsInPrimaryAttack = 1
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_orig_event) || !g_IsInPrimaryAttack)
        return FMRES_IGNORED
        
    if (!(1 <= invoker <= get_maxplayers()))
        return FMRES_IGNORED

    playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    return FMRES_SUPERCEDE
}

public fw_PrimaryAttack_Post(Weapon)
{
    g_IsInPrimaryAttack = 0
    new Player = get_pdata_cbase(Weapon, 41, 4)

    new szClip, szAmmo
    get_user_weapon(Player, szClip, szAmmo)
    
    if(!is_user_alive(Player))
        return
    
    if(szClip == 0)
        return

    if(!is_user_alive(Player))
        return

    if(g_has_item[Player] || szClip >= 1)
    {
        //set_pdata_float(Player , m_flNextAttack, OFFSET_TIME_ATTACK, PLAYER_LINUX_XTRA_OFF)
        set_pdata_float( Player, 83, OFFSET_TIME_ATTACK )
        make_shoot(Player, Weapon)
    }
}

public make_shoot(id, Weapon)
{
    if(!is_user_alive(id))
        return HAM_IGNORED;

    if(get_user_weapon(id) != CSW_WPN_POISON)
        return HAM_IGNORED;

    if(!g_has_item[id] || disc_opened[id])
        return HAM_IGNORED;

    new szClip
    get_user_weapon(id, szClip)

    if(szClip >= 1)
    {
        new Float:Puch[3]
        pev(id, pev_punchangle, Puch)
        Puch[0]-=random_float(3.0, 6.0)
        cs_set_weapon_ammo(Weapon, szClip-1)
        emit_sound(id, CHAN_WEAPON, fire_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
        UTIL_PlayWeaponAnimation(id, random_num(SHOOT_ANIM, SHOOT_ANIM2))
        throw_fire(id)
        set_pev(id,pev_punchangle,Puch)
    }
    return HAM_IGNORED;
}

public throw_fire(id)
{
    new iEnt = create_entity("info_target")
    new Float:vfVelocity[3]
    
    velocity_by_aim(id, (get_pcvar_num(cvar_shot_speed)*10), vfVelocity)
    
    // add velocity of Owner for ent
    new Float:vfAttack[3], Float:vfAngle[3], Float:vOfps[3]
    get_weapon_attackment(id, vfAttack, 20.0)
    pev(id, pev_view_ofs, vOfps)
    pev(id, pev_angles, vfAngle)
    
    // set info for ent
    set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
    set_pev(iEnt, PEV_ENT_TIME, get_gametime() + 5.0)    // time remove
    set_pev(iEnt, pev_classname, fire_classname)
    engfunc(EngFunc_SetModel, iEnt, fire_model_name)    //fire_model_name
    set_pev(iEnt, pev_mins, Float:{-2.0, -2.0, -2.0})
    set_pev(iEnt, pev_maxs, Float:{2.0, 2.0, 2.0})
    set_pev(iEnt, pev_body, 2)
    set_pev(iEnt, pev_origin, vfAttack)
    set_pev(iEnt, pev_velocity, vfVelocity)
    set_pev(iEnt, pev_solid, SOLID_BBOX)
    set_pev(iEnt, pev_owner, id)
    set_pev(iEnt, pev_iuser2, 1)
    set_pev(iEnt, pev_vuser1, vfVelocity)
    set_pev(iEnt, pev_angles, vfAngle)
    set_pev(iEnt, pev_v_angle, vOfps)

    set_pev(iEnt, pev_rendermode, kRenderTransAdd)
    set_pev(iEnt, pev_renderamt, 130.0)

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_BEAMFOLLOW) // TE id
    write_short(iEnt) // entity
    write_short(fire_spr_nameid) // sprite
    write_byte(8) // life
    write_byte(6) // width
    write_byte(RED) // r
    write_byte(GREEN) // g
    write_byte(BLUE) // b
    write_byte(180) // brightness
    message_end()
    set_task(OFFSET_TIME_ATTACK, "RemoveDisk", id+2242)
}
/*
public RemoveDisk(taskid)
{
    disc_opened[taskid-2242] = false;
    remove_task(taskid)
}
*/
public fw_SetModel(entity, model[])
{
    if(!is_valid_ent(entity))
        return FMRES_IGNORED;
    
    static szClassName[33]
    entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
        
    if(!equal(szClassName, "weaponbox"))
        return FMRES_IGNORED;
    
    static iOwner
    
    iOwner = entity_get_edict(entity, EV_ENT_owner)
    
    if(equal(model, "models/w_m3.mdl"))
    {
        static iStoredSVDID
        
        iStoredSVDID = find_ent_by_owner(ENG_NULLENT, gWeapon, entity)
    
        if(!is_valid_ent(iStoredSVDID))
            return FMRES_IGNORED;
    
        if(g_has_item[iOwner])
        {
            entity_set_int(iStoredSVDID, EV_INT_WEAPONKEY, POISON_WEAPONKEY)
            
            g_has_item[iOwner] = false
            
            entity_set_model(entity, w_model)
            
            return FMRES_SUPERCEDE;
        }
    }
    return FMRES_IGNORED;
}

public fw_think(iEnt)
{
    if(!pev_valid(iEnt))
        return
    
    new Float:fFrame, Float:fScale, Float:fNextThink
    pev(iEnt, pev_frame, fFrame)
    pev(iEnt, pev_scale, fScale)

    // effect exp
    new iMoveType = pev(iEnt, pev_movetype)
    if (iMoveType == MOVETYPE_NONE)
    {
        fNextThink = 0.015
        fFrame += 1.0
        fScale = floatmax(fScale, 1.55)
        
        if (fFrame > 21.0)
        {
            engfunc(EngFunc_RemoveEntity, iEnt)
            return
        }
    }
    
    // effect normal
    else
    {
        fNextThink = 0.045
        fFrame += 1.0
        fFrame = floatmin(21.0, fFrame)
        fScale += 0.2
        fScale = floatmin(fScale, 1.75)
    }

    set_pev(iEnt, pev_frame, fFrame)
    set_pev(iEnt, pev_scale, fScale)
    set_pev(iEnt, pev_nextthink, get_gametime() + fNextThink)
    
    // time remove
    static Float:fTimeRemove
    pev(iEnt, pev_fuser1, fTimeRemove)
    if (get_gametime() >= fTimeRemove)
    {
        engfunc(EngFunc_RemoveEntity, iEnt)
        return;
    }
}

public fw_remove_poison(taskEnt)
{
    new Ent=taskEnt-1234
    if(is_valid_ent(Ent)) engfunc(EngFunc_RemoveEntity, Ent)
    remove_task(taskEnt)
}

public fw_touch_poison(ent, touch)
{
    client_print(0, print_center, "Touch")
    if(is_user_alive(touch))
    {
        static Float:CurTime
        CurTime = get_gametime()
        
        if(CurTime - 1.0 > g_poison_touch[touch])
        {
            new Owner = pev(ent, pev_owner)
            ExecuteHamB(Ham_TakeDamage, touch, Owner, touch, 50.0, DMG_BLAST)
            set_pev(touch, pev_maxspeed, 20.0)   
            
            g_poison_touch[touch] = CurTime
        }
    }
}

public fw_touch_shot(ent, id)
{
    emit_sound(ent, CHAN_ITEM, g_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
    new Float:vOrigin[3]
    pev(ent, pev_origin, vOrigin);

    new classname[1024]
    pev(id, pev_classname, classname, charsmax(classname))
    if(equal(classname, "func_wall") || equal(classname, "func_breakable") || equal(classname, "worldspawn")) {
        new Gent = create_entity("info_target")

        set_pev(Gent, pev_owner, pev(ent, pev_owner))
        new Float:maxs[3] = {40.0, 40.0, 25.0}
        new Float:mins[3] = {-40.0, -40.0, -25.0}
        entity_set_size(Gent, mins, maxs)
        set_pev(Gent, pev_classname, poison_classname)
        engfunc(EngFunc_SetModel, Gent, fire_poison)

        new    Float:vNewOrigin[3],Float:vNormal[3],Float:vTraceDirection[3],
        Float:vTraceEnd[3],Float:vEntAngles[3];

        pev(ent, get_pcvar_num(cvar_movetype) ? pev_velocity : pev_vuser1, vTraceDirection)

        xs_vec_add(vTraceDirection, vOrigin, vTraceEnd);

        engfunc(EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, ent, 0);
        
        new Float:fFraction;
        get_tr2(0, TR_flFraction, fFraction);
        
        // -- We hit something!
        if(fFraction < 1.0)
        {
            // -- Save results to be used later.
            get_tr2(0, TR_vecEndPos, vTraceEnd);

            get_tr2(0, TR_vecPlaneNormal, vNormal);
        }
        xs_vec_add(vTraceEnd, vNormal, vNewOrigin);
    
        vector_to_angle(vNormal,vEntAngles);
        vEntAngles[0]-=90.0

        set_pev(Gent,pev_angles,vEntAngles);
        set_pev(Gent, pev_origin, vNewOrigin)

        set_pev(Gent, pev_rendermode, kRenderTransAdd)
        set_pev(Gent, pev_renderamt, 160.0)

        set_pev(Gent, pev_solid, SOLID_SLIDEBOX)
        set_pev(Gent, pev_movetype, MOVETYPE_NONE)

        effect_play_sprite(vOrigin, 40.0)

        set_task(TIME_POISON, "fw_remove_poison", Gent+1234)
        remove_entity(ent)
        return FMRES_IGNORED
    }
    
    if(!is_valid_ent(id))
        return FMRES_IGNORED
    
    if(!is_user_alive(id) || !is_user_connected(id)) {
        remove_entity(ent)
        return FMRES_IGNORED
    }
    
    if(pev(ent, pev_iuser2) == 1)
    {
        set_pev(ent, pev_iuser2, 0)
        pev(id, pev_origin, vOrigin)
        effect_play_sprite(vOrigin, 30.0)

        message_begin (MSG_BROADCAST,SVC_TEMPENTITY)
        write_byte( TE_SPRITETRAIL ) // Throws a shower of sprites or models
        write_coord( floatround(vOrigin[ 0 ]) ) // start pos
        write_coord( floatround(vOrigin[ 1 ]) )
        write_coord( floatround(vOrigin[ 2 ]) )
        write_coord( floatround(vOrigin[ 0 ]) ) // velocity
        write_coord( floatround(vOrigin[ 1 ]) )
        write_coord( floatround(vOrigin[ 2 ]) +20)
        write_short(sprite_ability ) // spr
        write_byte(18) // (count)
        write_byte(random_num(8,15)) // (life in 0.1's)
        write_byte(4) // byte (scale in 0.1's)
        write_byte(random_num(22,35)) // (velocity along vector in 10's)
        write_byte(20) // (randomness of velocity in 10's)
        message_end()
        
        static attacker
        
        attacker = pev(ent, pev_owner)

        if(!fm_get_user_godmode(id)) {
            new Float:velocity[3]
            pev(ent, pev_vuser1, velocity)
            velocity[2]+=30.0
            xs_vec_mul_scalar(velocity, 1000.0/xs_vec_len(velocity), velocity)

            ExecuteHam(Ham_TakeDamage, id, "poison_launcher", attacker, random_float(get_pcvar_float(cvar_start_damage), get_pcvar_float(cvar_end_damage)), DMG_BULLET)
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, id)
            write_byte(0) // damage save
            write_byte(0) // damage take
            write_long(DMG_POISON) // damage type
            write_coord(0) // x
            write_coord(0) // y
            write_coord(0) // z
            message_end()

            user_screen_shake(id, 4, 2, 5)
            do_screen_fade(id, 0.8, 0.7, RED, GREEN, BLUE, 180);

            set_pev(id, pev_velocity, velocity)
            gPoisonGlow[id] = get_gametime() + 1.0;
            gGlowPlayer[id] = true;

            fm_set_rendering(id, kRenderFxGlowShell, RED, GREEN, BLUE, kRenderNormal, 25)
        }
        remove_entity(ent)
        return FMRES_IGNORED
    }

    return FMRES_IGNORED
}

public client_PostThink(id)
{
    if (!is_user_alive(id)) return;

    if(gGlowPlayer[id]) {
        if(gPoisonGlow[id]>get_gametime())
            return

        set_pev(id, pev_maxspeed, 100.0) // prevent from moving
        set_pev(id, pev_renderfx, 0)   
        gGlowPlayer[id] = false;   
    }
}

effect_play_sprite(const Float:vOrigin[3], Float:Add)
{
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0)
    write_byte(TE_SPRITE)
    engfunc(EngFunc_WriteCoord, vOrigin[0])
    engfunc(EngFunc_WriteCoord, vOrigin[1])
    engfunc(EngFunc_WriteCoord, vOrigin[2] + Add)
    write_short(fire_spr_id)
    write_byte(8)
    write_byte(200)
    message_end()
}

public fw_Item_Deploy_Post(weapon_ent)
{
    static owner
    owner = fm_cs_get_weapon_ent_owner(weapon_ent)
    
    static weaponid
    weaponid = cs_get_weapon_id(weapon_ent)
    
    replace_weapon_models(owner, weaponid)
}

replace_weapon_models(id, weaponid)
{
    switch (weaponid)
    {
        case CSW_WPN_POISON:
        {
            //if (!avp_get_user_predator(id))
            //    return
            
            if(g_has_item[id])
            {
                set_pev(id, pev_viewmodel2, v_model)
                set_pev(id, pev_weaponmodel2, p_model)
                UTIL_PlayWeaponAnimation (id, DRAW_ANIM)
                emit_sound(id, CHAN_WEAPON, g_sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
                //set_pdata_float(id, m_flNextAttack, 1.3, PLAYER_LINUX_XTRA_OFF)
            }
        }
    }
    oldweap[id] = weaponid
}

public plasma_ItemPostFrame(weapon_entity)
{
     new id = pev(weapon_entity, pev_owner)
     if (!is_user_connected(id))
          return HAM_IGNORED

     if (!g_has_item[id])
          return HAM_IGNORED

     static iClipExtra
    
     iClipExtra = get_pcvar_num(cvar_clip)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_WPN_POISON)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)

     if( fInReload && flNextAttack <= 0.0 )
     {
         new j = min(iClipExtra - iClip, iBpAmmo)
    
         set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
         cs_set_user_bpammo(id, CSW_WPN_POISON, iBpAmmo-j)
        
         set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
         fInReload = 0
     }
     return HAM_IGNORED
}

public fw_Reload(weapon_entity)
{
    new id = pev(weapon_entity, pev_owner)
    if (!is_user_connected(id))
        return HAM_IGNORED
    
    if (!g_has_item[id])
        return HAM_IGNORED
    
    static iClipExtra
    
    if(g_has_item[id])
        iClipExtra = get_pcvar_num(cvar_clip)
    
    g_TmpClip[id] = -1
    
    new iBpAmmo = cs_get_user_bpammo(id, CSW_WPN_POISON)
    new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
    
    if (iBpAmmo <= 0)
        return HAM_SUPERCEDE

    if (iClip >= iClipExtra)
        return HAM_SUPERCEDE

    g_TmpClip[id] = iClip
    
    return HAM_IGNORED
}

public Reload_Post(weapon_entity)
{
    new id = pev(weapon_entity, pev_owner)
    
    if (!is_user_connected(id))
        return HAM_IGNORED

    if (!g_has_item[id])
        return HAM_IGNORED

    if (g_TmpClip[id] == -1)
        return HAM_IGNORED

    set_pdata_int(weapon_entity, m_iClip, g_TmpClip[id], WEAP_LINUX_XTRA_OFF)
    set_pdata_float(weapon_entity, m_flTimeWeaponIdle, WPN_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
    set_pdata_float(id, m_flNextAttack, WPN_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
    set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
    UTIL_PlayWeaponAnimation(id, RELOAD_ANIM)

    return HAM_IGNORED
}

stock fm_cs_get_current_weapon_ent(id)
{
    return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

stock fm_cs_get_weapon_ent_owner(ent)
{
    return get_pdata_cbase(ent, 41, 4)
}

stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
    set_pev(Player, pev_weaponanim, Sequence)
    
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    write_byte(Sequence)
    write_byte(pev(Player, pev_body))
    message_end()
}

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

stock do_screen_fade(       id, Float:fadeTime, Float:holdTime, red, green, blue, alpha, type = 0x0000       )
{
   static msgScreenFade;
   if (      !msgScreenFade    ) { msgScreenFade = get_user_msgid(    "ScreenFade"           ); }
   new fade, hold;
   fade = clamp(    floatround(     fadeTime * float(1<<12)), 0, 0xFFFF    );
   hold = clamp(     floatround(         holdTime * float(1<<12)), 0, 0xFFFF      );
   message_begin(    MSG_ONE_UNRELIABLE, msgScreenFade, _, id          );
   write_short(          fade    );
   write_short(    hold    );
   write_short(    type   );
   write_byte(      red    );
   write_byte(  green    );
   write_byte(    blue    );
   write_byte(     alpha    );
   message_end(    );
}

stock get_weapon_attackment(id, Float:output[3], Float:fDis = 40.0)
{
    new Float:vfEnd[3], viEnd[3]
    get_user_origin(id, viEnd, 3) 
    IVecFVec(viEnd, vfEnd)
    
    new Float:fOrigin[3], Float:fAngle[3]
    
    pev(id, pev_origin, fOrigin)
    pev(id, pev_view_ofs, fAngle)
    
    xs_vec_add(fOrigin, fAngle, fOrigin)
    
    new Float:fAttack[3]
    
    xs_vec_sub(vfEnd, fOrigin, fAttack)
    xs_vec_sub(vfEnd, fOrigin, fAttack)
    
    new Float:fRate
    
    fRate = fDis / vector_length(fAttack)
    xs_vec_mul_scalar(fAttack, fRate, fAttack)
    
    xs_vec_add(fOrigin, fAttack, output)
}

stock drop_weapons(id, dropwhat)
{
    static weapons[32], num, i, weaponid
    num = 0
    get_user_weapons(id, weapons, num)
    
    for (i = 0; i < num; i++)
    {
        weaponid = weapons[i]
          
        if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
        {
            static wname[32]
            get_weaponname(weaponid, wname, sizeof wname - 1)
            engclient_cmd(id, "drop", wname)
        }
    }
}
Помогите пожалуйста. Спасибо.
 

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Народ, ну что ? Ни кто не знает в чём может быть причина ?
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу