Участник
Пользователь
- Сообщения
- 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?
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")