[ CERERE PLUGIN - ZE ]

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

13 Sep 2019, 20:39

Plugin Cerut:Mini level
Descriere (adica ce face el mai exact):un plugin de arme pe xp in care sa apara asa [https://imgur.com/a/diXjt10], cu modele la arme v/p/w. Meniul acela sa apara automat , iar daca scrii /weapons iti apar toate armele pe care le detii in alt meniu ( in timp ce e deschis meniul weapons sa nu se suprapuna meniul care arata arma xp cu meniul care arata armele pe care le detii sa poti sa folosesti meniul weapons o data pe runda si sa alegi alta arma pe care o ai ), iar la zombie sa-ti schime skin-ul de la un nivel la altul cat si mainile (cutitul) + hp (sa pot sa-l setez First zombie , hp x , model x)
Serverul ruleaza (HLDS/ReHLDS):HLDS
Versiune AMX Mod X:1.8.2
Modul Serverului: ZE [sursa este a lui dias]
193.203.39.156:27015
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3016
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 458 times
Contact:

13 Sep 2019, 23:44

păi ai sistem de xp?
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent.
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

14 Sep 2019, 09:54

L E V I N wrote:
13 Sep 2019, 23:44
păi ai sistem de xp?
Da, daca se poate sa-l faci pe nick inca un cvar cu salvarea xp-ului si cele de sus de le-am mentionat.Multumesc ca-ti faci timp pentru mine.
| Afiseaza codul
#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  //#include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
#include <hamsandwich>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"


#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}

new const WEAPONCONST[MAXLEVEL][] = { "weapon_glock18",
"weapon_usp", 
"weapon_elite",
"weapon_deagle",
"weapon_tmp",
"weapon_mac10",
"weapon_mp5navy",
"weapon_m249",
"weapon_aug",
"weapon_m4a1",
"weapon_ak47"
}; // Give Weapons

new const WEAPONMDL[MAXLEVEL][] = { "models/w_glock18.mdl",
"models/w_usp.mdl",
"models/w_elite",
"models/w_deagle.mdl", 
"models/w_tmp10.mdl",
"models/w_mac10.mdl",
"models/w_mp5.mdl",
"models/w_m249.mdl",
"models/w_aug.mdl",
"models/w_m4a1.mdl",
"models/w_ak47.mdl"
}; // Blocks pick up weapon, don't change!

new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28
}

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say lvl", "showlevel");
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	register_clcmd("say menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","1"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","0"); // Save Xp by : 1 = SteamID, 0 = IP.
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();
}
public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}
public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);
}
public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}
public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}
public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}
public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}
public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}
public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0
		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}
public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}
public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}
public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}
public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}
// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
} 
public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}
// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
	{
		show_menu_level(id);
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}
public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}
public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}
//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players;
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
} 
// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables)
	}
}
public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}
public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}
public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
} 
// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}
// ============================================================//
//                          [~ Stocks ~]			       	   //
// ============================================================//
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	if (id) players[0] = id; else get_players(players,count,"ch");
	for (new i = 0; i < count; i++)
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, SayTxT, _, players);
			write_byte(players);
			write_string(msg);
			message_end();
		}
}	
public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
} 
193.203.39.156:27015
Filiq_
Utilizator neserios
Utilizator neserios
Posts: 733
Joined: 02 Nov 2014, 18:21
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Reputatie: Fost Scripter eXtreamCS
Utilizator neserios
Fond eXtream: 0
Location: Constanta
Has thanked: 26 times
Been thanked: 16 times

14 Sep 2019, 11:17

Pentru salvarea pe nume pune cvar-ul "xp_save" pe 2 si "xp_savetype" pe 0.
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3016
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 458 times
Contact:

14 Sep 2019, 13:20

uite baza, restu nu mai am timp să fac, am făcut doar meniul pentru arme, trebuie făcut și un public în care setează armele, când o să am timp poate o să l termin
nu ai pus inc necersae, deci nu știu dacă mergea sau va merge compilat

edit: cum credeam, nu merge compilat ce ai dat din start, și asta din cazua sursa, nu că ai editat sma prost

Code: Select all

#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  //#include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
#include <hamsandwich>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"


#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}

enum _:MF
{
	WName[32],
	WCCode,
	WTCode[32],
	WLevel,
	VModel[32],
	PModel[32],
	WModel[32]/*,*/
}
new const WeaponsFUNC[/*MAXLEVEL*/][MF] = {	//ARME PE LEVEL(meniu)

	{ "GLOCK 18", CSW_GLOCK18, "weapon_glock18", 1, "models/v_glock18.mdl", "models/p_glock18.mdl", "models/w_glock18.mdl" }/*,*/

};

/*
#define LEVELUPXP	400
#define SKINHATSLEVELCHANGE	30
new const WLVLS[MAXLEVEL]=//LVL ARME
{
	0,//DEF
	1,
	2,
	3
}*/

new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28 }

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/

new menuCBH

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say lvl", "showlevel");
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	register_clcmd("say menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","2"); // Save Xp by : 1 = SteamID, 0 = IP, 2 = Nicks
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();


	menuCBH = menu_makecallback( "menucallback1" );
	register_clcmd("say /tw","WM")
	register_clcmd("say_team /tw","WM")
}
public TW(id)
{
		if(!is_user_alive(id))	return

		new menu = menu_create( "Choose your weapon", "menuhandler1" );
		new level = PlayerLevel[id]//PlayerXp[ id ] / LEVELUPXP;
	   
		for( new i=0; i < sizeof(WeaponsFUNC); i++ )
		{
	/*
			for(new x;x<sizeof(WLVLS);x++)
			{
				menu_additem( menu, WeaponsFUNC[ i ][WName], _, level>=WLVLS[x], menuCBH );
			}
	*/
			new text[512]
			if(level<WeaponsFUNC[ i ][WLevel])	formatex(text,charsmax(text),"\w[\yLOCKED\w]\r %s\w [\dAvailable on level:\r %d\w]",WeaponsFUNC[ i ][WName],WeaponsFUNC[ i ][WLevel])
			menu_additem( menu, WeaponsFUNC[ i ][WName], _, _, menuCBH );
		}
	   
		menu_display( id, menu, 0);
}
public menuhandler1( id, menu, item )
{
		if(item == MENU_EXIT||!is_user_alive(id))
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		if(/*item == */user_has_weapon(id,WeaponsFUNC[item][WCCode]))
		{
			client_print(id,print_chat, "%s You already have: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		//Set_WP( id, WeaponsFUNC[item][WTCode],WeaponsFUNC[item][WCCode] );
		client_print(id,print_chat, "%s The weapon you chose is: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
		menu_destroy(menu);

		return PLUGIN_HANDLED
}
public menucallback1( id, menu, item )
{
		static szInfo[8], iAccess, iCallback;
		menu_item_getinfo(menu, item, iAccess, szInfo, charsmax(szInfo), .callback = iCallback);
		/*static iType;
		iType = str_to_num(szInfo);*/
		new level = PlayerLevel[ id ];
		if( WeaponsFUNC[item][WLevel] > level /*/ SKINWPEVELCHANGE||item == settingH[id]*/ )	return ITEM_DISABLED;
	   
		return ITEM_ENABLED;
}


// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
	{
		show_menu_level(id);
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}

public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}


public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);

	for(new i; i < sizeof(WeaponsFUNC); i++)
	{
		if(WeaponsFUNC[i][0])
		{
		precache_model(WeaponsFUNC[i][VModel])
		precache_model(WeaponsFUNC[i][PModel])
		precache_model(WeaponsFUNC[i][WModel])
		}
	}
}
public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}
public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}
public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}
public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}
public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}
public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0
		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}
public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}
public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}
public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}
public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}
// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
} 
public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}
public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}
//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players;
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
} 
// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables)
	}
}
public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}
public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}
public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
} 
// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}
// ============================================================//
//                          [~ Stocks ~]			       	   //
// ============================================================//
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	if (id) players[0] = id; else get_players(players,count,"ch");
	for (new i = 0; i < count; i++)
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, SayTxT, _, players);
			write_byte(players);
			write_string(msg);
			message_end();
		}
}	
public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
} 
Last edited by L E V I N on 14 Sep 2019, 19:41, edited 1 time in total.
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent.
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

14 Sep 2019, 13:34

L E V I N wrote:
14 Sep 2019, 13:20
uite baza, restu nu mai am timp să fac, am făcut doar meniul pentru arme, trebuie făcut și un public în care setează armele, când o să am timp poate o să l termin

BTW : acestea sunt erorile de mai jos , daca ai putea sa faci la fiecare win sa-ti dea X [ xp ] . Apreciez efortul, nu este o probleme cand ai tu timp .. astept cu nerabdare!
GUNXPv3.sma(185) : error 017: undefined symbol "PLUG_TAG"
GUNXPv3.sma(185) : warning 215: expression has no effect
GUNXPv3.sma(185) : error 001: expected token: ";", but found ")"
GUNXPv3.sma(185) : error 029: invalid expression, assumed zero
GUNXPv3.sma(185) : fatal error 107: too many error messages on one line
gunxpmod.cfg :
| Afiseaza codul
#define MAXLEVEL 24 // I suggest don't edit
#define MAX_PISTOLS_MENU 6 // I suggest don't edit

/*================================================================================
		       [!-->All those settings can be modified<--!]
=================================================================================*/
/*================================================================================
[Commenting/uncommenting MODS.]
=================================================================================*/
/*Normal mod,means simple cs style, without other mods.*/
//#define NORMAL_MOD

/*Uncomment it if you are using Zombie Swarm and comment other.*/
//#define ZOMBIE_SWARM

/*Uncomment it if you are using Zombie Infection style mods and comment other.*/
#define ZOMBIE_INFECTION

/*================================================================================
[Uncomment it if ZOMBIE_INFECTION and select zombie style MOD.]
=================================================================================*/
//#define ZOMBIE_BIOHAZARD
#define ZOMBIE_PLAGUE
/*================================================================================
[End of MODS.]
=================================================================================*/

/*================================================================================
[Admin 'Flag' for giving extra Experience to admins each kill.]
=================================================================================*/
#define ADMIN_EXTRA ADMIN_LEVEL_H
/*================================================================================
[End of flags.]
=================================================================================*/

/*================================================================================
[Sounds, Level Up wave sound.]
=================================================================================*/
new const LevelUp[] = "umbrella/levelup.wav";
/*================================================================================
[End of sounds.]
=================================================================================*/

/*================================================================================
[XP Table, rank,gun level names.]
=================================================================================*/
new const LEVELS[MAXLEVEL] = { 
90, // Needed on level 1
180, // Needed on level 2
300, // Needed on level 3
450, // Needed on level 4
700, // Needed on level 5
1200, // Needed on level 6
1800, // Needed on level 7
2800, // Needed on level 8
4100, // Needed on level 9
5200, // Needed on level 10
6000, // Needed on level 11
6800, // Needed on level 12
8200, // Needed on level 13
10200, // Needed on level 14
12000, // Needed on level 15
15000, // Needed on level 16
17500, // Needed on level 17
20500, // Needed on level 18
25500, // Needed on level 19
29000, // Needed on level 20
35000, // Needed on level 21
46000, // Needed on level 22
58000, // Needed on level 23
150000 // Needed on level 24
}; // Needed Xp on each Levels

new const GUN_LEVELS[MAXLEVEL] = { 
0, // level 0, Glock.
1, // level 1, USP.
2, // level 2, P228.
3, // level 3, Fiveseven.
4, // level 4, Deagle.
5, // level 5, Elite. // End of Secondary Weapons.
6, // level 6, TMP. 
7, // level 7, MAC-10.
8, // level 8, UMP 45.
9, // level 9, MP5 Navy.
10, // level 10, P90.
11, // level 11, Scout.
12, // level 12, AWP.
13, // level 13, Famas.
14, // level 14, Galil.
15, // level 15, M3/Pump.
16, // level 16, XM1014/Auto-pump.
17, // level 17, Ak47.
18, // level 18, M4a1.
19, // level 19, AUG.
20, // level 20, SG552.
21, // level 21, SG550.
22, // level 22, G3SG1.
23, // level 23, M249/Machinegun. // End of Primary Weapons.
}; // Needed Level to choose gun from menu

new const RANKLEVELS[MAXLEVEL][] = { "Beginner", "Beginner", "Beginner", "Beginner", "Beginner", "Slayer", "Slayer", "Slayer",
"Hunter", "Hunter", "Hunter", "Hunter", "Assassin", "Assassin", "Hero", "Hero", "Hero", "War Lord", "War Lord", 
"Supernatural", "Supernatural", "Supernatural", "Umbrella Soldier", "Umbrella Soldier"
}; // Rank Level Names

new const RANK[MAXLEVEL][] = { "Glock 18C", "USP .45 ACP Tactical", "P228 Compact", "FiveseveN", "Desert Eagle .50 AE", "Dual Elite Berettas", 
"Schmidt TMP", "Ingram MAC-10", "UMP 45", "MP5 Navy", "ES P90", "Scout", "AWP Magnum Sniper", "Famas", "IMI Galil", "M3 Super 90", "XM1014 M4", 
"AK-47", "M4A1 Carbine", "Steyr AUG A1", "SG-552 Commando", "SG-550 Auto-Sniper", "G3SG1 Auto-Sniper", "M249 Para Machinegun" 
}; // Gun Level Rank Names
/*================================================================================
[End of XP Table.]
=================================================================================*/

/*================================================================================
[Grenades on each level settings.]
=================================================================================*/
new const FLASHBANG_LEVEL[MAXLEVEL][] = { "", // 0 level, nothing if you want,won't give grenade on level 0
"", "", "",
"", "", "", 
"", "", "", // 9 level
"", "weapon_flashbang", "weapon_flashbang", "weapon_flashbang", 
"weapon_flashbang", "weapon_flashbang", "weapon_flashbang", 
"weapon_flashbang", "weapon_flashbang", "weapon_flashbang",
"weapon_flashbang", "weapon_flashbang", "weapon_flashbang", "weapon_flashbang" 
}; // Give Flashbangs on current level

new const HEGRENADE_LEVEL[MAXLEVEL][] = { "weapon_hegrenade",
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade",
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", 
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", // 9 level
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", 
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", 
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade",
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade" 
}; // Give Hegrenade on current level

new const SMOKEGRENADE_LEVEL[MAXLEVEL][] = { "weapon_smokegrenade",
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade",
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", 
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", // 9 level
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", 
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", 
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade",
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade" 
}; // Give Smokegrenade on current level

/*================================================================================
[Weapon's backpack ammo on spawn/menu choose.]
=================================================================================*/
new const AMMO2CONST[MAXLEVEL] = { 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 90, // <--awp 
400, 400, 80, 80, 400, 400, 400, 400, 200, 200, 400
}; // Weapons Ammo
gunxpmod.inc :
| Afiseaza codul
// Gun Xp Mod Include File //
#if defined _gunxpmod_included
  #endinput
#endif
#define _gunxpmod_included

#if !defined charsmax
    #define charsmax(%1) sizeof(%1)-1
#endif 

// Returns player Experience.
native get_user_xp(id)

// Sets player Experience.
native set_user_xp(id, amount)

// Returns player Level.
native get_user_level(id)

// Sets player Level.
native set_user_level(id, amount)

// Returns player Level by Xp.
native get_user_max_level(id)

// Register Item.
stock find_itemplugin()
{
	for(new i = 0; i < get_pluginsnum(); ++i)
	{
		new temp[2], name[64]
		get_plugin(i, name, 63, temp, 1, temp, 1, temp, 1, temp, 1)
 		if(equali(name, "gunxpmod_shop.amxx")) {
 			return i;
		}
	}
 	return -1;
}

stock find_itemindex()
{
	new temp[2], name[64], pluginname[64]
	get_plugin(-1, pluginname, 63, temp, 1, temp, 1, temp, 1, temp, 1)
	for (new i = 0; i < get_pluginsnum(); ++i)
	{
		get_plugin(i, name, 63, temp, 1, temp, 1, temp, 1, temp, 1)
 		if(equal(name, pluginname))
		{
 			return i
		}
	}
 	return -1
}

stock register_gxm_item(item_name[], item_desc[], item_cost)
{
	new item_index = find_itemindex()
	new itemplugin = find_itemplugin()
	new itemregfunc = get_func_id("register_item_gxm", itemplugin)

	new temp = callfunc_begin_i(itemregfunc, itemplugin)
	if(temp == -1 || temp == -2)
	{
		if(temp == -2) 
		{
			log_amx("You have to many items, and need to increase the MAX_UNLOCKS define!")
		} 
		else 
		{
			log_amx("A unkown error has happend, make sure the Upgrades plugin is loaded!")
		}
		return PLUGIN_HANDLED;		
	}

	callfunc_push_int(item_index)
	callfunc_push_str(item_name)
	callfunc_push_str(item_desc)
	callfunc_push_int(item_cost)
	
	temp = callfunc_end()
	if(temp == -1 || temp == -2) 
	{
		return PLUGIN_HANDLED;
	}
	return temp;
}
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	if (id) players[0] = id; else get_players(players,count,"ch");
	for (new i=0;i<count;i++)
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
			write_byte(players);
			write_string(msg);
			message_end();
		}
}	

Code: Select all

#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  //#include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
#include <hamsandwich>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"


#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}

enum _:MF
{
	WName[32],
	WCCode,
	WTCode[32],
	WLevel,
	VModel[32],
	PModel[32],
	WModel[32]/*,*/
}
new const WeaponsFUNC[/*MAXLEVEL*/][MF] = {	//ARME PE LEVEL(meniu)

	{ "GLOCK 18", CSW_GLOCK18, "weapon_glock18", 1, "models/v_glock18.mdl", "models/p_glock18.mdl", "models/w_glock18.mdl" }/*,*/

};

/*
#define LEVELUPXP	400
#define SKINHATSLEVELCHANGE	30
new const WLVLS[MAXLEVEL]=//LVL ARME
{
	0,//DEF
	1,
	2,
	3
}*/

new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28 }

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/

new menuCBH

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say lvl", "showlevel");
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	register_clcmd("say menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","2"); // Save Xp by : 1 = SteamID, 0 = IP, 2 = Nicks
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();


	menuCBH = menu_makecallback( "menucallback1" );
	register_clcmd("say /tw","WM")
	register_clcmd("say_team /tw","WM")
}
public TW(id)
{
		if(!is_user_alive(id))	return

		new menu = menu_create( "Choose your weapon", "menuhandler1" );
		new level = PlayerLevel[id]//PlayerXp[ id ] / LEVELUPXP;
	   
		for( new i=0; i < sizeof(WeaponsFUNC); i++ )
		{
	/*
			for(new x;x<sizeof(WLVLS);x++)
			{
				menu_additem( menu, WeaponsFUNC[ i ][WName], _, level>=WLVLS[x], menuCBH );
			}
	*/
			new text[512]
			if(level<WeaponsFUNC[ i ][WLevel])	formatex(text,charsmax(text),"\w[\yLOCKED\w]\r %s\w [\dAvailable on level:\r %d\w]",WeaponsFUNC[ i ][WName],WeaponsFUNC[ i ][WLevel])
			menu_additem( menu, WeaponsFUNC[ i ][WName], _, _, menuCBH );
		}
	   
		menu_display( id, menu, 0);
}
public menuhandler1( id, menu, item )
{
		if(item == MENU_EXIT||!is_user_alive(id))
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		if(/*item == */user_has_weapon(id,WeaponsFUNC[item][WCCode]))
		{
			client_print(id,print_chat, "%s You already have: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		//Set_WP( id, WeaponsFUNC[item][WTCode],WeaponsFUNC[item][WCCode] );
		client_print(id,print_chat, "%s The weapon you chose is: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
		menu_destroy(menu);

		return PLUGIN_HANDLED
}
public menucallback1( id, menu, item )
{
		static szInfo[8], iAccess, iCallback;
		menu_item_getinfo(menu, item, iAccess, szInfo, charsmax(szInfo), .callback = iCallback);
		/*static iType;
		iType = str_to_num(szInfo);*/
		new level = PlayerLevel[ id ];
		if( WeaponsFUNC[item][WLevel] > level /*/ SKINWPEVELCHANGE||item == settingH[id]*/ )	return ITEM_DISABLED;
	   
		return ITEM_ENABLED;
}


// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
	{
		show_menu_level(id);
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}

public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}


public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);

	for(new i; i < sizeof(WeaponsFUNC); i++)
	{
		if(WeaponsFUNC[i][0])
		{
		precache_model(WeaponsFUNC[i][VModel])
		precache_model(WeaponsFUNC[i][PModel])
		precache_model(WeaponsFUNC[i][WModel])
		}
	}
}
public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}
public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}
public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}
public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}
public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}
public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0
		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}
public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}
public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}
public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}
public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}
// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
} 
public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}
public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}
//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players;
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
} 
// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables)
	}
}
public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}
public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}
public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
} 
// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}
// ============================================================//
//                          [~ Stocks ~]			       	   //
// ============================================================//
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	if (id) players[0] = id; else get_players(players,count,"ch");
	for (new i = 0; i < count; i++)
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, SayTxT, _, players);
			write_byte(players);
			write_string(msg);
			message_end();
		}
}	
public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
} 
193.203.39.156:27015
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3016
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 458 times
Contact:

14 Sep 2019, 20:37

sper că am înțeles bine..
w_ nu știam că există..da mna

.sma

Code: Select all

#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  #include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <sqlx>
#include <nvault>
#include <colorchat>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"

#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}


enum _:MF
{
	WName[32],
	WCCode,
	WTCode[32],
	WAmmo,
	WLevel,
	VModel[32],
	PModel[32],
	WModel[32]/*,*/
}
new const WeaponsFUNC[/*MAXLEVEL*/][MF] = {	//ARME PE LEVEL(meniu)
//		NUME ARMA MENIU		COD CSW		COD WEAPON		AMMO ARMA		LEVEL NECESAR pentru ARMA		MODEL ARMA V_			MODEL ARMA P_			MODEL ARMA W_
	{	"GLOCK 18",		CSW_GLOCK18,	"weapon_glock18",	120,			1,				"models/v_glock18.mdl",		"models/p_glock18.mdl",		"models/w_glock18.mdl"	}/*,*/
};

/*
#define LEVELUPXP	400
#define SKINHATSLEVELCHANGE	30
new const WLVLS[MAXLEVEL]=//LVL ARME
{
	0,//DEF
	1,
	2,
	3
}*/
new menuCBH,bool:used[33]


enum _:ZMF
{
	SKIN[32],
	VKnife[32],
	PKnife[32],
	WKnife[32],
	HP,
	LVL
}
new const ZmFUNC[][ZMF]=
{
	{//	NUME SKIN(models/players/nume_skin/nume_skin.mdl)	NUME CUTIT(v)	NUME CUTIT(p)	NUME CUTIT(w)	HP START	LEVEL pentru BENEFICII
		"test_skin",						"v_knife1",	"p_knife1",	"w_knife1",	1337,		1
	}
}


/*inutile zic*/
new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28 }
new const WEAPONCONST[MAXLEVEL][] = {"weapon_glock18",
"weapon_usp", 
"weapon_elite",
"weapon_deagle",
"weapon_tmp",
"weapon_mac10",
"weapon_mp5navy",
"weapon_m249",
"weapon_aug",
"weapon_m4a1",
"weapon_ak47"
}; // Give Weapons

new const WEAPONMDL[MAXLEVEL][] = { "models/w_glock18.mdl",
"models/w_usp.mdl",
"models/w_elite",
"models/w_deagle.mdl", 
"models/w_tmp10.mdl",
"models/w_mac10.mdl",
"models/w_mp5.mdl",
"models/w_m249.mdl",
"models/w_aug.mdl",
"models/w_m4a1.mdl",
"models/w_ak47.mdl"
}; // Blocks pick up weapon, don't change!

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","2"); // Save Xp by : 1 = SteamID, 0 = IP, 2 = Nicks
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();


	menuCBH = menu_makecallback( "menucallback1" );//teste
	register_clcmd("say /tw","WM")
	register_clcmd("say_team /tw","WM")
	register_event("SendAudio", "Win_T", "a", "2=%!MRAD_terwin")
	register_event("SendAudio", "Win_CT", "a", "2=%!MRAD_ctwin")
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
	RegisterHam( Ham_Item_Deploy, "weapon_knife", "Ham_KnifeDeployPost", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
}
public event_new_round()	for(new id=1;id<=get_maxplayers();id++)	used[id]=false
public WM(id)
{
		if(!is_user_alive(id))	return

		new menu = menu_create( "Choose your weapon", "menuhandler1" );
		new level = PlayerLevel[id]//PlayerXp[ id ] / LEVELUPXP;
	   
		for( new i=0; i < sizeof(WeaponsFUNC); i++ )
		{
	/*
			for(new x;x<sizeof(WLVLS);x++)
			{
				menu_additem( menu, WeaponsFUNC[ i ][WName], _, level>=WLVLS[x], menuCBH );
			}
	*/
			new text[512]
			if(level<WeaponsFUNC[ i ][WLevel])	formatex(text,charsmax(text),"\w[\yLOCKED\w]\r %s\w [\dAvailable on level:\r %d\w]",WeaponsFUNC[ i ][WName],WeaponsFUNC[ i ][WLevel])
			menu_additem( menu, WeaponsFUNC[ i ][WName], _, _, menuCBH );
		}
	   
		menu_display( id, menu, 0);
}
public menuhandler1( id, menu, item )
{
		if(item == MENU_EXIT||!is_user_alive(id))
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		if(/*item == */user_has_weapon(id,WeaponsFUNC[item][WCCode]))
		{
			client_print(id,print_chat, "%s You already have: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		Set_WP( id, WeaponsFUNC[item][WTCode],WeaponsFUNC[item][WCCode],WeaponsFUNC[item][WAmmo] );
		client_print(id,print_chat, "%s The weapon you chose is: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
		menu_destroy(menu);

		return PLUGIN_HANDLED
}
public menucallback1( id, menu, item )
{
		static szInfo[8], iAccess, iCallback;
		menu_item_getinfo(menu, item, iAccess, szInfo, charsmax(szInfo), .callback = iCallback);
		/*static iType;
		iType = str_to_num(szInfo);*/
		new level = PlayerLevel[ id ];
		if( WeaponsFUNC[item][WLevel] > level /*/ SKINWPEVELCHANGE||item == settingH[id]*/ )	return ITEM_DISABLED;
	   
		return ITEM_ENABLED;
}
stock Set_WP(const id,const WPName[]="",WPCode,WPAmmo)
{
	if(!is_user_alive(id))	return

	strip_user_weapons(id)
	give_item(id,"weapon_knife")
	give_item(id,WPName)
	cs_set_user_bpammo(id,WPCode,WPAmmo)
}


// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			if(!used[id])	show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )///hmmm
	{
		show_menu_level(id);
	}

	used[id]=true

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}

public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}

public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);


	for(new i; i < sizeof(WeaponsFUNC); i++)
	{
		if(WeaponsFUNC[i][0])
		{
		precache_model(WeaponsFUNC[i][VModel])
		precache_model(WeaponsFUNC[i][PModel])
		precache_model(WeaponsFUNC[i][WModel])
		}
	}

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		precache_player_model(ZmFUNC[i][SKIN],1)

		precache_player_model(ZmFUNC[i][VKnife],2)
		precache_player_model(ZmFUNC[i][PKnife],2)
		precache_player_model(ZmFUNC[i][WKnife],2)
	}
}
precache_player_model(szModel[],mode)
{
	static szFile[512]

	switch(mode)
	{
		case 1:
		{
			formatex(szFile, charsmax(szFile), "models/player/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)

			replace(szFile, charsmax(szFile), ".mdl", "T.mdl")
			if(file_exists(szFile))	precache_model(szFile)
		}
		case 2:
		{
			formatex(szFile, charsmax(szFile), "models/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)
		}
	}
}

public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}

public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}

public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}

public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}

public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}

public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}

public fw_SetModel(entity, model[])//dropped knife??for W_....
{
	if(!pev_valid(entity))	return FMRES_IGNORED

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(!equali(model, ZmFUNC[i][WKnife])) return FMRES_IGNORED

		new className[33]
		pev(entity, pev_classname, className, 32)
    
		//            dropped weapons                    map weapons                       c4 + grenades
		if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
		{
			engfunc(EngFunc_SetModel, entity, ZmFUNC[i][WKnife])
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}
public Ham_KnifeDeployPost( iEnt ) 
{
	new id = get_pdata_cbase( iEnt, 41,4 ); // m_pPlayer = 41 , 4 - linux offset...
	if(!is_user_alive(id))	return

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			set_pev(id, pev_viewmodel2, ZmFUNC[i][VKnife])
			set_pev(id, pev_weaponmodel2, ZmFUNC[i][PKnife]);
			break
		}
	}
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0


	/*switch(PlayerLevel[id])
	{
		
	}*/
	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			cs_set_user_model(id,ZmFUNC[i][SKIN])
			set_user_health(id,ZmFUNC[i][HP])
			break
		}
	}

		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);

		WM(id)
	}
	#endif
}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}

public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}

public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}

public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}

public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}

public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}

// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
}

public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}

public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}

//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players[i];
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
}

// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
	}
}

public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}

public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}

public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}

public Win_T() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "TERRORIST") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i]

		if(is_user_connected(player))
		{
			PlayerXp[player] += T_WIN_XP
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,T_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += T_WIN_XP_ALIVE
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,T_WIN_XP_ALIVE)
		}
	} 
	return PLUGIN_CONTINUE
}
public Win_CT() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "CT") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i] 
		
		if(is_user_connected(player))
		{
			PlayerXp[player] += CT_WIN_XP
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,CT_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += CT_WIN_XP_ALIVE
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,CT_WIN_XP_ALIVE)
		}
	}
	return PLUGIN_CONTINUE
}

// ============================================================ //
//			[~ Stocks ~]				//
// ============================================================ //
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	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, SayTxT, _, players[i]);
		write_byte(players[i]);
		write_string(msg);
		message_end();
	}
}

public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
}
.cfg

Code: Select all

#define MAXLEVEL 11
#define MAX_PISTOLS_MENU 6


#define PLUG_TAG "[AMXX]"
#define CT_WIN_XP 10
#define CT_WIN_XP_ALIVE 15
#define T_WIN_XP 10
#define T_WIN_XP_ALIVE 15


/*================================================================================
		       [!-->All those settings can be modified<--!]
=================================================================================*/
/*================================================================================
[Commenting/uncommenting MODS.]
=================================================================================*/
/*Normal mod,means simple cs style, without other mods.*/
//#define NORMAL_MOD

/*Uncomment it if you are using Zombie Swarm and comment other.*/
//#define ZOMBIE_SWARM

/*Uncomment it if you are using Zombie Infection style mods and comment other.*/
#define ZOMBIE_INFECTION

/*================================================================================
[Uncomment it if ZOMBIE_INFECTION and select zombie style MOD.]
=================================================================================*/
//#define ZOMBIE_BIOHAZARD
#define ZOMBIE_PLAGUE
/*================================================================================
[End of MODS.]
=================================================================================*/

/*================================================================================
[Admin 'Flag' for giving extra Experience to admins each kill.]
=================================================================================*/
#define ADMIN_EXTRA ADMIN_LEVEL_H
/*================================================================================
[End of flags.]
=================================================================================*/

/*================================================================================
[Sounds, Level Up wave sound.]
=================================================================================*/
new const LevelUp[] = "umbrella/levelup.wav";
/*================================================================================
[End of sounds.]
=================================================================================*/

/*================================================================================
[XP Table, rank,gun level names.]
=================================================================================*/
new const LEVELS[MAXLEVEL] = { 
90, // Needed on level 1
180, // Needed on level 2
300, // Needed on level 3
450, // Needed on level 4
700, // Needed on level 5
1200, // Needed on level 6
1800, // Needed on level 7
2800, // Needed on level 8
4100, // Needed on level 9
5200, // Needed on level 10
6000 // Needed on level 11
}; // Needed Xp on each Levels

new const GUN_LEVELS[MAXLEVEL] = { 
0, // level 0, Glock.
1, // level 1, USP.
2, // level 2, P228.
3, // level 3, Fiveseven.
4, // level 4, Deagle.
5, // level 5, Elite. // End of Secondary Weapons.
6, // level 6, TMP. 
7, // level 7, MAC-10.
8, // level 8, UMP 45.
9, // level 9, MP5 Navy.
10 // level 10, P90.
}; // Needed Level to choose gun from menu

new const RANKLEVELS[MAXLEVEL][] = { "Beginner", "Beginner", "Beginner", "Beginner", "Beginner", "Slayer", "Slayer", "Slayer",
"Hunter", "Hunter", "Hunter"
}; // Rank Level Names

new const RANK[MAXLEVEL][] = { "Glock 18C", "USP .45 ACP Tactical", "P228 Compact", "FiveseveN", "Desert Eagle .50 AE", "Dual Elite Berettas", 
"Schmidt TMP", "Ingram MAC-10", "UMP 45", "MP5 Navy", "ES P90"
}; // Gun Level Rank Names
/*================================================================================
[End of XP Table.]
=================================================================================*/

/*================================================================================
[Grenades on each level settings.]
=================================================================================*/
new const FLASHBANG_LEVEL[MAXLEVEL][] = { "", // 0 level, nothing if you want,won't give grenade on level 0
"", "", "",
"", "", "", 
"", "", "",
"weapon_flashbang"
}; // Give Flashbangs on current level

new const HEGRENADE_LEVEL[MAXLEVEL][] = { "weapon_hegrenade",
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade",
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", 
"weapon_hegrenade", "weapon_hegrenade", "weapon_hegrenade", // 9 level
"weapon_hegrenade"
}; // Give Hegrenade on current level

new const SMOKEGRENADE_LEVEL[MAXLEVEL][] = { "weapon_smokegrenade",
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade",
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", 
"weapon_smokegrenade", "weapon_smokegrenade", "weapon_smokegrenade", // 9 level
"weapon_smokegrenade"
}; // Give Smokegrenade on current level

/*================================================================================
[Weapon's backpack ammo on spawn/menu choose.]
=================================================================================*/
new const AMMO2CONST[MAXLEVEL] = { 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400
}; // Weapons Ammo
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent.
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

14 Sep 2019, 21:25

Rectific totul , pluginul merge [ am modificat l-am pus pe normal mode ] dar , am omis ceva si te rog sa ma scuzi de deranj .. poti sa-mi scoti modelele p/w de la zombie [ deoarece mi-am dat seama p nu imi trebuie si w-ul nu exista eram obosit si nu mi-am dat seama ce am scris ]. Sa-mi lasi doar v. Multumesc! [ din cauza la p/w imi da eroare de la modele ]

BTW : sper ca in meniul de arme sa inceapa cu primary , dupa cu secondary alergerile . [ lvl 0 arma mare , dupa pistol ]
Last edited by King Innsane on 14 Sep 2019, 22:06, edited 3 times in total.
193.203.39.156:27015
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3016
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 458 times
Contact:

14 Sep 2019, 21:42

e activ pentru zm, pune l pe normal mod
eu ți am dat ce mi ai dat
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent.
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

15 Sep 2019, 16:02

L E V I N wrote:
14 Sep 2019, 21:42
e activ pentru zm, pune l pe normal mod
eu ți am dat ce mi ai dat
Da, multumesc frumos.Functioneza cum mi-ai zis , dar imi da eroare din cauza la p/w. [Modelele la zombie pentru knife ]. Daca se poate sa mi-le scoti cum am specificat mai sus.[Am editat].
193.203.39.156:27015
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3016
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 458 times
Contact:

15 Sep 2019, 17:45

nu știu ce eroare poate să-ți dea de la _p...dacă nu are _p lași "" la cazul său, sau dacă vrei să folosești ceva default pui modelul respecitv(gen p_knife)
e doar 1 meniu, în care bagi ce arme vrei...nu ai zis de primare sau secundare...

Code: Select all

#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  #include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <sqlx>
#include <nvault>
#include <colorchat>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"

#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}


enum _:MF
{
	WName[32],
	WCCode,
	WTCode[32],
	WAmmo,
	WLevel,
	VModel[32],
	PModel[32],
	WModel[32]/*,*/
}
new const WeaponsFUNC[/*MAXLEVEL*/][MF] = {	//ARME PE LEVEL(meniu)
//		NUME ARMA MENIU		COD CSW		COD WEAPON		AMMO ARMA		LEVEL NECESAR pentru ARMA		MODEL ARMA V_			MODEL ARMA P_			MODEL ARMA W_
	{	"GLOCK 18",		CSW_GLOCK18,	"weapon_glock18",	120,			1,				"models/v_glock18.mdl",		"models/p_glock18.mdl",		"models/w_glock18.mdl"	}/*,*/
};

/*
#define LEVELUPXP	400
#define SKINHATSLEVELCHANGE	30
new const WLVLS[MAXLEVEL]=//LVL ARME
{
	0,//DEF
	1,
	2,
	3
}*/
new menuCBH,bool:used[33]


enum _:ZMF
{
	SKIN[32],
	VKnife[32],
	/*PKnife[32],
	WKnife[32],*/
	HP,
	LVL
}
new const ZmFUNC[][ZMF]=
{
	{//	NUME SKIN(models/players/nume_skin/nume_skin.mdl)	NUME CUTIT(v)	NUME CUTIT(p)	NUME CUTIT(w)	HP START	LEVEL pentru BENEFICII
		"test_skin",						"v_knife1",	/*"p_knife1",	"w_knife1",*/	1337,		1
	}
}


/*inutile zic*/
new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28 }
new const WEAPONCONST[MAXLEVEL][] = {"weapon_glock18",
"weapon_usp", 
"weapon_elite",
"weapon_deagle",
"weapon_tmp",
"weapon_mac10",
"weapon_mp5navy",
"weapon_m249",
"weapon_aug",
"weapon_m4a1",
"weapon_ak47"
}; // Give Weapons

new const WEAPONMDL[MAXLEVEL][] = { "models/w_glock18.mdl",
"models/w_usp.mdl",
"models/w_elite",
"models/w_deagle.mdl", 
"models/w_tmp10.mdl",
"models/w_mac10.mdl",
"models/w_mp5.mdl",
"models/w_m249.mdl",
"models/w_aug.mdl",
"models/w_m4a1.mdl",
"models/w_ak47.mdl"
}; // Blocks pick up weapon, don't change!

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","2"); // Save Xp by : 1 = SteamID, 0 = IP, 2 = Nicks
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();


	menuCBH = menu_makecallback( "menucallback1" );//teste
	register_clcmd("say /tw","WM")
	register_clcmd("say_team /tw","WM")
	register_event("SendAudio", "Win_T", "a", "2=%!MRAD_terwin")
	register_event("SendAudio", "Win_CT", "a", "2=%!MRAD_ctwin")
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
	RegisterHam( Ham_Item_Deploy, "weapon_knife", "Ham_KnifeDeployPost", 1 );
	//register_forward(FM_SetModel, "fw_SetModel")
}
public event_new_round()	for(new id=1;id<=get_maxplayers();id++)	used[id]=false
public WM(id)
{
		if(!is_user_alive(id))	return

		new menu = menu_create( "Choose your weapon", "menuhandler1" );
		new level = PlayerLevel[id]//PlayerXp[ id ] / LEVELUPXP;
	   
		for( new i=0; i < sizeof(WeaponsFUNC); i++ )
		{
	/*
			for(new x;x<sizeof(WLVLS);x++)
			{
				menu_additem( menu, WeaponsFUNC[ i ][WName], _, level>=WLVLS[x], menuCBH );
			}
	*/
			new text[512]
			if(level<WeaponsFUNC[ i ][WLevel])	formatex(text,charsmax(text),"\w[\yLOCKED\w]\r %s\w [\dAvailable on level:\r %d\w]",WeaponsFUNC[ i ][WName],WeaponsFUNC[ i ][WLevel])
			menu_additem( menu, WeaponsFUNC[ i ][WName], _, _, menuCBH );
		}
	   
		menu_display( id, menu, 0);
}
public menuhandler1( id, menu, item )
{
		if(item == MENU_EXIT||!is_user_alive(id))
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		if(/*item == */user_has_weapon(id,WeaponsFUNC[item][WCCode]))
		{
			client_print(id,print_chat, "%s You already have: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		Set_WP( id, WeaponsFUNC[item][WTCode],WeaponsFUNC[item][WCCode],WeaponsFUNC[item][WAmmo] );
		client_print(id,print_chat, "%s The weapon you chose is: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
		menu_destroy(menu);

		return PLUGIN_HANDLED
}
public menucallback1( id, menu, item )
{
		static szInfo[8], iAccess, iCallback;
		menu_item_getinfo(menu, item, iAccess, szInfo, charsmax(szInfo), .callback = iCallback);
		/*static iType;
		iType = str_to_num(szInfo);*/
		new level = PlayerLevel[ id ];
		if( WeaponsFUNC[item][WLevel] > level /*/ SKINWPEVELCHANGE||item == settingH[id]*/ )	return ITEM_DISABLED;
	   
		return ITEM_ENABLED;
}
stock Set_WP(const id,const WPName[]="",WPCode,WPAmmo)
{
	if(!is_user_alive(id))	return

	strip_user_weapons(id)
	give_item(id,"weapon_knife")
	give_item(id,WPName)
	cs_set_user_bpammo(id,WPCode,WPAmmo)
}


// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			if(!used[id])	show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )///hmmm
	{
		show_menu_level(id);
	}

	used[id]=true

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}

public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}

public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);


	for(new i; i < sizeof(WeaponsFUNC); i++)
	{
		if(WeaponsFUNC[i][0])
		{
		precache_model(WeaponsFUNC[i][VModel])
		precache_model(WeaponsFUNC[i][PModel])
		precache_model(WeaponsFUNC[i][WModel])
		}
	}

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		precache_player_model(ZmFUNC[i][SKIN],1)

		precache_player_model(ZmFUNC[i][VKnife],2)
		/*precache_player_model(ZmFUNC[i][PKnife],2)
		precache_player_model(ZmFUNC[i][WKnife],2)*/
	}
}
precache_player_model(szModel[],mode)
{
	static szFile[512]

	switch(mode)
	{
		case 1:
		{
			formatex(szFile, charsmax(szFile), "models/player/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)

			replace(szFile, charsmax(szFile), ".mdl", "T.mdl")
			if(file_exists(szFile))	precache_model(szFile)
		}
		case 2:
		{
			formatex(szFile, charsmax(szFile), "models/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)
		}
	}
}

public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}

public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}

public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}

public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}

public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}

public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}

/*public fw_SetModel(entity, model[])//dropped knife??for W_....
{
	if(!pev_valid(entity))	return FMRES_IGNORED

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(!equali(model, ZmFUNC[i][WKnife])) return FMRES_IGNORED

		new className[33]
		pev(entity, pev_classname, className, 32)
    
		//            dropped weapons                    map weapons                       c4 + grenades
		if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
		{
			engfunc(EngFunc_SetModel, entity, ZmFUNC[i][WKnife])
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}*/
public Ham_KnifeDeployPost( iEnt ) 
{
	new id = get_pdata_cbase( iEnt, 41,4 ); // m_pPlayer = 41 , 4 - linux offset...
	if(!is_user_alive(id))	return

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			set_pev(id, pev_viewmodel2, ZmFUNC[i][VKnife])
			//set_pev(id, pev_weaponmodel2, ZmFUNC[i][PKnife]);
			break
		}
	}
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0


	/*switch(PlayerLevel[id])
	{
		
	}*/
	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			cs_set_user_model(id,ZmFUNC[i][SKIN])
			set_user_health(id,ZmFUNC[i][HP])
			break
		}
	}

		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);

		WM(id)
	}
	#endif
}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}

public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}

public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}

public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}

public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}

public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}

// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
}

public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}

public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}

//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players[i];
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
}

// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
	}
}

public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}

public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}

public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}

public Win_T() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "TERRORIST") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i]

		if(is_user_connected(player))
		{
			PlayerXp[player] += T_WIN_XP
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,T_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += T_WIN_XP_ALIVE
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,T_WIN_XP_ALIVE)
		}
	} 
	return PLUGIN_CONTINUE
}
public Win_CT() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "CT") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i] 
		
		if(is_user_connected(player))
		{
			PlayerXp[player] += CT_WIN_XP
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,CT_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += CT_WIN_XP_ALIVE
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,CT_WIN_XP_ALIVE)
		}
	}
	return PLUGIN_CONTINUE
}

// ============================================================ //
//			[~ Stocks ~]				//
// ============================================================ //
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	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, SayTxT, _, players[i]);
		write_byte(players[i]);
		write_string(msg);
		message_end();
	}
}

public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
} 
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent.
User avatar
King Innsane
Membru, skill 0
Membru, skill 0
Posts: 12
Joined: 30 Mar 2019, 15:34
Detinator Steam: Da
Detinator server CS: 193.203.39.156:27015
Fond eXtream: 0

15 Sep 2019, 18:23

L E V I N wrote:
15 Sep 2019, 17:45
nu știu ce eroare poate să-ți dea de la _p...dacă nu are _p lași "" la cazul său, sau dacă vrei să folosești ceva default pui modelul respecitv(gen p_knife)
e doar 1 meniu, în care bagi ce arme vrei...nu ai zis de primare sau secundare...

Code: Select all

#include "gunxpmod.cfg"

#if defined ZOMBIE_BIOHAZARD
  #include <biohazard>
#endif
#if defined ZOMBIE_PLAGUE
  #include <zombieplague>
#endif

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <sqlx>
#include <nvault>
#include <colorchat>

#define PLUGIN	"XP-Mod"
#define AUTHOR	"-"
#define VERSION	"2.5"

#define OFFSET_PRIMARYWEAPON 116
#define TASK_SHOW_LEVEL 10113
#define fm_cs_set_user_nobuy(%1) set_pdata_int(%1, 235, get_pdata_int(%1, 235) & ~(1<<0) ) //no weapon buy

new PlayerXp[33];
new PlayerLevel[33];

new g_Vault;
new g_remember_selection[33], g_kills[33], g_remember_selection_pistol[33];
new g_maxplayers, g_msgHudSync1, SayTxT, enable_grenades;
new levelspr, levelspr2, show_level_text, show_rank;
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, p_Enabled, level_style;
new enable_admin_xp, admin_xp;

/*================================================================================
						[MySQLx Vars, other]
=================================================================================*/
new Handle:g_hTuple;

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}


enum _:MF
{
	WName[32],
	WCCode,
	WTCode[32],
	WAmmo,
	WLevel,
	VModel[32],
	PModel[32],
	WModel[32]/*,*/
}
new const WeaponsFUNC[/*MAXLEVEL*/][MF] = {	//ARME PE LEVEL(meniu)
//		NUME ARMA MENIU		COD CSW		COD WEAPON		AMMO ARMA		LEVEL NECESAR pentru ARMA		MODEL ARMA V_			MODEL ARMA P_			MODEL ARMA W_
	{	"GLOCK 18",		CSW_GLOCK18,	"weapon_glock18",	120,			1,				"models/v_glock18.mdl",		"models/p_glock18.mdl",		"models/w_glock18.mdl"	}/*,*/
};

/*
#define LEVELUPXP	400
#define SKINHATSLEVELCHANGE	30
new const WLVLS[MAXLEVEL]=//LVL ARME
{
	0,//DEF
	1,
	2,
	3
}*/
new menuCBH,bool:used[33]


enum _:ZMF
{
	SKIN[32],
	VKnife[32],
	/*PKnife[32],
	WKnife[32],*/
	HP,
	LVL
}
new const ZmFUNC[][ZMF]=
{
	{//	NUME SKIN(models/players/nume_skin/nume_skin.mdl)	NUME CUTIT(v)	NUME CUTIT(p)	NUME CUTIT(w)	HP START	LEVEL pentru BENEFICII
		"test_skin",						"v_knife1",	/*"p_knife1",	"w_knife1",*/	1337,		1
	}
}


/*inutile zic*/
new const AMMOCONST[MAXLEVEL] = { 10, 16, 23, 26, 10, 16, 17, 20, 8, 19, 28 }
new const WEAPONCONST[MAXLEVEL][] = {"weapon_glock18",
"weapon_usp", 
"weapon_elite",
"weapon_deagle",
"weapon_tmp",
"weapon_mac10",
"weapon_mp5navy",
"weapon_m249",
"weapon_aug",
"weapon_m4a1",
"weapon_ak47"
}; // Give Weapons

new const WEAPONMDL[MAXLEVEL][] = { "models/w_glock18.mdl",
"models/w_usp.mdl",
"models/w_elite",
"models/w_deagle.mdl", 
"models/w_tmp10.mdl",
"models/w_mac10.mdl",
"models/w_mp5.mdl",
"models/w_m249.mdl",
"models/w_aug.mdl",
"models/w_m4a1.mdl",
"models/w_ak47.mdl"
}; // Blocks pick up weapon, don't change!

/*================================================================================
						[Plugin natives,precache,init]
=================================================================================*/

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("gxm_version", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
	set_cvar_string("gxm_version", VERSION)
	
	register_concmd("amx_level", "cmd_give_level", ADMIN_CFG, "<Nume Joc> <NR LVL>" );
	register_clcmd("say /lvl", "showlevel");
	register_clcmd("say /top20","showtop20");
	register_clcmd("say /menu","show_main_menu_info");
	
	p_Enabled = register_cvar( "xp_enable", "1" ); // Plugin enabled? 1 = Yes, 0 = No.
	save_type = register_cvar("xp_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("xp_save","2"); // Save Xp by : 1 = SteamID, 0 = IP, 2 = Nicks
	xp_kill = register_cvar("xp_nivel","10"); // How much xp gain if you killed someone?
	show_level_text = register_cvar("xp_level_text","0"); // Show your level by : 1 = HUD message, 0 = Simple colored text message.
	show_rank = register_cvar("xp_show_rank","1"); // Show rank in /top20? 1 = Yes, 0 = No.
	level_style = register_cvar("xp_level_style","0"); // You will gain each level new gun : 1 = Yes, 0 = No,select your gun by menu.
	enable_grenades = register_cvar("xp_grenades","1"); // Give to player grenades? 1 = Yes, 0 = No.
	
	enable_triple = register_cvar("xp_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("xp_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("xp_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("xp_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("xp_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("xp_ultra_kills","6"); // How much kills needed to give bonus xp?
	
	enable_admin_xp = register_cvar("xp_admin_xp","1"); // Enable Extra xp for killing? 1 = Yes, 0 = No.
	admin_xp = register_cvar("xp_extra_xp","10"); // How much extra xp give to admins?
	
					// SQLx cvars
	mysqlx_host = register_cvar ("xp_host", ""); // The host from the db
	mysqlx_user = register_cvar ("xp_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("xp_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("xp_dbname", ""); // The database name 
	
					// Events //
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	
					// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);
	
	register_forward(FM_Touch, "fwd_Touch");
	
					// Messages //
	#if defined NORMAL_MOD || defined ZOMBIE_SWARM
	register_message(get_user_msgid("StatusIcon"),	"Message_StatusIcon")
	#endif
	
					// Other //	
	register_menucmd(register_menuid("Main Menu"), 1023, "main_menu_info")
	
	register_dictionary("gunxpmod.txt");
	MySQLx_Init()
					
	SayTxT = get_user_msgid("SayText");
	
	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();


	menuCBH = menu_makecallback( "menucallback1" );//teste
	register_clcmd("say /tw","WM")
	register_clcmd("say_team /tw","WM")
	register_event("SendAudio", "Win_T", "a", "2=%!MRAD_terwin")
	register_event("SendAudio", "Win_CT", "a", "2=%!MRAD_ctwin")
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
	RegisterHam( Ham_Item_Deploy, "weapon_knife", "Ham_KnifeDeployPost", 1 );
	//register_forward(FM_SetModel, "fw_SetModel")
}
public event_new_round()	for(new id=1;id<=get_maxplayers();id++)	used[id]=false
public WM(id)
{
		if(!is_user_alive(id))	return

		new menu = menu_create( "Choose your weapon", "menuhandler1" );
		new level = PlayerLevel[id]//PlayerXp[ id ] / LEVELUPXP;
	   
		for( new i=0; i < sizeof(WeaponsFUNC); i++ )
		{
	/*
			for(new x;x<sizeof(WLVLS);x++)
			{
				menu_additem( menu, WeaponsFUNC[ i ][WName], _, level>=WLVLS[x], menuCBH );
			}
	*/
			new text[512]
			if(level<WeaponsFUNC[ i ][WLevel])	formatex(text,charsmax(text),"\w[\yLOCKED\w]\r %s\w [\dAvailable on level:\r %d\w]",WeaponsFUNC[ i ][WName],WeaponsFUNC[ i ][WLevel])
			menu_additem( menu, WeaponsFUNC[ i ][WName], _, _, menuCBH );
		}
	   
		menu_display( id, menu, 0);
}
public menuhandler1( id, menu, item )
{
		if(item == MENU_EXIT||!is_user_alive(id))
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		if(/*item == */user_has_weapon(id,WeaponsFUNC[item][WCCode]))
		{
			client_print(id,print_chat, "%s You already have: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}

		Set_WP( id, WeaponsFUNC[item][WTCode],WeaponsFUNC[item][WCCode],WeaponsFUNC[item][WAmmo] );
		client_print(id,print_chat, "%s The weapon you chose is: %s",PLUG_TAG, WeaponsFUNC[item][WName]);
		menu_destroy(menu);

		return PLUGIN_HANDLED
}
public menucallback1( id, menu, item )
{
		static szInfo[8], iAccess, iCallback;
		menu_item_getinfo(menu, item, iAccess, szInfo, charsmax(szInfo), .callback = iCallback);
		/*static iType;
		iType = str_to_num(szInfo);*/
		new level = PlayerLevel[ id ];
		if( WeaponsFUNC[item][WLevel] > level /*/ SKINWPEVELCHANGE||item == settingH[id]*/ )	return ITEM_DISABLED;
	   
		return ITEM_ENABLED;
}
stock Set_WP(const id,const WPName[]="",WPCode,WPAmmo)
{
	if(!is_user_alive(id))	return

	strip_user_weapons(id)
	give_item(id,"weapon_knife")
	give_item(id,WPName)
	cs_set_user_bpammo(id,WPCode,WPAmmo)
}


// Main Menu Level Style
public show_main_menu_level(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60], szChooseT[40], szLastG[40];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "main_menu_level");
	
	formatex(szChooseT, charsmax(szChooseT), "%L", LANG_SERVER, "CHOOSE_TEXT");
	menu_additem(menu, szChooseT, "1", 0);
	
	formatex(szLastG, charsmax(szLastG), "%L", LANG_SERVER, "LAST_GUNS");
	menu_additem(menu, szLastG, "2", 0);
	
	new szExit[15];
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_EXITNAME, szExit);
	
	menu_display(id , menu , 0);
} 
public main_menu_level(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);
	
	switch (item_id)
	{
		case 1: // show pistols
		{
			if(!used[id])	show_menu_level_pistol(id);
		}
		case 2: // last weapons
		{
			if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )
			{
				give_weapon_menu(id, g_remember_selection[id], 1, 1);
				give_weapon_menu(id, g_remember_selection_pistol[id], 0, 0);
			}
			else if ( PlayerLevel[id] < MAX_PISTOLS_MENU )
			{
				give_weapon_menu(id, g_remember_selection_pistol[id], 1, 1);
			}
		}
	}

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Pistols
public show_menu_level_pistol(id)
{
	if ( !is_user_alive(id) )
		return;
	
	new szInfo[60];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "pistol_menu");
	
	for (new item_id = 0; item_id < MAX_PISTOLS_MENU; item_id++)
	{
		new szItems[60], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
			
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public pistol_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection_pistol[id] = item_id;
	
	give_weapon_menu(id, item_id, 1, 1);
	
	if ( PlayerLevel[id] > MAX_PISTOLS_MENU - 1 )///hmmm
	{
		show_menu_level(id);
	}

	used[id]=true

	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
// Menu Level Style Primary
public show_menu_level(id)
{
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
		return;
	
	new szInfo[100];
	formatex(szInfo, charsmax(szInfo), "%L", LANG_SERVER, "TITLE_MENU", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]] );
	
	new menu = menu_create(szInfo , "level_menu");
	
	for (new item_id = MAX_PISTOLS_MENU; item_id < MAXLEVEL; item_id++)
	{
		new szItems[512], szTempid[32];
			
		if ( PlayerLevel[id] >= GUN_LEVELS[item_id] )
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "ACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )

			num_to_str(item_id, szTempid, charsmax(szTempid) );

			menu_additem(menu, szItems, szTempid, 0);
		}
		else
		{
			formatex(szItems, charsmax(szItems), "%L", LANG_SERVER, "INACTIVE_MENU", RANK[item_id], GUN_LEVELS[item_id] )
			menu_additem(menu, szItems, "999", 0, menu_makecallback("CallbackMenu"));
		}
	}
	
	new szNext[15], szBack[15], szExit[15];
	formatex(szBack, charsmax(szBack), "%L", LANG_SERVER, "BACK_MENU");
	formatex(szNext, charsmax(szNext), "%L", LANG_SERVER, "NEXT_MENU");
	formatex(szExit, charsmax(szExit), "%L", LANG_SERVER, "EXIT_MENU");
	
	menu_setprop(menu, MPROP_BACKNAME, szBack) 
	menu_setprop(menu, MPROP_NEXTNAME, szNext) 
	menu_setprop(menu, MPROP_EXITNAME, szExit) 
	
	menu_display(id , menu , 0); 
}
public level_menu(id , menu , item) 
{ 
	if ( !is_user_alive(id) || PlayerLevel[id] < MAX_PISTOLS_MENU )
	{
		return PLUGIN_HANDLED;
	}
	
	#if defined ZOMBIE_PLAGUE
	if ( zp_has_round_started() && cs_get_user_team(id) == CS_TEAM_T )
		return PLUGIN_HANDLED;
	#endif
	
	if(item == MENU_EXIT) 
	{ 
		menu_destroy(menu); 
		return PLUGIN_HANDLED;
	} 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);

	new item_id = str_to_num(data);

	g_remember_selection[id] = item_id;
	
	give_weapon_menu(id, item_id, 0, 0);
	
	menu_destroy(menu); 
	return PLUGIN_HANDLED;
}
public CallbackMenu(id, menu, item) 
{ 
    return ITEM_DISABLED; 
}

// Selected by menu or remember selection and give item
public give_weapon_menu(id, selection, strip, givegren)
{
	#if defined ZOMBIE_SWARM
    if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled) ) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
    if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
    {
		if ( strip )
		{
			StripPlayerWeapons(id);
		}
		
		if ( get_pcvar_num(enable_grenades) && givegren )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[selection]);

		cs_set_user_bpammo(id, AMMOCONST[selection], AMMO2CONST[selection])
    }
	#endif
}

public plugin_natives()
{
					// Player natives //
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}

public plugin_precache()
{
	levelspr = engfunc(EngFunc_PrecacheModel, "sprites/xfire.spr");
	levelspr2 = engfunc(EngFunc_PrecacheModel, "sprites/xfire2.spr");
	
	engfunc(EngFunc_PrecacheSound, LevelUp);


	for(new i; i < sizeof(WeaponsFUNC); i++)
	{
		if(WeaponsFUNC[i][0])
		{
		precache_model(WeaponsFUNC[i][VModel])
		precache_model(WeaponsFUNC[i][PModel])
		precache_model(WeaponsFUNC[i][WModel])
		}
	}

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		precache_player_model(ZmFUNC[i][SKIN],1)

		precache_player_model(ZmFUNC[i][VKnife],2)
		/*precache_player_model(ZmFUNC[i][PKnife],2)
		precache_player_model(ZmFUNC[i][WKnife],2)*/
	}
}
precache_player_model(szModel[],mode)
{
	static szFile[512]

	switch(mode)
	{
		case 1:
		{
			formatex(szFile, charsmax(szFile), "models/player/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)

			replace(szFile, charsmax(szFile), ".mdl", "T.mdl")
			if(file_exists(szFile))	precache_model(szFile)
		}
		case 2:
		{
			formatex(szFile, charsmax(szFile), "models/%s/%s.mdl", szModel, szModel)
			precache_model(szFile)
		}
	}
}

public plugin_cfg()
{
	new ConfDir[32], File[192];
	
	get_configsdir( ConfDir, charsmax( ConfDir ) );
	formatex( File, charsmax( File ), "%s/gunxpmod.cfg", ConfDir );
	
	if( !file_exists( File ) )
	{
		server_print( "File %s doesn't exist!", File );
		write_file( File, "", -1 );
	}
	else
	{	
		server_print( "%s successfully loaded.", File );
		server_cmd( "exec %s", File );
	}
	
    //Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "gunxpmod" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening GunXpMod nVault, file does not exist!" );
}

public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}

public client_connect(id)
{
	g_remember_selection[id] = MAX_PISTOLS_MENU;
	g_remember_selection_pistol[id] = 0;
	
	LoadLevel(id)
}

public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}

public Message_StatusIcon(iMsgId, MSG_DEST, id) 
{ 
	if( !get_pcvar_num(p_Enabled) )
		return PLUGIN_HANDLED;
		
	static szIcon[5] 
	get_msg_arg_string(2, szIcon, 4) 
	if( szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z' ) 
	{ 
		if( get_msg_arg_int(1)) 
		{ 
			fm_cs_set_user_nobuy(id) 
			return PLUGIN_HANDLED;
		} 
	}  
	
	return PLUGIN_CONTINUE;
}

public fwd_Touch(ent, id)
{
	if (!is_user_alive(id) || !pev_valid( ent ) )
		return FMRES_IGNORED;
 
	static szEntModel[32]; 
	pev( ent , pev_model , szEntModel , 31 ); 
     
	for (new level_equip_id = PlayerLevel[id] + 1; level_equip_id < MAXLEVEL; level_equip_id++) 
	{ 
		if ( equali( szEntModel , WEAPONMDL[level_equip_id] ) ) 
		{ 
			return FMRES_SUPERCEDE; 
		}  
	} 

	return FMRES_IGNORED;
}

/*public fw_SetModel(entity, model[])//dropped knife??for W_....
{
	if(!pev_valid(entity))	return FMRES_IGNORED

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(!equali(model, ZmFUNC[i][WKnife])) return FMRES_IGNORED

		new className[33]
		pev(entity, pev_classname, className, 32)
    
		//            dropped weapons                    map weapons                       c4 + grenades
		if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
		{
			engfunc(EngFunc_SetModel, entity, ZmFUNC[i][WKnife])
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}*/
public Ham_KnifeDeployPost( iEnt ) 
{
	new id = get_pdata_cbase( iEnt, 41,4 ); // m_pPlayer = 41 , 4 - linux offset...
	if(!is_user_alive(id))	return

	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			set_pev(id, pev_viewmodel2, ZmFUNC[i][VKnife])
			//set_pev(id, pev_weaponmodel2, ZmFUNC[i][PKnife]);
			break
		}
	}
}
public fwd_PlayerSpawn(id)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;
	
	g_kills[id] = 0


	/*switch(PlayerLevel[id])
	{
		
	}*/
	for(new i; i < sizeof(ZmFUNC); i++)
	{
		if(PlayerLevel[id]==ZmFUNC[i][LVL])
		{
			cs_set_user_model(id,ZmFUNC[i][SKIN])
			set_user_health(id,ZmFUNC[i][HP])
			break
		}
	}

		
	#if defined ZOMBIE_SWARM
	if ( !get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( !get_pcvar_num(level_style))
	{
		StripPlayerWeapons(id);
			
		set_task(2.0, "show_main_menu_level", id)
	}
	#endif
		
	if( get_pcvar_num(show_level_text) )
	{
		remove_task( TASK_SHOW_LEVEL + id );		

		set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
	}
	
	#if defined ZOMBIE_SWARM	
	if ( get_pcvar_num(level_style) && cs_get_user_team(id) == CS_TEAM_CT )
	{
		set_task(0.3, "give_weapon", id);
	}
	#endif

	#if defined NORMAL_MOD || defined ZOMBIE_INFECTION
	if ( get_pcvar_num(level_style) )
	{
		set_task(0.3, "give_weapon", id);

		WM(id)
	}
	#endif
}

#if defined ZOMBIE_PLAGUE
public zp_user_humanized_post(id, survivor)
{
	if( !get_pcvar_num(p_Enabled) || !is_user_alive(id) )
		return;

	set_task(1.0, "show_main_menu_level", id);
}
#endif

#if defined ZOMBIE_BIOHAZARD
public event_infect(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra) + get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

#if defined ZOMBIE_PLAGUE
public zp_user_infected_post(g_victim, g_attacker)
{
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}
#endif

public event_deathmsg()
{	
	if( !get_pcvar_num(p_Enabled) )
		return;
	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{
				if ( get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA)
				{
					PlayerXp[g_attacker] += get_pcvar_num(admin_xp)
				}
					
				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "TRIPLE_XP", counted_triple + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "%L", LANG_SERVER, "ULTRA_XP", counted_ultra + (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0))
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0)
					show_hudmessage(g_attacker, "+%i", (get_pcvar_num(enable_admin_xp) && get_user_flags(g_attacker) & ADMIN_EXTRA ? get_pcvar_num(admin_xp) : 0) + get_pcvar_num(xp_kill) )
				}
				
				check_level(g_attacker)
			}
		}
	}
}

public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0 && get_pcvar_num(p_Enabled))
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(255, 255, 255, 0.6, -1.0, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "%L", LANG_SERVER, "LEVEL_TEXT", sName, PlayerLevel[target], RANKLEVELS[PlayerLevel[target]])
	}
}

public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id) || !get_pcvar_num(show_level_text) || !get_pcvar_num(p_Enabled) )
		return;
	
	set_hudmessage(255, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "%L", LANG_SERVER, "LEVEL_HUD_TEXT", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]], RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}

public showlevel(id)
{
	if ( !get_pcvar_num(p_Enabled) || get_pcvar_num(show_level_text) )
		return PLUGIN_HANDLED;
	
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", PlayerLevel[id] , PlayerXp[id], LEVELS[PlayerLevel[id]]);
	client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT3", RANK[PlayerLevel[id]], RANKLEVELS[PlayerLevel[id]]);
	
	return PLUGIN_HANDLED;
}

public descriptionx(id)
{
	new szMotd[2048], szTitle[64], iPos = 0
	format(szTitle, 63, "Info")
	iPos += format(szMotd[iPos], 2047-iPos, "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-left:0px;}</style></head><pre><body>")
	iPos += format(szMotd[iPos], 2047-iPos, "^n^n<b>%s</b>^n^n", szTitle)
	iPos += format(szMotd[iPos], 2047-iPos, "%L^n", LANG_SERVER, "DESCRIPTION")
	
	iPos += format(szMotd[iPos], 2047-iPos, "%L", LANG_SERVER, "DESCRIPTION2")
		
	show_motd(id, szMotd, szTitle)
	return PLUGIN_HANDLED;
}

public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1 && get_pcvar_num(p_Enabled))
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
				
			if(is_user_alive(id))
			{	
				if ( get_pcvar_num(level_style) )
				{
					give_weapon(id);
				}
				
				new p_origin[3];
				get_user_origin(id, p_origin, 0);
				
				set_sprite(p_origin, levelspr, 30)
				set_sprite(p_origin, levelspr2, 30)
			}
			emit_sound(id, CHAN_ITEM, LevelUp, 1.0, ATTN_NORM, 0, PITCH_NORM);
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_printcolor(0, "%L", LANG_SERVER, "LEVEL_UP", name, PlayerLevel[id]);
		}
	} 
}

// Main Menu Info
public show_main_menu_info(id)
{
	if ( !get_pcvar_num(p_Enabled) )
		return;
	
	static menu[510], len;
	len = 0;
    
	new xKeys3 = MENU_KEY_0|MENU_KEY_1;

    // Title
	len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "TITLE_MENU_INFO")
	
	len += formatex(menu[len], sizeof menu - 1 - len, "\r1. \w%L", id, "INFO")
	if ( get_pcvar_num(show_rank) )
	{
		xKeys3 |= (MENU_KEY_2)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\r2. \wTop 20^n")
	}
	else
	{
		len += formatex(menu[len], sizeof menu - 1 - len, "^n\d2. Top 20^n")
	}
	
	if(find_plugin_byfile("gunxpmod_shop.amxx") != INVALID_PLUGIN_ID)
	{
		xKeys3 |= (MENU_KEY_3)
		
		len += formatex(menu[len], sizeof menu - 1 - len, "\r3. \w%L^n", id, "ITEM_LIST")
		if ( is_user_alive(id) )
		{
			xKeys3 |= (MENU_KEY_4)
			
			len += formatex(menu[len], sizeof menu - 1 - len, "\r4. \w%L^n", id, "UNLOCKS_SHOP_TEXT")
		}
	}
	
	len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "EXIT_MENU")

	show_menu(id, xKeys3, menu, -1, "Main Menu")
}

public main_menu_info(id, key)
{
	switch (key)
	{
		case 0:
		{
			show_main_menu_info(id)
			
			descriptionx(id)
		}
		case 1:
		{
			showtop20(id)
			
			show_main_menu_info(id)
		}
		case 2:
		{
			show_main_menu_info(id)
			
			if(callfunc_begin( "display_items","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 3:
		{
			if(callfunc_begin("item_upgrades","") == 1)
			{
				callfunc_push_int( id ); 
				callfunc_end();
			}
		}
		case 9:
		{
			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public give_weapon(id)
{
	#if defined ZOMBIE_SWARM
	if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}
		
		give_item(id, WEAPONCONST[PlayerLevel[id]]);
			
		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
	
	#if defined ZOMBIE_INFECTION || defined NORMAL_MOD
	if(is_user_alive(id) && get_pcvar_num(p_Enabled)) 
	{
		StripPlayerWeapons(id);
		
		if ( get_pcvar_num(enable_grenades) && get_pcvar_num(level_style) )
		{
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, FLASHBANG_LEVEL[PlayerLevel[id]]);
			give_item(id, HEGRENADE_LEVEL[PlayerLevel[id]]);
			give_item(id, SMOKEGRENADE_LEVEL[PlayerLevel[id]]);
		}

		give_item(id, WEAPONCONST[PlayerLevel[id]]);

		cs_set_user_bpammo(id, AMMOCONST[PlayerLevel[id]], AMMO2CONST[PlayerLevel[id]])
	}
	#endif
}

public set_sprite(p_origin[3], sprite, radius)
{
	// Explosion
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY, p_origin)
	write_byte(TE_EXPLOSION)
	write_coord(p_origin[0])
	write_coord(p_origin[1])
	write_coord(p_origin[2])
	write_short(sprite)
	write_byte(radius)
	write_byte(15)
	write_byte(4)
	message_end()
}

//Shows Top 20
public showtop20(id)
{
	if( !get_pcvar_num(p_Enabled) && !get_pcvar_num(show_rank) )
		return;
	
	static Sort[33][2];
	new players[32],num,count,index;
	get_players(players,num);
    
	for(new i = 0; i < num; i++)
	{
		index = players[i];
		Sort[count][0] = index;
		Sort[count][1] = PlayerXp[index];
		count++;
	}
    
	SortCustom2D(Sort,count,"CompareXp");
	new motd[1501],iLen;
	iLen = formatex(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "# Experience");
    
	new y = clamp(count,0,20);
	new name[32],kindex;
    
	for(new x = 0; x < y; x++)
	{
		kindex = Sort[x][0];
		get_user_name(kindex,name,sizeof name - 1);
		iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, Sort[x][1]);
	}
	iLen += formatex(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>");
	show_motd(id,motd, "GunXpMod Top 20");
}
public CompareXp(elem1[], elem2[])
{
    if(elem1[1] > elem2[1])
        return -1;
    else if(elem1[1] < elem2[1])
        return 1;
    
    return 0;
}

// Command to set player Level
public cmd_give_level(id, level, cid) 
{
	if( !cmd_access(id, level, cid, 3) || !get_pcvar_num(p_Enabled) )
	{
		return PLUGIN_HANDLED;
	}
	
	new Arg1[64], Target
	read_argv(1, Arg1, 63)
	Target = cmd_target(id, Arg1, 0)
	
	new iLevel[32], Value
	read_argv(2, iLevel, 31)
	Value = str_to_num(iLevel)
	
	if(iLevel[0] == '-') 
	{
		console_print(id, "You can't have a '-' in the value!")
		return PLUGIN_HANDLED;
	}
	
	if(!Target) 
	{
		console_print(id, "Target not found!")
		return PLUGIN_HANDLED;
	}
	
	if(Value > MAXLEVEL-1)
	{
		console_print(id, "You can't set a more than %d!", MAXLEVEL-1)
		return PLUGIN_HANDLED;
	}
	
	if(Value < 1)
	{
		console_print(id, "You can't set less than 1!")
		return PLUGIN_HANDLED;
	}
	
	new AdminName[32]
	get_user_name(id, AdminName, 31)
		
	new TargetName[32]
	get_user_name(Target, TargetName, 31)
	
	PlayerLevel[Target] = Value - 1
	PlayerXp[Target] = LEVELS[PlayerLevel[Target]]
	check_level(Target)
	
	client_printcolor(Target, "/gADMIN: /ctr%s /yhas set your level to /g%d", AdminName, Value)

	return PLUGIN_HANDLED;
}

// ============================================================//
//                          [~ Saving datas ~]			       //
// ============================================================//
public MySQLx_Init()
{
	if ( !get_pcvar_num(p_Enabled) || !get_pcvar_num(save_type) )
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
	}
}

public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}

public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}

public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

// ============================================================//
//                          [~ Natives ~]			       	   //
// ============================================================//
// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}

public Win_T() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "TERRORIST") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i]

		if(is_user_connected(player))
		{
			PlayerXp[player] += T_WIN_XP
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,T_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += T_WIN_XP_ALIVE
			ColorChat(player,RED, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,T_WIN_XP_ALIVE)
		}
	} 
	return PLUGIN_CONTINUE
}
public Win_CT() 
{ 
	new players[32], num, player; 
	get_players(players, num, "ch", "CT") 
	
	for(new i = 0; i < num; i++) 
	{ 
		player = players[i] 
		
		if(is_user_connected(player))
		{
			PlayerXp[player] += CT_WIN_XP
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru castigarea rundei.",PLUG_TAG,CT_WIN_XP)
		}
		if(is_user_alive(player))
		{
			PlayerXp[player] += CT_WIN_XP_ALIVE
			ColorChat(player,BLUE, "%s Ai castigat bonus %d XP pentru ca ai supravietuit.",PLUG_TAG,CT_WIN_XP_ALIVE)
		}
	}
	return PLUGIN_CONTINUE
}

// ============================================================ //
//			[~ Stocks ~]				//
// ============================================================ //
stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg,190,input,3);
	replace_all(msg,190,"/g","^4");// green txt
	replace_all(msg,190,"/y","^1");// orange txt
	replace_all(msg,190,"/ctr","^3");// team txt
	replace_all(msg,190,"/w","^0");// team txt
	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, SayTxT, _, players[i]);
		write_byte(players[i]);
		write_string(msg);
		message_end();
	}
}

public StripPlayerWeapons(id) 
{ 
	strip_user_weapons(id) 
	set_pdata_int(id, OFFSET_PRIMARYWEAPON, 0) 
	give_item(id, "weapon_knife");
} 
Nu este cum am explicat ... in primul rand, daca poti te rog frumos sa-mi scoti cele 2 meniuri. Primul meniu a lui dias de arme , iar al doilea meniu este cel standard din pluginul gunxp si sa-l lasi pe al tau.
In al doilea rand, eu am explicat in felul urmator si s-a inteles alt ceva : poza aceasta este meniul [ https://imgur.com/a/diXjt10 ] cand ajungi de la lvl 1 la lvl 2 acolo unde este arma [ M3 ] se inclocuieste cu alta ex [ AK47 ] iar jos unde este blocata arma respectiva iti apare urmatorea arma de la urmatorul nivel.. Si armele se inlocuiesc de la un nivel la altul pastrand cele 2 meniuri.

Imagini : https://imgur.com/a/11mUljJ [ acestea sunt meniurile pe care doresc sa le scoti primul este cel standard din gun xp al doilea cel a lui dias]

Pe scurt : eu voiam de fapt un meniu inlocuitor celui standard din gunxp.Adica meniul acela din poza cu cele 2 arme.Si ti-am explicat ca, de la nivel 1 Tu pornesti cu o arma primara sa zicem m4a1[ 1 . M4a1 ] , dupa ce ti-ai ales primara secundara [ deagle ] iar jos arma pe care o deblochezi [ LOCKED ] Ak47 [ valibil lvl x ]. Acesta este tot meniul pe care il voiam , dupa ce ajungi la lvl 2 in loc de m4a1 este ak47 , iar jos urmatoarea arma , iar cand scrii /weapons dupa ce ti-ai ales arma de la nivelul curent iti apare in alt meniu TOATE armele pe care le-ai acumulat/detii.

| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <orpheu>
#include <orpheu_stocks>
#include <orpheu_memory>

#define PLUGIN "Zombie Escape"
#define VERSION "2.2"
#define AUTHOR "Dias "

// Main Config 
#define CONFIG_FILE "zombie_escape.ini"
#define OFFICIAL_LANG LANG_PLAYER
const DMG_GRENADE = (1<<24)

//#define SET_MODELINDEX_OFFSET
new allow_map_prefix[1][] = 
{
	"ze_"
}

// Config Vars
new cfg_min_player, cfg_default_light[2], cfg_zom_release_time, cfg_hum_freeze_time, cfg_round_time
new cfg_use_fog, cfg_fog_density[16], cfg_fog_color[32]
new cfg_human_health, cfg_human_armor, Float:cfg_human_gravity, Float:cfg_human_speed	
new cfg_zombie_health, cfg_zombie_armor, Float:cfg_zombie_gravity, Float:cfg_zombie_speed, Float:cfg_zombie_kbpower
new cfg_skyname[10]
new Array:human_model, Array:human_modelindex, Array:host_zombie_model, Array:host_zombie_modelindex, Array:origin_zombie_model, Array:origin_zombie_modelindex, Array:zombie_claws_model
new Array:ready_sound, Array:ambience_sound, Array:zombieappear_sound, Array:zombieinfect_sound
new Array:zombiepain_sound, Array:zombieattack_sound, Array:zombieswing_sound, Array:zombiewall_sound
new count_sound[64], Array:escape_suc_sound, Array:escape_fail_sound

new const sound_nvg[2][] = {"items/nvg_off.wav", "items/nvg_on.wav"}

// Game Vars
new g_endround, g_count, bot_register, g_gamestart, score_hud, Float:delay_hud[33], stat_hud
new notice_hud, g_started, g_zombie[33], g_zombie_type[33], g_nvg[33], g_team_score[6]
new Float:g_spawn_origin[33][3], g_escape_point[33], g_escape_rank[4]

enum
{
	RANK_NONE = 0,
	RANK_FIRST,
	RANK_SECOND,
	RANK_THIRD
}

// Hardcode
new g_primaryweapons[][][] = 
{ 
	{ "M4A1",     "weapon_m4a1"    },
	{ "AK47",     "weapon_ak47"    },
	{ "AUG",      "weapon_aug"     },
	{ "SG552",    "weapon_sg552"   },
	{ "XM1014",   "weapon_xm1014"  },
	{ "P90",      "weapon_p90"     },
	{ "M249",     "weapon_m249"    }			
}

// secondary weapons (menu|game)
new g_secondaryweapons[][][] = 
{ 
	{ "USP",      "weapon_usp"     },
	{ "Deagle",   "weapon_deagle"  },
	{ "Elite",    "weapon_elite"   } 
}

// grenade loadout (game)
new g_grenades[][] = 
{ 
	"weapon_hegrenade",
	"weapon_smokegrenade"
}

new g_szObjectiveClassNames[][] =
{
	"func_bomb_target",
	"info_bomb_target",
	"info_vip_start",
	"func_vip_safetyzone",
	"func_escapezone",
	"hostage_entity",
	"monster_scientist",
	"func_hostage_rescue",
	"info_hostage_rescue",
	"item_longjump"
}
enum
{
	TASK_COUNTDOWN = 52000,
	TASK_COUNTDOWN2,
	TASK_AMBIENCE,
	TASK_ROUNDTIME
}
enum
{
	TEAM_T = 1,
	TEAM_CT = 2,
	TEAM_ALL = 5,
	TEAM_START = 6
}
enum
{
	AL_NOT = 0,
	AL_ALIVE = 1,
	AL_BOTH = 2
}
enum
{
	ZOMBIE_TYPE_HOST = 0,
	ZOMBIE_TYPE_ORIGIN
}

// Orpheu Vars
new OrpheuHook:handleHookCheckMapConditions;
new OrpheuHook:handleHookCheckWinConditions;
new OrpheuHook:handleHookHasRoundTimeExpired;

// Orpheu Def
new g_WinText[7][64], g_pGameRules
#define set_mp_pdata(%1,%2)  (OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
#define get_mp_pdata(%1)     (OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )

// Menu Weapon Code (Thank to Cheap_Suit)
new bool:g_showmenu[33], bool:g_menufailsafe[33], g_player_weapons[33][2], g_menuposition[33]
#define TASKID_WEAPONSMENU 564
#define EQUIP_PRI (1<<0)
#define EQUIP_SEC (1<<1)
#define EQUIP_GREN (1<<2)
#define EQUIP_ALL (1<<0 | 1<<1 | 1<<2)

#define OFFSET_LASTPRIM 368
#define OFFSET_LASTSEC 369
#define OFFSET_LASTKNI 370

#define OFFSET_DEATH 444
#define OFFSET_TEAM 114
#define OFFSET_ARMOR 112
#define OFFSET_NVG 129
#define OFFSET_CSMONEY 115
#define OFFSET_PRIMARYWEAPON 116
#define OFFSET_WEAPONTYPE 43
#define OFFSET_CLIPAMMO	51
#define EXTRAOFFSET_WEAPONS 4

#define OFFSET_AMMO_338MAGNUM 377
#define OFFSET_AMMO_762NATO 378
#define OFFSET_AMMO_556NATOBOX 379
#define OFFSET_AMMO_556NATO 380
#define OFFSET_AMMO_BUCKSHOT 381
#define OFFSET_AMMO_45ACP 382
#define OFFSET_AMMO_57MM 383
#define OFFSET_AMMO_50AE 384
#define OFFSET_AMMO_357SIG 385
#define OFFSET_AMMO_9MM 386

#define fm_lastprimary(%1) get_pdata_cbase(id, OFFSET_LASTPRIM)
#define fm_lastsecondry(%1) get_pdata_cbase(id, OFFSET_LASTSEC)
#define fm_lastknife(%1) get_pdata_cbase(id, OFFSET_LASTKNI)
#define fm_get_weapon_id(%1) get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)

new const g_weapon_ammo[][] =
{
	{ -1, -1 },
	{ 13, 200 },
	{ -1, -1 },
	{ 10, 200 },
	{ -1, -1 },
	{ 7, 200 },
	{ -1, -1 },
	{ 30, 200 },
	{ 30, 200 },
	{ -1, -1 },
	{ 30, 200 },
	{ 20, 200 },
	{ 25, 000 },
	{ 30, 200 },
	{ 35, 200 },
	{ 25, 200 },
	{ 12, 200 },
	{ 20, 200 },
	{ 10, 200 },
	{ 30, 200 },
	{ 100, 200 },
	{ 8, 200 },
	{ 30, 200 },
	{ 30, 200 },
	{ 20, 200 },
	{ -1, -1 },
	{ 7, 200 },
	{ 30, 200 },
	{ 30, 200 },
	{ -1, -1 },
	{ 50, 200 }
}

// Team API (Thank to WiLS)
#define TEAMCHANGE_DELAY 0.1

#define TASK_TEAMMSG 200
#define ID_TEAMMSG (taskid - TASK_TEAMMSG)

// CS Player PData Offsets (win32)
#define PDATA_SAFE 2
#define OFFSET_CSTEAMS 114

new const CS_TEAM_NAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }

new Float:g_TeamMsgTargetTime
new g_MsgTeamInfo, g_MsgScoreInfo
new g_MaxPlayers

// Set Model
#define OFFSET_MODELINDEX 491
new g_model_locked[33]

// Ham:Speed
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame;

// Fowards
#define MAX_FORWARD 5
enum
{
	FORWARD_NONE = 0,
	FORWARD_INFECTED,
	FORWARD_HUMANIZED,
	FORWARD_GAMESTART,
	FORWARD_ROUNDEND
}

new g_forwards[MAX_FORWARD], g_fwDummyResult

// Custom GamePlay
enum
{
	START_TYPE_NEW = 0,
	START_ZOMBIE_APPEAR,
	START_ZOMBIE_RELEASE
}

new g_gamestop[3]

// Player Config
new g_ena_ready_sound[33], g_ena_background_sound[33]

// Plugin & Precache & Config Zone
public plugin_init()
{
	new map_name[32], check_index
	get_mapname(map_name, sizeof(map_name))
	
	for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
	{
		if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
			break
	}
	
	if(check_index == sizeof(allow_map_prefix))
	{
		set_fail_state("[ZE] Wrong Map")
		return
	}  
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_cvar("ze_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
	set_cvar_string("ze_version", VERSION)	
	
	// Lang
	register_dictionary("ze_maddoxx.txt")
	
	format(g_WinText[TEAM_T], 63, "Escape Fail")
	format(g_WinText[TEAM_CT], 63, "Escape Success")		
	format(g_WinText[TEAM_ALL], 63, "#Round_Draw")
	format(g_WinText[TEAM_START], 63, "#Game_Commencing")	
	
	register_menu("Equipment", 1023, "action_equip")
	register_menu("Primary", 1023, "action_prim")
	register_menu("Secondary", 1023, "action_sec")
	
	// Event
	register_event("HLTV", "event_newround", "a", "1=0", "2=0")
	register_logevent("event_roundend", 2, "1=Round_End")
	register_event("TextMsg","event_roundend","a","2=#Game_Commencing","2=#Game_will_restart_in")	
	register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
	
	// Message
	register_message(get_user_msgid("Health"), "message_health")
	register_message(get_user_msgid("StatusIcon"), "message_StatusIcon")
	
	// Forward & Ham
	register_forward(FM_EmitSound, "fw_EmitSound")
	register_forward(FM_GetGameDescription, "fw_GetGameDesc")
	register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
	RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam(Ham_Killed, "player", "fw_Killed_Post", 1)
	RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
	RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
	RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
	RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_PlayerResetMaxSpeed", 0)
	
	PatchRoundInfinity()
	set_cvar_string("sv_skyname", cfg_skyname)
	
	// Hud
	notice_hud = CreateHudSyncObj(1)
	score_hud = CreateHudSyncObj(2)
	stat_hud = CreateHudSyncObj(3)
	
	// Cache
	g_MsgTeamInfo = get_user_msgid("TeamInfo")
	g_MsgScoreInfo = get_user_msgid("ScoreInfo")
	g_MaxPlayers = get_maxplayers()	
	
	// Create Forwards
	g_forwards[FORWARD_INFECTED] = CreateMultiForward("ze_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
	g_forwards[FORWARD_HUMANIZED] = CreateMultiForward("ze_user_humanized", ET_IGNORE, FP_CELL)
	g_forwards[FORWARD_GAMESTART] = CreateMultiForward("ze_gamestart", ET_IGNORE, FP_CELL)
	g_forwards[FORWARD_ROUNDEND] = CreateMultiForward("ze_roundend", ET_IGNORE, FP_CELL)

	// Some Commands
	register_clcmd("nightvision", "cmd_nightvision")
	register_clcmd("jointeam", "cmd_jointeam")
	register_clcmd("joinclass", "cmd_joinclass")
	register_clcmd("chooseteam", "cmd_jointeam")		
	
	set_task(60.0, "server_check", _, _, _, "b")
	
	// Reset GamePlay
	native_reset_gameplay(0)
}

public plugin_cfg()
{
	new map_name[32], check_index
	get_mapname(map_name, sizeof(map_name))
	
	for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
	{
		if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
			break
	}
	
	if(check_index == sizeof(allow_map_prefix))
		return
	
	set_cvar_float("mp_freezetime", float(cfg_hum_freeze_time) + 2.0)
	set_cvar_float("mp_roundtime", float(cfg_round_time))
}
	
public plugin_precache()
{
	new map_name[32], check_index
	get_mapname(map_name, sizeof(map_name))
	
	for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
	{
		if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
			break
	}
	
	if(check_index == sizeof(allow_map_prefix))
		return
	
	OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"),"OnInstallGameRules",OrpheuHookPost)
	
	// Create Array
	human_model = ArrayCreate(64, 1)
	human_modelindex = ArrayCreate(1, 1)
	host_zombie_model = ArrayCreate(64, 1)
	host_zombie_modelindex = ArrayCreate(1, 1)
	origin_zombie_model = ArrayCreate(64, 1)
	origin_zombie_modelindex = ArrayCreate(1, 1)
	zombie_claws_model = ArrayCreate(64, 1)
	
	ready_sound = ArrayCreate(64, 1)
	ambience_sound = ArrayCreate(64, 1)
	zombieappear_sound = ArrayCreate(64, 1)
	zombieinfect_sound = ArrayCreate(64, 1)
	
	zombiepain_sound = ArrayCreate(64, 1)
	zombieattack_sound = ArrayCreate(64, 1)
	zombieswing_sound = ArrayCreate(64, 1)
	zombiewall_sound = ArrayCreate(64, 1)
	
	escape_suc_sound = ArrayCreate(64, 1)
	escape_fail_sound = ArrayCreate(64, 1)
	
	// Load Custom Config
	load_config_file()
	
	new i, buffer[128], temp_string[256]
	
	// Model
	for(i = 0; i < ArraySize(human_model); i++)
	{
		ArrayGetString(human_model, i, temp_string, sizeof(temp_string))
		formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
		
		ArrayPushCell(human_modelindex, precache_model(buffer))
	}
	for(i = 0; i < ArraySize(origin_zombie_model); i++)
	{
		ArrayGetString(origin_zombie_model, i, temp_string, sizeof(temp_string))
		formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
		
		ArrayPushCell(origin_zombie_modelindex, precache_model(buffer))
	}
	for(i = 0; i < ArraySize(host_zombie_model); i++)
	{
		ArrayGetString(host_zombie_model, i, temp_string, sizeof(temp_string))
		formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
		
		ArrayPushCell(host_zombie_modelindex, precache_model(buffer))
	}
	
	for(i = 0; i < ArraySize(zombie_claws_model); i++)
	{
		ArrayGetString(zombie_claws_model, i, temp_string, sizeof(temp_string))
		precache_model(temp_string)
	}
	
	// Sound
	for(i = 0; i < ArraySize(ready_sound); i++)
	{
		ArrayGetString(ready_sound, i, temp_string, sizeof(temp_string))
	
		if(equal(temp_string[strlen(temp_string) - 4], ".mp3"))
		{
			format(buffer, charsmax(buffer), "sound/%s", temp_string)
			precache_generic(buffer)
		} else {
			precache_sound(temp_string)
		}
	}
	for(i = 0; i < ArraySize(ambience_sound); i++)
	{
		ArrayGetString(ambience_sound, i, temp_string, sizeof(temp_string))
	
		if(equal(temp_string[strlen(temp_string) - 4], ".mp3"))
		{
			format(buffer, charsmax(buffer), "sound/%s", temp_string)
			precache_generic(buffer)
		} else {
			precache_sound(temp_string)
		}
	}
	for(i = 0; i < ArraySize(zombieappear_sound); i++)
	{
		ArrayGetString(zombieappear_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(zombieinfect_sound); i++)
	{
		ArrayGetString(zombieinfect_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(zombiepain_sound); i++)
	{
		ArrayGetString(zombiepain_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(zombieattack_sound); i++)
	{
		ArrayGetString(zombieattack_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(zombieswing_sound); i++)
	{
		ArrayGetString(zombieswing_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(zombiewall_sound); i++)
	{
		ArrayGetString(zombiewall_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for (i = 1; i <= 10; i++)
	{
		new sound_count[64]
		format(sound_count, sizeof sound_count - 1, count_sound, i)
		engfunc(EngFunc_PrecacheSound, sound_count)
	}
	for(i = 0; i < ArraySize(escape_suc_sound); i++)
	{
		ArrayGetString(escape_suc_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}
	for(i = 0; i < ArraySize(escape_fail_sound); i++)
	{
		ArrayGetString(escape_fail_sound, i, temp_string, sizeof(temp_string))
		precache_sound(temp_string)
	}		
	
	formatex(buffer, sizeof(buffer), "gfx/env/%sbk.tga", cfg_skyname)
	precache_generic(buffer)
	formatex(buffer, sizeof(buffer), "gfx/env/%sdn.tga", cfg_skyname)
	precache_generic(buffer)
	formatex(buffer, sizeof(buffer), "gfx/env/%sft.tga", cfg_skyname)
	precache_generic(buffer)
	formatex(buffer, sizeof(buffer), "gfx/env/%slf.tga", cfg_skyname)
	precache_generic(buffer)
	formatex(buffer, sizeof(buffer), "gfx/env/%srt.tga", cfg_skyname)
	precache_generic(buffer)
	formatex(buffer, sizeof(buffer), "gfx/env/%sup.tga", cfg_skyname)
	precache_generic(buffer)	
	
	if(cfg_use_fog == 1)
	{
		static ent
		ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_fog"))
		if(pev_valid(ent))
		{
			DispatchKeyValue(ent, "density", cfg_fog_density)
			DispatchKeyValue(ent, "rendercolor", cfg_fog_color)
			DispatchSpawn(ent)
		}
	}
	
	register_forward(FM_Spawn, "fw_Spawn")	
}

public plugin_end()
{
	UnPatchRoundInfinity()
}

public server_check()
{
	// Check this every 60 second(s)
	check_win_con()
}
	
public fw_Spawn(iEnt)
{
	if (!pev_valid(iEnt))
		return FMRES_IGNORED;
	
	static s_szClassName[32], s_iNum
	pev(iEnt, pev_classname, s_szClassName, 31)
	
	for (s_iNum = 0; s_iNum < sizeof g_szObjectiveClassNames; s_iNum++)
	{
		if (equal(s_szClassName, g_szObjectiveClassNames[s_iNum]))
		{
			engfunc(EngFunc_RemoveEntity, iEnt)
			return FMRES_SUPERCEDE;
		}
	}

	return FMRES_IGNORED
}

public client_putinserver(id)
{
	if(!bot_register && is_user_bot(id))
	{
		bot_register = 1
		set_task(1.0, "do_register", id)
	}
	
	g_showmenu[id] = true
	g_escape_point[id] = 0
	g_ena_ready_sound[id] = g_ena_background_sound[id] = 1
}

public client_disconnect(id)
{
	remove_task(id+TASK_TEAMMSG)
	check_win_con()
}

public do_register(id)
{
	RegisterHamFromEntity(Ham_Spawn, id, "fw_Spawn_Post", 1)
	RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")	
	RegisterHamFromEntity(Ham_Killed, id, "fw_Killed_Post", 1)
	RegisterHamFromEntity(Ham_Player_ResetMaxSpeed, id, "fw_PlayerResetMaxSpeed", 0)
}

public PatchRoundInfinity()
{
	handleHookCheckMapConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckMapConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
	handleHookCheckWinConditions = OrpheuRegisterHook( OrpheuGetFunction( "CheckWinConditions" , "CHalfLifeMultiplay" ), "CheckConditions" );
	
	if (is_linux_server())
	{
		handleHookHasRoundTimeExpired = OrpheuRegisterHook( OrpheuGetFunction( "HasRoundTimeExpired" , "CHalfLifeMultiplay" ), "CheckConditions" );
	} else {
		BytesToReplace("roundTimeCheck", { 0x90, 0x90, 0x90 } );
	}
}

public UnPatchRoundInfinity()
{
	OrpheuUnregisterHook( handleHookCheckMapConditions );
	OrpheuUnregisterHook( handleHookCheckWinConditions );
	
	if(is_linux_server())
	{
		OrpheuUnregisterHook( handleHookHasRoundTimeExpired );
	} else {
		BytesToReplace("roundTimeCheck", { 0xF6, 0xC4, 0x41 } );
	}
}

public OrpheuHookReturn:CheckConditions ()
{
	OrpheuSetReturn(false)
	return OrpheuSupercede
}

public OnInstallGameRules()
{
	g_pGameRules = OrpheuGetReturn() 
}

public load_config_file()
{
	// Build customization file path
	new path[64]
	get_configsdir(path, charsmax(path))
	format(path, charsmax(path), "%s/%s", path, CONFIG_FILE)
	
	// File not present
	if (!file_exists(path))
	{
		new error[100]
		formatex(error, charsmax(error), "[ZE] Can't Load Config File: %s!", path)
		set_fail_state(error)
		return;
	}
	
	// Set up some vars to hold parsing info
	new linedata[1024], key[64], value[960], section
	
	// Open customization file for reading
	new file = fopen(path, "rt")
	
	while (file && !feof(file))
	{
		// Read one line at a time
		fgets(file, linedata, charsmax(linedata))
		
		// Replace newlines with a null character to prevent headaches
		replace(linedata, charsmax(linedata), "^n", "")
		
		// Blank line or comment
		if (!linedata[0] || linedata[0] == ';') continue;
		
		// New section starting
		if (linedata[0] == '[')
		{
			section++
			continue;
		}
	
		// Get key and value(s)
		strtok(linedata, key, charsmax(key), value, charsmax(value), '=')

		// Trim spaces
		trim(key)
		trim(value)

		switch (section)
		{
			case 1: // Main Config
			{	
				if (equal(key, "MIN_PLAYER"))
					cfg_min_player = str_to_num(value)
				else if (equal(key, "DEFAULT_LIGHT"))
					copy(cfg_default_light, sizeof(cfg_default_light), value)
				else if (equal(key, "ZOMBIE_RELEASE_TIME"))
					cfg_zom_release_time = str_to_num(value)
				else if (equal(key, "HUMAN_FREEZE_TIME"))
					cfg_hum_freeze_time = str_to_num(value)
				else if (equal(key, "ROUND_TIME"))
					cfg_round_time = str_to_num(value)					
					
			}
			case 2: // Fog
			{
				if (equal(key, "FOG_ENABLE"))
					cfg_use_fog = str_to_num(value)
				else if (equal(key, "FOG_DENSITY"))
					copy(cfg_fog_density, sizeof(cfg_fog_density), value)
				else if (equal(key, "FOG_COLOR"))
					copy(cfg_fog_color, sizeof(cfg_fog_color), value)		
			}
			case 3: // Human Config
			{
				if (equal(key, "HUMAN_HEALTH"))
					cfg_human_health = str_to_num(value)
				else if (equal(key, "HUMAN_ARMOR"))
					cfg_human_armor = str_to_num(value)
				else if (equal(key, "HUMAN_GRAVITY"))
					cfg_human_gravity = str_to_float(value)
				else if (equal(key, "HUMAN_SPEED"))
					cfg_human_speed = str_to_float(value)				
			}
			case 4: // Zombie Config
			{
				if (equal(key, "ZOMBIE_HEALTH"))
					cfg_zombie_health = str_to_num(value)
				else if (equal(key, "ZOMBIE_ARMOR"))
					cfg_zombie_armor = str_to_num(value)
				else if (equal(key, "ZOMBIE_GRAVITY"))
					cfg_zombie_gravity = str_to_float(value)
				else if (equal(key, "ZOMBIE_SPEED"))
					cfg_zombie_speed = str_to_float(value)	
				else if (equal(key, "ZOMBIE_KNOCKBACK_POWER"))
					cfg_zombie_kbpower = str_to_float(value)						
			}
			case 5: // Sky
			{
				if(equal(key, "SKY_NAME"))
					copy(cfg_skyname, sizeof(cfg_skyname), value)
			}
			case 6: // Model
			{
				if (equal(key, "HUMAN_MODEL"))
				{
					// Parse sounds
					while(value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to sounds array
						ArrayPushString(human_model, key)
					}
				}
				else if(equal(key, "ZOMBIE_ORIGIN_MODEL"))
				{
					// Parse sounds
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to sounds array
						ArrayPushString(origin_zombie_model, key)
					}
				}
				else if(equal(key, "ZOMBIE_HOST_MODEL"))
				{
					// Parse sounds
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to sounds array
						ArrayPushString(host_zombie_model, key)
					}
				}
				else if(equal(key, "ZOMBIE_CLAW_MODEL"))
				{
					// Parse sounds
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to sounds array
						ArrayPushString(zombie_claws_model, key)
					}
				}				
			}
			case 7: // Sound
			{
				if (equal(key, "READY"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(ready_sound, key)
					}
				}
				else if (equal(key, "AMBIENCE"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(ambience_sound, key)
					}
				}
				if (equal(key, "ZOMBIE_APPEAR"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombieappear_sound, key)
					}
				}
				else if (equal(key, "PLAYER_INFECT"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombieinfect_sound, key)
					}
				}
				else if (equal(key, "ZOMBIE_PAIN"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombiepain_sound, key)
					}
				}
				else if (equal(key, "COUNTDOWN"))
				{
					copy(count_sound, sizeof(count_sound), value)
				}
				else if (equal(key, "ESCAPE_SUCCESS"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(escape_suc_sound, key)
					}
				}
				else if (equal(key, "ESCAPE_FAIL"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(escape_fail_sound, key)
					}
				}
				else if (equal(key, "ATTACK_HIT"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombieattack_sound, key)
					}
				}
				else if (equal(key, "ATTACK_MISS"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombieswing_sound, key)
					}
				}			
				else if (equal(key, "ATTACK_WALL"))
				{
					// Parse weapons
					while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
					{
						// Trim spaces
						trim(key)
						trim(value)
						
						// Add to weapons array
						ArrayPushString(zombiewall_sound, key)
					}
				}	
			}
		}
	}
	if (file) fclose(file)	
}

public plugin_natives()
{
	new map_name[32], check_index
	get_mapname(map_name, sizeof(map_name))
	
	for(check_index = 0; check_index < sizeof(allow_map_prefix); check_index++)
	{
		if(equali(map_name, allow_map_prefix[check_index], strlen(allow_map_prefix[check_index])))
			break
	}
	
	if(check_index == sizeof(allow_map_prefix))
		return
		
	// Check
	register_native("ze_is_user_zombie", "native_get_zombie", 1)
	register_native("ze_get_zombie_type", "native_get_zombie_type", 1)
	
	// Set
	register_native("ze_set_user_zombie", "native_set_zombie", 1)
	register_native("ze_set_user_human", "native_set_human", 1)
	
	// GamePlays
	register_native("ze_set_stopgame", "native_set_stopgame", 1)
	register_native("ze_reset_gameplay", "native_reset_gameplay", 1)
}
// End of Plugin & Precache & Config Zone

// Native
public native_get_zombie(id)
{
	if(!is_user_connected(id))
		return 0 
	if(!is_user_alive(id))
		return 0
		
	return g_zombie[id]
}

public native_get_zombie_type(id)
{
	if(!is_user_connected(id))
		return -1
	if(!is_user_alive(id))
		return -1
		
	return g_zombie_type[id]
}

public native_set_zombie(id, zombie_type)
{
	if(!is_user_connected(id))
		return 0 
	if(!is_user_alive(id))
		return 0
	if(g_zombie[id])
		return 0
		
	set_user_zombie(id, zombie_type, 1)
	return 1
}

public native_set_human(id)
{
	if(!is_user_connected(id))
		return 0 
	if(!is_user_alive(id))
		return 0	
		
	set_human_stuff(id)
	return 0
}

public native_set_stopgame(stop_type, stop)
{
	g_gamestop[stop_type] = stop
	return 1
}

public native_reset_gameplay(restart)
{
	g_gamestop[START_TYPE_NEW] = 0
	g_gamestop[START_ZOMBIE_APPEAR] = 0
	g_gamestop[START_ZOMBIE_RELEASE] = 0
	
	if(restart) TerminateRound(TEAM_START)
}
// End Of Native

// Event: New Round
public event_newround()
{
	ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
	
	// Reset Vars
	g_endround = 0
	g_gamestart = 0
	g_count = cfg_hum_freeze_time
	
	// Remove Task
	remove_task(TASK_COUNTDOWN)
	remove_task(TASK_COUNTDOWN2)
	remove_task(TASK_ROUNDTIME)
	
	ambience_sound_stop(0)
	// Team
	for(new player = 1; player <= g_MaxPlayers; player++)
	{
		remove_task(player+TASK_TEAMMSG)
		remove_task(player+TASK_AMBIENCE)
	}
		
	if(g_gamestop[START_TYPE_NEW])
		return
	
	set_task(0.1, "event_newround2")	
}

public event_newround2()
{
	if(get_player_num(TEAM_ALL, AL_ALIVE) < cfg_min_player)
	{
		client_printc(0, "!g[MaddoxX]!n %L", OFFICIAL_LANG, "NOT_ENOUGH_PLAYER", cfg_min_player)
		g_started = 0
		
		return
	}
	
	client_printc(0, "!g[MaddoxX]!n %L", OFFICIAL_LANG, "GOOD_LUCK")
	
	static temp_string[128]
	ArrayGetString(ready_sound, random_num(0, ArraySize(ready_sound) - 1), temp_string, sizeof(temp_string))
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(!g_ena_ready_sound)
			continue

		PlaySound(i, temp_string)
	}
	
	set_task(1.0, "do_countdown", TASK_COUNTDOWN, _, _, "b")
	set_task(get_cvar_float("mp_roundtime") * 60.0 + 43.0, "do_zombie_win", TASK_ROUNDTIME)	
}

public do_countdown(taskid)
{
	if(g_endround)
	{
		remove_task(taskid)
		return
	}
	
	if (!g_count)
	{
		start_game_now()
		remove_task(taskid)
		return
	}
	
	if (g_count <= cfg_hum_freeze_time)
	{
		static sound[64]
		format(sound, sizeof sound - 1, count_sound, g_count)
		PlaySound(0, sound)
	}
	
	new message[64]
	format(message, charsmax(message), "%L", OFFICIAL_LANG, "RUN_READY_COUNTDOWN", g_count)
	client_print(0, print_center, message)
	
	g_count--
}
// End of Event: New Round

// Event: Round End
public event_roundend()
{
	g_endround = 1
	
	remove_task(TASK_COUNTDOWN)
	remove_task(TASK_COUNTDOWN2)
	for(new i = 0; i < g_MaxPlayers; i++)
		remove_task(i+TASK_AMBIENCE)
	remove_task(TASK_ROUNDTIME)
	
	ambience_sound_stop(0)
}

// End of Event: Round End

public cmd_jointeam(id)
{	
	if(!is_user_connected(id))
		return 1
	
	if(cs_get_user_team(id) == CS_TEAM_CT || cs_get_user_team(id) == CS_TEAM_T)
	{
		open_game_menu(id)
		return 1
	}
	
	return PLUGIN_CONTINUE
}

public cmd_joinclass(id)
{
	if(!is_user_connected(id))
		return 1
	if(cs_get_user_team(id) != CS_TEAM_CT || cs_get_user_team(id) != CS_TEAM_T)
		return 0
	if(g_gamestart == 1 || g_gamestart == 2)
	{
		fm_cs_set_user_team(id, CS_TEAM_CT, 1)
		
		g_zombie[id] = 0
		g_zombie_type[id] = 0
		g_nvg[id] = 0
		g_menufailsafe[id] = false
		
		if(TASKID_WEAPONSMENU + id) remove_task(TASKID_WEAPONSMENU + id)
	}
	
	return 0
}

public open_game_menu(id)
{
	static menu, string[128]
	
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "GAME_MENU_NAME")
	menu = menu_create(string, "gamem_handle")
	
	// Enable Equipment Menu
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "EQUIPMENT_NAME")
	menu_additem(menu, string, "1", 0)
	
	// Game Infomation
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "GAMEINFO_NAME")
	menu_additem(menu, string, "2", 0)
	
	// Game Infomation
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "PCONFIG_NAME")
	menu_additem(menu, string, "3", 0)	
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)
}

public gamem_handle(id, menu, item)
{
	if(!is_user_connected(id))
		return
	
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return
	}
	
	new data[6], szName[64];
	new access, callback;
	
	menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
	
	new key = str_to_num(data);
	
	switch(key)
	{
		case 1: // Equipment
		{
			g_showmenu[id] = true
			client_printc(id, "!g[MaddoxX]!n %L", OFFICIAL_LANG, "EQUIP_ENABLE")
		}
		case 2: // Game Info
		{
			static string_name[128], string_data[1028]
			
			// Game Infomation
			formatex(string_name, sizeof(string_name), "%L", OFFICIAL_LANG, "GAMEINFO_NAME")
			formatex(string_data, sizeof(string_data), "%L", OFFICIAL_LANG, "GAME_INFORMATION")
			
			show_motd(id, string_data, string_name)
		}	
		case 3: // Player Config
		{
			player_config(id)
		}			
	}
	
	return
}

// Player Config
public player_config(id)
{
	static menu, string[128], on_off[10]
	
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "PCONFIG_NAME")
	menu = menu_create(string, "pconfig_handle")
	
	// Ready Sound
	if(g_ena_ready_sound[id])
	{
		formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_ON")
		formatex(string, sizeof(string), "%L	\y%s", OFFICIAL_LANG, "PCONFIG_READY_SOUND", on_off)
	} else {
		formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_OFF")
		formatex(string, sizeof(string), "%L	\r%s", OFFICIAL_LANG, "PCONFIG_READY_SOUND", on_off)	
	}
	menu_additem(menu, string, "1", 0)
	
	// Background Sound
	if(g_ena_background_sound[id])
	{
		formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_ON")
		formatex(string, sizeof(string), "%L	\y%s", OFFICIAL_LANG, "PCONFIG_BACKGROUND_SOUND", on_off)
	} else {
		formatex(on_off, sizeof(on_off), "%L", OFFICIAL_LANG, "PCONFIG_OFF")
		formatex(string, sizeof(string), "%L	\r%s", OFFICIAL_LANG, "PCONFIG_BACKGROUND_SOUND", on_off)	
	}
	menu_additem(menu, string, "2", 0)
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
	menu_display(id, menu, 0)	
}

public pconfig_handle(id, menu, item)
{
	if(!is_user_connected(id))
		return
	
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return
	}
	
	new data[6], szName[64];
	new access, callback;
	
	menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
	
	new key = str_to_num(data);
	
	switch(key)
	{
		case 1: // Ready Sound
		{
			if(g_ena_ready_sound[id])
			{
				g_ena_ready_sound[id] = 0
				if(g_gamestart == 0) ambience_sound_stop(id)
			} else {
				g_ena_ready_sound[id] = 1
				if(g_gamestart == 0)
				{
					static temp_string[128]
					ArrayGetString(ready_sound, random_num(0, ArraySize(ready_sound) - 1), temp_string, sizeof(temp_string))
					
					PlaySound(id, temp_string)
				}
			}
			player_config(id)
		}
		case 2: // Background Sound
		{
			if(g_ena_background_sound[id])
			{
				g_ena_background_sound[id] = 0
				if(g_gamestart > 0) ambience_sound_stop(id)
			} else {
				g_ena_background_sound[id] = 1
				if(g_gamestart > 0)
				{
					static temp_string[128]
					ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
	
					PlaySound(id, temp_string)	
					set_task(105.0, "check_ambience_sound", id+TASK_AMBIENCE, _, _, "b")	
				}
			}
			player_config(id)			
		}
	}
}

// NightVision
public cmd_nightvision(id)
{
	if (!is_user_alive(id) || !g_zombie[id]) return PLUGIN_HANDLED;
	
	if (!g_nvg[id])
	{
		SwitchNvg(id, 1)
		PlaySound(id, sound_nvg[1])
	}
	else
	{
		SwitchNvg(id, 0)
		PlaySound(id, sound_nvg[0])
	}	
	
	return PLUGIN_CONTINUE
}

public SwitchNvg(id, mode)
{
	if (!is_user_connected(id)) return;
	
	g_nvg[id] = mode
	set_user_nvision(id)
}

public set_user_nvision(id)
{	
	if (!is_user_connected(id)) return;
	
	new alpha
	if (g_nvg[id]) alpha = 70
	else alpha = 0
	
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, id)
	write_short(0) // duration
	write_short(0) // hold time
	write_short(0x0004) // fade type
	write_byte(253) // r
	write_byte(110) // g
	write_byte(110) // b
	write_byte(alpha) // alpha
	message_end()
	
	if(g_nvg[id])
	{
		set_player_light(id, "z")
		} else {
		set_player_light(id, cfg_default_light)
	}
}

public set_player_light(id, const LightStyle[])
{
	message_begin(MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, .player = id)
	write_byte(0)
	write_string(LightStyle)
	message_end()
}
// End of NightVision

// Start Game
public start_game_now()
{
	g_gamestart = 1
	
	static temp_string[128]
	ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(!g_ena_background_sound)
			continue
		
		PlaySound(i, temp_string)	
		set_task(105.0, "check_ambience_sound", i+TASK_AMBIENCE, _, _, "b")
	}
	
	if(g_gamestop[START_ZOMBIE_APPEAR])
	{
		ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
		return
	}
		
	// Make Zombies
	for(new i = 0; i < require_zombie(); i++)
	{
		ExecuteForward(g_forwards[FORWARD_INFECTED], g_fwDummyResult, i, 0)
		set_user_zombie(get_random_player(TEAM_CT, AL_ALIVE), ZOMBIE_TYPE_ORIGIN, 0)
	}
	
	g_count = cfg_zom_release_time
	set_task(1.0, "do_count_rezombie", TASK_COUNTDOWN2, _, _, "b")
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(is_user_connected(i) && is_user_alive(i) && !g_zombie)
		{
			fm_reset_user_speed(i)
			fm_set_user_speed(i, cfg_human_speed)
			set_user_gravity(i, cfg_human_gravity)
		}
	}
	
	ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
}

public check_ambience_sound(id)
{
	id -= TASK_AMBIENCE
	
	if(g_endround)
	{
		remove_task(id+TASK_AMBIENCE)
		return
	}
	if(!g_ena_background_sound[id])
	{
		remove_task(id+TASK_AMBIENCE)
		return		
	}
	
	static temp_string[128]
	ArrayGetString(ambience_sound, random_num(0, ArraySize(ambience_sound) - 1), temp_string, sizeof(temp_string))
	
	PlaySound(id, temp_string)	
}

public do_count_rezombie(taskid)
{
	if(g_endround)
	{
		remove_task(taskid)
		return
	}
	
	if (!g_count)
	{
		release_zombie()
		remove_task(taskid)
		return
	}
	
	set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
	ShowSyncHudMsg(0, notice_hud, "%L", OFFICIAL_LANG, "ZOMBIE_RELEASE_COUNTDOWN", g_count)
	
	g_count--
}
// End of Start Game

// Game Main
public release_zombie()
{
	g_gamestart = 2
	
	if(g_gamestop[START_ZOMBIE_RELEASE])
	{
		ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)
		return
	}
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i) || !is_user_alive(i))
			continue
		if(!g_zombie)
			continue
		
		fm_set_user_speed(i, cfg_zombie_speed)
		set_user_gravity(i,  cfg_zombie_gravity)		
	}
	
	ExecuteForward(g_forwards[FORWARD_GAMESTART], g_fwDummyResult, g_gamestart)	
}

public client_PostThink(id)
{
	if(!is_user_connected(id))
		return
	if(get_gametime() - 1.0 > delay_hud[id])
	{
		// Show Score
		set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 2.0, 2.0)
		ShowSyncHudMsg(id, score_hud, "%L", OFFICIAL_LANG, "HUD_SCORE", g_team_score[TEAM_T], g_team_score[TEAM_CT])
		
		// Add Point for Who is Running Fast
		if(!g_zombie[id])
		{
			static Float:Velocity[3], Speed
			
			pev(id, pev_velocity, Velocity)
			Speed = floatround(vector_length(Velocity))
			
			switch(Speed)
			{
				case 210..229: g_escape_point[id] += 1
				case 230..249: g_escape_point[id] += 2
				case 250..300: g_escape_point[id] += 3
			}
		}
		
		// Show Stat
		show_stat(id)
		delay_hud[id] = get_gametime()
	}
	if(!g_gamestart)
	{
		if(!is_user_connected(id) || !is_user_alive(id))
			return
		
		if(cs_get_user_team(id) != CS_TEAM_CT) 
		{
			set_human_stuff(id)
		}
	} else {
		if(cs_get_user_team(id) == CS_TEAM_T && !g_zombie[id]) 
		{
			set_human_stuff(id)
		}
	}
}

public show_stat(id)
{
	get_stat()
	new temp_string_first[64], temp_string_second[64], temp_string_third[64], curid, Player_Name[64], none[32]
	
	formatex(none, sizeof(none), "%L", OFFICIAL_LANG, "RANK_NONE")
	
	// Rank First
	curid = g_escape_rank[RANK_FIRST]
	if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
	{
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_first, sizeof(temp_string_first), "%L", OFFICIAL_LANG, "RANK_FIRST", Player_Name)
	} else {
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_first, sizeof(temp_string_first), "%L", OFFICIAL_LANG, "RANK_FIRST", none)	
	}
	
	// Rank Second
	curid = g_escape_rank[RANK_SECOND]
	if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
	{
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_second, sizeof(temp_string_second), "%L", OFFICIAL_LANG, "RANK_SECOND", Player_Name)
	} else {
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_second, sizeof(temp_string_second), "%L", OFFICIAL_LANG, "RANK_SECOND", none)	
	}
	
	// Rank Third
	curid = g_escape_rank[RANK_THIRD]
	if(is_user_alive(curid) && !g_zombie[curid] && g_escape_point[curid] != 0)
	{
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_third, sizeof(temp_string_third), "%L", OFFICIAL_LANG, "RANK_THIRD", Player_Name)
	} else {
		get_user_name(curid, Player_Name, sizeof(Player_Name))
		formatex(temp_string_third, sizeof(temp_string_third), "%L", OFFICIAL_LANG, "RANK_THIRD", none)	
	}	

	set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 2.0, 2.0)
	ShowSyncHudMsg(id, stat_hud, "%L^n%s^n%s^n%s", OFFICIAL_LANG, "RANK_INFO", temp_string_first, temp_string_second, temp_string_third)	
}

public get_stat()
{
	static highest, current
	highest = current = 0
	
	// Rank First
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(!is_user_alive(i))
			continue
		if(g_zombie)
			continue
			
		if(g_escape_point > highest)
		{
			current = i
			highest = g_escape_point
		}
	}
	g_escape_rank[RANK_FIRST] = current
	
	// Rank Second
	highest = current = 0	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(!is_user_alive(i))
			continue
		if(g_zombie)
			continue			
		if(g_escape_rank[RANK_FIRST] == i)
			continue
			
		if(g_escape_point > highest)
		{
			current = i
			highest = g_escape_point
		}
	}
	g_escape_rank[RANK_SECOND] = current		
	
	// Rank Third
	highest = current = 0	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(!is_user_alive(i))
			continue
		if(g_zombie[i])
			continue			
		if(g_escape_rank[RANK_FIRST] == i || g_escape_rank[RANK_SECOND] == i)
			continue
			
		if(g_escape_point[i] > highest)
		{
			current = i
			highest = g_escape_point[i]
		}
	}
	g_escape_rank[RANK_THIRD] = current	
}

public set_user_zombie(id, zombie_type, forward_exec)
{
	fm_cs_set_user_team(id, CS_TEAM_T, 1)
	
	g_zombie[id] = 1
	g_zombie_type[id] = zombie_type
	
	set_user_health(id, zombie_type == 0 ? floatround(float(cfg_zombie_health) / 2.0) : cfg_zombie_health)
	set_user_armor(id, cfg_zombie_armor)
	
	if(zombie_type == ZOMBIE_TYPE_HOST)
	{
		fm_set_user_speed(id, cfg_zombie_speed)
		set_user_gravity(id, cfg_zombie_gravity)
	} else {
		if(!forward_exec)
			fm_set_user_speed(id, 0.1)
		else
			fm_set_user_speed(id, cfg_zombie_speed)
		set_user_gravity(id, cfg_zombie_gravity)		
	}
	
	static temp_string[128], temp_string2[128], random1
	if(!zombie_type) // Host
	{
		random1 = random_num(0, ArraySize(origin_zombie_model) - 1)
		
		ArrayGetString(host_zombie_model, random1, temp_string, sizeof(temp_string))
		fm_cs_set_user_model(id, temp_string)
		
		#if defined SET_MODELINDEX_OFFSET	
		static modelindex
		
		modelindex = ArrayGetCell(host_zombie_modelindex, random1)
		fm_cs_set_user_model_index(id, modelindex)
		
		#endif	
		} else { // Origin
		random1 = random_num(0, ArraySize(origin_zombie_model) - 1)
		
		ArrayGetString(origin_zombie_model, random1, temp_string, sizeof(temp_string))
		fm_cs_set_user_model(id, temp_string)	
		
		#if defined SET_MODELINDEX_OFFSET	
		static modelindex
		
		modelindex = ArrayGetCell(origin_zombie_modelindex, random1)
		fm_cs_set_user_model_index(id, modelindex)
		#endif			
	}
	
	set_default_zombie(id, zombie_type)
	
	ArrayGetString(zombieinfect_sound, random_num(0, ArraySize(zombieinfect_sound) - 1), temp_string, sizeof(temp_string))
	ArrayGetString(zombieappear_sound, random_num(0, ArraySize(zombieappear_sound) - 1), temp_string2, sizeof(temp_string2))
	
	emit_sound(id, CHAN_BODY, temp_string, 1.0, ATTN_NORM, 0, PITCH_NORM)
	PlaySound(0, temp_string2)
	
	SwitchNvg(id, 1)
	PlaySound(id, sound_nvg[1])	
	
	check_win_con()
}

stock set_default_zombie(id, zombie_type)
{
	if(!is_user_alive(id))
		return
	if(!g_zombie[id])
		return
	
	// Set Spawn Origin
	if(zombie_type == ZOMBIE_TYPE_ORIGIN) set_pev(id, pev_origin, g_spawn_origin[id])
	
	// Remove any zoom (bugfix)
	cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
	
	// Remove armor
	cs_set_user_armor(id, 0, CS_ARMOR_NONE)
	
	// Drop weapons when infected
	drop_weapons(id, 1)
	drop_weapons(id, 2)
	
	// Strip zombies from guns and give them a knife
	strip_user_weapons(id)
	give_item(id, "weapon_knife")
}

public event_CurWeapon(id)
{
	if(!is_user_alive(id))
		return 1
	if(!g_zombie[id])
		return 1
	if(get_user_weapon(id) != CSW_KNIFE)
	{
		drop_weapons(id, 1)
		drop_weapons(id, 2)
		
		engclient_cmd(id, "weapon_knife")
		} else {
		static temp_string[128]
		ArrayGetString(zombie_claws_model, random_num(0, ArraySize(zombie_claws_model) - 1), temp_string, sizeof(temp_string))
		
		set_pev(id, pev_viewmodel2, temp_string)
		set_pev(id, pev_weaponmodel2, "")
	}
	
	return 0
}

// End of Game Main
public check_win_con()
{
	if(g_endround)
		return
	if(!g_gamestart)
		return
	
	if(get_player_num(TEAM_T, AL_ALIVE) == 0)
	{
		TerminateRound(TEAM_CT)
		} else if(get_player_num(TEAM_CT, AL_ALIVE) == 0) {
		TerminateRound(TEAM_T)
	}
}

public do_zombie_win()
{
	TerminateRound(TEAM_T)
}

// Message
public message_StatusIcon(msg_id, msg_dest, msg_entity)
{
	static szMsg[8];
	get_msg_arg_string(2, szMsg ,7);
	
	if(equal(szMsg, "buyzone") && get_msg_arg_int(1))
	{
		set_pdata_int(msg_entity, 235, get_pdata_int(msg_entity, 235) & ~(1<<0));
		return PLUGIN_HANDLED;
	}
	
	return PLUGIN_CONTINUE;
}

public message_health(msg_id, msg_dest, msg_entity)
{
	static health
	health = get_msg_arg_int(1)
	
	if(health > 255)	
		set_msg_arg_int(1, get_msg_argtype(1), 255)
}
// End of Message

// Ham
public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
{
	// Block all those unneeeded hostage sounds
	if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
		return FMRES_SUPERCEDE;
	
	// Replace these next sounds for zombies only
	if (!is_user_connected(id) || !g_zombie[id])
		return FMRES_IGNORED;
	
	static temp_string[128]
	
	// Zombie being hit
	if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' ||
	sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
	{
		ArrayGetString(zombiepain_sound, random_num(0, ArraySize(zombiepain_sound) - 1), temp_string, sizeof(temp_string))
		emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
		
		return FMRES_SUPERCEDE;
	}
	
	// Zombie Attack
	new attack_type
	if (equal(sample,"weapons/knife_hitwall1.wav")) attack_type = 1
	else if (equal(sample,"weapons/knife_hit1.wav") ||
	equal(sample,"weapons/knife_hit3.wav") ||
	equal(sample,"weapons/knife_hit2.wav") ||
	equal(sample,"weapons/knife_hit4.wav") ||
	equal(sample,"weapons/knife_stab.wav")) attack_type = 2
	else if(equal(sample,"weapons/knife_slash1.wav") ||
		equal(sample,"weapons/knife_slash2.wav")) attack_type = 3
	if (attack_type)
	{
		if (attack_type == 1)
		{
			ArrayGetString(zombiewall_sound, random_num(0, ArraySize(zombiewall_sound) - 1), temp_string, sizeof(temp_string))
			emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
			} else if (attack_type == 2) {
			ArrayGetString(zombieattack_sound, random_num(0, ArraySize(zombieattack_sound) - 1), temp_string, sizeof(temp_string))
			emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
			} else if (attack_type == 3) {
			ArrayGetString(zombieswing_sound, random_num(0, ArraySize(zombieswing_sound) - 1), temp_string, sizeof(temp_string))
			emit_sound(id, channel, temp_string, volume, attn, flags, pitch)
		}
		
		return FMRES_SUPERCEDE;
	}
	
	return FMRES_IGNORED;
}

public fw_GetGameDesc()
{
	static GameName[64]
	formatex(GameName, sizeof(GameName), "%s %s", PLUGIN, VERSION)
	
	forward_return(FMV_STRING, GameName)
	return FMRES_SUPERCEDE
}

public fw_SetClientKeyValue(id, const infobuffer[], const key[])
{
	if(g_model_locked[id] && equal(key, "model"))
		return FMRES_SUPERCEDE
	
	return FMRES_HANDLED
}

public fw_Spawn_Post(id)
{
	if (get_player_num(TEAM_ALL, AL_ALIVE) > 1 && !g_started)
	{
		g_started = 1
		TerminateRound(TEAM_START)
	}		
	
	if(!is_user_connected(id))
		return HAM_IGNORED
	
	// Get Your Origin
	pev(id, pev_origin, g_spawn_origin[id])
	
	if(g_gamestart)
	{
		set_user_zombie(id, ZOMBIE_TYPE_ORIGIN, g_gamestart == 2 ? 1 : 0)
		return HAM_IGNORED
	}
	
	fm_cs_set_user_team(id, CS_TEAM_CT, 1)
	
	g_zombie[id] = 0
	g_zombie_type[id] = 0
	g_nvg[id] = 0
	g_menufailsafe[id] = false
	g_escape_point[id] = 0
	
	if(TASKID_WEAPONSMENU + id) remove_task(TASKID_WEAPONSMENU + id)
	
	set_task(random_float(0.1, 0.5), "set_user_nvision", id)
	set_human_stuff(id)
	
	if(g_showmenu[id])
		display_equipmenu(id)
	else
	{
		equipweapon(id, EQUIP_ALL)
	}
	
	return HAM_HANDLED
}

public display_equipmenu(id)
{
	static menubody[512], len
	len = formatex(menubody, 511, "\y%L^n^n", OFFICIAL_LANG, "WPNMENU_NAME")
	
	static bool:hasweap
	hasweap = ((g_player_weapons[id][0]) != -1 && (g_player_weapons[id][1] != -1)) ? true : false
	
	len += formatex(menubody[len], 511 - len,"\w1. %L^n", OFFICIAL_LANG, "MENU_NEW_WEAPON")
	len += formatex(menubody[len], 511 - len,"\w2. %L^n^n", OFFICIAL_LANG, "MENU_PRE_WEAPON")
	len += formatex(menubody[len], 511 - len,"\w3. %L^n^n", OFFICIAL_LANG, "MENU_PRE_DONTSHOW")
	len += formatex(menubody[len], 511 - len,"\w5. %L^n", OFFICIAL_LANG, "MENU_EXIT")
	
	static keys
	keys = (MENU_KEY_1|MENU_KEY_5)
	
	if(hasweap) 
		keys |= (MENU_KEY_2|MENU_KEY_3)
	
	static string[128]
	formatex(string, sizeof(string), "%L", OFFICIAL_LANG, "EQUIPMENT_NAME")
	
	show_menu(id, keys, menubody, -1, string)
}

public action_equip(id, key)
{
	if(!is_user_alive(id) || g_zombie[id])
		return PLUGIN_HANDLED
	
	switch(key)
	{
		case 0: display_weaponmenu(id, 1, g_menuposition[id] = 0)
			case 1: equipweapon(id, EQUIP_ALL)
			case 2:
		{
			g_showmenu[id] = false
			equipweapon(id, EQUIP_ALL)
			client_printc(id, "!g[MaddoxX]!n %L", OFFICIAL_LANG, "HOW_ENA_EQUIPMENU")
		}
	}
	
	if(key > 0)
	{
		g_menufailsafe[id] = false
		remove_task(TASKID_WEAPONSMENU + id)
	}
	return PLUGIN_HANDLED
}


public display_weaponmenu(id, menuid, pos)
{
	if(pos < 0 || menuid < 0)
		return
	
	static start
	start = pos * 8
	
	static maxitem
	maxitem = menuid == 1 ? sizeof g_primaryweapons : sizeof g_secondaryweapons
	
	if(start >= maxitem)
		start = pos = g_menuposition[id]
	
	static menubody[512], len, primary[64], secondary[64]
	
	formatex(primary, sizeof(primary), "%L", OFFICIAL_LANG, "WPN_PRIMARY")
	formatex(secondary, sizeof(secondary), "%L", OFFICIAL_LANG, "WPN_SECONDARY")
	
	len = formatex(menubody, 511, "\y%s\w^n^n", menuid == 1 ? primary : secondary)
	
	static end
	end = start + 8
	if(end > maxitem)
		end = maxitem
	
	static keys
	keys = MENU_KEY_0
	
	static a, b
	b = 0
	
	static string_next[32], string_back[32], string_exit[32]
	
	formatex(string_next, sizeof(string_next), "%L", OFFICIAL_LANG, "MENU_NEXT")
	formatex(string_back, sizeof(string_back), "%L", OFFICIAL_LANG, "MENU_BACK")
	formatex(string_exit, sizeof(string_exit), "%L", OFFICIAL_LANG, "MENU_EXIT")
	
	for(a = start; a < end; ++a) 
	{
		keys |= (1<<b)
		len += formatex(menubody[len], 511 - len,"%d. %s^n", ++b, menuid == 1 ? g_primaryweapons[a][0]: g_secondaryweapons[a][0])
	}
	
	if(end != maxitem)
	{
		formatex(menubody[len], 511 - len, "^n9. %s^n0. %s", string_next, pos ? string_back : string_exit)
		keys |= MENU_KEY_9
	}
	else	
		formatex(menubody[len], 511 - len, "^n0. %s", pos ? string_back : string_exit)
	
	show_menu(id, keys, menubody, -1, menuid == 1 ? primary : secondary)
}

public action_prim(id, key)
{
	if(!is_user_alive(id) || g_zombie[id])
		return PLUGIN_HANDLED
	
	switch(key)
	{
		case 8: display_weaponmenu(id, 1, ++g_menuposition[id])
		case 9: display_weaponmenu(id, 1, --g_menuposition[id])
		default:
		{
			g_player_weapons[id][0] = g_menuposition[id] * 8 + key
			equipweapon(id, EQUIP_PRI)
			
			display_weaponmenu(id, 2, g_menuposition[id] = 0)
		}
	}
	return PLUGIN_HANDLED
}

public action_sec(id, key)
{
	if(!is_user_alive(id) || g_zombie[id])
		return PLUGIN_HANDLED
		
	switch(key) 
	{
		case 8: display_weaponmenu(id, 2, ++g_menuposition[id])
		case 9: display_weaponmenu(id, 2, --g_menuposition[id])
		default:
		{
			g_menufailsafe[id] = false
			remove_task(TASKID_WEAPONSMENU + id)
			
			g_player_weapons[id][1] = g_menuposition[id] * 8 + key
			equipweapon(id, EQUIP_SEC)
			equipweapon(id, EQUIP_GREN)
		}
	}
	return PLUGIN_HANDLED
}

public set_human_stuff(id)
{
	fm_cs_set_user_team(id, CS_TEAM_CT, 1)
	
	g_zombie[id] = 0
	g_zombie_type[id] = 0
	
	set_user_health(id, cfg_human_health)
	set_user_armor(id, cfg_human_armor)
	set_task(random_float(0.1, 0.2), "do_set_human_model", id)
	
	if(g_gamestart < 1)
	{
		fm_set_user_speed(id, 0.1)
	} else {
		fm_set_user_speed(id, cfg_human_speed)
	}
	
	ExecuteForward(g_forwards[FORWARD_HUMANIZED], g_fwDummyResult, id)
}

public do_set_human_model(id)
{
	static model[128], random1
	
	random1 = random_num(0, ArraySize(human_model) - 1)
	ArrayGetString(human_model, random1, model, sizeof(model))
	
	fm_cs_set_user_model(id, model)
	#if defined SET_MODELINDEX_OFFSET	
	static modelindex
	
	modelindex = ArrayGetCell(human_modelindex, random1)
	fm_cs_set_user_model_index(id, modelindex)
	#endif		
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
	if(g_gamestart < 2)
		return HAM_SUPERCEDE
	if(!is_user_connected(victim) || !is_user_connected(attacker))
		return HAM_IGNORED
	if(!g_zombie[victim] && !g_zombie[attacker])
		return HAM_SUPERCEDE
	if(g_zombie[victim] && g_zombie[attacker])
		return HAM_SUPERCEDE		
	if(g_zombie[attacker] && get_user_weapon(attacker) == CSW_KNIFE)
	{
		if(damagebits == DMG_GRENADE)
			return HAM_SUPERCEDE
		
		OrpheuCall(OrpheuGetFunctionFromObject(g_pGameRules,"DeathNotice","CGameRules"), g_pGameRules, victim, attacker, inflictor)
		FixDeadAttrib(victim)
		
		update_frags(attacker, 1)
		update_deaths(victim, 1)
		
		set_user_zombie(victim, ZOMBIE_TYPE_HOST, 0)
		ExecuteForward(g_forwards[FORWARD_INFECTED], g_fwDummyResult, victim, attacker)
	} else if(g_zombie[victim] && !g_zombie[attacker]) {
		set_pdata_float(victim, 108, 1.0, 50)
		
		static Float:MyOrigin[3]
		pev(attacker, pev_origin, MyOrigin)
		
		hook_ent2(victim, MyOrigin, cfg_zombie_kbpower, 2)
	}
	
	return HAM_HANDLED
}

public update_frags(id, frag)
{
	if(!is_user_connected(id))
		return
	
	set_pev(id, pev_frags, float(pev(id, pev_frags) + frag))
	
	message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
	write_byte(id) // id
	write_short(pev(id, pev_frags)) // frags
	write_short(cs_get_user_deaths(id)) // deaths
	write_short(0) // class?
	write_short(get_pdata_int(id, 114, 5)) // team
	message_end()
}

public update_deaths(id, death)
{
	if(!is_user_connected(id))
		return
	
	cs_set_user_deaths(id, cs_get_user_deaths(id) + death)
	
	message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
	write_byte(id) // id
	write_short(pev(id, pev_frags)) // frags
	write_short(cs_get_user_deaths(id)) // deaths
	write_short(0) // class?
	write_short(get_pdata_int(id, 114, 5)) // team
	message_end()		
}

public fw_Killed_Post(id)
{
	check_win_con()
}

public fw_PlayerResetMaxSpeed(id)
{
	if(!g_zombie[id])
		return HAM_IGNORED
	
	return HAM_SUPERCEDE
}

public fw_TouchWeapon(weapon, id)
{
	// Not a player
	if (!is_user_connected(id))
		return HAM_IGNORED
	if (g_zombie[id])
		return HAM_SUPERCEDE
	
	return HAM_IGNORED
}
// End of Ham

// Ambience Sounds Stop Task
public ambience_sound_stop(id)
{
	if(id == 0)
	{
		client_cmd(0, "mp3 stop; stopsound")
	} else {
		if(!is_user_connected(id))
			return
			
		client_cmd(id, "mp3 stop; stopsound")
	}
}

// ============================ STOCK =================================
stock get_player_num(team, alive)
{
	static player_num
	player_num = 0
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		if(alive == AL_NOT)
		{
			if(is_user_alive(i))
				continue
			} else if(alive == AL_ALIVE) {
			if(!is_user_alive(i))
				continue	
		}
		
		if(team == TEAM_ALL)
		{
			if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
				continue
			} else if(team == TEAM_T) {
			if(cs_get_user_team(i) != CS_TEAM_T)
				continue
			} else if(team == TEAM_CT) {
			if(cs_get_user_team(i) != CS_TEAM_CT)
				continue
		}
		
		player_num++
	}
	
	return player_num
}

stock get_random_player(team, alive)
{
	static list_player[33], list_player_num
	static total_player
	total_player = get_player_num(team, alive)
	
	for(new i = 0; i < total_player; i++)
		list_player[i] = 0
	
	list_player_num = 0
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i))
			continue
		
		if(alive == AL_NOT)
		{
			if(is_user_alive(i))
				continue
			} else if(alive == AL_ALIVE) {
			if(!is_user_alive(i))
				continue	
		}
		
		if(team == TEAM_ALL)
		{
			if(cs_get_user_team(i) == CS_TEAM_UNASSIGNED || cs_get_user_team(i) == CS_TEAM_SPECTATOR)
				continue
			} else if(team == TEAM_T) {
			if(cs_get_user_team(i) != CS_TEAM_T)
				continue
			} else if(team == TEAM_CT) {
			if(cs_get_user_team(i) != CS_TEAM_CT)
				continue
		}
		
		list_player[list_player_num] = i
		list_player_num++
	}
	
	static random_player; random_player = 0
	random_player = list_player[random_num(0, list_player_num - 1)]
	
	return random_player
}

stock PlaySound(id, const sound[])
{
	if(id == 0)
	{
		if (equal(sound[strlen(sound)-4], ".mp3"))
			client_cmd(0, "mp3 play ^"sound/%s^"", sound)
		else
			client_cmd(0, "spk ^"%s^"", sound)
		} else {
		if(is_user_connected(id)&& is_user_alive(id))
		{
			if (equal(sound[strlen(sound)-4], ".mp3"))
				client_cmd(id, "mp3 play ^"sound/%s^"", sound)
			else
				client_cmd(id, "spk ^"%s^"", sound)			
		}
	}
}

stock client_printc(index, const text[], any:...)
{
	new szMsg[128];
	vformat(szMsg, sizeof(szMsg) - 1, text, 3);
	
	replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
	replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
	replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
	
	if(index == 0)
	{
		for(new i = 0; i < g_MaxPlayers; i++)
		{
			if(is_user_alive(i) && is_user_connected(i))
			{
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i);
				write_byte(i);
				write_string(szMsg);
				message_end();	
			}
		}		
		} else {
		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
		write_byte(index);
		write_string(szMsg);
		message_end();
	}
} 

stock require_zombie()
{
	switch(get_player_num(TEAM_CT, 1))
	{
		case 2..5: return 1
			case 6..15: return 2
			case 16..25: return 3
			case 26..32: return 4
		}
	
	return 0
}

stock check_spawn(Float:Origin[3])
{
	new Float:originE[3], Float:origin1[3], Float:origin2[3]
	new ent = -1
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "player")) != 0)
	{
		pev(ent, pev_origin, originE)
		
		// xoy
		origin1 = Origin
		origin2 = originE
		origin1[2] = origin2[2] = 0.0
		if (vector_distance(origin1, origin2) <= 2 * 16.0)
		{
			// oz
			origin1 = Origin
			origin2 = originE
			origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
			if (vector_distance(origin1, origin2) <= 72.0) return 0;
		}
	}
	
	return 1
}

// Drop primary/secondary weapons
stock drop_weapons(id, dropwhat)
{
	// Get user weapons
	static weapons[32], num, i, weaponid
	num = 0 // reset passed weapons count (bugfix)
	get_user_weapons(id, weapons, num)
	
	// Weapon bitsums
	const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
	const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)	
	
	// Loop through them and drop primaries or secondaries
	for (i = 0; i < num; i++)
	{
		// Prevent re-indexing the array
		weaponid = weapons[i]
		
		if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
		{
			// Get weapon entity
			static wname[32], weapon_ent
			get_weaponname(weaponid, wname, charsmax(wname))
			weapon_ent = fm_find_ent_by_owner(-1, wname, id)
			
			// Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
			set_pev(weapon_ent, pev_iuser1, cs_get_user_bpammo(id, weaponid))
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd(id, "drop", wname)
			cs_set_user_bpammo(id, weaponid, 0)
		}
	}
}

stock BytesToReplace ( identifier[], const bytes[], const bytesLength = sizeof bytes )
{
	new address;
	OrpheuMemoryGet( identifier, address );
	
	for ( new i; i < bytesLength; i++)
	{
		OrpheuMemorySetAtAddress( address, "roundTimeCheck|dummy", 1, bytes[ i ], address );
		address++;
	}
	
	server_cmd( "sv_restart 1" );
}

stock bool:TerminateRound(team)
{
	new winStatus;
	new event;
	new sound[64];
	
	switch(team)
	{
		case TEAM_T:
		{
			winStatus         = 2;
			event             = 9;
			ArrayGetString(escape_fail_sound, random_num(0, ArraySize(escape_fail_sound) - 1), sound, sizeof(sound))
			g_team_score[TEAM_T]++
			
			client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_FAIL")
		}
		case TEAM_CT:
		{
			winStatus         = 1;
			event             = 8;
			ArrayGetString(escape_suc_sound, random_num(0, ArraySize(escape_suc_sound) - 1), sound, sizeof(sound))
			g_team_score[TEAM_CT]++
			
			client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_SUCCESS")
		}
		case TEAM_ALL:
		{
			winStatus         = 3;
			event             = 10;
			sound             = "radio/rounddraw.wav";
			
			client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_DRAW")
		}
		case TEAM_START:
		{
			winStatus         = 3;	
			event             = 10;
			
			client_print(0, print_center, "%L", OFFICIAL_LANG, "ESCAPE_DRAW")
		}
		default:
		{
			return false;
		}
	}

	g_endround = 1
	EndRoundMessage(g_WinText[team], event)
	RoundTerminating(winStatus, team == TEAM_START ? 3.0 : 5.0)
	PlaySound(0, sound)

	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_connected(i) || !is_user_alive(i))
			continue
		if(g_zombie[i])
		{
			update_deaths(i, 1)
		} else {
			update_frags(i, 3)
			g_escape_point[i] += 5
		}
	}
	
	ExecuteForward(g_forwards[FORWARD_ROUNDEND], g_fwDummyResult, team)	
	
	return true;
}

stock RoundTerminating( const winStatus, const Float:delay )
{
	set_mp_pdata("m_iRoundWinStatus"  , winStatus );
	set_mp_pdata("m_fTeamCount"       , get_gametime() + delay );
	set_mp_pdata("m_bRoundTerminating", true );
}

stock EndRoundMessage( const message[], const event, const bool:notifyAllPlugins = false )
{
	static OrpheuFunction:handleFuncEndRoundMessage;
	
	if ( !handleFuncEndRoundMessage )
	{
		handleFuncEndRoundMessage = OrpheuGetFunction( "EndRoundMessage" );
	}
	
	( notifyAllPlugins ) ?
	OrpheuCallSuper( handleFuncEndRoundMessage, message, event ) :
	OrpheuCall( handleFuncEndRoundMessage, message, event );
}

stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
{
	static Float:fl_Velocity[3]
	static Float:EntOrigin[3]
	
	pev(ent, pev_origin, EntOrigin)
	static Float:distance_f
	distance_f = get_distance_f(EntOrigin, VicOrigin)
	
	new Float:fl_Time = distance_f / speed
	
	if(type == 1)
	{
		fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time		
		} else if(type == 2) {
		fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
		fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
		fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
	}
	
	entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}

stock equipweapon(id, weapon)
{
	if(!is_user_alive(id) || !is_user_connected(id)) 
		return
	
	static weaponid[2], weaponent
	
	if(weapon & EQUIP_PRI)
	{
		weaponent = fm_lastprimary(id)
		weaponid[1] = get_weaponid(g_primaryweapons[g_player_weapons[id][0]][1])
		
		if(pev_valid(weaponent))
		{
			weaponid[0] = fm_get_weapon_id(weaponent)
			if(weaponid[0] != weaponid[1])
				fm_strip_user_gun(id, weaponid[0])
		}
		else
			weaponid[0] = -1
		
		if(weaponid[0] != weaponid[1])
			give_item(id, g_primaryweapons[g_player_weapons[id][0]][1])
		
		cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
	}
	
	if(weapon & EQUIP_SEC)
	{
		weaponent = fm_lastsecondry(id)
		weaponid[1] = get_weaponid(g_secondaryweapons[g_player_weapons[id][1]][1])
		
		if(pev_valid(weaponent))
		{
			weaponid[0] = fm_get_weapon_id(weaponent)
			if(weaponid[0] != weaponid[1])
				fm_strip_user_gun(id, weaponid[0])
		}
		else
			weaponid[0] = -1
		
		if(weaponid[0] != weaponid[1])
			give_item(id, g_secondaryweapons[g_player_weapons[id][1]][1])
		
		cs_set_user_bpammo(id, weaponid[1], g_weapon_ammo[weaponid[1]][1])
	}
	
	if(weapon & EQUIP_GREN)
	{
		static i
		for(i = 0; i < sizeof g_grenades; i++) if(!user_has_weapon(id, get_weaponid(g_grenades[i])))
		give_item(id, g_grenades[i])
	}
}

// Set a Player's Team
stock fm_cs_set_user_team(id, CsTeams:team, send_message)
{
	// Prevent server crash if entity's private data not initalized
	if (pev_valid(id) != PDATA_SAFE)
		return;
	
	// Already belongs to the team
	if (cs_get_user_team(id) == team)
		return;
	
	// Remove previous team message task
	remove_task(id+TASK_TEAMMSG)
	
	// Set team offset
	set_pdata_int(id, OFFSET_CSTEAMS, _:team)
	
	// Send message to update team?
	if (send_message) fm_user_team_update(id)
}

// Send User Team Message (Note: this next message can be received by other plugins)
public fm_cs_set_user_team_msg(taskid)
{
	// Tell everyone my new team
	emessage_begin(MSG_ALL, g_MsgTeamInfo)
	ewrite_byte(ID_TEAMMSG) // player
	ewrite_string(CS_TEAM_NAMES[_:cs_get_user_team(ID_TEAMMSG)]) // team
	emessage_end()
	
	// Fix for AMXX/CZ bots which update team paramater from ScoreInfo message
	emessage_begin(MSG_BROADCAST, g_MsgScoreInfo)
	ewrite_byte(ID_TEAMMSG) // id
	ewrite_short(pev(ID_TEAMMSG, pev_frags)) // frags
	ewrite_short(cs_get_user_deaths(ID_TEAMMSG)) // deaths
	ewrite_short(0) // class?
	ewrite_short(_:cs_get_user_team(ID_TEAMMSG)) // team
	emessage_end()
}

// Update Player's Team on all clients (adding needed delays)
stock fm_user_team_update(id)
{	
	new Float:current_time
	current_time = get_gametime()
	
	if (current_time - g_TeamMsgTargetTime >= TEAMCHANGE_DELAY)
	{
		set_task(0.1, "fm_cs_set_user_team_msg", id+TASK_TEAMMSG)
		g_TeamMsgTargetTime = current_time + TEAMCHANGE_DELAY
	}
	else
	{
		set_task((g_TeamMsgTargetTime + TEAMCHANGE_DELAY) - current_time, "fm_cs_set_user_team_msg", id+TASK_TEAMMSG)
		g_TeamMsgTargetTime = g_TeamMsgTargetTime + TEAMCHANGE_DELAY
	}
}

stock fm_cs_set_user_model(id, const model[]) 
{
	g_model_locked[id] = 0
	engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", model)
	g_model_locked[id] = 1
}

stock fm_cs_set_user_model_index(id, model_index)
{
	if (pev_valid(id) != PDATA_SAFE)
		return;
	
	set_pdata_int(id, OFFSET_MODELINDEX, model_index)
}

stock FixDeadAttrib(id)
{
	message_begin(MSG_BROADCAST, get_user_msgid("ScoreAttrib"))
	write_byte(id) // id
	write_byte(0) // attrib
	message_end()
}

// Set Speed
stock fm_set_user_speed(id, Float:Speed)
{
	set_pev(id, pev_maxspeed, Speed)
	ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
}

stock fm_reset_user_speed(id)
{
	ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
}
193.203.39.156:27015
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests