Плагин CSDM Crossbow

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

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Всем доброго дня.
Народ, помогите пожалуйста подправить плагин.
Данный плагин был для Zombie Mod'a я его немного переделал под CSDM
Вроде как всё работает, но, проблема в том, что я могу купить оружие не зависимо от того, сколько у меня денег.
Допустим оружие стоит в магазине: 9000$ но если даже у меня 10$, оно всё равно покупается, но при этом пишет в чат, мол у меня не достаточно денег для покупки.

PHP:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <xs>

#include <ColorChat>

#define ENG_NULLENT        -1
#define EV_INT_WEAPONKEY    EV_INT_impulse
#define crossbow_WEAPONKEY    974
#define MAX_PLAYERS                32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 4
const OFFSET_LINUX_WEAPONS = 4

#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            4
#define m_flNextAttack                83

#define CROSSBOW_RELOAD_TIME 5.5
#define write_coord_f(%1)    engfunc(EngFunc_WriteCoord,%1)

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)
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_m4a1",
            "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
            "weapon_m3", "weapon_sg550", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
            "weapon_ak47", "weapon_knife", "weapon_p90" }

new const Fire_Sounds[][] = { "weapons/crossbow_shoot1.wav" }
new const Sound_Zoom[] = { "weapons/zoom.wav" }

new CROSSBOW_V_MODEL[64] = "models/v_crossbow.mdl"
new CROSSBOW_P_MODEL[64] = "models/p_crossbow.mdl"
new CROSSBOW_W_MODEL[64] = "models/w_crossbow.mdl"

new CROSSBOW_STRELA_MODEL[64] = "modelsarrow.mdl"
new CROSSBOW_STRELA_NAME[32] = "crossbow_bow"

new cvar_dmg_crossbow , cvar_recoil_crossbow , cvar_clip_crossbow , cvar_crossbow_cost , cvar_crossbow_ammo , cvar_crossbow_life , cvar_crossbow_speed
new g_MaxPlayers, g_orig_event_crossbow, g_clip_ammo[33], g_has_crossbow[33]
new g_crossbow_TmpClip[33] , g_dmg[33]
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]

public plugin_init()
{
    register_plugin("CSDM Crossbow", "1.0.6", "Crock")
    register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
    register_event("CurWeapon","CurrentWeapon","be","1=1")
    RegisterHam(Ham_Item_AddToPlayer, "weapon_sg550", "fw_crossbow_AddToPlayer")
    RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
    RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
    RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
    RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
    for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
        if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_sg550", "fw_crossbow_PrimaryAttack")
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_sg550", "fw_crossbow_PrimaryAttack_Post", 1)
    RegisterHam(Ham_Item_PostFrame, "weapon_sg550", "crossbow__ItemPostFrame");
    RegisterHam(Ham_Weapon_Reload, "weapon_sg550", "crossbow__Reload");
    RegisterHam(Ham_Weapon_Reload, "weapon_sg550", "crossbow__Reload_Post", 1);
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
    register_forward(FM_SetModel, "fw_SetModel")
    register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    register_forward(FM_PlaybackEvent, "fwPlaybackEvent")

    cvar_dmg_crossbow = register_cvar("crossbow_dmg", "50.0")  // Нанесённый урон.
    cvar_recoil_crossbow = register_cvar("crossbow_recoil", "2.5")  // Разброс от стрел.
    cvar_clip_crossbow = register_cvar("crossbow_clip", "30")  // Кол-во патронов в обойме.
    cvar_crossbow_cost = register_cvar("crossbow_cost", "9000")            // Стоимость оружия.
    cvar_crossbow_ammo = register_cvar("crossbow_ammo", "90")   // Общее кол-во патронов.
    cvar_crossbow_life = register_cvar("crossbow_bowlife", "10.0") // Скоросто исчезновения стрел в стене.
    cvar_crossbow_speed = register_cvar("crossbow_speed", "900")  // Скорость полёта стрел.

    register_touch(CROSSBOW_STRELA_NAME, "*" ,"strela_touch" )
    register_think(CROSSBOW_STRELA_NAME,"remove_strela")

    register_clcmd("say /cros", "give_crossbow")
    g_MaxPlayers = get_maxplayers()
}

public plugin_precache()
{
    precache_model(CROSSBOW_V_MODEL)
    precache_model(CROSSBOW_P_MODEL)
    precache_model(CROSSBOW_W_MODEL)
    precache_model(CROSSBOW_STRELA_MODEL)
    precache_sound(Sound_Zoom)
    precache_sound("weapons/crossbow_draw.wav")
    precache_sound("weapons/crossbow_foley1.wav")
    precache_sound("weapons/crossbow_foley2.wav")
    precache_sound("weapons/crossbow_foley3.wav")
    precache_sound("weapons/crossbow_foley4.wav")
    precache_sound(Fire_Sounds[0])
    m_iBlood[0] = precache_model("sprites/blood.spr")
    m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    precache_model("sprites/640hud5.spr")
    register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}

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

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_sg550.mdl"))
    {
        static iStoredSVDID
        
        iStoredSVDID = find_ent_by_owner(ENG_NULLENT, "weapon_sg550", entity)
    
        if(!is_valid_ent(iStoredSVDID))
            return FMRES_IGNORED;
    
        if(g_has_crossbow[iOwner])
        {
            entity_set_int(iStoredSVDID, EV_INT_WEAPONKEY, crossbow_WEAPONKEY)
            g_has_crossbow[iOwner] = false
            
            entity_set_model(entity, CROSSBOW_W_MODEL)
            
            return FMRES_SUPERCEDE;
        }
    }   
    
    return FMRES_IGNORED;
}
public give_crossbow(id)
{
    drop_weapons(id, 1)

    new money = cs_get_user_money(id)
    new iWep2 = give_item(id,"weapon_sg550")

    if( iWep2 > 0 )
    {
        if(money >= get_pcvar_num(cvar_crossbow_cost))
        {
            cs_set_user_money(id, money - get_pcvar_num(cvar_crossbow_cost))
            cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_crossbow))
            cs_set_user_bpammo (id, CSW_SG550, get_pcvar_num(cvar_crossbow_ammo))
        }
        else
            ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета);

    }
    g_has_crossbow[id] = true
}

public strela_touch(ptr, ptd)
{
    if(!is_valid_ent(ptr))
        return;

    new attacker = entity_get_edict(ptr, EV_ENT_owner)

    static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3];
    pev(ptr, pev_v_angle, plrViewAngles);

    static Float:VecSrc[3], Float:VecDst[3];
    
    //VecSrc = pev->origin + pev->view_ofs;
    pev(ptr, pev_origin, PlrOrigin)
    pev(ptr, pev_view_ofs, VecSrc)
    xs_vec_add(VecSrc, PlrOrigin, VecSrc)

    //VecDst = VecDir * 8192.0;
    angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
    xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
    xs_vec_add(VecDst, VecSrc, VecDst);
    
    new hTrace = create_tr2()
    engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, ptr, hTrace)
    get_tr2(hTrace, TR_vecEndPos, VecEnd);

    if(is_user_alive(ptd) && entity_get_edict(ptr, EV_ENT_owner) != ptd)
    {
        new Float:dmg = get_pcvar_float(cvar_dmg_crossbow)

        new hitGroup = get_tr2(hTrace, TR_iHitgroup);

        switch (hitGroup) {
            case HIT_HEAD: { dmg *= 3.0; }
            case HIT_LEFTARM: { dmg *= 0.9; }
            case HIT_RIGHTARM: { dmg *= 0.9; }
            case HIT_LEFTLEG: { dmg *= 0.9; }
            case HIT_RIGHTLEG: { dmg *= 0.9; }
        }

        g_dmg[ptd] = 1
        ExecuteHamB(Ham_TakeDamage, ptd, attacker, attacker, dmg, DMG_BULLET | DMG_NEVERGIB);
        ExecuteHamB(Ham_TraceBleed, ptd, dmg, VecDir, hTrace, DMG_BULLET | DMG_NEVERGIB);
        make_blood(PlrOrigin, dmg, ptd);

        remove_entity(ptr)
    }
    if(!is_user_alive(ptd))
    {
        if(is_valid_ent(ptr))
        {
            entity_set_int(ptr, EV_INT_movetype, 0)
            entity_set_int(ptr, EV_INT_solid, SOLID_NOT)
        }
    }
}

public fw_crossbow_AddToPlayer(crossbow, id)
{
    if(!is_valid_ent(crossbow) || !is_user_connected(id))
        return HAM_IGNORED;
    
    if(entity_get_int(crossbow, EV_INT_WEAPONKEY) == crossbow_WEAPONKEY)
    {
        g_has_crossbow[id] = true
        
        entity_set_int(crossbow, EV_INT_WEAPONKEY, 0)
        
        return HAM_HANDLED;
    }
    
    return HAM_IGNORED;
}

public fw_UseStationary_Post(entity, caller, activator, use_type)
{
    if (use_type == USE_STOPPED && is_user_connected(caller))
        replace_weapon_models(caller, get_user_weapon(caller))
}

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)
}

public CurrentWeapon(id)
{
    replace_weapon_models(id, read_data(2))
    static weapon[32],Ent
    get_weaponname(read_data(2),weapon,31)
    if(g_has_crossbow[id])
    {
    Ent = find_ent_by_owner(-1,weapon,id)
    if(Ent)
    {
    static Float:Delay, Float:M_Delay
    Delay = get_pdata_float( Ent, 46, 4) * 0.3
    M_Delay = get_pdata_float( Ent, 47, 4) * 0.3
    if (Delay > 0.0)
    {
    set_pdata_float(Ent, 46, Delay, 4)
    set_pdata_float(Ent, 47, M_Delay, 4)
    }
    }
           }
}

replace_weapon_models(id, weaponid)
{
    switch (weaponid)
    {
        case CSW_SG550:
        {
            if(g_has_crossbow[id])
            {
                set_pev(id, pev_viewmodel2, CROSSBOW_V_MODEL)
                set_pev(id, pev_weaponmodel2, CROSSBOW_P_MODEL)
            }
        }
    }
}

public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
{
        if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_SG550) || !g_has_crossbow[Player])
        return FMRES_IGNORED
    
        set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
        return FMRES_HANDLED
}

public fw_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
{
    if (get_user_weapon(attacker) == CSW_SG550 && g_has_crossbow[attacker])
        return HAM_SUPERCEDE;

    
    return HAM_IGNORED;
}

public fw_crossbow_PrimaryAttack(Weapon)
{
    new Player = get_pdata_cbase(Weapon, 41, 4)
    
    if (!g_has_crossbow[Player])
        return;
    
    pev(Player,pev_punchangle,cl_pushangle[Player])
    
    g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)


    if(g_has_crossbow[Player])
    {
        new Float:push[3]
        pev(Player,pev_punchangle,push)
        xs_vec_sub(push,cl_pushangle[Player],push)
        
        xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_crossbow),push)
        xs_vec_add(push,cl_pushangle[Player],push)
        set_pev(Player,pev_punchangle,push)
        
        if (!g_clip_ammo[Player])
            return
        
        emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
        UTIL_PlayWeaponAnimation(Player, 1)
    
    }

}

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_crossbow))
        return FMRES_IGNORED
    if (!(1 <= invoker <= g_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_crossbow_PrimaryAttack_Post(Weapon)
{
    new Player = get_pdata_cbase(Weapon, 41, 4)
    
    new szClip, szAmmo
    get_user_weapon(Player, szClip, szAmmo)

    if(!is_user_alive(Player)) return;

    if(!g_has_crossbow[Player])
    {
        if(szClip > 0) emit_sound(Player, CHAN_WEAPON, "weapons/sg550-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    }   

    if(g_has_crossbow[Player])
    {
        if (!g_clip_ammo[Player])
            return

        new Float:push[3]
        pev(Player,pev_punchangle,push)
        xs_vec_sub(push,cl_pushangle[Player],push)
        
        xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_crossbow),push)
        xs_vec_add(push,cl_pushangle[Player],push)
        set_pev(Player,pev_punchangle,push)
        
        emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
        UTIL_PlayWeaponAnimation(Player, 1)

        make_strela(Player)

        set_pdata_float(Player , m_flNextAttack, 0.2 , PLAYER_LINUX_XTRA_OFF)
    }
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
    if (victim != attacker && is_user_connected(attacker))
    {
        if(get_user_weapon(attacker) == CSW_SG550)
        {
            if(g_has_crossbow[attacker] && !g_dmg[victim])
            {
                g_dmg[victim] = 0
                return HAM_SUPERCEDE;
            }   
        }   
    }

    g_dmg[victim] = 0

    return HAM_IGNORED;
}

public message_DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iAttacker, iVictim
    
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
    
    iAttacker = get_msg_arg_int(1)
    iVictim = get_msg_arg_int(2)
    
    if(!is_user_connected(iAttacker) || iAttacker == iVictim)
        return PLUGIN_CONTINUE
    
    if(equal(szTruncatedWeapon, "sg550") && get_user_weapon(iAttacker) == CSW_SG550)
    {
        if(g_has_crossbow[iAttacker])
            set_msg_arg_string(4, "sg550")
    }
        
    return PLUGIN_CONTINUE
}

public make_strela(id)
{
    static Float:origin[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3];
    static Float:OriginX[3] , originplayerent[3] , Float:originend[3]
    get_user_origin(id,originplayerent,3)
    originend[0] = float(originplayerent[0])
    originend[1] = float(originplayerent[1])
    originend[2] = float(originplayerent[2])
    pev(id, pev_v_angle, angles);
    pev(id, pev_origin, OriginX);
    engfunc(EngFunc_MakeVectors, angles);

    global_get(glb_v_forward, v_forward);
    global_get(glb_v_right, v_right);
    global_get(glb_v_up, v_up);

    //m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
    pev(id, pev_origin, player_origin);
    pev(id, pev_view_ofs, player_view_offset);
    xs_vec_add(player_origin, player_view_offset, gun_position);

    xs_vec_mul_scalar(v_forward, 13.0, v_forward);
    xs_vec_mul_scalar(v_right, 3.0, v_right);
    xs_vec_mul_scalar(v_up, -5.0, v_up);

    xs_vec_add(gun_position, v_forward, origin);
    xs_vec_add(origin, v_right, origin);
    xs_vec_add(origin, v_up, origin);

    new Float:StartOrigin[3], Float:Angle[3]
            
    StartOrigin[0] = origin[0];
    StartOrigin[1] = origin[1];
    StartOrigin[2] = origin[2];
            
    entity_get_vector(id, EV_VEC_v_angle, Angle)

    new strela = create_entity("info_target")
    entity_set_string(strela, EV_SZ_classname, CROSSBOW_STRELA_NAME)
    entity_set_model(strela, CROSSBOW_STRELA_MODEL)
    entity_set_origin(strela, StartOrigin)
    entity_set_vector(strela, EV_VEC_angles, Angle)
        
    new Float:MinBox[3] = {-1.0, -1.0, -1.0}
    new Float:MaxBox[3] = {1.0, 1.0, 1.0}
    entity_set_vector(strela, EV_VEC_mins, MinBox)
    entity_set_vector(strela, EV_VEC_maxs, MaxBox)
    
    entity_set_int(strela, EV_INT_solid, 2)
    entity_set_int(strela, EV_INT_movetype, 5)

    entity_set_edict(strela, EV_ENT_owner , id)
        
    static Float:vec[3]
    aim_at_origin(strela, originend ,vec)
    engfunc(EngFunc_MakeVectors, vec)
    global_get(glb_v_forward, vec)
    vec[0] *= float(get_pcvar_num(cvar_crossbow_speed))
    vec[1] *= float(get_pcvar_num(cvar_crossbow_speed))
    vec[2] *= float(get_pcvar_num(cvar_crossbow_speed))
    set_pev(strela, pev_velocity, vec)

    entity_set_float(strela, EV_FL_nextthink, get_gametime() + get_pcvar_float(cvar_crossbow_life))

}

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, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
}

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()
}

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

    if (!g_has_crossbow[id])
        return HAM_IGNORED;

    new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

    new iBpAmmo = cs_get_user_bpammo(id, CSW_SG550);
    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(get_pcvar_num(cvar_clip_crossbow) - iClip, iBpAmmo)
    
        set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
        cs_set_user_bpammo(id, CSW_SG550, iBpAmmo-j);
        
        set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
        fInReload = 0
    }

    return HAM_IGNORED;
}

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

    if (!g_has_crossbow[id])
        return HAM_IGNORED;

    g_crossbow_TmpClip[id] = -1;

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

    if (iBpAmmo <= 0)
        return HAM_SUPERCEDE;

    if (iClip >= get_pcvar_num(cvar_clip_crossbow))
        return HAM_SUPERCEDE;


    g_crossbow_TmpClip[id] = iClip;

    return HAM_IGNORED;
}

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

    if (!g_has_crossbow[id])
        return HAM_IGNORED;

    if (g_crossbow_TmpClip[id] == -1)
        return HAM_IGNORED;

    set_pdata_int(weapon_entity, m_iClip, g_crossbow_TmpClip[id], WEAP_LINUX_XTRA_OFF)

    set_pdata_float(weapon_entity, m_flTimeWeaponIdle, CROSSBOW_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

    set_pdata_float(id, m_flNextAttack, CROSSBOW_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

    set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

    // relaod animation
    UTIL_PlayWeaponAnimation(id, 3)

    return HAM_IGNORED;
}

public client_connect(id)    reset_vars(id)
public client_disconnect(id) reset_vars(id)
public plugin_natives () register_native("give_weapon_crossbow", "native_give_weapon_add", 1)
public native_give_weapon_add(id) give_crossbow(id)
public remove_strela(ent) remove_entity(ent)

public reset_vars(id)
{
    g_has_crossbow[id] = false
    g_dmg[id] = 0
}

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))
          {
               static wname[32]
               get_weaponname(weaponid, wname, sizeof wname - 1)
               engclient_cmd(id, "drop", wname)
          }
     }
}

stock make_blood(const Float:vTraceEnd[3], Float:Damage, hitEnt) {
    new bloodColor = ExecuteHam(Ham_BloodColor, hitEnt);
    if (bloodColor == -1 || !is_user_alive(hitEnt))
        return;

    new amount = floatround(Damage);

    amount *= 2; //according to HLSDK

    message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
    write_byte(TE_BLOODSPRITE);
    write_coord(floatround(vTraceEnd[0]));
    write_coord(floatround(vTraceEnd[1]));
    write_coord(floatround(vTraceEnd[2]));
    write_short(m_iBlood[1]);
    write_short(m_iBlood[0]);
    write_byte(bloodColor);
    write_byte(min(max(3, amount/10), 16));
    message_end();
}

stock aim_at_origin(id, Float:target[3], Float:angles[3])
{
    static Float:vec[3]
    pev(id,pev_origin,vec)
    vec[0] = target[0] - vec[0]
    vec[1] = target[1] - vec[1]
    vec[2] = target[2] - vec[2]
    engfunc(EngFunc_VecToAngles,vec,angles)
    angles[0] *= -1.0, angles[2] = 0.0
}
Я так понял, проблема заключается тут:

PHP:
public give_crossbow(id)

{

    drop_weapons(id, 1)


    new money = cs_get_user_money(id)

    new iWep2 = give_item(id,"weapon_sg550")


    if( iWep2 > 0 )

    {

        if(money >= get_pcvar_num(cvar_crossbow_cost))

        {

            cs_set_user_money(id, money - get_pcvar_num(cvar_crossbow_cost))

            cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_crossbow))

            cs_set_user_bpammo (id, CSW_SG550, get_pcvar_num(cvar_crossbow_ammo))

        }

        else

            ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета");


    }

    g_has_crossbow[id] = true

}
Но не могу допетрить. Я так понял, не хватает проверки на то, сколько у меня имеется денег, чтобы купить или не купить, если у меня меньше денег, чем задано кваром.
Само сообщение: "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета" показывает, но денег то у меня не хватает, а оружие всё равно выдаёт.
Помогите пожалуйста.
И ещё маленькая просьба, можно добавить ещё одно сообщение при покупке: "^01[^04Сервер^01] Ты купил ^04Арбалет"
Спасибо.
 

BalbuR

Пользователь
Регистрация
26 Июл 2017
Сообщения
131
Симпатии
25
Пол
Мужской
public give_crossbow(id) { drop_weapons(id, 1) new money = cs_get_user_money(id) new iWep2 = give_item(id,"weapon_sg550") if( iWep2 > 0 ) { if(money >= get_pcvar_num(cvar_crossbow_cost)) { cs_set_user_money(id, money - get_pcvar_num(cvar_crossbow_cost)) cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_crossbow)) cs_set_user_bpammo (id, CSW_SG550, get_pcvar_num(cvar_crossbow_ammo)) } else ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета); } g_has_crossbow[id] = true }
PHP:
public give_crossbow(id)
{
    new money = cs_get_user_money(id)   
    if(money >= get_pcvar_num(cvar_crossbow_cost))
    {       
        drop_weapons(id, 1)
        new iWep2 = give_item(id,"weapon_sg550")
        if( iWep2 > 0 )
        {
            cs_set_user_money(id, money - get_pcvar_num(cvar_crossbow_cost))
            cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_crossbow))
            cs_set_user_bpammo (id, CSW_SG550, get_pcvar_num(cvar_crossbow_ammo))
            g_has_crossbow[id] = true
        }
    } else ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета);
}
 

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Ошибка в этой строке:
PHP:
        }    } else ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета);
}
 

BalbuR

Пользователь
Регистрация
26 Июл 2017
Сообщения
131
Симпатии
25
Пол
Мужской
наверное надо написать что за ошибка, чтобы я не гадал
 

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Строка 177
error 037: invalid string (possibly non-terminated string)
- неправильная строка.
5467987.png45к76078047675.png
 

BalbuR

Пользователь
Регистрация
26 Июл 2017
Сообщения
131
Симпатии
25
Пол
Мужской
PHP:
public give_crossbow(id)
{
    new money = cs_get_user_money(id)   
    if(money >= get_pcvar_num(cvar_crossbow_cost))
    {       
        drop_weapons(id, 1)
        new iWep2 = give_item(id,"weapon_sg550")
        if( iWep2 > 0 )
        {
            cs_set_user_money(id, money - get_pcvar_num(cvar_crossbow_cost))
            cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_crossbow))
            cs_set_user_bpammo (id, CSW_SG550, get_pcvar_num(cvar_crossbow_ammo))
            g_has_crossbow[id] = true
        }
    } else ColorChat(id, BLUE, "^01[^04Сервер^01] У тебя не хватает денег для покупки ^04Арбалета");
}
 
  • Мне нравится
Симпатии: urpok

urpok

Пользователь
Регистрация
16 Июл 2017
Сообщения
46
Симпатии
6
Пол
Мужской
Спасибо БОЛЬШОЕ !!! Всё работает как надо.
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу