chciałem wrzucić do siebie na serwer plugin, który będzie blokował zadawanie obrażeń osobie z tej samej drużyny, ale żeby temu atakującemu zabierał po 5hp za każde uderzenie w swojego i wypisywało mu na czacie info, żeby nie atakował swoich.
Obecnie plugin jest trochę pokręcony, bo raz działa, a raz nie. Raz bierze hp tylko atakującemu, a raz i ofierze i atakującemu razem.
Czasami jak ktoś chce zabić swojego a ma końcówkę hp, to zostaje temu atakującemu 0hp i ekran się obraca i nic nie można zrobić, a postać wygląda jak by miała laga.
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <ColorChat>
#define PLUGIN "Damage"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"
#define OFFSET_TEAM 114
#define fm_get_user_team(%1) get_pdata_int(%1, OFFSET_TEAM, 5)
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
RegisterHam(Ham_TakeDamage,"player", "client_damage");
}
public client_damage(id, idinflictor, idattacker, Float:damage, damagebits)
{
if(!is_user_connected(id) || !is_user_connected(idattacker))
return HAM_IGNORED;
if(fm_get_user_team(id) == fm_get_user_team(idattacker))
{
static Float:health, Float:newhealth;
pev(idattacker, pev_health, health);
newhealth = health - 5;
(newhealth < 0.0) ? ExecuteHam(Ham_Killed, idattacker, idattacker, 0) : set_pev(idattacker, pev_health, newhealth);
new tkiller[33];
get_user_name(idattacker, tkiller, 32)
ColorChat(idattacker, RED, "^%d, nie strzelaj do swoich!")
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}