Името на играч да се вижда в HUD на Army Ranks

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
dem12
Извън линия
Потребител
Потребител
Мнения: 56
Регистриран на: 06 Юни 2019, 10:04
Се отблагодари: 16 пъти
Получена благодарност: 6 пъти

Името на играч да се вижда в HUD на Army Ranks

Мнение от dem12 » 26 Юли 2019, 19:37

Здравейте, някой може ли да добави
името на играч да се вижда в HUD на Army Ranks?
Пример:
Name: Player
Rank: NEW
XP : [ 0 / 15 ]

Код за потвърждение: Избери целия код

/* 	
	Обещанного три года ждут ;)
*/
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
//
#define PLUGIN "Army Ranks"
#define VERSION "1.3"
#define AUTHOR "Arctic"
#pragma tabsize 0
#define ADM_MENU 	ADMIN_IMMUNITY // menu access flag
//
new g_vault;
new Handle:g_SqlTuple;
new g_Error[512]; 
enum _:PlData
{
	gId,gExp,gLevel,gTempKey
};
new UserData[33][PlData];
new gMessage[256];
new g_MsgHud,MaxPlayers,levelUp[33],gSayText;
new bool:restr_blocked;
new const gRankNames[][] = 
{
	"I_0","I_1","I_2","I_3","I_4","I_5","I_6","I_7","I_8","I_9","I_10","I_11","I_12","I_13","I_14",		
	"I_15","I_16","I_17","I_18","I_19","I_20"
};
new const gLevels[] = 
{
	0,15,30,60,100,180,350,750,999,1500,2200,2800,3200,3900,4500,5000,5500,6000,7000,8000
};
new const gNades[][] =
{
	{0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}
}
new const restrict_bonus[][] =
{
	"35hp",
	"most_wanted",
	"ka_wintershank"
};
new gRestrictMaps,gAdminGMsg,gBonusLevel,gFlash,gSmoke,gHe,
gHideRadar,gArmyChat,gSaveType,gTableName,gHost,gUser,gPassword,gDbName,gSlash,
gTk,gLostXpTk,gLevelUpmsg,gAllChat//,gDeleteNullRow;
//
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("army_ranks",VERSION, FCVAR_SERVER | FCVAR_SPONLY);
	set_cvar_string("army_ranks",VERSION);
//
	gRestrictMaps 	= register_cvar( "restrict_maps",     	"0");// вкл запрет бонусов на карте.	
	gBonusLevel	= register_cvar( "level_bonus",     	"1");// вкл оружие при получении уровня.
	gFlash		= register_cvar( "flash_nades",     	"0");// вкл бонуса флешек
	gSmoke		= register_cvar( "smoke_nades",     	"0");// вкл бонуса дымовых
	gHe		= register_cvar( "he_nades",     	"0");// вкл бонуса осколочных
	gHideRadar	= register_cvar( "hide_radar",     	"1");// скрывать радар у игрока
	gArmyChat	= register_cvar( "army_chat",     	"0");// использовать чат плагина, то есть приставка в чате, цвет сообщ. для админа
	gAdminGMsg	= register_cvar( "admin_color",    	"1");// 1 = сообщ.админа зеленое,0 = желтое, 2 = цвета команды
	gSaveType 	= register_cvar( "save_type",     	"0");// 0 - nvault, 1- mysql.
	gSlash 		= register_cvar( "slash_messages",     	"1");// не отображать команды со слэшем
	gTk 		= register_cvar( "team_kill_lost_xp",   	"1");// терять exp при тимкилле
	gLostXpTk 	= register_cvar( "lost_xp_val",     	"3");// кол-во теряемых exp при тк
	gLevelUpmsg	= register_cvar( "level_up_msg",     	"1");// сообщение при лвл-апе игрока : 1- вкл (всем), 2 - только игроку
	gAllChat	= register_cvar( "all_chat",     	"1");// 1 - чат для всех(метвые и живые), 0-живые не видят чат мертвых и наоборот
// для mysql	
	gHost		= register_cvar( "mysql_host", 		"127.0.0.1"); 	// host
	gUser		= register_cvar( "mysql_user", 		"root");	// username
	gPassword	= register_cvar( "mysql_password", 	"qwerty"); 	// password
	gDbName		= register_cvar( "mysql_db_name", 	"test"); 	// database name
	gTableName	= register_cvar( "mysql_table_name", 	"army_ranks"); 	// название таблицы mysql
//
	register_logevent( "EventRoundStart", 2, "1=Round_Start" );
	set_task(1.0,"Info",_,_,_, "b")
	register_event( "DeathMsg","EventDeath","a");
	register_message(get_user_msgid("SayText"), "msg_SayText");
	gSayText = get_user_msgid ("SayText");
//
	g_MsgHud = CreateHudSyncObj();
	MaxPlayers = get_maxplayers();
	register_dictionary("army.txt" );
//
	if(get_pcvar_num(gRestrictMaps))
	{
		new szMapName[64];
		get_mapname(szMapName,63);
		for(new a = 0; a < sizeof restrict_bonus; a++)
		{
			if(equal(szMapName, restrict_bonus[a]))
			{
				restr_blocked = true;
				log_amx("[army ranks] weapon menu is blocked on map [%s].",restrict_bonus[a]);
				break;
			} else {
				restr_blocked = false;
			}	
		}
	}
//
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			g_vault = nvault_open("army_ranks");
		}
		case 1: 
		{
			set_task(0.1, "sql_init");
		}
		default: 
		{
			g_vault = nvault_open("army_ranks");
		}
	}
//
	if(get_pcvar_num(gArmyChat))
	{
		register_clcmd("say", "hookSay") 
		register_clcmd("say_team", "hookSayTeam");
	}
	register_clcmd("amx_setlevel","set_level_menu");
}
public plugin_cfg()
{
	new szCfgDir[64], szFile[192];
	get_configsdir(szCfgDir, charsmax(szCfgDir));
	formatex(szFile,charsmax(szFile),"%s/army_ranks.cfg",szCfgDir);
	if(file_exists(szFile))
		server_cmd("exec %s", szFile);
}

public set_level_menu(id)
{
	if(get_user_flags(id) & ADM_MENU)
	{
		UserData[id][gTempKey] = 0;
		new players[32], num;
		get_players(players, num)
		new tempname[32], info[10];
		new players_menu = menu_create("SetLevel Menu:", "set_level_hl")
		for(new i = 0; i < num; i++)
		{
			get_user_name(players[i], tempname, 31);
			num_to_str(players[i], info, 9);
			menu_additem(players_menu, tempname, info, 0);
		}
		menu_setprop(players_menu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, players_menu, 0);
	}
	return PLUGIN_CONTINUE
}
public set_level_hl(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	UserData[id][gTempKey] = str_to_num(data);
	set_level_pl(id);
	return PLUGIN_CONTINUE
}
public set_level_pl(id)
{
	static szText[1024];
	formatex(szText,charsmax(szText), "%L", id, "CHOOSE_RANKN");
	new menu = menu_create( szText, "set_level_phl");
//======
	for(new i = 1; i < sizeof(gRankNames); i++)
	{
		new szItem[100],lang[10],num[5];
		format(lang,9,"I_%d",i);
		format(num,4,"%d",i);
		formatex(szItem,charsmax(szItem),"%L",id,lang);
		menu_additem(menu,szItem,num);
	}
//======
	menu_setprop(menu, MPROP_BACKNAME, "Back");
	menu_setprop(menu, MPROP_NEXTNAME, "Next");
	menu_setprop(menu, MPROP_EXITNAME, "Exit");
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public set_level_phl(id,menu,item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	new level = str_to_num(data);
	if(UserData[id][gTempKey] >= 1 && UserData[id][gTempKey] <= 32)
	{
		UserData[UserData[id][gTempKey]][gLevel] = level;
		UserData[UserData[id][gTempKey]][gExp] = gLevels[level-1];
		new szName[2][32];
		get_user_name(id, szName[0], 31);
		get_user_name(UserData[id][gTempKey], szName[1], 31);
		ColorChat(0,NORMAL,"%s give %L level to %s.",szName[0],LANG_PLAYER,gRankNames[level],szName[1])
	} else {
		set_level_menu(id);
	}
	UserData[id][gTempKey] = 0;
	return PLUGIN_HANDLED;
}

//
public sql_init()
{
	new szTableName[64],szHost[64],szUser[64],szPassword[64],szDbName[64],ErrorCode;
	get_pcvar_string(gTableName,szTableName,63);
	get_pcvar_string(gHost,szHost,63);
	get_pcvar_string(gUser,szUser,63);
	get_pcvar_string(gPassword,szPassword,63);
	get_pcvar_string(gDbName,szDbName,63);
	g_SqlTuple = SQL_MakeDbTuple(szHost,szUser,szPassword,szDbName);
	new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
	if(SqlConnection == Empty_Handle)
		set_fail_state(g_Error);

	new Handle:Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `%s`(`id` INT(10) NOT NULL AUTO_INCREMENT,`name` VARCHAR(32) NOT NULL,`exp` INT(10) NOT NULL,`level` INT(10) NOT NULL,PRIMARY KEY (id));", szTableName)
	if(!SQL_Execute(Queries))
	{
		SQL_QueryError(Queries,g_Error,charsmax(g_Error))
		set_fail_state(g_Error);
	}
	SQL_QueryAndIgnore(SqlConnection, "DELETE FROM %s WHERE exp=0 and level=1;",szTableName); // 24.10.12
	SQL_FreeHandle(Queries)
	SQL_FreeHandle(SqlConnection);
}
//
public plugin_end()
{
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			nvault_close(g_vault);
		}
		case 1: 
		{
			if(g_SqlTuple != Empty_Handle)
				SQL_FreeHandle(g_SqlTuple);
		}
		default: 
		{
			nvault_close(g_vault);
		}
	}
}
//
public client_putinserver(id) // путинсервер)
{
	if(get_pcvar_num(gHideRadar))
		client_cmd(id,"hideradar 1");
		
	UserData[id] = UserData[0];
	load_data(id);
}
//
public client_disconnect(id)
{
	save_usr(id);
	UserData[id] = UserData[0];
}
//
public check_level(id)
{
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;
		
	if(UserData[id][gExp] < 0)
		UserData[id][gExp] = 0;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
	{
		UserData[id][gLevel]++;
		levelUp[id] = 1;
		switch(get_pcvar_num(gLevelUpmsg))
		{
			case 1: 
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(0,NORMAL,buffer);
			}
			case 2:
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(id,NORMAL,buffer);
			}
		}
	}
}
public EventDeath()
{
	new iKiller = read_data(1);
	new iVictim = read_data(2);
	new head = read_data(3);
	if(iKiller != iVictim && is_user_connected(iKiller) && is_user_connected(iVictim) && UserData[iKiller][gLevel] <= 19)
	{
		// if tk?
		if(get_pcvar_num(gTk) && get_user_team(iKiller) == get_user_team(iVictim))
		{
			UserData[iKiller][gExp] -= get_pcvar_num(gLostXpTk);
			return PLUGIN_CONTINUE;
		}
		new weapon = get_user_weapon(iKiller);
		UserData[iKiller][gExp] += 1;
		if(weapon == CSW_KNIFE)
			UserData[iKiller][gExp] += 3;
			
		if(head)
			UserData[iKiller][gExp] += 2;

		if(weapon == CSW_HEGRENADE)
			UserData[iKiller][gExp] += 1;

		check_level(iKiller);
	}
	return PLUGIN_CONTINUE;
}
public EventRoundStart()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(is_user_alive(id) && is_user_connected(id))
		{
			if(restr_blocked)
				return PLUGIN_CONTINUE;
			
			if(get_pcvar_num(gFlash) && gNades[0][UserData[id][gLevel]])
				give_item(id,"weapon_flashbang");
			
			if(get_pcvar_num(gSmoke) && gNades[1][UserData[id][gLevel]])
				give_item(id,"weapon_smokegrenade");
				
			if(get_pcvar_num(gHe) && gNades[2][UserData[id][gLevel]])
				give_item(id,"weapon_hegrenade");
			
			if(levelUp[id] == 1 && get_pcvar_num(gBonusLevel))
			{
				GetWeapon(id);
				levelUp[id] = 0;
			}
		}
	}
	return PLUGIN_CONTINUE;
}
////////// save
public load_data(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511);
				log_amx(g_Error);
				return ;
			}
			if(SQL_NumResults(Query) > 0 )
			{
				next_load_data(id, "", 0);
			} else {
				register_player(id,"");
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
	}
}
public next_load_data(id,data[],len)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id,exp,level FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			if( SQL_NumResults(Query) > 0)
			{
				UserData[id][gId]= SQL_ReadResult(Query,0); 
				UserData[id][gExp]= SQL_ReadResult(Query,1); 
				UserData[id][gLevel]= SQL_ReadResult(Query,2); 
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
	}
// mini-check lvl_up
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
		UserData[id][gLevel]++;
}
public register_player(id,data[])
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"INSERT INTO %s (`id`,`name`,`exp`,`level`) VALUES (NULL,'%s','0','1');",szTableName,szName);
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
			UserData[id][gExp] = 0;
			UserData[id][gLevel] = 1;
		}
		default: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
	}
}
public save_usr(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
		case 1: 
		{
			new saveq[256],szTableName[32];
			get_pcvar_string(gTableName,szTableName,31);
			format(saveq,255,"UPDATE `%s` SET `exp`='%d',`level`='%d' WHERE `id`='%d';", szTableName,UserData[id][gExp],UserData[id][gLevel],UserData[id][gId])
			SQL_ThreadQuery(g_SqlTuple,"QueryHandler",saveq);
		}
		default: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
	}
}
///////// chat event
public hookSay(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
	
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG")
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
public hookSayTeam(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
		
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG");
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ^3%s^4 : ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]],szName);		
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
stock is_admin_msg(const Message[])
{
	if(Message[0] == '@')
		return true;
		
	return false;
}
stock is_empty_message(const Message[])
{
	if(equal(Message, "") || !strlen(Message))
		return true;
		
	return false;
}
stock Chat(id,team,chat_type)
{
	if(team)
	{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				if(get_user_team(id) == get_user_team(i))
					send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			}
		}
	} else{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			}
		}
	}
}
stock send_message(const message[], const id, const i)
{
	message_begin(MSG_ONE, gSayText, {0, 0, 0}, i)
	write_byte(id)
	write_string(message)
	message_end()
}
stock is_has_slash(const Message[])
{
	if(Message[0] == '/')
		return true;
		
	return false;
}

public client_infochanged(id)
{
	new newname[32],oldname[32]
	get_user_info(id, "name", newname,31)
	get_user_name(id,oldname,31)
	if(!is_user_connected(id) || is_user_bot(id)) 
		return PLUGIN_CONTINUE
		
	if(!equali(newname, oldname))
	{
		set_user_info(id,"name",oldname);
		log_amx("namechange BLOCKED.");
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
public msg_SayText()
{
	new arg[32]
	get_msg_arg_string(2, arg, 31)
	if(containi(arg,"name")!=-1)
		return PLUGIN_HANDLED

	return PLUGIN_CONTINUE
}
/////////// natives
public plugin_natives()
{
	register_native("get_user_exp", "native_get_user_exp", 1);
	register_native("get_user_lvl", "native_get_user_lvl", 1);
	register_native("set_user_exp", "native_set_user_exp", 1);
	register_native("set_user_lvl", "native_set_user_lvl", 1);
	register_native("get_user_rankname", "native_get_user_rankname", 1);
}
public native_set_user_exp(id,num)
{
	UserData[id][gExp] = num;
}
public native_set_user_lvl(id,num)
{
	UserData[id][gLevel] = num;
}
public native_get_user_exp(id)
{
	return UserData[id][gExp];
}
public native_get_user_lvl(id)
{
	return UserData[id][gLevel];
}
public native_get_user_rankname(id)
{
	static szRankName[64];
	format(szRankName, charsmax(szRankName), "%L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
	return szRankName;
}
//////// informer
public Info()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(!is_user_bot(id) && is_user_connected(id))
		{
			if(get_pcvar_num(gHideRadar))
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1);
			else
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1)
			
			static buffer[192], len;
			len = format(buffer, charsmax(buffer), "%L",LANG_PLAYER,"ZVANIE");
			len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
			if(UserData[id][gLevel] <= 19)
			{
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_XP",UserData[id][gExp],gLevels[UserData[id][gLevel]]);
			} else {
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_MAX");
			}
			ShowSyncHudMsg(id, g_MsgHud, "%s", buffer);
		}
	}
	return PLUGIN_CONTINUE
}
/////// weap menu per lvl
public GetWeapon(id)
{
	new szText[700 char];
	formatex( szText, charsmax( szText ), "%L", id, "GW_TITLE");
	new menu = menu_create( szText, "gw_menu" );
//
	formatex( szText, charsmax( szText ), "awp");
	menu_additem( menu, szText, "1", 0 );
//
	formatex( szText, charsmax( szText ), "ak-47");
	menu_additem( menu, szText, "2", 0 );
//
	formatex( szText, charsmax( szText ), "m4a1");
	menu_additem( menu, szText, "3", 0 );
//
	formatex( szText, charsmax( szText ), "famas");
	menu_additem( menu, szText, "4", 0 );
//
	menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public gw_menu(id,menu,item)
{
	if( item == MENU_EXIT )
	{
		return PLUGIN_HANDLED;
	}
	
	new data[ 6 ], iName[ 64 ], access, callback;
	menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
	new key = str_to_num( data );
	switch( key )
	{
		case 1:
		{
			give_item(id,"weapon_awp");
			cs_set_user_bpammo( id, CSW_AWP, 100);
		}
		case 2:
		{
			give_item(id,"weapon_ak47");
			cs_set_user_bpammo( id, CSW_AK47, 200);
		}
		case 3:
		{
			give_item(id,"weapon_m4a1");
			cs_set_user_bpammo( id, CSW_M4A1, 200);
		}
		case 4:
		{
			give_item(id,"weapon_famas");
			cs_set_user_bpammo( id, CSW_FAMAS, 200);
		}
	}
	
	return PLUGIN_HANDLED;
}
public QueryHandler(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
	switch(FailState)
	{
		case -2: log_amx("[Army Ranks] Failed to connect (%d): %s", Errcode, Error);
		case -1: log_amx("[Army Ranks] (%d): %s", Errcode, Error);
	}
	return PLUGIN_HANDLED
}

Аватар
mi0
Извън линия
AMXX Скриптър
AMXX Скриптър
Мнения: 534
Регистриран на: 09 Дек 2016, 22:02
Се отблагодари: 97 пъти
Получена благодарност: 120 пъти
Обратна връзка:

Името на играч да се вижда в HUD на Army Ranks

Мнение от mi0 » 26 Юли 2019, 19:41

Трябва да качиш Lang файла, който се намира в amxmodx/data/lang и се казва army.txt.
aka kurdokoleno
Catch Mod - 87.121.112.232:27021

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Името на играч да се вижда в HUD на Army Ranks

Мнение от OciXCrom » 26 Юли 2019, 19:42

Няма смисъл да ползваш този калпаво написан и стар код. Това е 10 пъти по-добре направено и има вградена опция в конфигурационния файл точно за това, което искаш.

Аватар
dem12
Извън линия
Потребител
Потребител
Мнения: 56
Регистриран на: 06 Юни 2019, 10:04
Се отблагодари: 16 пъти
Получена благодарност: 6 пъти

Името на играч да се вижда в HUD на Army Ranks

Мнение от dem12 » 26 Юли 2019, 19:46

mi0 написа: 26 Юли 2019, 19:41 Трябва да качиш Lang файла, който се намира в amxmodx/data/lang и се казва army.txt.
Давам!
Прикачени файлове
army.txt
(3.86 KiB) Свалено 135 пъти
army.txt
(3.86 KiB) Свалено 135 пъти

Аватар
mi0
Извън линия
AMXX Скриптър
AMXX Скриптър
Мнения: 534
Регистриран на: 09 Дек 2016, 22:02
Се отблагодари: 97 пъти
Получена благодарност: 120 пъти
Обратна връзка:

Името на играч да се вижда в HUD на Army Ranks

Мнение от mi0 » 26 Юли 2019, 20:31

Код -

Код за потвърждение: Избери целия код

/* 	
	Обещанного три года ждут ;)
*/
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
//
#define PLUGIN "Army Ranks"
#define VERSION "1.3"
#define AUTHOR "Arctic"
#pragma tabsize 0
#define ADM_MENU 	ADMIN_IMMUNITY // menu access flag
//
new g_vault;
new Handle:g_SqlTuple;
new g_Error[512]; 
enum _:PlData
{
	gId,gExp,gLevel,gTempKey
};
new UserData[33][PlData];
new gMessage[256];
new g_MsgHud,MaxPlayers,levelUp[33],gSayText;
new bool:restr_blocked;
new const gRankNames[][] = 
{
	"I_0","I_1","I_2","I_3","I_4","I_5","I_6","I_7","I_8","I_9","I_10","I_11","I_12","I_13","I_14",		
	"I_15","I_16","I_17","I_18","I_19","I_20"
};
new const gLevels[] = 
{
	0,15,30,60,100,180,350,750,999,1500,2200,2800,3200,3900,4500,5000,5500,6000,7000,8000
};
new const gNades[][] =
{
	{0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}
}
new const restrict_bonus[][] =
{
	"35hp",
	"most_wanted",
	"ka_wintershank"
};
new gRestrictMaps,gAdminGMsg,gBonusLevel,gFlash,gSmoke,gHe,
gHideRadar,gArmyChat,gSaveType,gTableName,gHost,gUser,gPassword,gDbName,gSlash,
gTk,gLostXpTk,gLevelUpmsg,gAllChat//,gDeleteNullRow;
//
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("army_ranks",VERSION, FCVAR_SERVER | FCVAR_SPONLY);
	set_cvar_string("army_ranks",VERSION);
//
	gRestrictMaps 	= register_cvar( "restrict_maps",     	"0");// вкл запрет бонусов на карте.	
	gBonusLevel	= register_cvar( "level_bonus",     	"1");// вкл оружие при получении уровня.
	gFlash		= register_cvar( "flash_nades",     	"0");// вкл бонуса флешек
	gSmoke		= register_cvar( "smoke_nades",     	"0");// вкл бонуса дымовых
	gHe		= register_cvar( "he_nades",     	"0");// вкл бонуса осколочных
	gHideRadar	= register_cvar( "hide_radar",     	"1");// скрывать радар у игрока
	gArmyChat	= register_cvar( "army_chat",     	"0");// использовать чат плагина, то есть приставка в чате, цвет сообщ. для админа
	gAdminGMsg	= register_cvar( "admin_color",    	"1");// 1 = сообщ.админа зеленое,0 = желтое, 2 = цвета команды
	gSaveType 	= register_cvar( "save_type",     	"0");// 0 - nvault, 1- mysql.
	gSlash 		= register_cvar( "slash_messages",     	"1");// не отображать команды со слэшем
	gTk 		= register_cvar( "team_kill_lost_xp",   	"1");// терять exp при тимкилле
	gLostXpTk 	= register_cvar( "lost_xp_val",     	"3");// кол-во теряемых exp при тк
	gLevelUpmsg	= register_cvar( "level_up_msg",     	"1");// сообщение при лвл-апе игрока : 1- вкл (всем), 2 - только игроку
	gAllChat	= register_cvar( "all_chat",     	"1");// 1 - чат для всех(метвые и живые), 0-живые не видят чат мертвых и наоборот
// для mysql	
	gHost		= register_cvar( "mysql_host", 		"127.0.0.1"); 	// host
	gUser		= register_cvar( "mysql_user", 		"root");	// username
	gPassword	= register_cvar( "mysql_password", 	"qwerty"); 	// password
	gDbName		= register_cvar( "mysql_db_name", 	"test"); 	// database name
	gTableName	= register_cvar( "mysql_table_name", 	"army_ranks"); 	// название таблицы mysql
//
	register_logevent( "EventRoundStart", 2, "1=Round_Start" );
	set_task(1.0,"Info",_,_,_, "b")
	register_event( "DeathMsg","EventDeath","a");
	register_message(get_user_msgid("SayText"), "msg_SayText");
	gSayText = get_user_msgid ("SayText");
//
	g_MsgHud = CreateHudSyncObj();
	MaxPlayers = get_maxplayers();
	register_dictionary("army.txt" );
//
	if(get_pcvar_num(gRestrictMaps))
	{
		new szMapName[64];
		get_mapname(szMapName,63);
		for(new a = 0; a < sizeof restrict_bonus; a++)
		{
			if(equal(szMapName, restrict_bonus[a]))
			{
				restr_blocked = true;
				log_amx("[army ranks] weapon menu is blocked on map [%s].",restrict_bonus[a]);
				break;
			} else {
				restr_blocked = false;
			}	
		}
	}
//
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			g_vault = nvault_open("army_ranks");
		}
		case 1: 
		{
			set_task(0.1, "sql_init");
		}
		default: 
		{
			g_vault = nvault_open("army_ranks");
		}
	}
//
	if(get_pcvar_num(gArmyChat))
	{
		register_clcmd("say", "hookSay") 
		register_clcmd("say_team", "hookSayTeam");
	}
	register_clcmd("amx_setlevel","set_level_menu");
}
public plugin_cfg()
{
	new szCfgDir[64], szFile[192];
	get_configsdir(szCfgDir, charsmax(szCfgDir));
	formatex(szFile,charsmax(szFile),"%s/army_ranks.cfg",szCfgDir);
	if(file_exists(szFile))
		server_cmd("exec %s", szFile);
}

public set_level_menu(id)
{
	if(get_user_flags(id) & ADM_MENU)
	{
		UserData[id][gTempKey] = 0;
		new players[32], num;
		get_players(players, num)
		new tempname[32], info[10];
		new players_menu = menu_create("SetLevel Menu:", "set_level_hl")
		for(new i = 0; i < num; i++)
		{
			get_user_name(players[i], tempname, 31);
			num_to_str(players[i], info, 9);
			menu_additem(players_menu, tempname, info, 0);
		}
		menu_setprop(players_menu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, players_menu, 0);
	}
	return PLUGIN_CONTINUE
}
public set_level_hl(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	UserData[id][gTempKey] = str_to_num(data);
	set_level_pl(id);
	return PLUGIN_CONTINUE
}
public set_level_pl(id)
{
	static szText[1024];
	formatex(szText,charsmax(szText), "%L", id, "CHOOSE_RANKN");
	new menu = menu_create( szText, "set_level_phl");
//======
	for(new i = 1; i < sizeof(gRankNames); i++)
	{
		new szItem[100],lang[10],num[5];
		format(lang,9,"I_%d",i);
		format(num,4,"%d",i);
		formatex(szItem,charsmax(szItem),"%L",id,lang);
		menu_additem(menu,szItem,num);
	}
//======
	menu_setprop(menu, MPROP_BACKNAME, "Back");
	menu_setprop(menu, MPROP_NEXTNAME, "Next");
	menu_setprop(menu, MPROP_EXITNAME, "Exit");
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public set_level_phl(id,menu,item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	new level = str_to_num(data);
	if(UserData[id][gTempKey] >= 1 && UserData[id][gTempKey] <= 32)
	{
		UserData[UserData[id][gTempKey]][gLevel] = level;
		UserData[UserData[id][gTempKey]][gExp] = gLevels[level-1];
		new szName[2][32];
		get_user_name(id, szName[0], 31);
		get_user_name(UserData[id][gTempKey], szName[1], 31);
		ColorChat(0,NORMAL,"%s give %L level to %s.",szName[0],LANG_PLAYER,gRankNames[level],szName[1])
	} else {
		set_level_menu(id);
	}
	UserData[id][gTempKey] = 0;
	return PLUGIN_HANDLED;
}

//
public sql_init()
{
	new szTableName[64],szHost[64],szUser[64],szPassword[64],szDbName[64],ErrorCode;
	get_pcvar_string(gTableName,szTableName,63);
	get_pcvar_string(gHost,szHost,63);
	get_pcvar_string(gUser,szUser,63);
	get_pcvar_string(gPassword,szPassword,63);
	get_pcvar_string(gDbName,szDbName,63);
	g_SqlTuple = SQL_MakeDbTuple(szHost,szUser,szPassword,szDbName);
	new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
	if(SqlConnection == Empty_Handle)
		set_fail_state(g_Error);

	new Handle:Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `%s`(`id` INT(10) NOT NULL AUTO_INCREMENT,`name` VARCHAR(32) NOT NULL,`exp` INT(10) NOT NULL,`level` INT(10) NOT NULL,PRIMARY KEY (id));", szTableName)
	if(!SQL_Execute(Queries))
	{
		SQL_QueryError(Queries,g_Error,charsmax(g_Error))
		set_fail_state(g_Error);
	}
	SQL_QueryAndIgnore(SqlConnection, "DELETE FROM %s WHERE exp=0 and level=1;",szTableName); // 24.10.12
	SQL_FreeHandle(Queries)
	SQL_FreeHandle(SqlConnection);
}
//
public plugin_end()
{
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			nvault_close(g_vault);
		}
		case 1: 
		{
			if(g_SqlTuple != Empty_Handle)
				SQL_FreeHandle(g_SqlTuple);
		}
		default: 
		{
			nvault_close(g_vault);
		}
	}
}
//
public client_putinserver(id) // путинсервер)
{
	if(get_pcvar_num(gHideRadar))
		client_cmd(id,"hideradar 1");
		
	UserData[id] = UserData[0];
	load_data(id);
}
//
public client_disconnect(id)
{
	save_usr(id);
	UserData[id] = UserData[0];
}
//
public check_level(id)
{
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;
		
	if(UserData[id][gExp] < 0)
		UserData[id][gExp] = 0;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
	{
		UserData[id][gLevel]++;
		levelUp[id] = 1;
		switch(get_pcvar_num(gLevelUpmsg))
		{
			case 1: 
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(0,NORMAL,buffer);
			}
			case 2:
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(id,NORMAL,buffer);
			}
		}
	}
}
public EventDeath()
{
	new iKiller = read_data(1);
	new iVictim = read_data(2);
	new head = read_data(3);
	if(iKiller != iVictim && is_user_connected(iKiller) && is_user_connected(iVictim) && UserData[iKiller][gLevel] <= 19)
	{
		// if tk?
		if(get_pcvar_num(gTk) && get_user_team(iKiller) == get_user_team(iVictim))
		{
			UserData[iKiller][gExp] -= get_pcvar_num(gLostXpTk);
			return PLUGIN_CONTINUE;
		}
		new weapon = get_user_weapon(iKiller);
		UserData[iKiller][gExp] += 1;
		if(weapon == CSW_KNIFE)
			UserData[iKiller][gExp] += 3;
			
		if(head)
			UserData[iKiller][gExp] += 2;

		if(weapon == CSW_HEGRENADE)
			UserData[iKiller][gExp] += 1;

		check_level(iKiller);
	}
	return PLUGIN_CONTINUE;
}
public EventRoundStart()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(is_user_alive(id) && is_user_connected(id))
		{
			if(restr_blocked)
				return PLUGIN_CONTINUE;
			
			if(get_pcvar_num(gFlash) && gNades[0][UserData[id][gLevel]])
				give_item(id,"weapon_flashbang");
			
			if(get_pcvar_num(gSmoke) && gNades[1][UserData[id][gLevel]])
				give_item(id,"weapon_smokegrenade");
				
			if(get_pcvar_num(gHe) && gNades[2][UserData[id][gLevel]])
				give_item(id,"weapon_hegrenade");
			
			if(levelUp[id] == 1 && get_pcvar_num(gBonusLevel))
			{
				GetWeapon(id);
				levelUp[id] = 0;
			}
		}
	}
	return PLUGIN_CONTINUE;
}
////////// save
public load_data(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511);
				log_amx(g_Error);
				return ;
			}
			if(SQL_NumResults(Query) > 0 )
			{
				next_load_data(id, "", 0);
			} else {
				register_player(id,"");
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
	}
}
public next_load_data(id,data[],len)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id,exp,level FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			if( SQL_NumResults(Query) > 0)
			{
				UserData[id][gId]= SQL_ReadResult(Query,0); 
				UserData[id][gExp]= SQL_ReadResult(Query,1); 
				UserData[id][gLevel]= SQL_ReadResult(Query,2); 
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
	}
// mini-check lvl_up
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
		UserData[id][gLevel]++;
}
public register_player(id,data[])
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"INSERT INTO %s (`id`,`name`,`exp`,`level`) VALUES (NULL,'%s','0','1');",szTableName,szName);
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
			UserData[id][gExp] = 0;
			UserData[id][gLevel] = 1;
		}
		default: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
	}
}
public save_usr(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
		case 1: 
		{
			new saveq[256],szTableName[32];
			get_pcvar_string(gTableName,szTableName,31);
			format(saveq,255,"UPDATE `%s` SET `exp`='%d',`level`='%d' WHERE `id`='%d';", szTableName,UserData[id][gExp],UserData[id][gLevel],UserData[id][gId])
			SQL_ThreadQuery(g_SqlTuple,"QueryHandler",saveq);
		}
		default: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
	}
}
///////// chat event
public hookSay(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
	
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG")
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
public hookSayTeam(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
		
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG");
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ^3%s^4 : ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]],szName);		
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
stock is_admin_msg(const Message[])
{
	if(Message[0] == '@')
		return true;
		
	return false;
}
stock is_empty_message(const Message[])
{
	if(equal(Message, "") || !strlen(Message))
		return true;
		
	return false;
}
stock Chat(id,team,chat_type)
{
	if(team)
	{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				if(get_user_team(id) == get_user_team(i))
					send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			}
		}
	} else{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			}
		}
	}
}
stock send_message(const message[], const id, const i)
{
	message_begin(MSG_ONE, gSayText, {0, 0, 0}, i)
	write_byte(id)
	write_string(message)
	message_end()
}
stock is_has_slash(const Message[])
{
	if(Message[0] == '/')
		return true;
		
	return false;
}

public client_infochanged(id)
{
	new newname[32],oldname[32]
	get_user_info(id, "name", newname,31)
	get_user_name(id,oldname,31)
	if(!is_user_connected(id) || is_user_bot(id)) 
		return PLUGIN_CONTINUE
		
	if(!equali(newname, oldname))
	{
		set_user_info(id,"name",oldname);
		log_amx("namechange BLOCKED.");
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
public msg_SayText()
{
	new arg[32]
	get_msg_arg_string(2, arg, 31)
	if(containi(arg,"name")!=-1)
		return PLUGIN_HANDLED

	return PLUGIN_CONTINUE
}
/////////// natives
public plugin_natives()
{
	register_native("get_user_exp", "native_get_user_exp", 1);
	register_native("get_user_lvl", "native_get_user_lvl", 1);
	register_native("set_user_exp", "native_set_user_exp", 1);
	register_native("set_user_lvl", "native_set_user_lvl", 1);
	register_native("get_user_rankname", "native_get_user_rankname", 1);
}
public native_set_user_exp(id,num)
{
	UserData[id][gExp] = num;
}
public native_set_user_lvl(id,num)
{
	UserData[id][gLevel] = num;
}
public native_get_user_exp(id)
{
	return UserData[id][gExp];
}
public native_get_user_lvl(id)
{
	return UserData[id][gLevel];
}
public native_get_user_rankname(id)
{
	static szRankName[64];
	format(szRankName, charsmax(szRankName), "%L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
	return szRankName;
}
//////// informer
public Info()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(!is_user_bot(id) && is_user_connected(id))
		{
			if(get_pcvar_num(gHideRadar))
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1);
			else
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1)
			
			static buffer[192], name[32], len;

			get_user_name(id, name, charsmax(name))
			len = format(buffer, charsmax(buffer), "%L",LANG_PLAYER,"NAME");
			len += format(buffer[len], charsmax(buffer) - len, " %s", name);
			len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"ZVANIE");
			len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
			if(UserData[id][gLevel] <= 19)
			{
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_XP",UserData[id][gExp],gLevels[UserData[id][gLevel]]);
			} else {
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_MAX");
			}
			ShowSyncHudMsg(id, g_MsgHud, "%s", buffer);
		}
	}
	return PLUGIN_CONTINUE
}
/////// weap menu per lvl
public GetWeapon(id)
{
	new szText[700 char];
	formatex( szText, charsmax( szText ), "%L", id, "GW_TITLE");
	new menu = menu_create( szText, "gw_menu" );
//
	formatex( szText, charsmax( szText ), "awp");
	menu_additem( menu, szText, "1", 0 );
//
	formatex( szText, charsmax( szText ), "ak-47");
	menu_additem( menu, szText, "2", 0 );
//
	formatex( szText, charsmax( szText ), "m4a1");
	menu_additem( menu, szText, "3", 0 );
//
	formatex( szText, charsmax( szText ), "famas");
	menu_additem( menu, szText, "4", 0 );
//
	menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public gw_menu(id,menu,item)
{
	if( item == MENU_EXIT )
	{
		return PLUGIN_HANDLED;
	}
	
	new data[ 6 ], iName[ 64 ], access, callback;
	menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
	new key = str_to_num( data );
	switch( key )
	{
		case 1:
		{
			give_item(id,"weapon_awp");
			cs_set_user_bpammo( id, CSW_AWP, 100);
		}
		case 2:
		{
			give_item(id,"weapon_ak47");
			cs_set_user_bpammo( id, CSW_AK47, 200);
		}
		case 3:
		{
			give_item(id,"weapon_m4a1");
			cs_set_user_bpammo( id, CSW_M4A1, 200);
		}
		case 4:
		{
			give_item(id,"weapon_famas");
			cs_set_user_bpammo( id, CSW_FAMAS, 200);
		}
	}
	
	return PLUGIN_HANDLED;
}
public QueryHandler(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
	switch(FailState)
	{
		case -2: log_amx("[Army Ranks] Failed to connect (%d): %s", Errcode, Error);
		case -1: log_amx("[Army Ranks] (%d): %s", Errcode, Error);
	}
	return PLUGIN_HANDLED
}
army.txt

Код за потвърждение: Избери целия код

[en]
I_0		= NEW^nLevel : [ 1 / 20 ]
I_1		= NEW^nLevel : [ 1 / 20 ]
I_2		= User^nLevel : [ 2 / 20 ]
I_3		= Good^nLevel : [ 3 / 20 ]
I_4		= Survivor^nLevel : [ 4 / 20 ]
I_5		= Steel^nLevel : [ 5 / 20 ]
I_6		= Silver^nLevel : [ 6 / 20 ]
I_7		= Golden^nLevel : [ 7 / 20 ]
I_8		= Hunter^nLevel : [ 8 / 20 ]
I_9		= Warrior^nLevel : [ 9 / 20 ]
I_10		= Soldier^nLevel : [ 10 / 20 ]
I_11		= Marine^nLevel : [ 11 / 20 ]
I_12		= Captain^nLevel : [ 12 / 20 ]
I_13		= Major^nLevel : [ 13 / 20 ]
I_14		= General^nLevel : [ 14 / 20 ]
I_15		= Killer^nLevel : [ 15 / 20 ]
I_16		= VIP^nLevel : [ 16 / 20 ]
I_17		= The Best^nLevel : [ 17 / 20 ]
I_18		= GOD^nLevel : [ 18 / 20 ]
I_19		= Maniac^nLevel : [ 19 / 20 ]
I_20		= PRO^nLevel : [ 20 / 20 ]

NAME		= Player :
ZVANIE 		= Rank :
PL_XP 		= XP : [ %d / %d ]
PL_XP_STEXT	= XP: %d of %d
PL_MAX		= congratulate!
SEND_TEAM 	= Team
A_NAME 		= Nick:
PLAYER 		= Player
NEW_LEVEL 	= is 
CONTR 		= congratulate!
GW_TITLE 	= Select the weapons

EMPTY_MSG	= Message should not be empty.
CHOOSE_RANKN    = Select rank :
DEFUSE_XP	= You received the %d EX for demining bombs.
MIN_PLAYERS	= Little players on the server. EX for demining bombs is not added.
PLANT_XP	= You received the %d EX for mined bombs!
BEEN_PLANTED	= Bombs already mined...

ARMY_MENU	= Choose function:
MUST_NUM	= The value must be numeric!
MIN_EXP		= Min. value - 1 EX!
MAX_EXP		= Max. value - 999 EX!
ADMIN_ADD	= Admin %s give %d EX %s.
TYPE_AMOUNT	= Enter number of EX.
SET_LVL		= Install level
ADMIN_LEVEL	= Admin %s install level
ADD_EXP		= Give EX

[ru]
I_0		= новое^nниво : [ 1 / 20 ]
I_1		= новое^nниво : [ 1 / 20 ]
I_2		= Потребитель^nниво : [ 2 / 20 ]
I_3		= хорошо^nниво : [ 3 / 20 ]
I_4		= уцелевший^nниво : [ 4 / 20 ]
I_5		= сталь^nниво : [ 5 / 20 ]
I_6		= серебро^nниво : [ 6 / 20 ]
I_7		= золотой^nниво : [ 7 / 20 ]
I_8		= охотник^nниво : [ 8 / 20 ]
I_9		= воин^nниво : [ 9 / 20 ]
I_10		= солдат^nниво : [ 10 / 20 ]
I_11		= морской^nниво : [ 11 / 20 ]
I_12		= Капитан^nниво : [ 12 / 20 ]
I_13		= Майор^nниво : [ 13 / 20 ]
I_14		= общий^nниво : [ 14 / 20 ]
I_15		= убийца^nниво : [ 15 / 20 ]
I_16		= важное лицо^nниво : [ 16 / 20 ]
I_17		= Лучшее^nниво : [ 17 / 20 ]
I_18		= бог^nниво : [ 18 / 20 ]
I_19		= маньяк^nниво : [ 19 / 20 ]
I_20		= за^nниво : [ 20 / 20 ]

NAME		= Игрок :
ZVANIE 		= Звание :
PL_XP 		= Опыт : [ %d / %d ]
PL_XP_STEXT	= Опыт: %d из %d
PL_MAX		= Поздравляем!
SEND_TEAM 	= Команде
A_NAME 		= Ник :
PLAYER 		= Боец
NEW_LEVEL 	= получил новое звание 
CONTR 		= Поздравляем!
GW_TITLE 	= Какое оружие хотите взять?

EMPTY_MSG	= Сообщение не может быть пустым.
CHOOSE_RANKN = Выбери звание :
DEFUSE_XP	= Вы получили %d опыта за разминирование бомбы!
MIN_PLAYERS	= На сервере мало игроков, опыт за действия с бомбой не начисляется.
PLANT_XP	= Вы получили %d опыта за минирование бомбы!
BEEN_PLANTED	= Бомбу уже минировали ранее..

ARMY_MENU	= Выберите действие:
MUST_NUM	= Значение должно быть числом!
MIN_EXP		= Минимальное значение - 1 опыта!
MAX_EXP		= Максиальное значение - 999 опыта!
ADMIN_ADD	= Админ %s дал %d опыта %s.
TYPE_AMOUNT	= В появившуюся вверху строку введите кол-во опыта.
SET_LVL		= Установить звание
ADD_EXP		= Добавить опыт
ADMIN_LEVEL	= Админ %s установил звание
Все пак, както каза @OciXCrom, ще е много по-добре, ако използваш плъгина, който той е дал.
aka kurdokoleno
Catch Mod - 87.121.112.232:27021

Аватар
dem12
Извън линия
Потребител
Потребител
Мнения: 56
Регистриран на: 06 Юни 2019, 10:04
Се отблагодари: 16 пъти
Получена благодарност: 6 пъти

Името на играч да се вижда в HUD на Army Ranks

Мнение от dem12 » 26 Юли 2019, 20:46

Работи, но ми излиза слято ето така: namedem12Rank : NEW

Аватар
mi0
Извън линия
AMXX Скриптър
AMXX Скриптър
Мнения: 534
Регистриран на: 09 Дек 2016, 22:02
Се отблагодари: 97 пъти
Получена благодарност: 120 пъти
Обратна връзка:

Името на играч да се вижда в HUD на Army Ranks

Мнение от mi0 » 26 Юли 2019, 20:56

Много се извинявам за тъпата грешка

Код за потвърждение: Избери целия код

/* 	
	Обещанного три года ждут ;)
*/
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>
//
#define PLUGIN "Army Ranks"
#define VERSION "1.3"
#define AUTHOR "Arctic"
#pragma tabsize 0
#define ADM_MENU 	ADMIN_IMMUNITY // menu access flag
//
new g_vault;
new Handle:g_SqlTuple;
new g_Error[512]; 
enum _:PlData
{
	gId,gExp,gLevel,gTempKey
};
new UserData[33][PlData];
new gMessage[256];
new g_MsgHud,MaxPlayers,levelUp[33],gSayText;
new bool:restr_blocked;
new const gRankNames[][] = 
{
	"I_0","I_1","I_2","I_3","I_4","I_5","I_6","I_7","I_8","I_9","I_10","I_11","I_12","I_13","I_14",		
	"I_15","I_16","I_17","I_18","I_19","I_20"
};
new const gLevels[] = 
{
	0,15,30,60,100,180,350,750,999,1500,2200,2800,3200,3900,4500,5000,5500,6000,7000,8000
};
new const gNades[][] =
{
	{0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
	{0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}
}
new const restrict_bonus[][] =
{
	"35hp",
	"most_wanted",
	"ka_wintershank"
};
new gRestrictMaps,gAdminGMsg,gBonusLevel,gFlash,gSmoke,gHe,
gHideRadar,gArmyChat,gSaveType,gTableName,gHost,gUser,gPassword,gDbName,gSlash,
gTk,gLostXpTk,gLevelUpmsg,gAllChat//,gDeleteNullRow;
//
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("army_ranks",VERSION, FCVAR_SERVER | FCVAR_SPONLY);
	set_cvar_string("army_ranks",VERSION);
//
	gRestrictMaps 	= register_cvar( "restrict_maps",     	"0");// вкл запрет бонусов на карте.	
	gBonusLevel	= register_cvar( "level_bonus",     	"1");// вкл оружие при получении уровня.
	gFlash		= register_cvar( "flash_nades",     	"0");// вкл бонуса флешек
	gSmoke		= register_cvar( "smoke_nades",     	"0");// вкл бонуса дымовых
	gHe		= register_cvar( "he_nades",     	"0");// вкл бонуса осколочных
	gHideRadar	= register_cvar( "hide_radar",     	"1");// скрывать радар у игрока
	gArmyChat	= register_cvar( "army_chat",     	"0");// использовать чат плагина, то есть приставка в чате, цвет сообщ. для админа
	gAdminGMsg	= register_cvar( "admin_color",    	"1");// 1 = сообщ.админа зеленое,0 = желтое, 2 = цвета команды
	gSaveType 	= register_cvar( "save_type",     	"0");// 0 - nvault, 1- mysql.
	gSlash 		= register_cvar( "slash_messages",     	"1");// не отображать команды со слэшем
	gTk 		= register_cvar( "team_kill_lost_xp",   	"1");// терять exp при тимкилле
	gLostXpTk 	= register_cvar( "lost_xp_val",     	"3");// кол-во теряемых exp при тк
	gLevelUpmsg	= register_cvar( "level_up_msg",     	"1");// сообщение при лвл-апе игрока : 1- вкл (всем), 2 - только игроку
	gAllChat	= register_cvar( "all_chat",     	"1");// 1 - чат для всех(метвые и живые), 0-живые не видят чат мертвых и наоборот
// для mysql	
	gHost		= register_cvar( "mysql_host", 		"127.0.0.1"); 	// host
	gUser		= register_cvar( "mysql_user", 		"root");	// username
	gPassword	= register_cvar( "mysql_password", 	"qwerty"); 	// password
	gDbName		= register_cvar( "mysql_db_name", 	"test"); 	// database name
	gTableName	= register_cvar( "mysql_table_name", 	"army_ranks"); 	// название таблицы mysql
//
	register_logevent( "EventRoundStart", 2, "1=Round_Start" );
	set_task(1.0,"Info",_,_,_, "b")
	register_event( "DeathMsg","EventDeath","a");
	register_message(get_user_msgid("SayText"), "msg_SayText");
	gSayText = get_user_msgid ("SayText");
//
	g_MsgHud = CreateHudSyncObj();
	MaxPlayers = get_maxplayers();
	register_dictionary("army.txt" );
//
	if(get_pcvar_num(gRestrictMaps))
	{
		new szMapName[64];
		get_mapname(szMapName,63);
		for(new a = 0; a < sizeof restrict_bonus; a++)
		{
			if(equal(szMapName, restrict_bonus[a]))
			{
				restr_blocked = true;
				log_amx("[army ranks] weapon menu is blocked on map [%s].",restrict_bonus[a]);
				break;
			} else {
				restr_blocked = false;
			}	
		}
	}
//
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			g_vault = nvault_open("army_ranks");
		}
		case 1: 
		{
			set_task(0.1, "sql_init");
		}
		default: 
		{
			g_vault = nvault_open("army_ranks");
		}
	}
//
	if(get_pcvar_num(gArmyChat))
	{
		register_clcmd("say", "hookSay") 
		register_clcmd("say_team", "hookSayTeam");
	}
	register_clcmd("amx_setlevel","set_level_menu");
}
public plugin_cfg()
{
	new szCfgDir[64], szFile[192];
	get_configsdir(szCfgDir, charsmax(szCfgDir));
	formatex(szFile,charsmax(szFile),"%s/army_ranks.cfg",szCfgDir);
	if(file_exists(szFile))
		server_cmd("exec %s", szFile);
}

public set_level_menu(id)
{
	if(get_user_flags(id) & ADM_MENU)
	{
		UserData[id][gTempKey] = 0;
		new players[32], num;
		get_players(players, num)
		new tempname[32], info[10];
		new players_menu = menu_create("SetLevel Menu:", "set_level_hl")
		for(new i = 0; i < num; i++)
		{
			get_user_name(players[i], tempname, 31);
			num_to_str(players[i], info, 9);
			menu_additem(players_menu, tempname, info, 0);
		}
		menu_setprop(players_menu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, players_menu, 0);
	}
	return PLUGIN_CONTINUE
}
public set_level_hl(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	UserData[id][gTempKey] = str_to_num(data);
	set_level_pl(id);
	return PLUGIN_CONTINUE
}
public set_level_pl(id)
{
	static szText[1024];
	formatex(szText,charsmax(szText), "%L", id, "CHOOSE_RANKN");
	new menu = menu_create( szText, "set_level_phl");
//======
	for(new i = 1; i < sizeof(gRankNames); i++)
	{
		new szItem[100],lang[10],num[5];
		format(lang,9,"I_%d",i);
		format(num,4,"%d",i);
		formatex(szItem,charsmax(szItem),"%L",id,lang);
		menu_additem(menu,szItem,num);
	}
//======
	menu_setprop(menu, MPROP_BACKNAME, "Back");
	menu_setprop(menu, MPROP_NEXTNAME, "Next");
	menu_setprop(menu, MPROP_EXITNAME, "Exit");
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public set_level_phl(id,menu,item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], _access, callback;
	menu_item_getinfo( menu, item, _access, data, charsmax(data), _, _, callback);
	new level = str_to_num(data);
	if(UserData[id][gTempKey] >= 1 && UserData[id][gTempKey] <= 32)
	{
		UserData[UserData[id][gTempKey]][gLevel] = level;
		UserData[UserData[id][gTempKey]][gExp] = gLevels[level-1];
		new szName[2][32];
		get_user_name(id, szName[0], 31);
		get_user_name(UserData[id][gTempKey], szName[1], 31);
		ColorChat(0,NORMAL,"%s give %L level to %s.",szName[0],LANG_PLAYER,gRankNames[level],szName[1])
	} else {
		set_level_menu(id);
	}
	UserData[id][gTempKey] = 0;
	return PLUGIN_HANDLED;
}

//
public sql_init()
{
	new szTableName[64],szHost[64],szUser[64],szPassword[64],szDbName[64],ErrorCode;
	get_pcvar_string(gTableName,szTableName,63);
	get_pcvar_string(gHost,szHost,63);
	get_pcvar_string(gUser,szUser,63);
	get_pcvar_string(gPassword,szPassword,63);
	get_pcvar_string(gDbName,szDbName,63);
	g_SqlTuple = SQL_MakeDbTuple(szHost,szUser,szPassword,szDbName);
	new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
	if(SqlConnection == Empty_Handle)
		set_fail_state(g_Error);

	new Handle:Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `%s`(`id` INT(10) NOT NULL AUTO_INCREMENT,`name` VARCHAR(32) NOT NULL,`exp` INT(10) NOT NULL,`level` INT(10) NOT NULL,PRIMARY KEY (id));", szTableName)
	if(!SQL_Execute(Queries))
	{
		SQL_QueryError(Queries,g_Error,charsmax(g_Error))
		set_fail_state(g_Error);
	}
	SQL_QueryAndIgnore(SqlConnection, "DELETE FROM %s WHERE exp=0 and level=1;",szTableName); // 24.10.12
	SQL_FreeHandle(Queries)
	SQL_FreeHandle(SqlConnection);
}
//
public plugin_end()
{
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			nvault_close(g_vault);
		}
		case 1: 
		{
			if(g_SqlTuple != Empty_Handle)
				SQL_FreeHandle(g_SqlTuple);
		}
		default: 
		{
			nvault_close(g_vault);
		}
	}
}
//
public client_putinserver(id) // путинсервер)
{
	if(get_pcvar_num(gHideRadar))
		client_cmd(id,"hideradar 1");
		
	UserData[id] = UserData[0];
	load_data(id);
}
//
public client_disconnect(id)
{
	save_usr(id);
	UserData[id] = UserData[0];
}
//
public check_level(id)
{
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;
		
	if(UserData[id][gExp] < 0)
		UserData[id][gExp] = 0;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
	{
		UserData[id][gLevel]++;
		levelUp[id] = 1;
		switch(get_pcvar_num(gLevelUpmsg))
		{
			case 1: 
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(0,NORMAL,buffer);
			}
			case 2:
			{
				new szName[33];
				get_user_name(id, szName, 32);
				static buffer[192],len;
				len = format(buffer, charsmax(buffer), "^4[^3Army Ranks^4]^1 %L ^4%s^1",LANG_PLAYER,"PLAYER",szName);
				len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,"NEW_LEVEL"); 
				len += format(buffer[len], charsmax(buffer) - len, " ^4%L^1.",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
				len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"CONTR");
				ColorChat(id,NORMAL,buffer);
			}
		}
	}
}
public EventDeath()
{
	new iKiller = read_data(1);
	new iVictim = read_data(2);
	new head = read_data(3);
	if(iKiller != iVictim && is_user_connected(iKiller) && is_user_connected(iVictim) && UserData[iKiller][gLevel] <= 19)
	{
		// if tk?
		if(get_pcvar_num(gTk) && get_user_team(iKiller) == get_user_team(iVictim))
		{
			UserData[iKiller][gExp] -= get_pcvar_num(gLostXpTk);
			return PLUGIN_CONTINUE;
		}
		new weapon = get_user_weapon(iKiller);
		UserData[iKiller][gExp] += 1;
		if(weapon == CSW_KNIFE)
			UserData[iKiller][gExp] += 3;
			
		if(head)
			UserData[iKiller][gExp] += 2;

		if(weapon == CSW_HEGRENADE)
			UserData[iKiller][gExp] += 1;

		check_level(iKiller);
	}
	return PLUGIN_CONTINUE;
}
public EventRoundStart()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(is_user_alive(id) && is_user_connected(id))
		{
			if(restr_blocked)
				return PLUGIN_CONTINUE;
			
			if(get_pcvar_num(gFlash) && gNades[0][UserData[id][gLevel]])
				give_item(id,"weapon_flashbang");
			
			if(get_pcvar_num(gSmoke) && gNades[1][UserData[id][gLevel]])
				give_item(id,"weapon_smokegrenade");
				
			if(get_pcvar_num(gHe) && gNades[2][UserData[id][gLevel]])
				give_item(id,"weapon_hegrenade");
			
			if(levelUp[id] == 1 && get_pcvar_num(gBonusLevel))
			{
				GetWeapon(id);
				levelUp[id] = 0;
			}
		}
	}
	return PLUGIN_CONTINUE;
}
////////// save
public load_data(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511);
				log_amx(g_Error);
				return ;
			}
			if(SQL_NumResults(Query) > 0 )
			{
				next_load_data(id, "", 0);
			} else {
				register_player(id,"");
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			static data[256], timestamp;
			if(nvault_lookup(g_vault, szName, data, sizeof(data) - 1, timestamp) )
			{
				next_load_data(id, data, sizeof(data) - 1);
				return;
			} else {
				register_player(id,"");
			}
		}
	}
}
public next_load_data(id,data[],len)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT id,exp,level FROM %s WHERE name = '%s';",szTableName,szName)
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			if( SQL_NumResults(Query) > 0)
			{
				UserData[id][gId]= SQL_ReadResult(Query,0); 
				UserData[id][gExp]= SQL_ReadResult(Query,1); 
				UserData[id][gLevel]= SQL_ReadResult(Query,2); 
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
		}
		default: 
		{
			replace_all(data,len,"|"," ");
			new exp[5],level[5];
			parse(data,exp,4,level,4);
			UserData[id][gExp]= str_to_num(exp);
			UserData[id][gLevel]= str_to_num(level);
		}
	}
// mini-check lvl_up
	if(UserData[id][gLevel] <= 0)
		UserData[id][gLevel] = 1;

	while(UserData[id][gExp] >= gLevels[UserData[id][gLevel]]) 
		UserData[id][gLevel]++;
}
public register_player(id,data[])
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
		case 1: 
		{
			new szTableName[32],ErrorCode;
			new Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
			SQL_QuoteString(SqlConnection, szName, 32, szName);
			get_pcvar_string(gTableName,szTableName,31);
			if(SqlConnection == Empty_Handle)
			{
				log_amx(g_Error);
				return ;
			}
			new Handle:Query = SQL_PrepareQuery(SqlConnection,"INSERT INTO %s (`id`,`name`,`exp`,`level`) VALUES (NULL,'%s','0','1');",szTableName,szName);
			if(!SQL_Execute(Query))
			{
				SQL_QueryError(Query,g_Error,511)
				log_amx(g_Error)
			}
			SQL_FreeHandle(Query);
			SQL_FreeHandle(SqlConnection);
			UserData[id][gExp] = 0;
			UserData[id][gLevel] = 1;
		}
		default: 
		{
			UserData[id][gExp]= 0
			UserData[id][gLevel]= 1;
		}
	}
}
public save_usr(id)
{
	new szName[33];
	get_user_name(id,szName,32);
	switch(get_pcvar_num(gSaveType))
	{
		case 0: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
		case 1: 
		{
			new saveq[256],szTableName[32];
			get_pcvar_string(gTableName,szTableName,31);
			format(saveq,255,"UPDATE `%s` SET `exp`='%d',`level`='%d' WHERE `id`='%d';", szTableName,UserData[id][gExp],UserData[id][gLevel],UserData[id][gId])
			SQL_ThreadQuery(g_SqlTuple,"QueryHandler",saveq);
		}
		default: 
		{
			static data[256];
			formatex(data, 255, "|%i|%i|", UserData[id][gExp],UserData[id][gLevel]);
			nvault_set(g_vault, szName, data);
		}
	}
}
///////// chat event
public hookSay(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
	
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG")
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^4[^3%L^4] ",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,0,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
public hookSayTeam(id)
{
	if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
		return PLUGIN_CONTINUE;

	new message[192],Len;
	read_args(message, 191);
	remove_quotes(message);
	if(is_admin_msg(message))
		return PLUGIN_CONTINUE;
		
	if(is_empty_message(message))
	{
		ColorChat(id,NORMAL,"^4[^3Army Ranks^4]^1 %L",LANG_PLAYER,"EMPTY_MSG");
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(gSlash))
	{
		if(is_has_slash(message))
			return PLUGIN_HANDLED_MAIN
	}
	new szName[32];
	get_user_name(id,szName,31);
	if(is_user_admin(id))
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ^3%s^4 : ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]],szName);		
		switch(get_pcvar_num(gAdminGMsg))
		{
			case 1:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "%s",message);
			}
			case 2:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s",message);
			}
			default:
			{
				Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
			}
		}
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	else 
	{
		Len = format(gMessage[Len], charsmax(gMessage) - 1, "^3%L^1 ^4[^3%L^4] ",LANG_PLAYER,"SEND_TEAM",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^3%s^4 : ",szName);
		Len += format(gMessage[Len], charsmax(gMessage) - 1, "^1%s",message);
		Chat(id,1,get_pcvar_num(gAllChat));
	}
	return PLUGIN_HANDLED_MAIN
}
stock is_admin_msg(const Message[])
{
	if(Message[0] == '@')
		return true;
		
	return false;
}
stock is_empty_message(const Message[])
{
	if(equal(Message, "") || !strlen(Message))
		return true;
		
	return false;
}
stock Chat(id,team,chat_type)
{
	if(team)
	{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				if(get_user_team(id) == get_user_team(i))
					send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					if(get_user_team(id) == get_user_team(i))
						send_message(gMessage, id, i);
				}
			}
		}
	} else{
		if(chat_type)
		{
			for(new i = 1; i <= MaxPlayers; i++)
			{
				if(!is_user_connected(i))
					continue
			
				send_message(gMessage, id, i);
			}
		} else {
			if(is_user_alive(id))
			{
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || !is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			} else if(!is_user_alive(id)){
				for(new i = 1; i <= MaxPlayers; i++)
				{
					if(!is_user_connected(i) || is_user_alive(i))
						continue
				
					send_message(gMessage, id, i);
				}
			}
		}
	}
}
stock send_message(const message[], const id, const i)
{
	message_begin(MSG_ONE, gSayText, {0, 0, 0}, i)
	write_byte(id)
	write_string(message)
	message_end()
}
stock is_has_slash(const Message[])
{
	if(Message[0] == '/')
		return true;
		
	return false;
}

public client_infochanged(id)
{
	new newname[32],oldname[32]
	get_user_info(id, "name", newname,31)
	get_user_name(id,oldname,31)
	if(!is_user_connected(id) || is_user_bot(id)) 
		return PLUGIN_CONTINUE
		
	if(!equali(newname, oldname))
	{
		set_user_info(id,"name",oldname);
		log_amx("namechange BLOCKED.");
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
public msg_SayText()
{
	new arg[32]
	get_msg_arg_string(2, arg, 31)
	if(containi(arg,"name")!=-1)
		return PLUGIN_HANDLED

	return PLUGIN_CONTINUE
}
/////////// natives
public plugin_natives()
{
	register_native("get_user_exp", "native_get_user_exp", 1);
	register_native("get_user_lvl", "native_get_user_lvl", 1);
	register_native("set_user_exp", "native_set_user_exp", 1);
	register_native("set_user_lvl", "native_set_user_lvl", 1);
	register_native("get_user_rankname", "native_get_user_rankname", 1);
}
public native_set_user_exp(id,num)
{
	UserData[id][gExp] = num;
}
public native_set_user_lvl(id,num)
{
	UserData[id][gLevel] = num;
}
public native_get_user_exp(id)
{
	return UserData[id][gExp];
}
public native_get_user_lvl(id)
{
	return UserData[id][gLevel];
}
public native_get_user_rankname(id)
{
	static szRankName[64];
	format(szRankName, charsmax(szRankName), "%L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
	return szRankName;
}
//////// informer
public Info()
{
	for(new id = 1; id <= MaxPlayers; id++)
	{
		if(!is_user_bot(id) && is_user_connected(id))
		{
			if(get_pcvar_num(gHideRadar))
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1);
			else
				set_hudmessage(100, 100, 100, 0.01, 0.19, 0, 1.0, 1.0, _, _, -1)
			
			static buffer[192], name[32], len;

			get_user_name(id, name, charsmax(name))
			len = format(buffer, charsmax(buffer), "%L",LANG_PLAYER,"NAME");
			len += format(buffer[len], charsmax(buffer) - len, " %s^n", name);
			len += format(buffer[len], charsmax(buffer) - len, "%L",LANG_PLAYER,"ZVANIE");
			len += format(buffer[len], charsmax(buffer) - len, " %L",LANG_PLAYER,gRankNames[UserData[id][gLevel]]);
			if(UserData[id][gLevel] <= 19)
			{
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_XP",UserData[id][gExp],gLevels[UserData[id][gLevel]]);
			} else {
				len += format(buffer[len], charsmax(buffer) - len, "^n%L",LANG_PLAYER,"PL_MAX");
			}
			ShowSyncHudMsg(id, g_MsgHud, "%s", buffer);
		}
	}
	return PLUGIN_CONTINUE
}
/////// weap menu per lvl
public GetWeapon(id)
{
	new szText[700 char];
	formatex( szText, charsmax( szText ), "%L", id, "GW_TITLE");
	new menu = menu_create( szText, "gw_menu" );
//
	formatex( szText, charsmax( szText ), "awp");
	menu_additem( menu, szText, "1", 0 );
//
	formatex( szText, charsmax( szText ), "ak-47");
	menu_additem( menu, szText, "2", 0 );
//
	formatex( szText, charsmax( szText ), "m4a1");
	menu_additem( menu, szText, "3", 0 );
//
	formatex( szText, charsmax( szText ), "famas");
	menu_additem( menu, szText, "4", 0 );
//
	menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
	menu_display( id, menu,0);
	return PLUGIN_CONTINUE;
}
public gw_menu(id,menu,item)
{
	if( item == MENU_EXIT )
	{
		return PLUGIN_HANDLED;
	}
	
	new data[ 6 ], iName[ 64 ], access, callback;
	menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
	new key = str_to_num( data );
	switch( key )
	{
		case 1:
		{
			give_item(id,"weapon_awp");
			cs_set_user_bpammo( id, CSW_AWP, 100);
		}
		case 2:
		{
			give_item(id,"weapon_ak47");
			cs_set_user_bpammo( id, CSW_AK47, 200);
		}
		case 3:
		{
			give_item(id,"weapon_m4a1");
			cs_set_user_bpammo( id, CSW_M4A1, 200);
		}
		case 4:
		{
			give_item(id,"weapon_famas");
			cs_set_user_bpammo( id, CSW_FAMAS, 200);
		}
	}
	
	return PLUGIN_HANDLED;
}
public QueryHandler(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
	switch(FailState)
	{
		case -2: log_amx("[Army Ranks] Failed to connect (%d): %s", Errcode, Error);
		case -1: log_amx("[Army Ranks] (%d): %s", Errcode, Error);
	}
	return PLUGIN_HANDLED
}
aka kurdokoleno
Catch Mod - 87.121.112.232:27021

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: Bing [Bot], Google [Bot] и 49 госта