Граната Молотов

Сообщения
165
Реакции
-8
как сделать так чтобы в начале раунда граната исчезала, бывает под конец раунда кто то кинет на спавн и в начале раунда сносит Хп


Код:
#include < amxmodx >
#include < fakemeta_util >
#include < hamsandwich >

#define ZP_SUPPORT // Поддержка Zombie Plague 4.3

#if defined ZP_SUPPORT
    #include < zombieplague >
#endif

#define linux_diff_weapon        4
#define linux_diff_player        5

// CBasePlayerItem
#define m_pPlayer                41

#define MAX_CLIENTS                32
#define NADE_TYPE                1337

#define FLAME_CLASSNAME            "ent_flame" // Класснейм огня
#define FLAME_DURATION            5.0 // Сколько будет идти горение
#define FLAME_TIMERESET            0.2 // Через сколько будет наносится урон

// Урон от огня
#if defined ZP_SUPPORT
    #define FLAME_DAMAGE        random_float(30.0, 50.0)
#else
    #define FLAME_DAMAGE        random_float(3.0, 5.0)
#endif

#define GRENADE_VIEW_MODEL        "models/STRIKE_TEAM/MOLOTOV/v_molotov.mdl"
#define GRENADE_PLAYER_MODEL    "models/STRIKE_TEAM/MOLOTOV/p_molotov.mdl"
#define GRENADE_WORLD_MODEL        "models/STRIKE_TEAM/MOLOTOV/w_molotov.mdl"
#define GRENADE_MODEL_BODY        0

#define GRENADE_EXPLODE_SOUND    "STRIKE_TEAM/MOLOTOV/molotov_exp.wav"

#define WEAPON_OLD                "weapon_smokegrenade"
#define WEAPON_NEW                "x/weapon_molotov"
#define WEAPON_HUD                 "sprites/x/640hudx1.spr"

new const iWeaponList[] = { 
    13, 1,  -1, -1, 3, 3, 9,  24 // weapon_smokegrenade
}


#if defined ZP_SUPPORT
    new g_iItemID;
#endif

new g_iThinkTimes[512];
new g_iszModelIndexSprite;
new g_iUserHasMolotov[MAX_CLIENTS + 1];

public plugin_init()
{
    register_plugin("[AMXX] Grenade: Molotov", "1.1", "xUnicorn (t3rkecorejz)");

    RegisterHam(Ham_Killed, "player", "CPlayer__Killed_Post", .Post = 1);
    RegisterHam(Ham_Touch, "grenade", "CGrenade__Touch_Pre", .Post = 0);
    RegisterHam(Ham_Think, "grenade", "CGrenade__Think_Pre", .Post = 0);
    RegisterHam(Ham_Think, "info_target", "CEntity__Think_Pre", .Post = 0);
    RegisterHam(Ham_Item_Deploy, WEAPON_OLD, "CGrenade__Item_Deploy_Post", .Post = 1);
    RegisterHam(Ham_Item_AddToPlayer, WEAPON_OLD, "CGrenade__Item_AddToPlayer_Post", .Post = 1);
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");

    register_forward(FM_SetModel, "FM_Hook_SetModel_Pre", ._post = 0);

    register_clcmd(WEAPON_NEW, "HookSelect");

    #if defined ZP_SUPPORT
        g_iItemID = zp_register_extra_item("Molotov", 10, ZP_TEAM_HUMAN);
    #else
        register_clcmd("say molotov", "Command_GiveMolotov");
    #endif
}

public plugin_precache()
{
    new szBuffer[64]; formatex(szBuffer, charsmax(szBuffer), "sprites/%s.txt", WEAPON_NEW);

    engfunc(EngFunc_PrecacheGeneric, szBuffer);
    engfunc(EngFunc_PrecacheGeneric, WEAPON_HUD);
    
    g_iszModelIndexSprite = engfunc(EngFunc_PrecacheModel, "sprites/STRIKE_TEAM/MOLOTOV/flame.spr");

    engfunc(EngFunc_PrecacheModel, GRENADE_VIEW_MODEL);
    engfunc(EngFunc_PrecacheModel, GRENADE_PLAYER_MODEL);
    engfunc(EngFunc_PrecacheModel, GRENADE_WORLD_MODEL);

    engfunc(EngFunc_PrecacheSound, GRENADE_EXPLODE_SOUND);
}

public client_disconnect(iPlayer) g_iUserHasMolotov[iPlayer] = 0;

#if defined ZP_SUPPORT
    public zp_extra_item_selected(iPlayer, iItemID)
    {
        if(iItemID == g_iItemID)
            Command_GiveMolotov(iPlayer);
    }
#endif

public event_round_start(iEntity)
{
        if(!pev_valid(iEntity))
        return HAM_IGNORED;
    
    set_pev(iEntity, pev_flags, FL_KILLME);
    return PLUGIN_HANDLED;
}

public HookSelect(iPlayer)
{
    engclient_cmd(iPlayer, WEAPON_OLD);
    return PLUGIN_HANDLED;
}

public Command_GiveMolotov(iPlayer)
{
    if(!is_user_alive(iPlayer))
        return PLUGIN_HANDLED;

    if(user_has_weapon(iPlayer, CSW_SMOKEGRENADE))
    {
        g_iUserHasMolotov[iPlayer]++;
        ExecuteHamB(Ham_GiveAmmo, iPlayer, 1, "SmokeGrenade", 32);
        emit_sound(iPlayer, CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }

    if(CPlayer__MakeWeapon(iPlayer))
    {
        g_iUserHasMolotov[iPlayer]++;
        emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }
    #if defined ZP_SUPPORT
        else return ZP_PLUGIN_HANDLED;
    #else
        else return PLUGIN_HANDLED;
    #endif

    return PLUGIN_HANDLED;
}

public CPlayer__Killed_Post(iVictim) g_iUserHasMolotov[iVictim] = 0;
public CGrenade__Touch_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    if(pev(iEntity, pev_flTimeStepSound) == NADE_TYPE)
    {
        static Float: vecOrigin[3];
        pev(iEntity, pev_origin, vecOrigin);

        if(engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_WATER) {
            set_pev(iEntity, pev_flags, FL_KILLME);
            return HAM_IGNORED;
        }

        set_pev(iEntity, pev_dmgtime, get_gametime());
    }

    return HAM_IGNORED;
}

public CGrenade__Think_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    static Float: flDamageTime; pev(iEntity, pev_dmgtime, flDamageTime);
    
    if(flDamageTime > get_gametime())
        return HAM_IGNORED;

    if(pev(iEntity, pev_flTimeStepSound) == NADE_TYPE)
    {
        static Float: vecOrigin[3];
        pev(iEntity, pev_origin, vecOrigin);

        if(engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_WATER) {
            set_pev(iEntity, pev_flags, FL_KILLME);
            return HAM_IGNORED;
        }

        MolotovExplode(iEntity);
        return HAM_SUPERCEDE;
    }

    return HAM_IGNORED;
}

MolotovExplode(iEntity)
{
    if(iEntity < 0)
        return;
    
    static Float: vecOrigin[3];
    pev(iEntity, pev_origin, vecOrigin);

    emit_sound(iEntity, CHAN_WEAPON, GRENADE_EXPLODE_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

    static iReference;

    new iOwner; iOwner = pev(iEntity, pev_owner);

    if(iReference || (iReference = engfunc(EngFunc_AllocString, "info_target")))
    {
        new iFlameEntity = engfunc(EngFunc_CreateNamedEntity, iReference);

        g_iThinkTimes[iFlameEntity] = 0;

        set_pev(iFlameEntity, pev_classname, FLAME_CLASSNAME);
        set_pev(iFlameEntity, pev_solid, SOLID_TRIGGER);
        set_pev(iFlameEntity, pev_movetype, MOVETYPE_TOSS);
        set_pev(iFlameEntity, pev_effects, EF_NODRAW);
        set_pev(iFlameEntity, pev_owner, iOwner);
        set_pev(iFlameEntity, pev_nextthink, get_gametime() + FLAME_TIMERESET);

        engfunc(EngFunc_SetModel, iFlameEntity, "models/w_ak47.mdl");
        engfunc(EngFunc_SetOrigin, iFlameEntity, vecOrigin);
    }

    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_SPRITETRAIL);
    engfunc(EngFunc_WriteCoord, vecOrigin[0]);
    engfunc(EngFunc_WriteCoord, vecOrigin[1]);
    engfunc(EngFunc_WriteCoord, vecOrigin[2] + 100.0);
    engfunc(EngFunc_WriteCoord, vecOrigin[0]);
    engfunc(EngFunc_WriteCoord, vecOrigin[1]);
    engfunc(EngFunc_WriteCoord, vecOrigin[2] + 30.0);
    write_short(g_iszModelIndexSprite);
    write_byte(50);
    write_byte(random_num(17, 20));
    write_byte(random_num(4, 6));
    write_byte(15);
    write_byte(10);
    message_end();

    set_pev(iEntity, pev_flags, FL_KILLME);
}

public CEntity__Think_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    static iVictim = -1;

    new szClassName[32], vecOrigin[3], iOwner;
    pev(iEntity, pev_classname, szClassName, charsmax(szClassName));

    if(equal(szClassName, FLAME_CLASSNAME))
    {
        pev(iEntity, pev_origin, vecOrigin);
        iOwner = pev(iEntity, pev_owner);

        if(g_iThinkTimes[iEntity] == floatround(FLAME_DURATION / FLAME_TIMERESET))
        {
            set_pev(iEntity, pev_flags, FL_KILLME);

            return HAM_IGNORED;
        }

        while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 100.0)))
        {
            if(iOwner == iVictim || !is_user_alive(iVictim))
                continue;

            #if defined ZP_SUPPORT
                if(zp_get_user_zombie(iOwner) || !zp_get_user_zombie(iVictim))
                    continue;
            #endif

            ExecuteHamB(Ham_TakeDamage, iVictim, iEntity, iOwner, FLAME_DAMAGE, DMG_BURN | DMG_NEVERGIB);
        }

        g_iThinkTimes[iEntity] += 1;
        set_pev(iEntity, pev_nextthink, get_gametime() + FLAME_TIMERESET);
    }

    return HAM_IGNORED;
}

public CGrenade__Item_Deploy_Post(iEntity)
{
    static iPlayer; iPlayer = get_pdata_cbase(iEntity, m_pPlayer, linux_diff_weapon);

    #if defined ZP_SUPPORT
        if(zp_get_user_zombie(iPlayer))
            return;
    #endif

    if(!g_iUserHasMolotov[iPlayer])
        return;

    set_pev(iPlayer, pev_viewmodel2, GRENADE_VIEW_MODEL);
    set_pev(iPlayer, pev_weaponmodel2, GRENADE_PLAYER_MODEL);
}

public CGrenade__Item_AddToPlayer_Post(iItem, iPlayer) p_set_user_weaponlist(iPlayer, g_iUserHasMolotov[iPlayer]);
public FM_Hook_SetModel_Pre(iEntity, const szModel[])
{
    if(!pev_valid(iEntity))
        return FMRES_IGNORED;

    static Float: flDamageTime; pev(iEntity, pev_dmgtime, flDamageTime);
    
    if(flDamageTime == 0.0)
        return FMRES_IGNORED;

    static iOwner; iOwner = pev(iEntity, pev_owner);

    if(equal(szModel, "models/w_smokegrenade.mdl"))
    {
        if(g_iUserHasMolotov[iOwner])
        {
            engfunc(EngFunc_SetModel, iEntity, GRENADE_WORLD_MODEL);
            
            set_pev(iEntity, pev_body, GRENADE_MODEL_BODY);
            set_pev(iEntity, pev_flTimeStepSound, NADE_TYPE);

            g_iUserHasMolotov[iOwner] -= 1;

            return FMRES_SUPERCEDE;
        }
    }

    return FMRES_IGNORED;
}

public CPlayer__MakeWeapon(iPlayer)
{
    static iEntity, g_AllocString_E;

    if(g_AllocString_E || (g_AllocString_E = engfunc(EngFunc_AllocString, WEAPON_OLD)))
        iEntity = engfunc(EngFunc_CreateNamedEntity, g_AllocString_E);

    if(iEntity <= 0)
        return 0;

    g_iUserHasMolotov[iPlayer]++;
    set_pev(iEntity, pev_spawnflags, SF_NORESPAWN);
    ExecuteHam(Ham_Spawn, iEntity);

    if(!ExecuteHamB(Ham_AddPlayerItem, iPlayer, iEntity))
    {
        set_pev(iEntity, pev_flags, FL_KILLME);
        return 0;
    }

    ExecuteHamB(Ham_Item_AttachToPlayer, iEntity, iPlayer);
    return iEntity;
}

stock p_set_user_weaponlist(iPlayer, iList) {
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, iPlayer);
    write_string(iList ? WEAPON_NEW : WEAPON_OLD);
    write_byte(iWeaponList[0]);
    write_byte(iWeaponList[1]);
    write_byte(iWeaponList[2]);
    write_byte(iWeaponList[3]);
    write_byte(iWeaponList[4]);
    write_byte(iWeaponList[5]);
    write_byte(iWeaponList[6]);
    write_byte(iWeaponList[7]);
    message_end();
}
Код:
public event_round_start(iEntity)
{
        if(!pev_valid(iEntity))
        return HAM_IGNORED;
    
    set_pev(iEntity, pev_flags, FL_KILLME);
    return PLUGIN_HANDLED;
}

не помогло!
 
Сообщения
134
Реакции
463
Помог
2 раз(а)
Попробуй
Код:
#include < engine >

public event_round_start()
{
    new iFlame = MaxClients + 1;

    while ((iFlame = find_ent_by_class(iFlame, FLAME_CLASSNAME)))
    {
        set_pev(iFlame, pev_flags, FL_KILLME);
    }
}
 
Сообщения
594
Реакции
350
Предупреждения
1
Помог
9 раз(а)
Schokk, хыхыхы
Код:
#include < amxmodx >
#include < fakemeta_util >
#include < hamsandwich >
#include <reapi>

#define ZP_SUPPORT // Поддержка Zombie Plague 4.3

#if defined ZP_SUPPORT
    #include < zombieplague >
#endif

#define linux_diff_weapon        4
#define linux_diff_player        5

// CBasePlayerItem
#define m_pPlayer                41

#define MAX_CLIENTS                32
#define NADE_TYPE                1337

#define FLAME_CLASSNAME            "ent_flame" // Класснейм огня
#define FLAME_DURATION            5.0 // Сколько будет идти горение
#define FLAME_TIMERESET            0.2 // Через сколько будет наносится урон

// Урон от огня
#if defined ZP_SUPPORT
    #define FLAME_DAMAGE        random_float(30.0, 50.0)
#else
    #define FLAME_DAMAGE        random_float(3.0, 5.0)
#endif

#define GRENADE_VIEW_MODEL        "models/STRIKE_TEAM/MOLOTOV/v_molotov.mdl"
#define GRENADE_PLAYER_MODEL    "models/STRIKE_TEAM/MOLOTOV/p_molotov.mdl"
#define GRENADE_WORLD_MODEL        "models/STRIKE_TEAM/MOLOTOV/w_molotov.mdl"
#define GRENADE_MODEL_BODY        0

#define GRENADE_EXPLODE_SOUND    "STRIKE_TEAM/MOLOTOV/molotov_exp.wav"

#define WEAPON_OLD                "weapon_smokegrenade"
#define WEAPON_NEW                "x/weapon_molotov"
#define WEAPON_HUD                 "sprites/x/640hudx1.spr"

new const iWeaponList[] = {
    13, 1,  -1, -1, 3, 3, 9,  24 // weapon_smokegrenade
}


#if defined ZP_SUPPORT
    new g_iItemID;
#endif

new g_iThinkTimes[512];
new g_iszModelIndexSprite;
new g_iUserHasMolotov[MAX_CLIENTS + 1];

public plugin_init()
{
    register_plugin("[AMXX] Grenade: Molotov", "1.1", "xUnicorn (t3rkecorejz)");

    RegisterHam(Ham_Killed, "player", "CPlayer__Killed_Post", .Post = 1);
    RegisterHam(Ham_Touch, "grenade", "CGrenade__Touch_Pre", .Post = 0);
    RegisterHam(Ham_Think, "grenade", "CGrenade__Think_Pre", .Post = 0);
    RegisterHam(Ham_Think, "info_target", "CEntity__Think_Pre", .Post = 0);
    RegisterHam(Ham_Item_Deploy, WEAPON_OLD, "CGrenade__Item_Deploy_Post", .Post = 1);
    RegisterHam(Ham_Item_AddToPlayer, WEAPON_OLD, "CGrenade__Item_AddToPlayer_Post", .Post = 1);

    RegisterHookChain(RG_CSGameRules_RestartRound, "CGRules_RestartRound_Post", .post = true);

    register_forward(FM_SetModel, "FM_Hook_SetModel_Pre", ._post = 0);

    register_clcmd(WEAPON_NEW, "HookSelect");

    #if defined ZP_SUPPORT
        g_iItemID = zp_register_extra_item("Molotov", 10, ZP_TEAM_HUMAN);
    #else
        register_clcmd("say molotov", "Command_GiveMolotov");
    #endif
}

public plugin_precache()
{
    new szBuffer[64]; formatex(szBuffer, charsmax(szBuffer), "sprites/%s.txt", WEAPON_NEW);

    engfunc(EngFunc_PrecacheGeneric, szBuffer);
    engfunc(EngFunc_PrecacheGeneric, WEAPON_HUD);
  
    g_iszModelIndexSprite = engfunc(EngFunc_PrecacheModel, "sprites/STRIKE_TEAM/MOLOTOV/flame.spr");

    engfunc(EngFunc_PrecacheModel, GRENADE_VIEW_MODEL);
    engfunc(EngFunc_PrecacheModel, GRENADE_PLAYER_MODEL);
    engfunc(EngFunc_PrecacheModel, GRENADE_WORLD_MODEL);

    engfunc(EngFunc_PrecacheSound, GRENADE_EXPLODE_SOUND);
}

public client_disconnect(iPlayer) g_iUserHasMolotov[iPlayer] = 0;

#if defined ZP_SUPPORT
    public zp_extra_item_selected(iPlayer, iItemID)
    {
        if(iItemID == g_iItemID)
            Command_GiveMolotov(iPlayer);
    }
#endif

public CGRules_RestartRound_Post()
{
    new iEntity = 33;
    while((iEntity = rg_find_ent_by_class(iEntity, FLAME_CLASSNAME)))
    {
        if(!is_nullent(iEntity))
        {
            engfunc(EngFunc_RemoveEntity, iEntity);
        }
    }
}

public HookSelect(iPlayer)
{
    engclient_cmd(iPlayer, WEAPON_OLD);
    return PLUGIN_HANDLED;
}

public Command_GiveMolotov(iPlayer)
{
    if(!is_user_alive(iPlayer))
        return PLUGIN_HANDLED;

    if(user_has_weapon(iPlayer, CSW_SMOKEGRENADE))
    {
        g_iUserHasMolotov[iPlayer]++;
        ExecuteHamB(Ham_GiveAmmo, iPlayer, 1, "SmokeGrenade", 32);
        emit_sound(iPlayer, CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }

    if(CPlayer__MakeWeapon(iPlayer))
    {
        g_iUserHasMolotov[iPlayer]++;
        emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
    }
    #if defined ZP_SUPPORT
        else return ZP_PLUGIN_HANDLED;
    #else
        else return PLUGIN_HANDLED;
    #endif

    return PLUGIN_HANDLED;
}

public CPlayer__Killed_Post(iVictim) g_iUserHasMolotov[iVictim] = 0;
public CGrenade__Touch_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    if(pev(iEntity, pev_flTimeStepSound) == NADE_TYPE)
    {
        static Float: vecOrigin[3];
        pev(iEntity, pev_origin, vecOrigin);

        if(engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_WATER) {
            set_pev(iEntity, pev_flags, FL_KILLME);
            return HAM_IGNORED;
        }

        set_pev(iEntity, pev_dmgtime, get_gametime());
    }

    return HAM_IGNORED;
}

public CGrenade__Think_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    static Float: flDamageTime; pev(iEntity, pev_dmgtime, flDamageTime);
  
    if(flDamageTime > get_gametime())
        return HAM_IGNORED;

    if(pev(iEntity, pev_flTimeStepSound) == NADE_TYPE)
    {
        static Float: vecOrigin[3];
        pev(iEntity, pev_origin, vecOrigin);

        if(engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_WATER) {
            set_pev(iEntity, pev_flags, FL_KILLME);
            return HAM_IGNORED;
        }

        MolotovExplode(iEntity);
        return HAM_SUPERCEDE;
    }

    return HAM_IGNORED;
}

MolotovExplode(iEntity)
{
    if(iEntity < 0)
        return;
  
    static Float: vecOrigin[3];
    pev(iEntity, pev_origin, vecOrigin);

    emit_sound(iEntity, CHAN_WEAPON, GRENADE_EXPLODE_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

    static iReference;

    new iOwner; iOwner = pev(iEntity, pev_owner);

    if(iReference || (iReference = engfunc(EngFunc_AllocString, "info_target")))
    {
        new iFlameEntity = engfunc(EngFunc_CreateNamedEntity, iReference);

        g_iThinkTimes[iFlameEntity] = 0;

        set_pev(iFlameEntity, pev_classname, FLAME_CLASSNAME);
        set_pev(iFlameEntity, pev_solid, SOLID_TRIGGER);
        set_pev(iFlameEntity, pev_movetype, MOVETYPE_TOSS);
        set_pev(iFlameEntity, pev_effects, EF_NODRAW);
        set_pev(iFlameEntity, pev_owner, iOwner);
        set_pev(iFlameEntity, pev_nextthink, get_gametime() + FLAME_TIMERESET);

        engfunc(EngFunc_SetModel, iFlameEntity, "models/w_ak47.mdl");
        engfunc(EngFunc_SetOrigin, iFlameEntity, vecOrigin);
    }

    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_SPRITETRAIL);
    engfunc(EngFunc_WriteCoord, vecOrigin[0]);
    engfunc(EngFunc_WriteCoord, vecOrigin[1]);
    engfunc(EngFunc_WriteCoord, vecOrigin[2] + 100.0);
    engfunc(EngFunc_WriteCoord, vecOrigin[0]);
    engfunc(EngFunc_WriteCoord, vecOrigin[1]);
    engfunc(EngFunc_WriteCoord, vecOrigin[2] + 30.0);
    write_short(g_iszModelIndexSprite);
    write_byte(50);
    write_byte(random_num(17, 20));
    write_byte(random_num(4, 6));
    write_byte(15);
    write_byte(10);
    message_end();

    set_pev(iEntity, pev_flags, FL_KILLME);
}

public CEntity__Think_Pre(iEntity)
{
    if(!pev_valid(iEntity))
        return HAM_IGNORED;

    static iVictim = -1;

    new szClassName[32], vecOrigin[3], iOwner;
    pev(iEntity, pev_classname, szClassName, charsmax(szClassName));

    if(equal(szClassName, FLAME_CLASSNAME))
    {
        pev(iEntity, pev_origin, vecOrigin);
        iOwner = pev(iEntity, pev_owner);

        if(g_iThinkTimes[iEntity] == floatround(FLAME_DURATION / FLAME_TIMERESET))
        {
            set_pev(iEntity, pev_flags, FL_KILLME);

            return HAM_IGNORED;
        }

        while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, vecOrigin, 100.0)))
        {
            if(iOwner == iVictim || !is_user_alive(iVictim))
                continue;

            #if defined ZP_SUPPORT
                if(zp_get_user_zombie(iOwner) || !zp_get_user_zombie(iVictim))
                    continue;
            #endif

            ExecuteHamB(Ham_TakeDamage, iVictim, iEntity, iOwner, FLAME_DAMAGE, DMG_BURN | DMG_NEVERGIB);
        }

        g_iThinkTimes[iEntity] += 1;
        set_pev(iEntity, pev_nextthink, get_gametime() + FLAME_TIMERESET);
    }

    return HAM_IGNORED;
}

public CGrenade__Item_Deploy_Post(iEntity)
{
    static iPlayer; iPlayer = get_pdata_cbase(iEntity, m_pPlayer, linux_diff_weapon);

    #if defined ZP_SUPPORT
        if(zp_get_user_zombie(iPlayer))
            return;
    #endif

    if(!g_iUserHasMolotov[iPlayer])
        return;

    set_pev(iPlayer, pev_viewmodel2, GRENADE_VIEW_MODEL);
    set_pev(iPlayer, pev_weaponmodel2, GRENADE_PLAYER_MODEL);
}

public CGrenade__Item_AddToPlayer_Post(iItem, iPlayer) p_set_user_weaponlist(iPlayer, g_iUserHasMolotov[iPlayer]);
public FM_Hook_SetModel_Pre(iEntity, const szModel[])
{
    if(!pev_valid(iEntity))
        return FMRES_IGNORED;

    static Float: flDamageTime; pev(iEntity, pev_dmgtime, flDamageTime);
  
    if(flDamageTime == 0.0)
        return FMRES_IGNORED;

    static iOwner; iOwner = pev(iEntity, pev_owner);

    if(equal(szModel, "models/w_smokegrenade.mdl"))
    {
        if(g_iUserHasMolotov[iOwner])
        {
            engfunc(EngFunc_SetModel, iEntity, GRENADE_WORLD_MODEL);
          
            set_pev(iEntity, pev_body, GRENADE_MODEL_BODY);
            set_pev(iEntity, pev_flTimeStepSound, NADE_TYPE);

            g_iUserHasMolotov[iOwner] -= 1;

            return FMRES_SUPERCEDE;
        }
    }

    return FMRES_IGNORED;
}

public CPlayer__MakeWeapon(iPlayer)
{
    static iEntity, g_AllocString_E;

    if(g_AllocString_E || (g_AllocString_E = engfunc(EngFunc_AllocString, WEAPON_OLD)))
        iEntity = engfunc(EngFunc_CreateNamedEntity, g_AllocString_E);

    if(iEntity <= 0)
        return 0;

    g_iUserHasMolotov[iPlayer]++;
    set_pev(iEntity, pev_spawnflags, SF_NORESPAWN);
    ExecuteHam(Ham_Spawn, iEntity);

    if(!ExecuteHamB(Ham_AddPlayerItem, iPlayer, iEntity))
    {
        set_pev(iEntity, pev_flags, FL_KILLME);
        return 0;
    }

    ExecuteHamB(Ham_Item_AttachToPlayer, iEntity, iPlayer);
    return iEntity;
}

stock p_set_user_weaponlist(iPlayer, iList) {
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, iPlayer);
    write_string(iList ? WEAPON_NEW : WEAPON_OLD);
    write_byte(iWeaponList[0]);
    write_byte(iWeaponList[1]);
    write_byte(iWeaponList[2]);
    write_byte(iWeaponList[3]);
    write_byte(iWeaponList[4]);
    write_byte(iWeaponList[5]);
    write_byte(iWeaponList[6]);
    write_byte(iWeaponList[7]);
    message_end();
}
или попробовать заюзать RG_CSGameRules_CleanUpMap
 
Сообщения
1,698
Реакции
1,510
Помог
26 раз(а)
steelzzz, removentity крашит иногда.
medusa, а чем фм не угодил?
 
Последнее редактирование:
Сообщения
1,549
Реакции
1,555
Помог
2 раз(а)
Была у меня ситуацыя,когда я хукал подменённый дым ( газ ),в области которого ещё и отнимаеться здоровье.

Нужно было в конце раунда гасить сам дым и что-бы потом на месте его не отнималось здоровье

Выйшло

Здесь не хочу осматриваться, - но скину код где это сделано ( думаю розберёшься )

Код:
public FwdClear( )
{
    new iEnt = FM_NULLENT;
    while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
    {
        if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
            engfunc(EngFunc_RemoveEntity, iEnt);
    }
    Healer(0);
}
Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#pragma semicolon 1

#define PLUGIN "Gas Poison"
#define AUTHOR "ConnorMcLeod"
#define VERSION "2.0.1"

#define PEV_PDATA_SAFE    2

#define MAX_PLAYERS    32

#define m_bitsDamageType        76 // VEN

#define OFFSET_TEAM            114
#define fm_get_user_team(%1)    get_pdata_int(%1,OFFSET_TEAM)

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

#define GASNADE_HURT    -666
#define GASNADE_HEAL    -777

new g_pCvarRadius, g_pCvarCheckTime, g_pCvarDmg, g_pCvarFF, g_pCvarLife, g_pCvarRestore, g_pCvarNoSmoke, g_pCvarEnabled, g_pCvarGasFade, g_msgScreenFade;
new mp_friendlyfire;

new g_iMaxPlayers;

new g_iHealer;

new Float:g_fLastHurt[MAX_PLAYERS+1];
new Float:g_fDmgToRestore[MAX_PLAYERS+1];

new g_iForwardEmitSound;
new HamHook:g_iHamTouch, HamHook:g_iHamThink;

public plugin_init()
{
    register_plugin( PLUGIN, VERSION, AUTHOR );
    register_cvar("gasnade", VERSION, FCVAR_SERVER);

    g_pCvarEnabled = register_cvar("amx_gasnades", "1");

    g_pCvarDmg = register_cvar("amx_gasdmg", "15");
    g_pCvarRadius = register_cvar("amx_gasradius", "90");
    g_pCvarCheckTime = register_cvar("amx_gascheck", "1");
    g_pCvarFF = register_cvar("amx_gasobeyFF", "0");
    g_pCvarLife = register_cvar("amx_gaslife", "23");
    g_pCvarRestore = register_cvar("amx_gas_restore", "0");
    g_pCvarNoSmoke = register_cvar("amx_gas_nosmoke", "0");
    g_pCvarGasFade = register_cvar("amx_gasfade", "1");
    g_msgScreenFade = get_user_msgid("ScreenFade");
    
    register_event("HLTV", "Event_HLTV_NewRound", "a", "1=0", "2=0");
    register_logevent("FwdClear", 2, "1=Round_End");

    g_iMaxPlayers = get_maxplayers();
    mp_friendlyfire = get_cvar_pointer("mp_friendlyfire");

    Event_HLTV_NewRound();
}

public plugin_pause()
{
    new iEnt = FM_NULLENT;
    while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
    {
        if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
            engfunc(EngFunc_RemoveEntity, iEnt);
    }
    Healer(0);
}

public FwdClear( )
{
    new iEnt = FM_NULLENT;
    while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
    {
        if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
            engfunc(EngFunc_RemoveEntity, iEnt);
    }
    Healer(0);
}

public Event_HLTV_NewRound()
{
    new iEnt = FM_NULLENT;
    while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
    {
        if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
            engfunc(EngFunc_RemoveEntity, iEnt);
    }

    for(new id=1; id<=g_iMaxPlayers; id++)
    {
        g_fLastHurt[id] = g_fDmgToRestore[id] = 0.0;
    }

    if( get_pcvar_num(g_pCvarEnabled) )
    {
        if( !g_iForwardEmitSound )
        {
            g_iForwardEmitSound = register_forward(FM_EmitSound, "EmitSound");
        }

        if( g_iHamTouch )
        {
            EnableHamForward(g_iHamTouch);
        }
        else
        {
            g_iHamTouch = RegisterHam(Ham_Touch, "trigger_hurt", "HurtTouch");
        }

        if( g_iHamThink )
        {
            EnableHamForward(g_iHamThink);
        }
        else
        {       
            g_iHamThink = RegisterHam(Ham_Think, "trigger_hurt", "HurtThink");
        }

        Healer(get_pcvar_num(g_pCvarRestore) ? 1 : 0);
    }
    else
    {
        if( g_iForwardEmitSound )
        {
            unregister_forward(FM_EmitSound, g_iForwardEmitSound);
            g_iForwardEmitSound = 0;
        }

        if( g_iHamTouch )
        {
            DisableHamForward(g_iHamTouch);
        }

        if( g_iHamThink )
        {
            DisableHamForward(g_iHamThink);
        }

        Healer(0);
    }
}

public EmitSound(iEntity, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch)
{
    if( !equal(szSample, "weapons/sg_explode.wav") )
        return;

    new iEnt = engfunc( EngFunc_CreateNamedEntity , engfunc( EngFunc_AllocString, "trigger_hurt") );

    dllfunc(DLLFunc_Spawn, iEnt);

    new Float:fRadius = get_pcvar_float(g_pCvarRadius);
    new Float:fMins[3], Float:fMaxs[3];
    for(new i; i<3; i++)
    {
        fMins[i] = -fRadius;
        fMaxs[i] = fRadius;
    }
    engfunc(EngFunc_SetSize , iEnt , fMins , fMaxs );

    new Float:fOrigin[3];
    pev(iEntity, pev_origin, fOrigin);
    engfunc(EngFunc_SetOrigin, iEnt, fOrigin);

    set_pev(iEnt, pev_dmg, get_pcvar_float(g_pCvarDmg));

    set_pev(iEnt, pev_iuser1, GASNADE_HURT);

    new iOwner = pev(iEntity, pev_owner);
    if( pev_valid(iOwner) == PEV_PDATA_SAFE )
    {
        set_pev(iEnt, pev_iuser2, fm_get_user_team(iOwner));
        set_pev(iEnt, pev_owner, iOwner);
    }

    set_pev(iEnt, pev_nextthink, get_gametime() + get_pcvar_float(g_pCvarLife));

    if( get_pcvar_num(g_pCvarNoSmoke) )
    {
        emit_sound(iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch);
        engfunc(EngFunc_RemoveEntity, iEntity);
    }
}

public HurtThink(iEnt)
{
    if( pev(iEnt, pev_iuser1) == GASNADE_HURT )
    {
        engfunc(EngFunc_RemoveEntity, iEnt);
    }
}

public screen_fade(id)
{
    message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, id);
    write_short(1<<12);
    write_short(1<<12);
    write_short(1<<12);
    write_byte(0);
    write_byte(255);
    write_byte(0);
    write_byte(75);
    message_end();
}

public HurtTouch(iEnt, id)
{
    static iPod;
    iPod = pev(iEnt, pev_iuser1);
    if( (iPod != GASNADE_HURT && iPod != GASNADE_HEAL) ||
        !(1 <= id <= g_iMaxPlayers) )
    {
        return HAM_IGNORED;
    }

    new iOwner = pev(iEnt, pev_owner);


    if( iPod == GASNADE_HURT && get_pcvar_num(g_pCvarFF) && !get_pcvar_num(mp_friendlyfire) &&
        pev(iEnt, pev_iuser2) == fm_get_user_team(id)  )
    {
        return HAM_SUPERCEDE;
    }

    static Float:flTime, Float:flDmgTime;
    flTime = get_gametime();
    pev(iEnt, pev_dmgtime, flDmgTime);
    
    if( flDmgTime > flTime )
    {
        static Float:flPainFinished;
        pev(iEnt, pev_pain_finished, flPainFinished);
        if( flTime != flPainFinished )
        {
            static iImpulse;
            iImpulse = pev(iEnt, pev_impulse);
            if ( iImpulse & (1<<(id-1)) )
                return HAM_SUPERCEDE;

            set_pev(iEnt, pev_impulse, iImpulse | (1<<(id-1)));
        }
    }
    else
    {
        set_pev(iEnt, pev_impulse, (1<<(id-1)));
    }

    static Float:flDmg, Float:flCheckTime;
    pev(iEnt, pev_dmg, flDmg);
    flCheckTime = get_pcvar_float(g_pCvarCheckTime);

    if(get_pcvar_num(g_pCvarGasFade))
        screen_fade(id);

    if( iPod == GASNADE_HURT )
    {
        TakeDamage(id, iEnt, iOwner, flDmg, DMG_SLOWFREEZE);
        g_fDmgToRestore[id] += flDmg;
        g_fLastHurt[id] = flTime;       
    }
    else
    {
        if( flTime - g_fLastHurt[id] > flCheckTime && g_fDmgToRestore[id])
        {
            if( g_fDmgToRestore[id] < flDmg )
            {
                flDmg = g_fDmgToRestore[id];
            }
            g_fDmgToRestore[id] -= flDmg;
            TakeHealth(id, flDmg);
        }
    }
    
    if(pev_valid(iEnt))
    {
        set_pev(iEnt, pev_pain_finished, flTime);
        set_pev(iEnt, pev_dmgtime, flTime + flCheckTime);
    }
    return HAM_SUPERCEDE;
}

Healer(iStatus)
{
    if( iStatus )
    {
        if( !pev_valid(g_iHealer) )
        {
            g_iHealer = engfunc( EngFunc_CreateNamedEntity , engfunc( EngFunc_AllocString, "trigger_hurt") );
            dllfunc(DLLFunc_Spawn, g_iHealer);
            engfunc(EngFunc_SetSize , g_iHealer , Float:{-4096.0, -4096.0, -4096.0} , Float:{4096.0, 4096.0, 4096.0} );
            set_pev(g_iHealer, pev_iuser1, GASNADE_HEAL);   
        }
        set_pev(g_iHealer, pev_dmg, get_pcvar_float(g_pCvarDmg));
    }
    else
    {
        if( pev_valid(g_iHealer) )
        {
            engfunc(EngFunc_RemoveEntity, g_iHealer);
            g_iHealer = FM_NULLENT;
        }
    }
}

TakeHealth(id, Float:flDmg)
{
    new Float:flHealth, Float:flMaxHealth;

    pev(id, pev_health, flHealth);
    pev(id, pev_max_health, flMaxHealth);

    if( flMaxHealth <= flHealth )
        return;

    flHealth += flDmg;

    if( flHealth > flMaxHealth )
        flHealth = flMaxHealth;

    set_pev(id, pev_health, flHealth);
}

TakeDamage(id, iEnt, iAttacker, Float:flDmg, iDmgBit)
{
    new Float:flHealth;
    pev(id, pev_health, flHealth);

    flHealth -= flDmg;

    if( flHealth < 1 )
    {
        ExecuteHamB( Ham_Killed, id, iAttacker, 0 );
        return;
    }

    set_pev(id, pev_health, flHealth);

    set_pev(id, pev_dmg_take, flDmg);
    set_pdata_int(id, m_bitsDamageType, iDmgBit);
    set_pev(id, pev_dmg_inflictor, iEnt);
}
 
Сообщения
165
Реакции
-8
MayroN, Не помогло
2 Ноя 2020
MayroN,
Код:
public FwdClear( )
{
    new iEnt = FM_NULLENT;
    while( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "trigger_hurt")) > 0 )
    {
        if( pev(iEnt, pev_iuser1) == NADE_TYPE )
            engfunc(EngFunc_RemoveEntity, iEnt);
    }
    return PLUGIN_HANDLED;
}
 

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

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