Zrobię to na przykładzie przykładzie klasy beż żadnej mocy.
oraz na talibie.
1 bez mocy:
#include <amxmodx> #include <codmod> new const nazwa[] = "nazwa"; new const opis[] = "Brak"; new const bronie = 1<<CSW_M4A1 | 1<<CSW_DEAGLE; new const zdrowie = 1; new const kondycja = 1; new const inteligencja = 1; new const wytrzymalosc = 1; public plugin_init(){ cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc); }
Szukamy:
#include <codmod>
Dodajemy pod:
#include <fakemeta> #include <hamsandwich> new bool:ma_klase[33];
do plugin init dopisujemy
register_event("DeathMsg", "DeathMsg", "ade"); RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
i na koniec wklejamy:
public cod_class_enabled(id) { ma_klase[id] = true; return COD_CONTINUE; } public cod_class_disabled(id) ma_klase[id] = false; public DeathMsg() { new killer = read_data(1); new victim = read_data(2); if(!is_user_connected(killer)) return PLUGIN_CONTINUE; if(ma_klase[victim] && !ma_klase[killer]) cod_set_user_xp(killer, cod_get_user_xp(killer)+10); if(ma_klase[killer]) { new cur_health = pev(killer, pev_health); new Float:max_health = 100.0+cod_get_user_health(killer); new Float:new_health = cur_health+30.0<max_health? cur_health+30.0: max_health; set_pev(killer, pev_health, new_health); } return PLUGIN_CONTINUE; } public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits) { if(!is_user_connected(idattacker)) return HAM_IGNORED; if(!ma_klase[idattacker]) return HAM_IGNORED; return HAM_IGNORED; }
W załączniku przykładowa klasa nazwałem ją szturmowiec.
teraz na przykładzie taliba
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <engine> #include <hamsandwich> #include <codmod> #include <colorchat> new bool:ma_klase[33]; new const nazwa[] = "Talib"; new const opis[] = "1/4 szansy na natychmiastowe zabicie z deagle, AutoBH"; new const bronie = 1<<CSW_DEAGLE | 1<<CSW_HEGRENADE; new const zdrowie = 10; new const kondycja = 50; new const inteligencja = 10; new const wytrzymalosc = 10; public plugin_init() { register_plugin(nazwa, "1.0", "QTM_Peyote"); cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc); RegisterHam(Ham_TakeDamage, "player", "TakeDamage"); } public cod_class_enabled(id) { ma_klase[id] = true; ColorChat(id, GREEN, "Klasa %s zostanie zmieniona po odrodzeniu (wpisz /respawn).", nazwa); } 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_weapon(idattacker) == CSW_DEAGLE && !random(4) && damagebits & DMG_BULLET) cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits); return HAM_IGNORED; } public client_PreThink(id) { if(!ma_klase[id]) return PLUGIN_CONTINUE; if(!(get_user_button(id) & IN_JUMP)) return PLUGIN_CONTINUE; new flags = get_entity_flags(id); if (flags & FL_WATERJUMP) return PLUGIN_CONTINUE; if (entity_get_int(id, EV_INT_waterlevel) >= 2) return PLUGIN_CONTINUE; if (!(flags & FL_ONGROUND)) return PLUGIN_CONTINUE; new Float:velocity[3]; entity_get_vector(id, EV_VEC_velocity, velocity); velocity[2] += 250.0 entity_set_vector(id, EV_VEC_velocity, velocity); entity_set_int(id, EV_INT_gaitsequence, 6); return PLUGIN_CONTINUE; }
pod
#include <colorchat>
dodajemy:
#include <fakemeta>
do plugin init dodajemy:
register_event("DeathMsg", "DeathMsg", "ade");
na koniec kodu dodajemy
public DeathMsg() { new killer = read_data(1); new victim = read_data(2); if(!is_user_connected(killer)) return PLUGIN_CONTINUE; if(ma_klase[victim] && !ma_klase[killer]) cod_set_user_xp(killer, cod_get_user_xp(killer)+10); if(ma_klase[killer]) { new cur_health = pev(killer, pev_health); new Float:max_health = 100.0+cod_get_user_health(killer); new Float:new_health = cur_health+30.0<max_health? cur_health+30.0: max_health; set_pev(killer, pev_health, new_health); } return PLUGIN_CONTINUE; }
ILOŚĆ HP za zabójstwo ustalamy w tej linijce
new Float:new_health = cur_health+30.0<max_health? cur_health+30.0: max_health;zamiast+30.0 dodajemy swoją wartość.