if(random_num(1, 1) != 1)
return HAM_IGNORED;
A tu zawsze fałszywy warunek.
@edit.
W pliku
ham_const.inc znajdziesz bez problemu
/**
* Description: Usually called whenever an entity takes any kind of damage.
* Inflictor is the entity that caused the damage (such as a gun).
* Attacker is the entity that tirggered the damage (such as the gun's owner).
* Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
*/
Ham_TakeDamage,
damagebits to suma binarna typów obrażeń, ty potrzebujesz jedynie sprawdzić, czy jest to DMG_BULLET, więc użujesz warunku
damagebits & DMG_BULLET
Dla this (ofiary) wypadałoby sprawdzić, czy w ogóle jest graczem, a następnie, czy żyje, skoro chcesz zabrać jej granaty.
IsPlayer(this) && is_user_alive(this)
Nieco poprawiony kod:
#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <hamsandwich>
#include <StripWeapons>
#define DMG_BULLET (1<<1)
#define IsPlayer(%1) (1<=%1<=maxPlayers)
new const perk_name[] = "Rozbrajacz";
new const perk_desc[] = "1/1 szans na wyrzucenie granatow przeciwnika";
new ma_perk[33];
new bool:bSwitchIfActive[33];
new maxPlayers;
public plugin_init()
{
register_plugin(perk_name, "1.0", "amxx.pl");
cod_register_perk(perk_name, perk_desc);
RegisterHam(Ham_TakeDamage, "player", "Granades_Drop");
maxPlayers=get_maxplayers();
}
public Grenades_Drop(this, idinflictor, idattacker, Float:damage, damagebits)
{
if(
damagebits & DMG_BULLET
&& IsPlayer(this)
&& is_user_alive(this)
&& is_user_connected(idattacker)
&& ma_perk[idattacker]
)
bSwitchIfActive[this] = true;
StripWeapons(this, Grenades)
client_print(this, print_chat, "Straciles granaty!");
return HAM_IGNORED;
}