Problem ze StripWeapons
MAGNET
28.03.2013
Witam
Mój problem jest następujący:
Postanowiłem, że stworzę perk do CODa, który będzie wywalał przeciwnikowi granaty po strzale.
Podczas kompilacji wywala 1 warninga, a granatów już nie ;]
Oto sma:
Proszę o pomoc.
Z góry dziękuję i pozdrawiam
Mój problem jest następujący:
Postanowiłem, że stworzę perk do CODa, który będzie wywalał przeciwnikowi granaty po strzale.
Podczas kompilacji wywala 1 warninga, a granatów już nie ;]
Oto sma:
Spoiler
Proszę o pomoc.
Z góry dziękuję i pozdrawiam
DarkGL
28.03.2013
if DMG_BULLET return HAM_IGNORED;zawsze prawdziwy warunek
http://amxx.pl/topic...e-na-obrazenia/
public Grenades_Drop(idattacker, this, damagebits, id)sprawdź sobie listę parametrów w poradniku
Gość_21977_* 28.03.2013
A tu zawsze fałszywy warunek.if(random_num(1, 1) != 1)
return HAM_IGNORED;
@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;
}