нужна помощь [dispencer]раздатчик

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
21
Реакции
-5
Плагин раздатчик здоровья и брони или Dispenser , нужна помощь для создания скрипта для раздачи патронов

Код:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <engine>
#include <fun>
#include <xs>


#if AMXX_VERSION_NUM < 183
    #include <colorchat>

    #define print_team_default DontChange
    #define print_team_grey Grey
    #define print_team_red Red
    #define print_team_blue Blue

    #include <dhudmessage>
#endif

new g_iCvar[30], g_Flag[18], g_pcvar_flag;
new Float:g_fTime[33];


#define PLUGIN_VERSION                  "#1.0.5"
#define PLUGIN_PREFIX                   "[Раздатчик]"
#define BREAK_COMPUTER                  6
#define HUD_DELAYTIME                   0.2
#define TASK_PLANT                              15100

#define is_valid_player(%1) (1 <= %1 <= gMaxPlayers)

enum
{
    STATUS_BUILDING,
    STATUS_ACTIVE
}

new const gDamageSounds[][] = {
    "debris/metal1.wav",
    "debris/metal2.wav",
    "debris/metal3.wav",
};

#define Sound_ignor "nova/sentry/ignor.wav"
#define Sprite_Chastic "sprites/nova/spr_2.spr"

new g_Chastic;
new const gDispenserClassnameHpArm[] = "NiceDispenserHpArm";
new const gDispenserActive[] = "buttons/button9.wav";
new const gDispenserDestroy[] = "grab_bury.wav";
new const gHealingSprite[] = "sprites/dispensers.spr";

new gBeamcolor[MAX_PLAYERS + 1][3];
new bDispenserHpArm[MAX_PLAYERS + 1];
new max_pcvar;

new gHealingBeam, gMaxPlayers;
new iEntity;

new const SPRITELIST[][] = {
    "sprites/kf/b.spr",
    "sprites/kf/g.spr",
    "sprites/kf/r.spr",
    "sprites/kf/y.spr",
};

new g_pSprites[sizeof SPRITELIST];


new g_model_1_ct, g_model_2_ct, g_model_3_ct, g_model_1_t, g_model_2_t, g_model_3_t;
new Model_disp_1_ct[90], Model_disp_2_ct[90], Model_disp_3_ct[90];
new Model_disp_1_t[90], Model_disp_2_t[90], Model_disp_3_t[90];

new g_vampir[3], g_vampir_max[3];

new Float:g_HEALTHS[4];
new g_bar_time;
new g_iSPR_Smoke3;

public plugin_init()
{
    register_plugin("Build Dispenser", PLUGIN_VERSION, "NOVA");
    register_dictionary("nv_dispenser.txt");

    register_event("TextMsg", "EVENT_TextMsg", "a", "2&#Game_C", "2&#Game_w", "2&#Game_will_restart_in");
    register_logevent("LOG_RoundEnd", 2, "1=Round_End");

    register_forward(FM_TraceLine, "fw_TraceLine_Post", 1);
    register_forward(FM_CmdStart, "fm_cmdstart");

    register_touch(gDispenserClassnameHpArm, "player", "fw_DispenserTouch");

    RegisterHam(Ham_TakeDamage, "info_target", "bacon_TakeDamage", 1);
    RegisterHam(Ham_TakeDamage, "info_target", "bacon_TakeDamagePre", 0);
    RegisterHam(Ham_TraceAttack, "info_target", "bacon_TraceAttack");

    register_think(gDispenserClassnameHpArm, "DispenserHpArmThink");

    register_clcmd("dhealth", "HpArmDispenserBuild");
    register_clcmd("radio2", "HpArmDispenserBuild");
    register_clcmd("say /health", "HpArmDispenserBuild");
    g_bar_time = get_user_msgid("BarTime2");
    gMaxPlayers = get_maxplayers();

    g_iCvar[0] = register_cvar("disp_reward", "3000");                 //Награда за разрушение
    g_iCvar[1] = register_cvar("disp_cost", "3000");                   //Цена раздатчика
    g_iCvar[2] = register_cvar("disp_cost_up", "4000");                //Цена Улудшения
    g_iCvar[24] = register_cvar("disp_cost_up2", "4000");
    g_iCvar[3] = register_cvar("disp_radius", "400");                  //Радиус лечения
    g_iCvar[4] = register_cvar("disp_hp_1", "900.0");                  //Здоровие раздатчика 1 уровень
    g_iCvar[5] = register_cvar("disp_hp_2", "1500.0");                 //Здоровие раздатчика 2 уровень
    g_iCvar[6] = register_cvar("disp_hp_3", "2000.0");                 //Здоровие раздатчика 3 уровень
    g_iCvar[7] = register_cvar("disp_hp_p_max_1", "200");                      //Здоровие на которое лечит раздатчик 1 уровня
    g_iCvar[8] = register_cvar("disp_hp_p_max_2", "400");                      //Здоровие на которое лечит раздатчик 2 уровня
    g_iCvar[9] = register_cvar("disp_hp_p_max_3", "600");                      //Здоровие на которое лечит раздатчик 3 уровня
    g_iCvar[10] = register_cvar("disp_ap_p_max_1", "200");                     //Браня на которую лечит раздатчик 1 уровня
    g_iCvar[11] = register_cvar("disp_ap_p_max_2", "400");                     //Браня на которую лечит раздатчик 2 уровня
    g_iCvar[12] = register_cvar("disp_ap_p_max_3", "600");                     //Браня на которую лечит раздатчик 3 уровня
    g_iCvar[13] = register_cvar("disp_ap_p_speed_1", "1");
    g_iCvar[14] = register_cvar("disp_ap_p_speed_2", "1");
    g_iCvar[15] = register_cvar("disp_ap_p_speed_3", "1");
    g_iCvar[16] = register_cvar("disp_hp_p_speed_1", "1");
    g_iCvar[17] = register_cvar("disp_hp_p_speed_2", "1");
    g_iCvar[18] = register_cvar("disp_hp_p_speed_3", "1");
    g_iCvar[19] = register_cvar("disp_hp_e_speed_1", "1");
    g_iCvar[20] = register_cvar("disp_hp_e_speed_2", "1");
    g_iCvar[21] = register_cvar("disp_hp_e_speed_3", "1");
    g_iCvar[22] = register_cvar("disp_rem_cost", "1");
    g_iCvar[23] = register_cvar("disp_rem_speed", "5");
    g_iCvar[25] = register_cvar("disp_ugol_float", "50.0");
    g_iCvar[26] = register_cvar("disp_up_time", "2.5");
    max_pcvar = register_cvar("disp_max", "2");

    g_pcvar_flag = register_cvar("disp_flag", "t");
    g_vampir[0] = register_cvar("disp_vampir_1", "1");
    g_vampir[1] = register_cvar("disp_vampir_2", "1");
    g_vampir[2] = register_cvar("disp_vampir_3", "1");
    g_vampir_max[0] = register_cvar("disp_vampir_max_1", "50");
    g_vampir_max[1] = register_cvar("disp_vampir_max_2", "30");
    g_vampir_max[2] = register_cvar("disp_vampir_max_3", "20");

    g_HEALTHS[0] = get_pcvar_float(register_cvar("nv_sg_hp_1", "3000.0"));
    g_HEALTHS[1] = get_pcvar_float(register_cvar("nv_sg_hp_2", "4000.0"));
    g_HEALTHS[2] = get_pcvar_float(register_cvar("nv_sg_hp_3", "6000.0"));
    g_HEALTHS[3] = get_pcvar_float(register_cvar("nv_sg_hp_4", "8000.0"));

}

public plugin_cfg() {
    new configsdir[128];
    get_localinfo("amxx_configsdir", configsdir, 127);
    server_cmd("exec %s/nova/dispenser.cfg", configsdir);
    server_exec();
    get_pcvar_string(g_pcvar_flag, g_Flag, 17);
}


public plugin_natives() {
    set_native_filter("native_filter");
}

public native_filter(const name[], index, trap) {
    if (!trap)
    {
        return PLUGIN_HANDLED;
    }
    return PLUGIN_CONTINUE;
}



new remont_is[33];
public fm_cmdstart(id, uc_handle, seed) {
    if (!is_user_alive(id)) return;
    if (g_fTime[id] > get_gametime()) return;

    new buttons = get_uc(uc_handle, UC_Buttons);

    if (buttons & IN_RELOAD)
    {
        new target, body;
        get_user_aiming(id, target, body, 128);

        static ClassName[32];
        pev(target, pev_classname, ClassName, charsmax(ClassName));
        if (equal(ClassName, gDispenserClassnameHpArm))
        {
            g_fTime[id] = get_gametime() + 0.000103;
            new iTeam = pev(target, pev_team);

            if (_:cs_get_user_team(id) != iTeam)
                return;

            new Float:Health;
            pev(target, pev_health, Health);

            remont_is[id] = 1;
            if (cs_get_user_money(id) < get_pcvar_num(g_iCvar[22])) {
                set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
                show_dhudmessage(id, "[%d$]", get_pcvar_num(g_iCvar[22]));
                return;
            }

            new Float:Max = get_pcvar_float(g_iCvar[pev(target, pev_euser4) + 3]);

            if (Health >= Max) return;

            if (Health >= Max - get_pcvar_num(g_iCvar[23])) {

                set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
                show_dhudmessage(id, "[repaired]");
                Health = Max;
                message_begin(MSG_ONE, g_bar_time, _, id);
                write_short(10000);
                write_short(100);
                message_end();
            } else {
                new Float:max_pro = Max / 100;
                new Float:progres_bar = Health / max_pro;
                message_begin(MSG_ONE, g_bar_time, _, id);
                write_short(10000);
                write_short(floatround(progres_bar));
                message_end();
                Health += get_pcvar_num(g_iCvar[23]);
            }
            g_fTime[id] = get_gametime() + 0.000103;
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(g_iCvar[22]));
            set_pev(target, pev_health, Health);
        }
    } else {
        if (remont_is[id] == 1) {
            remont_is[id] = 0;
            message_begin(MSG_ONE, 108, _, id);
            write_byte(0);
            write_byte(0);
            message_end();
        }
    }
}

public client_disconnected(id) {
    new iEnt;
    while ((iEnt = find_ent_by_class(iEnt, gDispenserClassnameHpArm)))
    {
        new iOwner = pev(iEnt, pev_iuser2);
        if (id == iOwner)
        {
            bDispenserHpArm[id]--;
            set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME);
        }
    }

}

public plugin_precache()
{
    g_iSPR_Smoke3 = precache_model("sprites/black_smoke4.spr");
    g_model_1_ct = 0;
    g_model_2_ct = 0;
    g_model_3_ct = 0;
    g_model_1_t = 0;
    g_model_2_t = 0;
    g_model_3_t = 0;

    new iFile = fopen("addons/amxmodx/configs/nova/dispenser.cfg", "rt");
    if (iFile) {
        new szLineBuffer[600];
        while (!(feof(iFile))) {
            fgets(iFile, szLineBuffer, charsmax(szLineBuffer));

            if (!(szLineBuffer[0]) || szLineBuffer[0] == ';' || szLineBuffer[0] == '#')
            {
                continue;
            }
            new Imeil[600];
            new Model[600];

            parse(szLineBuffer, Imeil, charsmax(Imeil), Model, charsmax(Model));

            if (equal(Imeil, "mdl_disp_1_t")) {
                g_model_1_t = 1;
                formatex(Model_disp_1_t, charsmax(Model_disp_1_t), "%s", Model);
            } if (equal(Imeil, "mdl_disp_2_t")) {
                g_model_2_t = 1;
                formatex(Model_disp_2_t, charsmax(Model_disp_2_t), "%s", Model);
            } if (equal(Imeil, "mdl_disp_3_t")) {
                g_model_3_t = 1;
                formatex(Model_disp_3_t, charsmax(Model_disp_3_t), "%s", Model);
            } if (equal(Imeil, "mdl_disp_1_ct")) {
                g_model_1_ct = 1;
                formatex(Model_disp_1_ct, charsmax(Model_disp_1_ct), "%s", Model);
            } if (equal(Imeil, "mdl_disp_2_ct")) {
                g_model_2_ct = 2;
                formatex(Model_disp_2_ct, charsmax(Model_disp_2_ct), "%s", Model);
            } if (equal(Imeil, "mdl_disp_3_ct")) {
                g_model_3_ct = 3;
                formatex(Model_disp_3_ct, charsmax(Model_disp_3_ct), "%s", Model);
            }
        }
    }

    if (g_model_1_t == 0) {
        formatex(Model_disp_1_t, charsmax(Model_disp_1_t), "models/nova/dispenser/dispenser_1_lvl_te.mdl");
    } if (g_model_2_t == 0) {
        formatex(Model_disp_2_t, charsmax(Model_disp_2_t), "models/nova/dispenser/dispenser_2_lvl_te.mdl");
    } if (g_model_3_t == 0) {
        formatex(Model_disp_3_t, charsmax(Model_disp_3_t), "models/nova/dispenser/dispenser_3_lvl_te.mdl");
    } if (g_model_1_ct == 0) {
        formatex(Model_disp_1_ct, charsmax(Model_disp_1_ct), "models/nova/dispenser/dispenser_1_lvl_ct.mdl");
    } if (g_model_2_ct == 0) {
        formatex(Model_disp_2_ct, charsmax(Model_disp_2_ct), "models/nova/dispenser/dispenser_2_lvl_ct.mdl");
    } if (g_model_3_ct == 0) {
        formatex(Model_disp_3_ct, charsmax(Model_disp_3_ct), "models/nova/dispenser/dispenser_3_lvl_ct.mdl");
    }

    precache_model(Model_disp_1_ct);
    precache_model(Model_disp_2_ct);
    precache_model(Model_disp_3_ct);
    precache_model(Model_disp_1_t);
    precache_model(Model_disp_2_t);
    precache_model(Model_disp_3_t);
    precache_sound(Sound_ignor);
    precache_sound(gDispenserActive);
    precache_sound(gDispenserDestroy);
    g_Chastic = precache_model(Sprite_Chastic);
    new i;
    for (i = 0; i < sizeof gDamageSounds; i++)
    {
        precache_sound(gDamageSounds[i]);
    }
    for (new i; i < sizeof SPRITELIST; i++) {
        g_pSprites[i] = precache_model(SPRITELIST[i]);
    }
    gHealingBeam = precache_model(gHealingSprite);
}

new Float: Trace_lini[999];
public fw_TraceLine_Post(Float:v1[3], Float:v2[3], noMonsters, id)
{
    if (!is_valid_player(id) || is_user_bot(id) || !is_user_alive(id)) return FMRES_IGNORED;
    if (Trace_lini[id] > get_gametime()) return FMRES_IGNORED;

    Trace_lini[id] = get_gametime() + 0.5;
    new iHitEnt = get_tr(TR_pHit);

    if (iHitEnt <= gMaxPlayers || !pev_valid(iHitEnt)) return FMRES_IGNORED;
    new sClassname[32];
    pev(iHitEnt, pev_classname, sClassname, charsmax(sClassname));

    if (!equal(sClassname, gDispenserClassnameHpArm)) return FMRES_IGNORED;

    new iTeam = pev(iHitEnt, pev_team);

    if (_:cs_get_user_team(id) != iTeam) return FMRES_IGNORED;
    new iHealth = pev(iHitEnt, pev_health);

    if (iHealth <= 0) return FMRES_IGNORED;

    new iOwner = pev(iHitEnt, pev_iuser2);
    if (!is_user_connected(iOwner)) return FMRES_IGNORED;

    new sName[33];
    get_user_name(iOwner, sName, charsmax(sName));
    new iLevel = pev(iHitEnt, pev_euser4);
    set_hudmessage(255, 255, 255, -1.0, 0.54, 0, 0.0, 0.7, 0.0, 0.0);
    show_hudmessage(id, "%L", id, "DISP_INFO", sName, iHealth, iLevel);
    return FMRES_IGNORED;
}

new Float: Disp_toush_up[33];

public fw_DispenserTouch(ent, id)
{
    if (!is_valid_player(id) || is_user_bot(id) || !is_user_alive(id)) return;

    if (Disp_toush_up[id] > get_gametime()) return;

    Disp_toush_up[id] = get_gametime() + get_pcvar_float(g_iCvar[26]);

    if (pev(ent, pev_team) != _:cs_get_user_team(id))
        return;

    new iOwner = pev(ent, pev_iuser2);
    /*
       if(get_user_flags(id) & read_flags(g_Flag)){
            if ( iOwner == id ){
                    emit_sound(id,0,Sound_ignor,1.0, ATTN_NORM, 0, PITCH_NORM )
                    client_print_color(id,print_team_blue,"%L", id, "DISP_INFORM_1" )
                    return
            }
       }
     */
    if (pev(ent, pev_euser4) >= 3) return;

    new money = cs_get_user_money(id);

    if (pev(ent, pev_euser4) == 1) {
        if (money < get_pcvar_num(g_iCvar[2])) {
            emit_sound(id, 0, Sound_ignor, 1.0, ATTN_NORM, 0, PITCH_NORM);
            set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
            show_dhudmessage(id, "[%d$]", get_pcvar_num(g_iCvar[2]));
            return;
        }

        set_pev(ent, pev_euser4, 2);
        set_pev(ent, pev_health, get_pcvar_float(g_iCvar[5]));
        switch (_:cs_get_user_team(id)) {
            case 1: entity_set_model(ent, Model_disp_2_t);
            case 2: entity_set_model(ent, Model_disp_2_ct);
        }
        engfunc(EngFunc_SetSize, ent, Float:{ -12.0, -10.0, -1.0 }, Float:{ 5.0, 5.0, 50.0 });
        emit_sound(ent, CHAN_STATIC, gDispenserActive, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);


        new Float:flAngles[3];
        pev(ent, pev_angles, flAngles);
        flAngles[1] += get_pcvar_float(g_iCvar[25]);
        set_pev(ent, pev_angles, flAngles);

        if (!is_user_connected(iOwner)) return;
        cs_set_user_money(id, money - get_pcvar_num(g_iCvar[2]));

        set_pev(ent, pev_iuser1, id);
        new sUpgraderName[32];
        get_user_name(id, sUpgraderName, charsmax(sUpgraderName));
        set_dhudmessage(255, 255, 255, -1.0, 0.35, 0, 0.0, 0.2, 0.4, 0.2);
        show_dhudmessage(iOwner, "%s [update you dispencer to lvl] 2", sUpgraderName);
        return;
    }

    if (pev(ent, pev_euser4) == 2) {
        set_pev(ent, pev_iuser1, id);
        /*
           if(id == pev( ent, pev_iuser1)){
                if(get_user_flags(id) & read_flags(g_Flag)){
                        emit_sound(id,0,Sound_ignor,1.0, ATTN_NORM, 0, PITCH_NORM )
                        client_print_color(id,print_team_blue,"%L", id, "DISP_INFORM_3" )
                }
           }
         */
        if (money < get_pcvar_num(g_iCvar[24])) {
            emit_sound(id, 0, Sound_ignor, 1.0, ATTN_NORM, 0, PITCH_NORM);
            set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
            show_dhudmessage(id, "[%d$]", get_pcvar_num(g_iCvar[24]));
            return;
        }

        set_pev(ent, pev_euser4, 3);
        set_pev(ent, pev_health, get_pcvar_float(g_iCvar[6]));
        switch (_:cs_get_user_team(id)) {
            case 1: entity_set_model(ent, Model_disp_3_t);
            case 2: entity_set_model(ent, Model_disp_3_ct);
        }
        engfunc(EngFunc_SetSize, ent, Float:{ -12.0, -10.0, -1.0 }, Float:{ 5.0, 5.0, 50.0 });
        emit_sound(ent, CHAN_STATIC, gDispenserActive, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

        new Float:flAngles[3];
        pev(ent, pev_angles, flAngles);
        flAngles[1] += get_pcvar_float(g_iCvar[25]);
        set_pev(ent, pev_angles, flAngles);

        if (!is_user_connected(iOwner)) return;

        cs_set_user_money(id, money - get_pcvar_num(g_iCvar[2]));

        new sUpgraderName[32];
        get_user_name(id, sUpgraderName, charsmax(sUpgraderName));
        set_dhudmessage(255, 255, 255, -1.0, 0.35, 0, 0.0, 0.2, 0.4, 0.2);
        show_dhudmessage(iOwner, "%s [update you dispencer to lvl] 3", sUpgraderName);
    }

}

public HpArmDispenserBuild(id)
{

    if (!is_user_alive(id)) {
        set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
        show_dhudmessage(id, "dead");
        return PLUGIN_CONTINUE;
    }

    if (!(pev(id, pev_flags) & FL_ONGROUND)) return PLUGIN_HANDLED;

    if (pev(id, pev_flags) & FL_DUCKING || pev(id, pev_oldbuttons) & IN_DUCK) return PLUGIN_HANDLED;


    if (bDispenserHpArm[id] >= get_pcvar_num(max_pcvar)) {
        set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
        show_dhudmessage(id, "[limit]");
        return PLUGIN_HANDLED;
    }

    new iMoney = cs_get_user_money(id);
    new iCost = get_pcvar_num(g_iCvar[1]);

    if (iMoney < iCost) {
        set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.4, 0.2);
        show_dhudmessage(id, "[%d$]", iCost);
        return PLUGIN_HANDLED;
    }

    new Float:flPlayerOrigin[3];
    pev(id, pev_origin, flPlayerOrigin);

    new Float:flHealth = get_pcvar_float(g_iCvar[4]);
    iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));

    if (!pev_valid(iEntity))
        return PLUGIN_HANDLED;

    flPlayerOrigin[2] -= 35.0;

    switch (_:cs_get_user_team(id)) {
        case 1: entity_set_model(iEntity, Model_disp_1_t);
        case 2: entity_set_model(iEntity, Model_disp_1_ct);
    }

    new szName[32];
    set_pev(iEntity, pev_classname, gDispenserClassnameHpArm);
    engfunc(EngFunc_SetSize, iEntity, Float:{ -12.0, -10.0, -1.0 }, Float:{ 5.0, 5.0, 50.0 });
    set_pev(iEntity, pev_origin, flPlayerOrigin);
    set_pev(iEntity, pev_solid, SOLID_NOT);
    set_pev(iEntity, pev_movetype, MOVETYPE_TOSS);
    set_pev(iEntity, pev_health, flHealth);
    set_pev(iEntity, pev_takedamage, DAMAGE_YES);
    set_pev(iEntity, pev_iuser2, id);
    set_pev(iEntity, pev_team, _:cs_get_user_team(id));
    set_pev(iEntity, pev_euser4, 1);   // уровень
    set_pev(iEntity, pev_nextthink, get_gametime() + 0.1);

    bDispenserHpArm[id]++;

    set_task(2.0, "BuildDispenserSolid", iEntity);
    cs_set_user_money(id, iMoney - iCost, 1);
    get_user_name(id, szName, charsmax(szName));
    return PLUGIN_HANDLED;
}

public bacon_TakeDamagePre(ent, idinflictor, idattacker, Float:damage, damagebits)
{
    new szClassname[32];
    pev(ent, pev_classname, szClassname, charsmax(szClassname));

    if (equal(szClassname, gDispenserClassnameHpArm)) {
        new iOwner = pev(ent, pev_iuser2);

        if (!is_user_connected(iOwner) || 1 > iOwner > 32 || !is_user_connected(idattacker) || 1 > idattacker > 32) return HAM_SUPERCEDE;

        if (cs_get_user_team(iOwner) == cs_get_user_team(idattacker) && idattacker != iOwner) return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public bacon_TakeDamage(ent, idinflictor, idattacker, Float:damage, damagebits)
{
    if (!pev_valid(ent))
        return HAM_IGNORED;

    new szClassname[32];
    pev(ent, pev_classname, szClassname, charsmax(szClassname));

    if (equal(szClassname, gDispenserClassnameHpArm))
    {
        new iOwner = pev(ent, pev_iuser2);

        if (!is_user_connected(iOwner) || 1 > iOwner > 32 || !is_user_connected(idattacker) || 1 > idattacker > 32) return HAM_SUPERCEDE;

        if (cs_get_user_team(iOwner) == cs_get_user_team(idattacker) && idattacker != iOwner) return HAM_SUPERCEDE;

        new Float:entorigin[3];
        pev(ent, pev_origin, entorigin);

        message_begin(MSG_ALL, SVC_TEMPENTITY);
        write_byte(TE_SPRITETRAIL);
        engfunc(EngFunc_WriteCoord, entorigin[0] + random_num(-10, 10));
        engfunc(EngFunc_WriteCoord, entorigin[1] + random_num(-10, 10));
        engfunc(EngFunc_WriteCoord, entorigin[2] + random_num(10, 30));
        engfunc(EngFunc_WriteCoord, entorigin[0] - random_num(-100, 100));
        engfunc(EngFunc_WriteCoord, entorigin[1] - random_num(-100, 100));
        engfunc(EngFunc_WriteCoord, entorigin[2] + random_num(-100, 100));
        write_short(g_Chastic); // Индекс спрайта из прекеша (index of precached sprite)
        write_byte(3);  //колличество спрайтов
        write_byte(1); //вроде время сущиствования
        write_byte(1); //размер
        write_byte(1); // 10's
        write_byte(5); // 10's
        message_end();

        if (pev(ent, pev_health) <= 0.0) {
            new szName[32];
            get_user_name(idattacker, szName, charsmax(szName));
            new Float:flOrigin[3];
            pev(ent, pev_origin, flOrigin);
            set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME);

            if (idattacker == iOwner) {
                set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.7, 0.2);
                show_dhudmessage(iOwner, "[dispencer destroyed]");
            } else {
                set_dhudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 0.2, 0.7, 0.2);
                show_dhudmessage(iOwner, "%s [destroyed you dispencer]", szName);
            }
            //set_hudmessage( 255, 255, 255, -1.0, 0.50, 0, 0.0, 0.2, 0.4, 0.2 )
            //show_dhudmessage ( idattacker, "Вы получили деньги за уничтожение Раздачика!" )
            cs_set_user_money(idattacker, min(cs_get_user_money(idattacker) + get_pcvar_num(g_iCvar[0]), 999999));
            for (new i; i < sizeof g_pSprites; i++) {
                CREATE_SPRITETRAIL(flOrigin, g_pSprites[i]);
            }
            emit_sound(ent, CHAN_STATIC, gDispenserDestroy, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
            bDispenserHpArm[iOwner]--;
        }
        emit_sound(ent, CHAN_STATIC, gDamageSounds[random_num(0, charsmax(gDamageSounds))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }
    return HAM_IGNORED;
}

stock CREATE_SPRITETRAIL(Float:fOrigin[3], pSprite, iReliable = 0) {
    message_begin(iReliable ? MSG_ALL : MSG_BROADCAST, SVC_TEMPENTITY);
    write_byte(TE_SPRITETRAIL);
    engfunc(EngFunc_WriteCoord, fOrigin[0]);
    engfunc(EngFunc_WriteCoord, fOrigin[1]);
    engfunc(EngFunc_WriteCoord, fOrigin[2]);
    engfunc(EngFunc_WriteCoord, fOrigin[0]);
    engfunc(EngFunc_WriteCoord, fOrigin[1]);
    engfunc(EngFunc_WriteCoord, fOrigin[2] + 5.0);
    write_short(pSprite); // Индекс спрайта из прекеша (index of precached sprite)
    write_byte(12);
    write_byte(20); // 0.1's
    write_byte(4);
    write_byte(25); // 10's
    write_byte(20); // 10's
    message_end();
}

public bacon_TraceAttack(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], iTr, iDamageBits) {
    new szClassname[32];
    pev(iVictim, pev_classname, szClassname, charsmax(szClassname));
    if (equal(szClassname, gDispenserClassnameHpArm)) {
        new Float:flEndOrigin[3];
        get_tr2(iTr, TR_vecEndPos, flEndOrigin);
        UTIL_Sparks(flEndOrigin);
    }
    return HAM_IGNORED;
}

public DispenserHpArmThink(iEnt)
{
    new Float:origin[3];
    pev(iEnt, pev_origin, origin);
    new HP = pev(iEnt, pev_health);
    if (HP <= 600.0) {
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
        write_byte(TE_SMOKE);
        engfunc(EngFunc_WriteCoord, origin[0] + random_float(-8.0, 8.0));
        engfunc(EngFunc_WriteCoord, origin[1] + random_float(-8.0, 8.0));
        engfunc(EngFunc_WriteCoord, origin[2] + random_float(25.0, 35.0));
        write_short(g_iSPR_Smoke3);
        write_byte(random_num(3, 7));
        write_byte(30);
        message_end();
    }



    if (pev_valid(iEnt)) {
        new iOwner = pev(iEnt, pev_iuser2);
        if (_:cs_get_user_team(iOwner) != pev(iEnt, pev_team)) {
            bDispenserHpArm[iOwner]--;
            set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME);
            return;
        }

        new Float:P_Pos[3];
        pev(iEnt, pev_origin, P_Pos);

        new iStatus = pev(iEnt, pev_iuser3);

        switch (iStatus) {
            case STATUS_BUILDING:
            {
                switch (cs_get_user_team(iOwner)) {
                    case CS_TEAM_T: set_rendering(iEnt, kRenderFxDistort, 255, 0, 0, kRenderTransAdd, 70);
                    case CS_TEAM_CT: set_rendering(iEnt, kRenderFxDistort, 0, 0, 255, kRenderTransAdd, 70);
                }
            }

            case STATUS_ACTIVE: {

                new iLevel = pev(iEnt, pev_euser4);

                new iHealth;
                new iArmor;
                new Speed_HP, Speed_AP, Float:Speed_ent;
                new vampire_num, vampire_max;
                if (iLevel == 1) {
                    iHealth = get_pcvar_num(g_iCvar[7]);
                    iArmor = get_pcvar_num(g_iCvar[10]);
                    Speed_HP = get_pcvar_num(g_iCvar[16]);
                    Speed_AP = get_pcvar_num(g_iCvar[13]);
                    Speed_ent = float(get_pcvar_num(g_iCvar[19]));
                    vampire_num = get_pcvar_num(g_vampir[0]);
                    vampire_max = get_pcvar_num(g_vampir_max[0]);
                } else if (iLevel == 2) {
                    iHealth = get_pcvar_num(g_iCvar[8]);
                    iArmor = get_pcvar_num(g_iCvar[11]);
                    Speed_HP = get_pcvar_num(g_iCvar[17]);
                    Speed_AP = get_pcvar_num(g_iCvar[14]);
                    Speed_ent = float(get_pcvar_num(g_iCvar[20]));
                    vampire_num = get_pcvar_num(g_vampir[1]);
                    vampire_max = get_pcvar_num(g_vampir_max[1]);
                } else if (iLevel == 3) {
                    iHealth = get_pcvar_num(g_iCvar[9]);
                    iArmor = get_pcvar_num(g_iCvar[12]);
                    Speed_HP = get_pcvar_num(g_iCvar[18]);
                    Speed_AP = get_pcvar_num(g_iCvar[15]);
                    Speed_ent = float(get_pcvar_num(g_iCvar[21]));
                    vampire_num = get_pcvar_num(g_vampir[2]);
                    vampire_max = get_pcvar_num(g_vampir_max[2]);
                }
                new ent;


                while ((ent = find_ent_by_class(ent, "NiceDispenserHpArm")) != 0) {
                    if (ent == iEnt) continue;
                    new owner_disp = pev(ent, pev_iuser2);

                    if (fm_cs_get_user_team(iOwner) == fm_cs_get_user_team(owner_disp)) {
                        new iLevel = pev(ent, pev_euser4);
                        new Float:entorigin[3];
                        pev(ent, pev_origin, entorigin);

                        if (UTIL_IsVisible(ent, iEnt) && get_distance_f(P_Pos, entorigin)  <=  get_pcvar_num(g_iCvar[3])) {
                            if (pev(ent, pev_health) < get_pcvar_float(g_iCvar[iLevel + 3])) {
                                set_pev(ent, pev_health, pev(ent, pev_health) + Speed_ent);
                                UTIL_BeamEnts(P_Pos, entorigin, gBeamcolor[iOwner][0], gBeamcolor[iOwner][1], gBeamcolor[iOwner][2]);
                            }
                        }
                    }
                }

                new id;
                for (id = 1; id <= gMaxPlayers; id++) {
                    if (is_user_alive(id)) {
                        new Float:flOrigin[3], iOrigin1[3], iOrigin2[3];
                        pev(id, pev_origin, flOrigin);

                        FVecIVec(P_Pos, iOrigin1);
                        FVecIVec(flOrigin, iOrigin2);

                        if (get_distance_f(P_Pos, flOrigin) <= get_pcvar_num(g_iCvar[3]) && UTIL_IsVisible(id, iEnt)) {
                            if (cs_get_user_team(id) == cs_get_user_team(iOwner)) {
                                if (get_user_health(id) < iHealth) {
                                    set_user_health(id, get_user_health(id) + Speed_HP);
                                } else {
                                }

                                if (get_user_armor(id) < iArmor) {
                                    set_user_armor(id, get_user_armor(id) + Speed_AP);
                                } else {
                                }

                                if (get_user_health(id) < iHealth || get_user_armor(id) < iArmor) {
                                    UTIL_BeamEnts(P_Pos, flOrigin, gBeamcolor[iOwner][0], gBeamcolor[iOwner][1], gBeamcolor[iOwner][2]);
                                }
                            }

                            if (cs_get_user_team(id) != cs_get_user_team(iOwner))
                            {
                                if (get_user_health(id) > vampire_max) {
                                    set_user_health(id, get_user_health(id) - vampire_num);

                                    if (pev(iEnt, pev_health) < get_pcvar_float(g_iCvar[pev(iEnt, pev_euser4) + 3])) set_pev(iEnt, pev_health, pev(iEnt, pev_health) + float(vampire_num));

                                    new Float:StartOrigin[3];
                                    StartOrigin[0] = flOrigin[0];
                                    StartOrigin[1] = flOrigin[1];
                                    StartOrigin[2] = flOrigin[2] - 35.0;
                                    switch (cs_get_user_team(iOwner)) {
                                        case CS_TEAM_T: UTIL_BeamEnts(StartOrigin, P_Pos, 80, 50, 255);
                                        case CS_TEAM_CT: UTIL_BeamEnts(StartOrigin, P_Pos, 255, 50, 80);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        set_pev(iEnt, pev_nextthink, get_gametime() + 0.1);
    }
}

public BuildDispenserSolid(iEntity)
{
    if (pev_valid(iEntity)) {
        new iOwner = pev(iEntity, pev_iuser2);

        switch (cs_get_user_team(iOwner)) {
            case CS_TEAM_T: {
                gBeamcolor[iOwner][0] = 255, gBeamcolor[iOwner][1] = 50, gBeamcolor[iOwner][2] = 80;
                set_rendering(iEntity, kRenderFxGlowShell, gBeamcolor[iOwner][0], gBeamcolor[iOwner][1], gBeamcolor[iOwner][2], kRenderNormal, 3);
            } case CS_TEAM_CT: {
                gBeamcolor[iOwner][0] = 80, gBeamcolor[iOwner][1] = 50, gBeamcolor[iOwner][2] = 255;
                set_rendering(iEntity, kRenderFxGlowShell, gBeamcolor[iOwner][0], gBeamcolor[iOwner][1], gBeamcolor[iOwner][2], kRenderNormal, 3);
            }
        }
        set_pev(iEntity, pev_solid, SOLID_SLIDEBOX);
        set_pev(iEntity, pev_iuser3, STATUS_ACTIVE);
        engfunc(EngFunc_DropToFloor, iEntity);
        emit_sound(iEntity, CHAN_STATIC, gDispenserActive, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }
}

public EVENT_TextMsg() {
    UTIL_DestroyDispensers();
}

public LOG_RoundEnd() {
    UTIL_DestroyDispensers();
}

stock UTIL_DestroyDispensers() {
    new iEnt = FM_NULLENT;

    while ((iEnt = find_ent_by_class(iEnt, gDispenserClassnameHpArm))) {
        new iOwner = pev(iEnt, pev_iuser2);
        bDispenserHpArm[iOwner]--;
        set_pev(iEnt, pev_flags, pev(iEnt, pev_flags) | FL_KILLME);
    }
}

stock UTIL_BuildBar(index, timer) {
    message_begin(MSG_ONE, 108, _, index);
    write_short(timer);
    message_end();
}

stock UTIL_BreakModel(Float:flOrigin[3], model, flags) {
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0);
    write_byte(TE_BREAKMODEL);
    engfunc(EngFunc_WriteCoord, flOrigin[0]);
    engfunc(EngFunc_WriteCoord, flOrigin[1]);
    engfunc(EngFunc_WriteCoord, flOrigin[2]);
    write_coord(16);
    write_coord(16);
    write_coord(16);
    write_coord(random_num(-20, 20));
    write_coord(random_num(-20, 20));
    write_coord(10);
    write_byte(10);
    write_short(model);
    write_byte(10);
    write_byte(9);
    write_byte(flags);
    message_end();
}

stock UTIL_BeamEnts(Float:flStart[3], Float:flEnd[3], r, g, b) {
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flStart);
    write_byte(TE_BEAMPOINTS);
    engfunc(EngFunc_WriteCoord, flEnd[0]);
    engfunc(EngFunc_WriteCoord, flEnd[1]);
    engfunc(EngFunc_WriteCoord, flEnd[2]);
    engfunc(EngFunc_WriteCoord, flStart[0]);
    engfunc(EngFunc_WriteCoord, flStart[1]);
    engfunc(EngFunc_WriteCoord, flStart[2] + 35.0);
    write_short(gHealingBeam);
    write_byte(5);
    write_byte(2);
    write_byte(1);
    write_byte(60);
    write_byte(0);
    write_byte(r);
    write_byte(g);
    write_byte(b);
    write_byte(999);
    write_byte(30);
    message_end();
}

stock UTIL_Sparks(Float:flOrigin[3]) {
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0);
    write_byte(TE_SPARKS);
    engfunc(EngFunc_WriteCoord, flOrigin[0]);
    engfunc(EngFunc_WriteCoord, flOrigin[1]);
    engfunc(EngFunc_WriteCoord, flOrigin[2]);
    message_end();
}

stock bool:UTIL_IsVisible(index, entity, ignoremonsters = 0) {
    new Float:flStart[3], Float:flDest[3];
    pev(index, pev_origin, flStart);
    pev(index, pev_view_ofs, flDest);

    xs_vec_add(flStart, flDest, flStart);

    pev(entity, pev_origin, flDest);
    engfunc(EngFunc_TraceLine, flStart, flDest, ignoremonsters, index, 0);

    new Float:flFraction;
    get_tr2(0, TR_flFraction, flFraction);

    if (flFraction == 1.0 || get_tr2(0, TR_pHit) == entity)
    {
        return true;
    }

    return false;
}

stock UTIL_ChatColor(const id, const input[], any: ...) {
    new count = 1, players[32];
    static msg[191];
    vformat(msg, 190, input, 3);
    replace_all(msg, 190, "!g", "^4");
    replace_all(msg, 190, "!y", "^1");
    replace_all(msg, 190, "!t", "^3");
    if (id)
        players[0] = id;
    else
        get_players(players, count, "ch");
    for (new i = 0; i < count; i++) {
        if (is_user_connected(players[i])) {
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
            write_byte(players[i]);
            write_string(msg);
            message_end();
        }
    }
}

stock fm_cs_get_user_team(id) {
    if (pev_valid(id) != 2) return 0;

    return get_pdata_int(id, 114, 5);
}
public client_putinserver(id)
{
    static isbot;
    if (isbot == 0)
    {
        if (is_user_bot(id))
        {
            set_task(30.0, "BuildBot", .flags = "b");
            isbot = 1;
        }
    }
    //get_user_name(iPlayer, g_szName[iPlayer], 31)
}

public BuildBot()
{
    new Players[32], Count;
    get_players(Players, Count, "dh");
    if (Count > 0)
    {
        HpArmDispenserBuild(Players[random(Count)]);
    }
}
 

Вложения

Последнее редактирование модератором:
Сообщения
29
Реакции
15
Помог
1 раз(а)
Конкретнее. Что вы уже сделали, что получилось и не получилось, и где конкретно вам нужна помощь? Пока что это "просто сделайте за меня". В таком случае вам сюда: https://dev-cs.ru/forums/90/
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.

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

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