←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

CoD Nowy
Czy klasa jest poprawnie napisana?

  • +
  • -
1stADXionC - zdjęcie 1stADXionC 09.07.2015

Witam, tak jak w temacie: Czy klasa jest poprawnie napisana?

#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <fun>
#include <hamsandwich>
#include <ColorChat>


#define DMG_BULLET (1<<1)
#define DMG_HEGRENADE (1<<24)
        
new const nazwa[]   = "Kapitan (P)";
new const opis[]    = "Klasa premium, 1/1 z AWP | 1/4 z HE";
new const bronie    = (1<<CSW_HEGRENADE)|(1<<CSW_AWP)|(1<<CSW_M4A1)|(1<<CSW_DEAGLE);
new const zdrowie   = 40;
new const kondycja  = 5;
new const inteligencja = 0;
new const wytrzymalosc = 5;


new ma_klase[33];


public plugin_init()
{
register_plugin(nazwa, "1.0", "amxx.pl");


cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);


RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}


public cod_class_enabled(id)
{
ColorChat(0, GREEN, "[COD:MW3]^x01 Klasa %s zostala stworzona przez xxx", nazwa);


if(!(get_user_flags(id) & ADMIN_LEVEL_A))
{
ColorChat(0, GREEN, "[COD:MW3]^x01 Nie masz uprawnien, aby uzywac tej klasy.")
return COD_STOP;
}
give_item(id, "weapon_hegrenade");
         ma_klase[id] = true;


return COD_CONTINUE;
}


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(get_user_team(this) != get_user_team(idattacker) && get_user_weapon(idattacker) == CSW_AWP && damagebits & DMG_BULLET)
cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);


if(damagebits & DMG_HEGRENADE && get_user_team(this) != get_user_team(idattacker) && random_num(1,4) == 1)
cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);


return HAM_IGNORED;
}

 


Użytkownik 1stADXionC edytował ten post 09.07.2015 13:02
Odpowiedz

  • +
  • -
Linux' - zdjęcie Linux' 09.07.2015

Klasa jest napisana poprawnie, chociaz sprawdzanie warunkow w takedamage mozna napisac troche inaczej, lepiej. Np:

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker) || !ma_klase[idattacker])
		return HAM_IGNORED;

	if(get_user_team(this) == get_user_team(idattacker))
		return HAM_IGNORED;

	ifget_user_weapon(idattacker) == CSW_AWP && damagebits & DMG_BULLET)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);

	if(damagebits & DMG_HEGRENADE && random_num(1,4) == 1)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);

	return HAM_IGNORED;
}
Odpowiedz

  • +
  • -
1stADXionC - zdjęcie 1stADXionC 09.07.2015

Dzięki wielkie, a co powoduje, że gracz otrzymuje 5 he ?

Oraz jak usunąć Warning'i:

 

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team


Warning: Loose indentation on line 40
Warning: Loose indentation on line 42
Header size:            856 bytes
Code size:             3840 bytes
Data size:             1216 bytes
Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
Total requirements:   22296 bytes


2 Warnings.
Done.

 


Użytkownik 1stADXionC edytował ten post 09.07.2015 19:22
Odpowiedz

  • +
  • -
Rivit - zdjęcie Rivit 09.07.2015


Oraz jak usunąć Warning'i:

 

Pod ostatnim #include dodaj

#pragma tabsize 0


Dzięki wielkie, a co powoduje, że gracz otrzymuje 5 he ?

Perk/klasa nie ma warunku ze sprawdzeniem czy gracz ma ta klase, tak to daje wszystkim

Odpowiedz