Drop bomb after death (explode)

Сообщения
282
Реакции
34
Помог
3 раз(а)
Hi,

I am using plugin which works to drop grenade after death like in Call of Duty, which detonates, but for some reason, sometimes, when firing shots from weapon, if someone damages me like 75DMG, it swaps my weapon to bomb (flash grenade for example).
What could be the reason in code to do so?
This plugin is old so if it needs update, could anyone confirm me?

Код:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Martyrdom"
#define VERSION "1.3b"
#define AUTHOR "Soccdoodcss"

#define HE_GRENADE    (1<<0)
#define SMOKE_GRENADE    (1<<1)
#define FLASH_GRENADE    (1<<2)

new pOn, pMult, pHas, pGrens

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    RegisterHam(Ham_TakeDamage, "player", "beforeDamage")
    RegisterHam(Ham_Spawn, "player", "onSpawn")
    
    pOn = register_cvar("md_on", "1", FCVAR_SERVER)
    pMult = register_cvar("md_mult", "1.0", FCVAR_SERVER)
    pHas = register_cvar("md_hasgrenade", "0", FCVAR_SERVER)
    pGrens = register_cvar("md_grenades", "ab", FCVAR_SERVER)
    
    register_clcmd("md_grenades", "onSay")
    
    register_cvar("md_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
}

public onSay(id)
{
    new grens[33]
    get_pcvar_string(pGrens, grens, 32)
    client_print(id, print_console, "''md_grenades'' is ''%s'' ; a:hegrenade b:smokegrenade c:flashbang", grens)
}

public onSpawn(id)
{
    minAttack(id)
    if(get_pcvar_num(pOn))
    {
        set_hudmessage(15, 15, 15, -1.0, 0.0, 0, 6.0, 12.0, 0.1, 0.2, 3)
        show_hudmessage(id, "Martyrdom^nDrops Live Grenade On Death")
    }
}

public beforeDamage(id, weapon, attacker, Float:damage, damagebits)
{
    if(!get_pcvar_num(pOn) || !is_user_connected(attacker))
        return HAM_IGNORED
    
    new temp = floatround(damage, floatround_ceil)
    damage = float(temp)
    
    if(weapon != attacker)
        damage *= get_pcvar_float(pMult)
    
    if(damage >= get_user_health(id))
        passDamage(id, weapon, attacker, Float:damage, damagebits)
    
    else
        ExecuteHam(Ham_TakeDamage, id, weapon, attacker, damage, damagebits)
    
    return HAM_SUPERCEDE
}

public passDamage(id, weapon, attacker, Float:f_damage, damagebits)
{
    new gren[33], grens[33]
    new parm[5]
    new damage = floatround(f_damage)
    parm[0] = id
    parm[1] = weapon
    parm[2] = attacker
    parm[3] = damage
    parm[4] = damagebits
    
    get_pcvar_string(pGrens, grens, 32)
    
    if(!get_pcvar_num(pHas))
    {
        if(getNades() & HE_GRENADE)
            gren = "weapon_hegrenade"
        
        else if(getNades() & SMOKE_GRENADE)
            gren = "weapon_smokegrenade"
        
        else if(getNades() & FLASH_GRENADE)
            gren = "weapon_flashbang"
        
        else
        {
            set_task(0.1, "reDamage", id, parm, 5)
            return HAM_HANDLED
        }
        
        if(!user_has_weapon(id, get_weaponid(gren)))
            bacon_give_weapon(id, gren)
    }
    
    else
    {
        if(user_has_weapon(id, CSW_HEGRENADE) && getNades() & HE_GRENADE)
            gren = "weapon_hegrenade"
        
        else if(user_has_weapon(id, CSW_SMOKEGRENADE) && getNades() & SMOKE_GRENADE)
            gren = "weapon_smokegrenade"
        
        else if(user_has_weapon(id, CSW_FLASHBANG) && getNades() & FLASH_GRENADE)
            gren = "weapon_flashbang"
        
        else
        {
            set_task(0.1, "reDamage", id, parm, 5)
            return HAM_HANDLED
        }
    }
    
    
    
    client_cmd(id, gren)
    client_cmd(id, "+attack")
    
    set_task(0.1, "reDamage", id, parm, 5)
    return HAM_HANDLED
    
}

public getNades()
{
    new nades[16];
    get_pcvar_string(pGrens , nades , 15);

    return read_flags(nades);
}

public reDamage(parm[])
{
    ExecuteHam(Ham_TakeDamage, parm[0], parm[1], parm[2], float(parm[3]), parm[4])
    minAttack(parm[0])
}

stock bacon_give_weapon(index, weapon[])
{
    if(!equal(weapon,"weapon_", 7)) return 0
    
    static ent; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, weapon))
    if(!pev_valid(ent)) return 0
    
    set_pev(ent, pev_spawnflags, SF_NORESPAWN)
    dllfunc(DLLFunc_Spawn, ent)
    
    if(!ExecuteHamB(Ham_AddPlayerItem, index, ent))
    {
        if(pev_valid(ent)) set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME)
        return 0
    }
    ExecuteHamB(Ham_Item_AttachToPlayer, ent, index)
    
    return 1
}

public minAttack(id)
    client_cmd(id, "-attack")
 
Сообщения
336
Реакции
174
Помог
11 раз(а)
drag1c,
Use the standard kvar from ReGameDll to reset the grenades after death. Discard the plugin.
Код:
// Drop a grenade after player death
// 0 - disabled
// 1 - drop one the grenade
// 2 - drop an everyone grenades
//
// Default value: "0"
mp_nadedrops 0
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
drag1c,
Use the standard kvar from ReGameDll to reset the grenades after death. Discard the plugin.
Код:
// Drop a grenade after player death
// 0 - disabled
// 1 - drop one the grenade
// 2 - drop an everyone grenades
//
// Default value: "0"
mp_nadedrops 0
This plugin detonate grenade which is dropped. This is not standard drop.

I assume something in
Код:
public passDamage(id, weapon, attacker, Float:f_damage, damagebits)
happens which disturb it and cast
Код:
client_cmd(id, gren)
client_cmd(id, "+attack")
before it's time.

Could it be because I have vampire plugin so it does not take in account my current hp?
 
Последнее редактирование:
Сообщения
282
Реакции
34
Помог
3 раз(а)
I've found out it's not a switch of weapon to he grenade or any other type. It is litteraly give_weapon event.
Код:
stock bacon_give_weapon(index, weapon[])
{
    if(!equal(weapon,"weapon_", 7)) return 0
  
    static ent; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, weapon))
    if(!pev_valid(ent)) return 0
  
    set_pev(ent, pev_spawnflags, SF_NORESPAWN)
    dllfunc(DLLFunc_Spawn, ent)
  
    if(!ExecuteHamB(Ham_AddPlayerItem, index, ent))
    {
        if(pev_valid(ent)) set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME)
        return 0
    }
    ExecuteHamB(Ham_Item_AttachToPlayer, ent, index)
  
    return 1
}
It happens whenever hp drops a lot (from 100hp to 25hp, or to 7hp, etc.)

I dont know why it's happening.
It seems there is conflict with some other plugin.
 
Последнее редактирование:

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

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