BLOG [questions] Вопросы от maFFyoZZyk, или над чем я ломаю голову.

Сообщения
839
Реакции
519
Помог
12 раз(а)
на каком этапе перестало работать?
принтуй давай, ленивая задница
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
на каком этапе перестало работать?
ну на себя и не начинало работать, либо работает в упор с тем на кого смотрю
22 Мар 2023
тем, кто в состоянии помочь, скину полный код (не то, чтобы это приват, просто не хочу, чтоб растянули каждый себе, а потом кричали, того не хватает или этого)
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
кстати, когда делаю с массивом игроков, то почему-то получается, что переменная всегда true
 
Сообщения
839
Реакции
519
Помог
12 раз(а)
а зачем ты статус текст юзаешь?)
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
BalbuR, честно, я сколько сталкиваюсь с плагинами, в register_event я не понимаю эти магические числа
22 Мар 2023
это если я тебя правильно понял, а так вроде использую, то что нужно
Код:
   StatusValue                 105     -1
   StatusText                  106     -1
   StatusIcon                  107     -1
 
Сообщения
839
Реакции
519
Помог
12 раз(а)
BalbuR, честно, я сколько сталкиваюсь с плагинами, в register_event я не понимаю эти магические числа
22 Мар 2023
это если я тебя правильно понял, а так вроде использую, то что нужно
Код:
   StatusValue                 105     -1
   StatusText                  106     -1
   StatusIcon                  107     -1
я не о том
ты юзаешь UseEmpty и статус текст, потом в UseEmpty юзаешь get_user_aiming, тогда зачем тебе StatusText? :scratch_one-s_head:
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
BalbuR, потому как в use, не вышло сделать проверку на свой чужой
 
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
maFFyoZZyk,
Код:
 new iPlayer, iBody;
get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);
get_member(iPlayer, m_iTeam) == get_member(id, m_iTeam)
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
steelzzz, я читал уже это, я через aiming получаю, id того на кого смотрит, чтобы в дальнейшем его можно было излечить
22 Мар 2023
Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

#define    MAX_COORDINATES            3
#define IsTeam(%1)                get_member(%1, m_iTeam)

enum any:CVARS
{
    IMK_MP_BUY,
    IMK_MP_BUY_MONEY,
    IMK_MP_BUY_MAX,
    IMK_MP_ACCESS[MAX_NAME_LENGTH],
    IMK_MP_RND_LIMIT,
    IMK_MP_MK_MAX,
    IMK_MP_DISTANCE,
    Float: IMK_MP_HP,
    Float: IMK_MP_ADD_HP,
    IMK_MP_ANIMATION[MAX_NAME_LENGTH],
    Float: IMK_MP_SPEED_ANIM,
    IMK_MP_HEAL_SPR,
    IMK_MP_HEALER_SND,
    IMK_MP_HEALED_SND
};
new g_Cvar[CVARS];

new const VIEW_MDL[]    =        "models/injection/v_syringe.mdl";                // Модель шприца в руках
new const PLAYER_MDL[]    =        "models/injection/p_syringe.mdl";                // Модель шприца со стороны
new const SND_HEAL[]    =        "injection/heal.wav";                            // Звук для исцеляемого
new const SND_HEALING[]    =        "injection/medic.wav";                            // Звук для целителя
new const HEALTH_SPR[]    =        "sprites/injection/heal_shape.spr";                // Спрайт после лечения
new const COMM_MK[][]    =         {"say /medkit", "say_team /medkit", "medkit"};    // Команды для получения, либо покупки
enum any:
{
    STATUS_HIDE, // 0
    STATUS_SHOW, // 1
    STATUS_FLASH, // 2
}

const TASK_INDEX = 0xA6123;
new const SPRITE_MSG_NAME[] = "plus"; // Спрайт
new g_iMsgStatusIcon;
new g_iHealSprite;
new g_iHealter[MAX_PLAYERS+1], g_iMedKit[MAX_PLAYERS+1];
new g_fOrigin[MAX_COORDINATES];
new bool: g_bStatus[MAX_PLAYERS+1] = false;

enum _: INT_VALUES_NAMES
{   
    HID,    // id использующего
    PLID,    // id на ком используют
    HWPN    // оружие использующего
};

public plugin_init()
{
    register_plugin("Injection Med-Kit", "1.0", "maFFyoZZyk");

    register_dictionary("injection_med-kit.txt");
    RegisterCvars();
    AutoExecConfig(true, "injection_med-kit");   

    for (new i = 0; i < sizeof COMM_MK; i ++)
        register_clcmd(COMM_MK[i], "medkit");

    RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
    RegisterHookChain(RG_PlantBomb, "PlantBomb", .post = true);
    RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Pre", .post = false);
    g_iMsgStatusIcon = get_user_msgid("StatusIcon");
    register_event("StatusValue", "EventStatusValueShow", "be", "1=2", "2!0");
    register_event("StatusValue", "EventStatusValueHide", "be", "1=1", "2=0");
    RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty", .post = true);
}

public plugin_precache()
{
    precache_model(VIEW_MDL);
    precache_model(PLAYER_MDL);
    g_iHealSprite = precache_model(HEALTH_SPR);
    precache_sound(SND_HEAL);
    precache_sound(SND_HEALING);
}

public client_disconnected(id)
{
    g_iHealter[id] = 0;
    g_bStatus[id] = false;
    remove_task(id);
}

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

    if(g_iMedKit[id] == g_Cvar[IMK_MP_BUY_MAX])
    {
        client_print(id, print_center, "Вы не можете купить больше %i инъектора.", g_Cvar[IMK_MP_BUY_MAX]);
        return;
    }

    if(get_user_flags(id) & read_flags(g_Cvar[IMK_MP_ACCESS]))
        return;

    new iMoney = get_member(id,m_iAccount)

    if(g_Cvar[IMK_MP_BUY_MONEY] > iMoney)
    {
        UTIL_Blink_Money(id, 5);            // 5 - количество мерцаний денег
        client_print(id, print_center, "У Вас недостаточно денежных средств.");
        return;
    }
    else
    {
        g_iMedKit[id] = 1;
        set_msg_status_icon(id, STATUS_HIDE, SPRITE_MSG_NAME);
        client_print_color(id, -2, "Нажмите 'E' - чтобы вылечить себя или союзника");
        set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + id);
        rg_add_account(id,iMoney - g_Cvar[IMK_MP_BUY_MONEY], AS_SET);
    }
}

public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
    if(!is_user_alive(pPlayer))
        return HC_CONTINUE;

    remove_task(pPlayer);
    g_iHealter[pPlayer] = 0;
    
    if(!(get_user_flags(pPlayer) & read_flags(g_Cvar[IMK_MP_ACCESS])))
        return HC_CONTINUE;

                            //  обнуляем количество попыток лечения
    g_iMedKit[pPlayer] = g_Cvar[IMK_MP_BUY_MAX];        // Выдаем инъекторы одминам
    
    set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
    client_print_color(pPlayer, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_EQUIPMSG");
    set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + pPlayer);
    
    return HC_CONTINUE;
}

public PlantBomb(id, Float:vecStart[3], Float:vecVelocity[3])
{
    new pEntity = GetHookChainReturn(ATYPE_INTEGER);

    if (is_nullent(pEntity))
        return;
    
    get_entvar(pEntity, var_origin, g_fOrigin);   
}

public CBasePlayerWeapon_DefaultDeploy_Pre(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
    new pPlayer = get_member(pEntity, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    if(task_exists(pPlayer))
    {
        rg_send_bartime(pPlayer, 0, true);
        remove_task(pPlayer);
        set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
        set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
    }
}

public task_send_msg_status_icon(pPlayer)
{
    pPlayer -= TASK_INDEX;

    if(!is_user_alive(pPlayer))
        return;
    
    set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
}

public EventStatusValueShow(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;
    
    g_bStatus[id] = true;
    client_print(id, print_chat, "%s", g_bStatus ? "видит" : "не_видит");
    
    return HC_CONTINUE;
}

public EventStatusValueHide(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;

    g_bStatus[id] = false;
    client_print(id, print_chat, "%s", g_bStatus ? "видит" : "не_видит");
    
    return HC_CONTINUE;
}

public CBasePlayer_UseEmpty(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;
    
    new iPlayer, iBody;
    get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);

    if(!is_user_connected(iPlayer))
        return HC_CONTINUE;
    
    // if(!(get_user_flags(id) & read_flags(g_Cvar[IMK_MP_ACCESS])) || g_iMedKit[id] == 0)
        // return HC_CONTINUE;

    if(~get_entvar(id, var_flags) & FL_ONGROUND)
        return HC_CONTINUE;

    if(g_iHealter[id] >= g_Cvar[IMK_MP_RND_LIMIT])       
    {
        client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_EXHAUSTED");
        return HC_CONTINUE;
    }

    if(g_bStatus[id])
    {
        new iAimOrigin[3], iPlayerOrigin[3];
        get_user_origin(iPlayer, iAimOrigin);
        get_user_origin(id, iPlayerOrigin);

        if(get_distance(iPlayerOrigin, iAimOrigin) > g_Cvar[IMK_MP_DISTANCE])
        {
            client_print_color(id, -2, "Вы слишком далеко от раненого");
            return HC_CONTINUE;
        }
            
        if(IsTeam(id) != IsTeam(iPlayer))
        {
            client_print_color(id, -2, "Придурок, товарищей лечить надо");
            return HC_CONTINUE;
        }

        if((Float:get_entvar(iPlayer, var_health) * 100.0 / Float:get_entvar(iPlayer, var_max_health)) >= g_Cvar[IMK_MP_HP])
        {
            client_print_color(id, -2, "Этот чувак еще полон сил");
            return HC_CONTINUE;
        }
    }
    else
    {       
        if((Float:get_entvar(id, var_health) * 100.0 / Float:get_entvar(id, var_max_health)) >= g_Cvar[IMK_MP_HP])
        {
            client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_FULL");
            return HC_CONTINUE;
        }
        
        if(rg_is_bomb_planted() && (get_member(id, m_iTeam) == TEAM_CT))
        {   
            new fpOrigin[MAX_COORDINATES];
            get_entvar(id, var_origin, fpOrigin);
                
            if(get_distance(fpOrigin, g_fOrigin) <= 30)
                return HC_CONTINUE;   
        }
        set_entvar(id, var_weaponmodel, PLAYER_MDL);
        UTIL_PlayerAnimation(id, g_Cvar[IMK_MP_ANIMATION], g_Cvar[IMK_MP_SPEED_ANIM]);
    }

    new sArgValue[INT_VALUES_NAMES];                       
    sArgValue[HID] = id;
    sArgValue[PLID] = iPlayer;
    sArgValue[HWPN] = get_member(id, m_pActiveItem);
    
    if(is_nullent(sArgValue[HWPN]))
        return HC_CONTINUE;

    client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_USE");
    set_entvar(id, var_viewmodel, VIEW_MDL);
    UTIL_PlayWeaponAnimation(id, 0);       
    set_msg_status_icon(id, STATUS_FLASH, SPRITE_MSG_NAME);
    set_task(float(2), "Healing", id, sArgValue, sizeof(sArgValue));
    rg_send_bartime(id, 2, true);

    return HC_CONTINUE;
}

public Healing(sArgValue[], id)
{   
    if(g_bStatus[sArgValue[HID]])
    {   
        new Float: fpAddHealth = Float:get_entvar(sArgValue[PLID], var_health) + g_Cvar[IMK_MP_ADD_HP];
        
        if(fpAddHealth > 100.0)
            fpAddHealth = 100.0;   
        
        set_entvar(sArgValue[PLID], var_health, fpAddHealth);
        
        new Float:fOrigin[3];
        get_entvar(sArgValue[PLID], var_origin, fOrigin);

        if(g_Cvar[IMK_MP_HEAL_SPR] == 1)
            UTIL_SpriteTrail(fOrigin, g_iHealSprite);
    }
    else
    {
        new Float: fAddHealth = Float:get_entvar(sArgValue[HID], var_health) + g_Cvar[IMK_MP_ADD_HP];
        
        if(fAddHealth > 100.0)
            fAddHealth = 100.0;   
            
        set_entvar(sArgValue[HID], var_health, fAddHealth);
        
        new Float:origin[3];
        get_entvar(sArgValue[HID], var_origin, origin);
        
        if(g_Cvar[IMK_MP_HEAL_SPR] == 1)
            UTIL_SpriteTrail(origin, g_iHealSprite);
    }
    
    rg_switch_weapon(sArgValue[HID], sArgValue[HWPN]);
    client_print_color(sArgValue[HID], -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_USED");

    if(g_Cvar[IMK_MP_HEALER_SND])
        emit_sound(0, CHAN_AUTO, SND_HEALING, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    if(g_Cvar[IMK_MP_HEALED_SND])
        emit_sound(sArgValue[HID], CHAN_AUTO, SND_HEAL, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    
    set_msg_status_icon(sArgValue[HID], STATUS_HIDE, SPRITE_MSG_NAME);
    
    g_iHealter[sArgValue[HID]]++;
    
    if(g_iHealter[sArgValue[HID]] < g_Cvar[IMK_MP_RND_LIMIT])       
        set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + sArgValue[HID]);
    
    UTIL_ScreenFade(id);
    remove_task(id);
}

stock UTIL_SpriteTrail(Float:origin[3], const sprite, const cound = 20, const life = 20, const scale = 4, const noise = 20, const speed = 10) {
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY); // MSG_PVS
    write_byte(TE_SPRITETRAIL);
    write_coord_f(origin[0]);
    write_coord_f(origin[1]);
    write_coord_f(origin[2] + 20.0);
    write_coord_f(origin[0]);
    write_coord_f(origin[1]);
    write_coord_f(origin[2] + 80.0);
    write_short(sprite);
    write_byte(cound);
    write_byte(life);
    write_byte(scale);
    write_byte(noise);
    write_byte(speed);
    message_end();
}

stock set_msg_status_icon(pPlayer, iStatus, const sSprite[], iRed = 0, iGreen = 0, iBlue = 0)
{
    message_begin(MSG_ONE, g_iMsgStatusIcon, .player = pPlayer);
    write_byte(iStatus);
    write_string(sSprite);

    if(iStatus != STATUS_HIDE)
    {
        write_byte(iRed);
        write_byte(iGreen);
        write_byte(iBlue);
    }

    message_end();
}

stock UTIL_PlayerAnimation( const pPlayer, const szAnim[ ], const Float: flFrameRateAnim = 1.0, const Activity: iActivity = ACT_RANGE_ATTACK1 )
{
    new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
    if ( ( iAnimDesired = lookup_sequence( pPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed ) ) == -1 )
        iAnimDesired = 0;

    static Float: flGameTime; flGameTime = get_gametime( );

    UTIL_SetEntityAnim( pPlayer, iAnimDesired, .flFrameRate = flFrameRateAnim );

    set_member( pPlayer, m_fSequenceLoops, bLoops );
    set_member( pPlayer, m_fSequenceFinished, 0 );
    set_member( pPlayer, m_flFrameRate, flFrameRate );
    set_member( pPlayer, m_flGroundSpeed, flGroundSpeed );
    set_member( pPlayer, m_flLastEventCheck, flGameTime );
    set_member( pPlayer, m_Activity, iActivity );
    set_member( pPlayer, m_IdealActivity, iActivity );
    set_member( pPlayer, m_flLastFired, flGameTime );
}

stock UTIL_SetEntityAnim( const pEntity, const iSequence = 0, const Float: flFrame = 0.0, const Float: flFrameRate = 1.0 )
{
    set_entvar( pEntity, var_frame, flFrame );
    set_entvar( pEntity, var_framerate, flFrameRate );
    set_entvar( pEntity, var_animtime, get_gametime( ) );
    set_entvar( pEntity, var_sequence, iSequence );
}

stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
    set_entvar(Player, var_weaponanim, Sequence);

    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player);
    write_byte(Sequence);
    write_byte(get_entvar(Player, var_body));
    message_end();
}

stock UTIL_ScreenFade(const Player)
{
    if(!is_player_blinded(Player))
    {
        message_begin(MSG_ONE_UNRELIABLE, 98, _, Player);
        write_short(1<<10);
        write_short(1<<10);
        write_short(0x0000);
        write_byte(0);
        write_byte(200);
        write_byte(0);
        write_byte(40);
        message_end();
    }
}
stock bool:is_player_blinded(iPlayer)
{
    return bool:(Float:get_member(iPlayer, m_blindStartTime) + Float:get_member(iPlayer, m_blindFadeTime) >= get_gametime())
}

stock UTIL_Blink_Money(const id, const blinkQty = 1)
{
    static msg_BlinkAcct;
    if(!msg_BlinkAcct)
        msg_BlinkAcct = get_user_msgid("BlinkAcct");

    message_begin(MSG_ONE, msg_BlinkAcct, .player = id);
    write_byte(blinkQty);
    message_end();
}

stock set_user_health(const id)
{
    message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "Health" ), _, id );
    write_long( 3 );
    write_byte(0);    // don't display the additional new-old HUD money amount difference
    message_end();
}

RegisterCvars()
{
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy_money",
            .string = "200",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY_MONEY"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY_MONEY]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy_max",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY_MAX"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY_MAX]
    );
    bind_pcvar_string(
        create_cvar(
          .name = "imk_mp_access",
          .string = "z",
          .flags = FCVAR_SERVER,
          .description = fmt("%l", "IMK_CVAR_MP_ACCESS")
          ), g_Cvar[IMK_MP_ACCESS], charsmax(g_Cvar[IMK_MP_ACCESS])
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_rnd_limit",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_RND_LIMIT"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_RND_LIMIT]
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_mk_max",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_MK_MAX"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_MK_MAX]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_distance",
            .string = "40",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_DISTANCE"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_DISTANCE]
    );   
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_hp",
            .string = "80.0",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_HP"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HP]
    );   
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_add_hp",
            .string = "50.0",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_ADD_HP"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_ADD_HP]
    );
    bind_pcvar_string(
        create_cvar(
          .name = "imk_mp_animation",
          .string = "ref_shoot_shieldknife",
          .flags = FCVAR_SERVER,
          .description = fmt("%l", "IMK_CVAR_MP_ANIMATION")
          ), g_Cvar[IMK_MP_ANIMATION], charsmax(g_Cvar[IMK_MP_ANIMATION])
    );
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_speed_anim",
            .string = "0.5",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_SPEED_ANIM"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_SPEED_ANIM]
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_heal_spr",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEAL_SPR"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEAL_SPR]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_healer_snd",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEALER_SND"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEALER_SND]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_healed_snd",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEALED_SND"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEALED_SND]
    );
}
 
Сообщения
839
Реакции
519
Помог
12 раз(а)
public CBasePlayer_UseEmpty(id)

вообще не вызывается? принтани
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
BalbuR, вызывается, я только что зашел на сервер и смог себя вылечить
22 Мар 2023
но при условии, что я подошел к своему тиммейту
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
ну вот, выложил код и сразу тишина гробовая
 
Сообщения
839
Реакции
519
Помог
12 раз(а)
1679663906735.png


Код:
public CBasePlayer_UseEmpty(id)

{

    if(!is_user_alive(id))

        return HC_CONTINUE;

 

    new iPlayer, iBody;

    get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);

    // if(!is_user_connected(iPlayer))

    //     return HC_CONTINUE;

 

    // if(!(get_user_flags(id) & read_flags(g_Cvar[IMK_MP_ACCESS])) || g_iMedKit[id] == 0)

        // return HC_CONTINUE;

    if(~get_entvar(id, var_flags) & FL_ONGROUND)

        return HC_CONTINUE;

    if(g_iHealter[id] >= g_Cvar[IMK_MP_RND_LIMIT])    

    {

        client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_EXHAUSTED");

        return HC_CONTINUE;

    }

    if(is_user_alive(iPlayer))

    {

        new iAimOrigin[3], iPlayerOrigin[3];

        get_user_origin(iPlayer, iAimOrigin);

        get_user_origin(id, iPlayerOrigin);

        if(get_distance(iPlayerOrigin, iAimOrigin) > g_Cvar[IMK_MP_DISTANCE])

        {

            client_print_color(id, -2, "Вы слишком далеко от раненого");

            return HC_CONTINUE;

        }

         

        if(IsTeam(id) != IsTeam(iPlayer))

        {

            client_print_color(id, -2, "Придурок, товарищей лечить надо");

            return HC_CONTINUE;

        }

        if((Float:get_entvar(iPlayer, var_health) * 100.0 / Float:get_entvar(iPlayer, var_max_health)) >= g_Cvar[IMK_MP_HP])

        {

            client_print_color(id, -2, "Этот чувак еще полон сил");

            return HC_CONTINUE;

        }

    }

    else

    {    

        if((Float:get_entvar(id, var_health) * 100.0 / Float:get_entvar(id, var_max_health)) >= g_Cvar[IMK_MP_HP])

        {

            client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_FULL");

            return HC_CONTINUE;

        }

     

        if(rg_is_bomb_planted() && (get_member(id, m_iTeam) == TEAM_CT))

        {

            new fpOrigin[MAX_COORDINATES];

            get_entvar(id, var_origin, fpOrigin);

             

            if(get_distance(fpOrigin, g_fOrigin) <= 30)

                return HC_CONTINUE;

        }

        set_entvar(id, var_weaponmodel, PLAYER_MDL);

        UTIL_PlayerAnimation(id, g_Cvar[IMK_MP_ANIMATION], g_Cvar[IMK_MP_SPEED_ANIM]);

    }

    new sArgValue[INT_VALUES_NAMES];                    

    sArgValue[HID] = id;

    sArgValue[PLID] = iPlayer;

    sArgValue[HWPN] = get_member(id, m_pActiveItem);

 

    if(is_nullent(sArgValue[HWPN]))

        return HC_CONTINUE;

    client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_USE");

    set_entvar(id, var_viewmodel, VIEW_MDL);

    UTIL_PlayWeaponAnimation(id, 0);    

    set_msg_status_icon(id, STATUS_FLASH, SPRITE_MSG_NAME);

    set_task(float(2), "Healing", id, sArgValue, sizeof(sArgValue));

    rg_send_bartime(id, 2, true);

    return HC_CONTINUE;

}
 
Последнее редактирование модератором:

d3m37r4

111111
Сообщения
1,449
Реакции
1,175
Помог
10 раз(а)
BalbuR, ты чо коды под спойлером не как коды скинул👀
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
BalbuR, я твой код не проверял. но пока тут все молчали, я продолжал тестировать. пришел к тому, что не мог себя лечить из-за
Код:
new iPlayer, iBody;
        get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);
по этому, запихнул его в
Код:
if(g_bStatus[id])
    {
        new iPlayer, iBody;
        get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);

        if(!is_user_connected(iPlayer))
            return HC_CONTINUE;

        new iAimOrigin[3], iPlayerOrigin[3];
        get_user_origin(iPlayer, iAimOrigin);
        get_user_origin(id, iPlayerOrigin);

        if(get_distance(iPlayerOrigin, iAimOrigin) > g_Cvar[IMK_MP_DISTANCE])
        {
            client_print_color(id, -2, "Вы слишком далеко от раненого");
            return HC_CONTINUE;
        }
            
        if(IsTeam(id) != IsTeam(iPlayer))
        {
            client_print_color(id, -2, "Придурок, товарищей лечить надо");
            return HC_CONTINUE;
        }

        if((Float:get_entvar(iPlayer, var_health) * 100.0 / Float:get_entvar(iPlayer, var_max_health)) >= g_Cvar[IMK_MP_HP])
        {
            client_print_color(id, -2, "Этот чувак еще полон сил");
            return HC_CONTINUE;
        }   
        sArgValue[PLID] = iPlayer;
        
        set_entvar(id, var_viewmodel, VIEW_P_MDL);
    }
По итогу код в принципе рабочий, но если я буду смотреть на своего и пытаться себя лечить на любом расстоянии, то работать не будет.
Если же просто не будет на прицеле ни кого, тогда будет выполняться лечение.

Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

#define    MAX_COORDINATES            3
#define IsTeam(%1)                get_member(%1, m_iTeam)

enum any:CVARS
{
    IMK_MP_BUY,
    IMK_MP_BUY_MONEY,
    IMK_MP_BUY_MAX,
    IMK_MP_ACCESS[MAX_NAME_LENGTH],
    IMK_MP_RND_LIMIT,
    IMK_MP_MK_MAX,
    IMK_MP_DISTANCE,
    Float: IMK_MP_HP,
    Float: IMK_MP_ADD_HP,
    IMK_MP_ANIMATION[MAX_NAME_LENGTH],
    Float: IMK_MP_SPEED_ANIM,
    IMK_MP_HEAL_SPR,
    IMK_MP_HEALER_SND,
    IMK_MP_HEALED_SND
};
new g_Cvar[CVARS];

new const VIEW_MDL[]    =        "models/injection/v_syringe.mdl";                // Модель шприца в руках
new const PLAYER_MDL[]    =        "models/injection/p_syringe.mdl";                // Модель шприца со стороны
new const VIEW_P_MDL[]    =        "models/injection/v_healtshoot.mdl";            // Модель шприца при лечении юзверя
new const SND_HEAL[]    =        "injection/heal.wav";                            // Звук для исцеляемого
new const SND_HEALING[]    =        "injection/medic.wav";                            // Звук для целителя
new const HEALTH_SPR[]    =        "sprites/injection/heal_shape.spr";                // Спрайт после лечения
new const COMM_MK[][]    =         {"say /medkit", "say_team /medkit", "medkit"};    // Команды для получения, либо покупки
enum any:
{
    STATUS_HIDE, // 0
    STATUS_SHOW, // 1
    STATUS_FLASH, // 2
}

const TASK_INDEX = 0xA6123;
new const SPRITE_MSG_NAME[] = "plus"; // Спрайт
new g_iMsgStatusIcon;
new g_iHealSprite;
new g_iHealter[MAX_PLAYERS+1], g_iMedKit[MAX_PLAYERS+1];
new g_fOrigin[MAX_COORDINATES];
new g_bStatus[MAX_PLAYERS+1];

enum _: INT_VALUES_NAMES
{   
    HID,    // id использующего
    PLID,    // id на ком используют
    HWPN    // оружие использующего
};

public plugin_init()
{
    register_plugin("Injection Med-Kit", "1.0", "maFFyoZZyk");

    register_dictionary("injection_med-kit.txt");
    RegisterCvars();
    AutoExecConfig(true, "injection_med-kit");   

    for (new i = 0; i < charsmax(COMM_MK); i ++)
        register_clcmd(COMM_MK[i], "med_kit");

    RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
    RegisterHookChain(RG_PlantBomb, "PlantBomb", .post = true);
    RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Pre", .post = false);
    g_iMsgStatusIcon = get_user_msgid("StatusIcon");
    register_event("StatusValue", "EventStatusValueShow", "be", "1=2", "2!0");
    register_event("StatusValue", "EventStatusValueHide", "be", "1=1", "2=0");
    RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty", .post = true);
}

public plugin_precache()
{
    precache_model(VIEW_MDL);
    precache_model(VIEW_P_MDL);
    precache_model(PLAYER_MDL);
    g_iHealSprite = precache_model(HEALTH_SPR);
    precache_sound(SND_HEAL);
    precache_sound(SND_HEALING);
}

public client_disconnected(id)
{
    g_iHealter[id] = 0;
    g_bStatus[id] = false;
    remove_task(id);
}

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

    if(g_iMedKit[id] == g_Cvar[IMK_MP_BUY_MAX])
    {
        client_print(id, print_center, "Вы не можете купить больше %i инъектора.", g_Cvar[IMK_MP_BUY_MAX]);
        return;
    }

    // if(get_user_flags(id) & read_flags(g_Cvar[IMK_MP_ACCESS]))
        // return;

    new iMoney = get_member(id,m_iAccount)

    if(g_Cvar[IMK_MP_BUY_MONEY] > iMoney)
    {
        UTIL_Blink_Money(id, 5);            // 5 - количество мерцаний денег
        client_print(id, print_center, "У Вас недостаточно денежных средств.");
        return;
    }
    else
    {
        g_iMedKit[id] = 1;
        set_msg_status_icon(id, STATUS_HIDE, SPRITE_MSG_NAME);
        client_print_color(id, -2, "Нажмите 'E' - чтобы вылечить себя или союзника");
        set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + id);
        rg_add_account(id,iMoney - g_Cvar[IMK_MP_BUY_MONEY], AS_SET);
    }
}

public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
    if(!is_user_alive(pPlayer))
        return HC_CONTINUE;

    remove_task(pPlayer);
    g_iHealter[pPlayer] = 0;
    
    if(!(get_user_flags(pPlayer) & read_flags(g_Cvar[IMK_MP_ACCESS])))
        return HC_CONTINUE;

                            //  обнуляем количество попыток лечения
    g_iMedKit[pPlayer] = g_Cvar[IMK_MP_BUY_MAX];        // Выдаем инъекторы одминам
    
    set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
    client_print_color(pPlayer, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_EQUIPMSG");
    set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + pPlayer);
    
    return HC_CONTINUE;
}

public PlantBomb(id, Float:vecStart[3], Float:vecVelocity[3])
{
    new pEntity = GetHookChainReturn(ATYPE_INTEGER);

    if (is_nullent(pEntity))
        return;
    
    get_entvar(pEntity, var_origin, g_fOrigin);   
}

public CBasePlayerWeapon_DefaultDeploy_Pre(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
    new pPlayer = get_member(pEntity, m_pPlayer);

    if(!is_user_alive(pPlayer))
        return;

    if(task_exists(pPlayer))
    {
        rg_send_bartime(pPlayer, 0, true);
        remove_task(pPlayer);
        set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
        set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
    }
}

public task_send_msg_status_icon(pPlayer)
{
    pPlayer -= TASK_INDEX;

    if(!is_user_alive(pPlayer))
        return;
    
    set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
}

public EventStatusValueShow(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;
    
    g_bStatus[id] = true;
    client_print(id, print_chat, "%s", g_bStatus[id] ? "видит" : "не_видит");
    
    return HC_CONTINUE;
}

public EventStatusValueHide(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;

    g_bStatus[id] = false;
    client_print(id, print_chat, "%s", g_bStatus[id] ? "видит" : "не_видит");
    
    return HC_CONTINUE;
}

public CBasePlayer_UseEmpty(id)
{
    if(!is_user_alive(id))
        return HC_CONTINUE;
    
    // if(!(get_user_flags(id) & read_flags(g_Cvar[IMK_MP_ACCESS])) || g_iMedKit[id] == 0)
        // return HC_CONTINUE;

    if(~get_entvar(id, var_flags) & FL_ONGROUND)
        return HC_CONTINUE;

    if(g_iHealter[id] >= g_Cvar[IMK_MP_RND_LIMIT])       
    {
        client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_EXHAUSTED");
        return HC_CONTINUE;
    }
    
    new sArgValue[INT_VALUES_NAMES];   

    if(g_bStatus[id])
    {
        new iPlayer, iBody;
        get_user_aiming(id, iPlayer, iBody, g_Cvar[IMK_MP_DISTANCE] + 60);

        if(!is_user_connected(iPlayer))
            return HC_CONTINUE;

        new iAimOrigin[3], iPlayerOrigin[3];
        get_user_origin(iPlayer, iAimOrigin);
        get_user_origin(id, iPlayerOrigin);

        if(get_distance(iPlayerOrigin, iAimOrigin) > g_Cvar[IMK_MP_DISTANCE])
        {
            client_print_color(id, -2, "Вы слишком далеко от раненого");
            return HC_CONTINUE;
        }
            
        if(IsTeam(id) != IsTeam(iPlayer))
        {
            client_print_color(id, -2, "Придурок, товарищей лечить надо");
            return HC_CONTINUE;
        }

        if((Float:get_entvar(iPlayer, var_health) * 100.0 / Float:get_entvar(iPlayer, var_max_health)) >= g_Cvar[IMK_MP_HP])
        {
            client_print_color(id, -2, "Этот чувак еще полон сил");
            return HC_CONTINUE;
        }   
        sArgValue[PLID] = iPlayer;
        
        set_entvar(id, var_viewmodel, VIEW_P_MDL);
    }
    else
    {
        if((Float:get_entvar(id, var_health) * 100.0 / Float:get_entvar(id, var_max_health)) >= g_Cvar[IMK_MP_HP])
        {
            client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_FULL");
            return HC_CONTINUE;
        }
        
        if(rg_is_bomb_planted() && (get_member(id, m_iTeam) == TEAM_CT))
        {   
            new fpOrigin[MAX_COORDINATES];
            get_entvar(id, var_origin, fpOrigin);
                
            if(get_distance(fpOrigin, g_fOrigin) <= 30)
                return HC_CONTINUE;   
        }
        set_entvar(id, var_viewmodel, VIEW_MDL);
    }

    sArgValue[HID] = id;
    sArgValue[HWPN] = get_member(id, m_pActiveItem);
    
    if(is_nullent(sArgValue[HWPN]))
        return HC_CONTINUE;

    client_print_color(id, -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_USE");
    
    UTIL_PlayWeaponAnimation(id, 0);       
    set_msg_status_icon(id, STATUS_FLASH, SPRITE_MSG_NAME);
    set_task(float(2), "Healing", id, sArgValue, sizeof(sArgValue));
    rg_send_bartime(id, 2, true);

    return HC_CONTINUE;
}

public Healing(sArgValue[], id)
{   
    if(g_bStatus[sArgValue[PLID]])
    {
        client_print_color(0, -2, "Лечим уебка");
        
        new Float: fpAddHealth = Float:get_entvar(sArgValue[PLID], var_health) + g_Cvar[IMK_MP_ADD_HP];
        
        if(fpAddHealth > 100.0)
            fpAddHealth = 100.0;   
        
        set_entvar(sArgValue[PLID], var_health, fpAddHealth);
        
        new Float:fOrigin[3];
        get_entvar(sArgValue[PLID], var_origin, fOrigin);

        if(g_Cvar[IMK_MP_HEAL_SPR] == 1)
            UTIL_SpriteTrail(fOrigin, g_iHealSprite);
    }
    else
    {
        client_print_color(0, -2, "Лечим себя родимого");
        new Float: fAddHealth = Float:get_entvar(sArgValue[HID], var_health) + g_Cvar[IMK_MP_ADD_HP];
        
        if(fAddHealth > 100.0)
            fAddHealth = 100.0;   
            
        set_entvar(sArgValue[HID], var_health, fAddHealth);
        
        new Float:origin[3];
        get_entvar(sArgValue[HID], var_origin, origin);
        
        if(g_Cvar[IMK_MP_HEAL_SPR] == 1)
            UTIL_SpriteTrail(origin, g_iHealSprite);
    }
    
    rg_switch_weapon(sArgValue[HID], sArgValue[HWPN]);
    client_print_color(sArgValue[HID], -2, "%L %L", LANG_PLAYER, "IMK_PREFIX", LANG_PLAYER, "IMK_USED");

    if(g_Cvar[IMK_MP_HEALER_SND])
        emit_sound(0, CHAN_AUTO, SND_HEALING, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    if(g_Cvar[IMK_MP_HEALED_SND])
        emit_sound(sArgValue[HID], CHAN_AUTO, SND_HEAL, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    
    set_msg_status_icon(sArgValue[HID], STATUS_HIDE, SPRITE_MSG_NAME);
    
    g_iHealter[sArgValue[HID]]++;
    g_iMedKit[sArgValue[HID]]--;
    
    if(g_iHealter[sArgValue[HID]] < g_Cvar[IMK_MP_RND_LIMIT])       
        set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + sArgValue[HID]);
    
    UTIL_ScreenFade(id);
    remove_task(id);
}

stock UTIL_SpriteTrail(Float:origin[3], const sprite, const cound = 20, const life = 20, const scale = 4, const noise = 20, const speed = 10) {
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY); // MSG_PVS
    write_byte(TE_SPRITETRAIL);
    write_coord_f(origin[0]);
    write_coord_f(origin[1]);
    write_coord_f(origin[2] + 20.0);
    write_coord_f(origin[0]);
    write_coord_f(origin[1]);
    write_coord_f(origin[2] + 80.0);
    write_short(sprite);
    write_byte(cound);
    write_byte(life);
    write_byte(scale);
    write_byte(noise);
    write_byte(speed);
    message_end();
}

stock set_msg_status_icon(pPlayer, iStatus, const sSprite[], iRed = 0, iGreen = 0, iBlue = 0)
{
    message_begin(MSG_ONE, g_iMsgStatusIcon, .player = pPlayer);
    write_byte(iStatus);
    write_string(sSprite);

    if(iStatus != STATUS_HIDE)
    {
        write_byte(iRed);
        write_byte(iGreen);
        write_byte(iBlue);
    }

    message_end();
}

stock UTIL_PlayerAnimation( const pPlayer, const szAnim[ ], const Float: flFrameRateAnim = 1.0, const Activity: iActivity = ACT_RANGE_ATTACK1 )
{
    new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
    if ( ( iAnimDesired = lookup_sequence( pPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed ) ) == -1 )
        iAnimDesired = 0;

    static Float: flGameTime; flGameTime = get_gametime( );

    UTIL_SetEntityAnim( pPlayer, iAnimDesired, .flFrameRate = flFrameRateAnim );

    set_member( pPlayer, m_fSequenceLoops, bLoops );
    set_member( pPlayer, m_fSequenceFinished, 0 );
    set_member( pPlayer, m_flFrameRate, flFrameRate );
    set_member( pPlayer, m_flGroundSpeed, flGroundSpeed );
    set_member( pPlayer, m_flLastEventCheck, flGameTime );
    set_member( pPlayer, m_Activity, iActivity );
    set_member( pPlayer, m_IdealActivity, iActivity );
    set_member( pPlayer, m_flLastFired, flGameTime );
}

stock UTIL_SetEntityAnim( const pEntity, const iSequence = 0, const Float: flFrame = 0.0, const Float: flFrameRate = 1.0 )
{
    set_entvar( pEntity, var_frame, flFrame );
    set_entvar( pEntity, var_framerate, flFrameRate );
    set_entvar( pEntity, var_animtime, get_gametime( ) );
    set_entvar( pEntity, var_sequence, iSequence );
}

stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
    set_entvar(Player, var_weaponanim, Sequence);

    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player);
    write_byte(Sequence);
    write_byte(get_entvar(Player, var_body));
    message_end();
}

stock UTIL_ScreenFade(const Player)
{
    if(!is_player_blinded(Player))
    {
        message_begin(MSG_ONE_UNRELIABLE, 98, _, Player);
        write_short(1<<10);
        write_short(1<<10);
        write_short(0x0000);
        write_byte(0);
        write_byte(200);
        write_byte(0);
        write_byte(40);
        message_end();
    }
}
stock bool:is_player_blinded(iPlayer)
{
    return bool:(Float:get_member(iPlayer, m_blindStartTime) + Float:get_member(iPlayer, m_blindFadeTime) >= get_gametime())
}

stock UTIL_Blink_Money(const id, const blinkQty = 1)
{
    static msg_BlinkAcct;
    if(!msg_BlinkAcct)
        msg_BlinkAcct = get_user_msgid("BlinkAcct");

    message_begin(MSG_ONE, msg_BlinkAcct, .player = id);
    write_byte(blinkQty);
    message_end();
}

stock set_user_health(const id)
{
    message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "Health" ), _, id );
    write_long( 3 );
    write_byte(0);    // don't display the additional new-old HUD money amount difference
    message_end();
}

RegisterCvars()
{
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy_money",
            .string = "200",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY_MONEY"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY_MONEY]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_buy_max",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_BUY_MAX"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_BUY_MAX]
    );
    bind_pcvar_string(
        create_cvar(
          .name = "imk_mp_access",
          .string = "z",
          .flags = FCVAR_SERVER,
          .description = fmt("%l", "IMK_CVAR_MP_ACCESS")
          ), g_Cvar[IMK_MP_ACCESS], charsmax(g_Cvar[IMK_MP_ACCESS])
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_rnd_limit",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_RND_LIMIT"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_RND_LIMIT]
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_mk_max",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_MK_MAX"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_MK_MAX]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_distance",
            .string = "40",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_DISTANCE"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_DISTANCE]
    );   
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_hp",
            .string = "80.0",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_HP"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HP]
    );   
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_add_hp",
            .string = "50.0",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_ADD_HP"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_ADD_HP]
    );
    bind_pcvar_string(
        create_cvar(
          .name = "imk_mp_animation",
          .string = "ref_shoot_shieldknife",
          .flags = FCVAR_SERVER,
          .description = fmt("%l", "IMK_CVAR_MP_ANIMATION")
          ), g_Cvar[IMK_MP_ANIMATION], charsmax(g_Cvar[IMK_MP_ANIMATION])
    );
    bind_pcvar_float(
        create_cvar(
            .name = "imk_mp_speed_anim",
            .string = "0.5",
            .flags = FCVAR_SERVER,
            .description =  fmt("%l", "IMK_CVAR_MP_SPEED_ANIM"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_SPEED_ANIM]
    );
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_heal_spr",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEAL_SPR"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEAL_SPR]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_healer_snd",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEALER_SND"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEALER_SND]
    );   
    bind_pcvar_num(
        create_cvar(
            .name = "imk_mp_healed_snd",
            .string = "1",
            .flags = FCVAR_SERVER,
            .description = fmt("%l", "IMK_CVAR_MP_HEALED_SND"),
            .has_min = true,
            .min_val = 0.0
        ), g_Cvar[IMK_MP_HEALED_SND]
    );
}
 
Сообщения
75
Реакции
82
Помог
6 раз(а)
Код:
#include <amxmodx>
#include <reapi>

new const INFECTION_MODEL[] = "models/v_syringe.mdl";
const Float:USE_TIME = 2.3;
const Float:ADD_HEALTH = 30.0;
const Float:MAX_HEALTH = 200.0;

new Float:fUseTime[MAX_PLAYERS + 1];
new iUseData[MAX_PLAYERS + 1];

public plugin_init()
{
    register_plugin("[ReAPI] Infection Med Kit", "1.0", "Flymic24");
    
    RegisterHookChain(RG_CBasePlayerWeapon_CanDeploy, "CBasePlayerWeapon_CanDeploy", .post = false);
    RegisterHookChain(RG_CBasePlayer_PostThink, "CBasePlayer_PostThink", .post = true);
    
    RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty", .post = true);
}

public plugin_precache()
    precache_model(INFECTION_MODEL);

public client_putinserver(iPlayer)    {
    fUseTime[iPlayer] = 0.0;
    iUseData[iPlayer] = NULLENT;
}

public CBasePlayer_UseEmpty(iPlayer)
{
    if(!is_user_alive(iPlayer))
        return HC_CONTINUE;
    
    new iHitPlayer, iBody;
    get_user_aiming(iPlayer, iHitPlayer, iBody);
    
    if (is_user_connected(iHitPlayer))    {
        iUseData[iPlayer] = iHitPlayer;
    }
    else    {
        iUseData[iPlayer] = iPlayer;
    }
    
    if (get_member(iPlayer, m_iTeam) != get_member(iUseData[iPlayer], m_iTeam))    {
        client_print_color(iPlayer, print_team_default, "Товарищей лечить надо");
        return HC_CONTINUE;
    }
    
    if(Float:get_entvar(iUseData[iPlayer], var_health) >= MAX_HEALTH)    {
        client_print_color(iPlayer, print_team_default, "Этот чувак еще полон сил");
        return HC_CONTINUE;
    }
    
    set_entvar(iPlayer, var_viewmodel, INFECTION_MODEL);
    set_member(iPlayer, m_flNextAttack, USE_TIME + 0.1);
    fUseTime[iPlayer] = get_gametime() + USE_TIME;
    
    UTIL_PlayWeaponAnimation(iPlayer, 0);
    
    return HC_CONTINUE;
}

public CBasePlayer_PostThink(iPlayer)    {
    if (!is_user_alive(iPlayer) || !fUseTime[iPlayer])
        return;
    
    if (get_gametime() > fUseTime[iPlayer] && is_user_alive(iUseData[iPlayer]))    {
        fUseTime[iPlayer] = 0.0;
        iUseData[iPlayer] = NULLENT;
        set_entvar(iUseData[iPlayer], var_health, floatmin(Float: get_entvar(iUseData[iPlayer], var_health) + ADD_HEALTH, MAX_HEALTH));
        rh_emit_sound2(iPlayer, 0, CHAN_STATIC, "items/tr_kevlar.wav");
        
        new iItem = get_member(iPlayer, m_pActiveItem);
        if(is_entity(iItem)) rg_switch_weapon(iPlayer, iItem);
    }
}

public CBasePlayerWeapon_CanDeploy(iItem)    {
    new iPlayer;
    if(!(iPlayer = get_member(iItem, m_pPlayer)) || !is_user_connected(iPlayer))
        return HC_CONTINUE;
    
    if(fUseTime[iPlayer])    {
        SetHookChainReturn(ATYPE_INTEGER, false);
        return HC_SUPERCEDE;
    }
    return HC_CONTINUE;
}

stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
    set_entvar(Player, var_weaponanim, Sequence);

    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player);
    write_byte(Sequence);
    write_byte(0);
    message_end();
}
 

Вложения

Сообщения
839
Реакции
519
Помог
12 раз(а)
maFFyoZZyk,
по итогу
конструкция StatusValue тут не нужна, т.к. ты юзаешь get_user_aiming

отличный пример у флимика, лучше разбери его
а еще мне все же не нравится get_user_aiming по игроку, т.к. он скорее всего не сможет выполниться с модулем семиклипа, но это уже чисто мое ощущение.
Как говорится вас предупредили
 

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

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