←  Problemy

AMXX.pl: Support AMX Mod X i SourceMod

»

CoD Nowy
Problem z klasą (natychmiastowe zabicie)

  • +
  • -
V!p3r's Photo V!p3r 12.12.2014

Witajcie. Mam problem z klasą. Dotyczy on tego, że ze Scouta mam 1/1, a z kosy niby wchodzi natychmiastowe zabicie ale rzadko.

Załączam kod:

#include <amxmodx>
#include <codmod>
#include <hamsandwich>

#define DMG_BULLET (1<<1)

new const nazwa[]   = "klasa test";
new const opis[]    = "testowy opis";
new const frakcja[]   = "Free";
new const bronie    = (1<<CSW_SCOUT)|(1<<CSW_XM1014);
new const zdrowie   = 300;
new const kondycja  = 200;
new const inteligencja = 100;
new const wytrzymalosc = 60;

new bool:ma_klase[33];

public plugin_init()
{
	register_plugin(nazwa, "1.0", "amxx.pl");
	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc, frakcja);
	
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled(id)
{
	ma_klase[id] = true;
}

public cod_class_disabled(id)
{
	ma_klase[id] = false;
}

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_klase[idattacker])
		return HAM_IGNORED;
	
	if(!(damagebits & DMG_BULLET))
		return HAM_IGNORED;
	
	if(get_user_weapon(idattacker) == CSW_SCOUT || get_user_weapon(idattacker) == CSW_KNIFE && random_num(1,2) == 1)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
	
	return HAM_IGNORED;
}

Quote

  • +
  • -
Wielkie Jol's Photo Wielkie Jol 12.12.2014

Ze scouta jest 1/1 a z kosy 50% szans na zabicie.

 

W czym problem?

Quote

  • +
  • -
wiwi249's Photo wiwi249 12.12.2014

	if(!(damagebits & DMG_BULLET))
		return HAM_IGNORED;

I powiedzcie mi, jak tu ma wchodzić strzał z kosy...

Quote

  • +
  • -
Wielkie Jol's Photo Wielkie Jol 12.12.2014

Rzeczywiście.

 

Zmień to na 

 

if(!(damagebits & DMG_BULLET || damagebits & DMG_SLASH))
return HAM_IGNORED;
Quote

  • +
  • -
Linux''s Photo Linux' 12.12.2014

 

Rzeczywiście.

 

Zmień to na 

if(!(damagebits & DMG_BULLET || damagebits & DMG_SLASH))
return HAM_IGNORED;

 

DMG_BULLET nie ma raczej nic do rzeczy, poniewaz dziala on zarowno dla broni jak i noza.

 

Jak chcesz by bylo 1.2 z noza i scouta to nizej daje kod.

#include <amxmodx>
#include <codmod>
#include <hamsandwich>

#define DMG_BULLET (1<<1)

new const nazwa[]   = "klasa test";
new const opis[]    = "testowy opis";
new const frakcja[]   = "Free";
new const bronie    = (1<<CSW_SCOUT)|(1<<CSW_XM1014);
new const zdrowie   = 300;
new const kondycja  = 200;
new const inteligencja = 100;
new const wytrzymalosc = 60;

new bool:ma_klase[33];

public plugin_init()
{
	register_plugin(nazwa, "1.0", "amxx.pl");	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc, frakcja);
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled(id)
{
	ma_klase[id] = true;
}

public cod_class_disabled(id)
{
	ma_klase[id] = false;
}

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_klase[idattacker])
		return HAM_IGNORED;
	
	if(!(damagebits & DMG_BULLET))
		return HAM_IGNORED;
	
	if(get_user_weapon(idattacker) == (CSW_SCOUT | CSW_KNIFE ) && random_num(1,2) == 1)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
	
	return HAM_IGNORED;
}
Quote