#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <zombieplague>

new SayText, g_maxplayers, g_class[33], g_speed[33]

/* Настройка текста */
#define ZP_PREFIX			"!g[ZP]"				// (ex. "[ZP] Text")
#define ZP_CHOOSE			"!yYou choose !t[%s]"	// (ex. "[ZP] You choose [Gerrard]")
#define ZP_NOT_ADMIN		"!yYou have no access."	// (ex. "[ZP] You have no access.")

#define PLUGIN_NAME			"[ZP] Human Classes (1.0)"
#define PLUGIN_VERSION		"1.0 - 29.08.2014"
#define PLUGIN_AUTHOR		"TERKECOREJZ"

enum
{
	CLASS_GERRARD,
	CLASS_DAVIDBLACK,
	CLASS_ARA,
	CLASS_SPADE,
	CLASS_YURI2,
	CLASS_ALICE2,
	CLASS_GUNSMITH,
	CLASS_CHOIJIYOON2,
	CLASS_NULL
}

/* Флаг , чтобы взять "Spade" или "Choi Ji Yoon Limited" */
#define ADMIN_FLAG			ADMIN_LEVEL_A

/* Названия классов */
#define HUMAN_GERRARD		"Gerrard"
#define HUMAN_DAVIDBLACK	"David Black"
#define HUMAN_ARA			"Asia Red Army"
#define HUMAN_SPADE			"Spade"
#define HUMAN_YURI2			"Yuri Limited"
#define HUMAN_ALICE2		"Alice Limited"
#define HUMAN_GUNSMITH		"Gunsmith"
#define HUMAN_CHOIJIYOON2	"Choi Ji Yoon Limited"

public plugin_init() {
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	// register_clcmd("say /hc", "open_menu")
	register_event("HLTV", "Event_RoundNew", "a", "1=0", "2=0")
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam(Ham_Spawn, "player", "Spawn_post", 1)
	register_menucmd(register_menuid("Menu Classes"), 1023, "menu_handler")
	SayText = get_user_msgid("SayText") ;}

public zp_user_humanized_post(id) open_menu(id)

public Spawn_post(id){      
    if(is_user_alive(id) && is_user_connected(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id)){   
        open_menu(id)  
        return PLUGIN_HANDLED;}   
    return PLUGIN_HANDLED;}
	
/* Прикеш моделей */
public plugin_precache(){
	engfunc(EngFunc_PrecacheModel, "models/player/gerrard/gerrard.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/davidblack/davidblack.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/jra/jra.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/spade/spade.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/yuri2/yuri2.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/alice2/alice2.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/gunsmith/gunsmith.mdl")
	engfunc(EngFunc_PrecacheModel, "models/player/choijiyoon2/choijiyoon2.mdl");}
	
public client_connect(id)
	if(is_user_connected(id))
		g_class[id] = CLASS_GERRARD
	
public open_menu(id) {
	new menu[512], len, keys = MENU_KEY_0
	len += formatex(menu[len], charsmax(menu) - len, "\wChoose \yHuman Class^n^n")
	len += formatex(menu[len], charsmax(menu) - len, "\wClass: \yMale^n")
	len += formatex(menu[len], charsmax(menu) - len, "\r1. \w%s\w^n", HUMAN_GERRARD)
	keys += MENU_KEY_1
	len += formatex(menu[len], charsmax(menu) - len, "\r2. \w%s\w^n", HUMAN_DAVIDBLACK)
	keys += MENU_KEY_2
	len += formatex(menu[len], charsmax(menu) - len, "\r3. \w%s\w^n", HUMAN_ARA)
	keys += MENU_KEY_3
	if(get_user_flags(id) & ADMIN_FLAG){
		len += formatex(menu[len], charsmax(menu) - len, "\r4. \w%s \d- \y[DAMAGE x1.1] \d- \r[VIP]\w\^n", HUMAN_SPADE)
		keys += MENU_KEY_4
	} else {
		len += formatex(menu[len], charsmax(menu) - len, "\r4. \d%s - \y[DAMAGE x1.1] \d- \r[VIP]\w\^n", HUMAN_SPADE)
		keys += MENU_KEY_4;}
	len += formatex(menu[len], charsmax(menu) - len, "^n^n\wClass: \yFemale^n")
	len += formatex(menu[len], charsmax(menu) - len, "\r5. \w%s^n", HUMAN_YURI2)
	keys += MENU_KEY_5
	len += formatex(menu[len], charsmax(menu) - len, "\r6. \w%s^n", HUMAN_ALICE2)
	keys += MENU_KEY_6
	len += formatex(menu[len], charsmax(menu) - len, "\r7. \w%s^n", HUMAN_GUNSMITH)
	keys += MENU_KEY_7
	if(get_user_flags(id) & ADMIN_FLAG){
		len += formatex(menu[len], charsmax(menu) - len, "\r8. \w%s \d- \y[JUMP x1.1] \d- \r[VIP]\w^n", HUMAN_CHOIJIYOON2)
		keys += MENU_KEY_8
	} else {
		len += formatex(menu[len], charsmax(menu) - len, "\r8. \d%s - \y[JUMP x1.1] \d- \r[VIP]\w^n", HUMAN_CHOIJIYOON2)
		keys += MENU_KEY_8;}
	len += formatex(menu[len], charsmax(menu) - len, "^n\r0. \w%L", id, "ZB3_MENU_EXIT")
	if (pev_valid(id) == 2) set_pdata_int(id, 205, 0, 5)
	show_menu(id, keys, menu, -1, "Menu Classes")
	return PLUGIN_HANDLED;}

public menu_handler(id, key){
	if(!is_user_alive(id))
		return;
	switch (key) {
		case 0: classGerrard(id)
		case 1: classDavid(id)
		case 2: classAra(id)
		case 3: classSpade(id)
		case 4: classYuri2(id)
		case 5: classAlice2(id)
		case 6: classGunsmith(id)
		case 7: classChoiJiYoon2(id);}
	return;}
	
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
	if (victim != attacker && is_user_connected(attacker))
		if(g_class[attacker] == CLASS_SPADE)
			SetHamParamFloat(4, damage * 1.1)
			
public fw_CS_Player_ResetMaxSpeed(id) {
	if(!is_user_alive(id) || !g_speed[id]) return HAM_IGNORED;
	return HAM_SUPERCEDE;}
	
public Event_RoundNew() 
	for(new id = 1; id <= g_maxplayers; id++)
		g_class[id] = CLASS_NULL

public classGerrard(id){
	g_class[id] = CLASS_GERRARD
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_GERRARD)
	zp_override_user_model(id, "gerrard");}
	
public classDavid(id){
	g_class[id] = CLASS_DAVIDBLACK
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_DAVIDBLACK)
	zp_override_user_model(id, "davidblack");}
	
public classAra(id){
	g_class[id] = CLASS_ARA
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_ARA)
	zp_override_user_model(id, "jra");}
	
public classSpade(id){
	if(get_user_flags(id) & ADMIN_FLAG){
		g_class[id] = CLASS_SPADE
		zp_override_user_model(id, "spade")
		print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_SPADE)
	} else {
		open_menu(id)
		print_col_chat(id, "%s %s", ZP_PREFIX, ZP_NOT_ADMIN);} }
	
public classYuri2(id){
	g_class[id] = CLASS_YURI2
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_YURI2)
	zp_override_user_model(id, "yuri2");}
	
public classAlice2(id){
	g_class[id] = CLASS_ALICE2
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_ALICE2)
	zp_override_user_model(id, "alice2");}
	
public classGunsmith(id){
	g_class[id] = CLASS_GUNSMITH
	print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_GUNSMITH)
	zp_override_user_model(id, "gunsmith");}
	
public classChoiJiYoon2(id){
	if(get_user_flags(id) & ADMIN_FLAG){
		g_class[id] = CLASS_CHOIJIYOON2
		zp_override_user_model(id, "choijiyoon2")
		set_user_gravity(id, 0.9)
		print_col_chat(id, "%s %s", ZP_PREFIX, ZP_CHOOSE, HUMAN_CHOIJIYOON2)
	} else {
		open_menu(id)
		print_col_chat(id, "%s %s", ZP_PREFIX, ZP_NOT_ADMIN);} }
	
stock print_col_chat(const id, const input[], any:...){    
    new count = 1, players[32];    
    static msg[191];    
    vformat(msg, 190, input, 3);    
    replace_all(msg, 190, "!g", "^4")
    replace_all(msg, 190, "!y", "^1")
    replace_all(msg, 190, "!t", "^3")
    if (id) players[0] = id; else get_players(players, count, "ch");{    
        for ( new i = 0; i < count; i++ )    {    
            if ( is_user_connected(players[i]) )    {    
                message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);    
                write_byte(players[i]);    
                write_string(msg);    
                message_end();} } } }