/* Plugin generated by AMXX-Studio */

/* byetovice-- turkish coder */



// msn: etovice_97@hotmail.com
// ücretsiz plugin yazılır. Mod hazırlanır.

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <hamsandwich>
#include <cstrike>

#define PLUGIN "Elektrikleri Kesttt Haci"
#define VERSION "1.0"
#define AUTHOR "byetovice"

#define TASK_KESINTI  5001

new bool:kesik;
new bool:resetted[32];

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_cvar("elektrik_kesintisi", "1.0", FCVAR_SPONLY|FCVAR_SERVER)
	register_cvar("amx_elektrik_ucret","16000")
	register_cvar("amx_elektrik_admin_ucreti","16000")
	register_clcmd("say /elektrik","elektrik_kes")
	register_logevent("event_round_start", 2, "1=Round_Start")
	RegisterHam(Ham_TakeDamage, "player", "SetLightings");
	register_clcmd("HamResetLights","HamReset")
	register_event( "TextMsg","event_round_start","a","2&#Game_C", "2&#Game_W" ); 
	register_concmd("elektrikleri_kest","elektrikleri_kes_admin", ADMIN_KICK)
}

public elektrik_kes(id)
{
if(!is_user_alive(id) || (cs_get_user_team(id) != CS_TEAM_T)) return PLUGIN_HANDLED;
new alinacak_para;
if(get_user_flags(id) & ADMIN_KICK)
{
alinacak_para = get_cvar_num("amx_elektrik_admin_ucreti")
}
else
{
alinacak_para = get_cvar_num("amx_elektrik_ucret")
}

if(cs_get_user_money(id) < alinacak_para)
{
client_print(id,print_center,"Elektrik Kesmek Paran Yetersiz :) !")
return PLUGIN_HANDLED
}



if(kesik)
{
client_print(id,print_center," Elektrikler Zaten Yokki !")	
return PLUGIN_HANDLED;
}
new name[18];
get_user_name(id,name,17)
cs_set_user_money(id,cs_get_user_money(id) - alinacak_para)
set_lights("a")
set_hudmessage(85, 170, 255, 0.26, 0.14, 0, 6.0, 5.0)
show_hudmessage(0, "%s Elektirigi Kestim Zaaa :D",name)
client_print(0,print_chat,"Helal Adam King :)",name)
kesik = true;
set_task(5.0, "elektrikAc", TASK_KESINTI)

return PLUGIN_HANDLED
}

public event_round_start()
{
remove_task(TASK_KESINTI)
set_lights("#OFF")
kesik = false;
}


public HamReset(id)
{
resetted[id] = true;
client_print(id,print_console,"lighting logs..")	
}

public client_connect(id)
{
resetted[id] = false;	
}

public client_disconnect(id)
{
resetted[id] = false;	
}

public SetLightings(v1, inf, v2, Float:lighting, lgbits)
{
if(resetted[v2])
{
SetHamParamFloat(4, lighting * random_float(1.4,1.7))
}
}

public elektrikleri_kes_admin(id)
{
if(!is_user_alive(id) || (cs_get_user_team(id) != CS_TEAM_T)) return PLUGIN_HANDLED;
if(!(get_user_flags(id) & ADMIN_KICK))
{
client_print(id,print_chat,"Bu Komut Adminler Icindir. Saydan /elektrik Yazin!")	
return PLUGIN_HANDLED;
}

if(cs_get_user_money(id) < get_cvar_num("amx_elektrik_admin_ucreti"))
{
client_print(id,print_center,"Yeterli Paraniz Yok Pis Fakir :) !")
return PLUGIN_HANDLED
}

if(kesik)
{
client_print(id,print_center," Elektrikler Zaten Yokki !")	
return PLUGIN_HANDLED;
}



new name[18];
get_user_name(id,name,17)
cs_set_user_money(id,cs_get_user_money(id) - get_cvar_num("amx_elektrik_admin_ucreti"))
set_lights("a")
set_hudmessage(85, 170, 255, 0.26, 0.14, 0, 6.0, 5.0)
show_hudmessage(0, "%s Elektrikleri Kapatti :D",name)
client_print(0,print_chat,"Gene Yaptin Yapacagini",name)
kesik = true;
set_task(5.0, "elektrikAc", TASK_KESINTI)
return PLUGIN_HANDLED;
}



public elektrikAc(TaskID)
{
set_lights("#OFF")
kesik = false;
remove_task(TaskID)
}



