#include <amxmodx>
#include <reapi>
#include <fakemeta>
new klCvars[2], bool:blKahraman[MAX_CLIENTS+1];
new const TAG[] = "SCH";
new const kahramanmodel[] = "hero";
public plugin_init() {
register_plugin("Kahraman", "1.1", "LyNcH");
bind_pcvar_float(create_cvar("kahraman_can", "255"), Float:klCvars[0]);
bind_pcvar_float(create_cvar("kahraman_armor", "255"), Float:klCvars[1]);
RegisterHookChain(RG_CBasePlayer_Spawn, "@IsSpawn", .post = true);
RegisterHookChain(RG_HandleMenu_ChooseTeam, "@fwdHandleMenu_ChooseTeam", .post = false);
register_forward(FM_ClientKill, "@fwd_FM_ClientKill");
set_task(45.0, "@KahramanSec");
}
public plugin_precache() {
precache_model(fmt("models/player/%s/%s.mdl", kahramanmodel, kahramanmodel));
}
public client_disconnected(id) {
if(blKahraman[id]) {
client_print_color(0,0, "^1[^3%s^1] ^4Kahraman Oyundan Ciktigi Icin Yeni Kahraman Seciliyor !", TAG);
set_task(5.0, "@KahramanSec");
}
}
@fwd_FM_ClientKill(id) {
if(blKahraman[id]) {
client_print_color(0,0, "^1[^3%s^1] ^4%n Adli Kahraman Kill Cekti. Yeni Kahraman Seciliyor ^1!", TAG, id);
@KahramanSec();
}
}
@KahramanSec() {
new Players[32], kliNum, klRandom; get_players( Players, kliNum, "achi" );
if(kliNum >= 1) {
klRandom = Players[random_num(0, kliNum-1)];
if(is_user_connected(klRandom) || is_user_alive(klRandom)) {
blKahraman[klRandom] = true;
set_entvar(klRandom, var_health, klCvars[0]);
set_entvar(klRandom, var_armorvalue, klCvars[1]);
rg_set_user_model(klRandom, kahramanmodel);
set_hudmessage(255, 255, 255, 0.0, 0.14, 0, 6.0, 6.0);
show_hudmessage(0, "%n Adli Oyuncu Kahraman Secildi",klRandom);
client_print_color(0,0, "^4[^4 %s ^4] [^3 %n ^1] ^1Adli Oyuncu ^4Kahraman ^1Olarak Secildi.", TAG, klRandom);
}
}
}
@fwdHandleMenu_ChooseTeam(const iPlayer, const MenuChooseTeam:key)
{
switch(key){
case MenuChoose_Spec: {
if(blKahraman[iPlayer]){
client_print_color(0,0, "^1[^3%s^1] ^4%n Adli Kahraman Spece Gecti. Yeni Kahraman Seciliyor ^1!", TAG, iPlayer);
@KahramanSec();
}
}
}
}
@CBasePlayer_Killed(const this, pevAttacker, iGib) {
if(!is_user_connected(this) || !is_user_connected(pevAttacker)) {
return;
}
if(blKahraman[this]) {
blKahraman[this] = false;
blKahraman[pevAttacker] = true;
set_entvar(pevAttacker, var_health, klCvars[0]);
set_entvar(pevAttacker, var_armorvalue, klCvars[1]);
rg_set_user_model(pevAttacker, kahramanmodel);
client_print_color(0,0, "^4[^4%s^4] ^3%n ^1Adli Oyuncu ^3%n ^1Adli Kahramani Oldurerek ^4Kahraman ^1Oldu !", TAG, pevAttacker, this);
}
}