Заявка за преработка на set admin

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Заключена
Потребителски аватар

Автор на темата
Fatall ЦРУ
Потребител
Потребител
Мнения: 216
Регистриран: 30 авг 2018, 09:35
Местоположение: София
Се отблагодари: 22 пъти
Получена благодарност: 8 пъти
Години: 24
Контакти:

Заявка за преработка на set admin

Мнение от Fatall ЦРУ » 16 яну 2020, 18:21

Може ли на този плъгин да се добави да записва кога съм направил админа (дата и час) да мога да ги следя по лесно кой кога му изтича правата. Благодаря предварително :)

Код: Избери всички

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "SET ADMIN"
#define VERSION "1.1"
#define AUTHOR "author"

#define ADMIN_DUENO ADMIN_RCON

new Array:Admins, g_admin_tipes, user_menu, g_tipe

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_cvar("SETADMIN", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_concmd("amx_setadminmenu", "cmd_set_admin")
	
	load()
}
load()
{
	g_admin_tipes = 0
	Admins = ArrayCreate(64, 1)
	
	new File[120]; get_configsdir(File, charsmax(File))
	add(File, charsmax(File), "/AdminConfig.ini")
	
	if(!file_exists(File))
		set_fail_state("File configs/AdminConfig.ini Not Found")
	
	new Linea[100], open = fopen(File, "rt")
	
	while(!feof(open))
	{
		fgets(open, Linea, charsmax(Linea))
		trim(Linea)
		
		if(!Linea[0] || Linea[0] == ';')
			continue;
			
		ArrayPushString(Admins, Linea)
		g_admin_tipes++
	}
	fclose(open)
}
	
public cmd_set_admin(id)
{
	if(get_user_flags(id) & ADMIN_DUENO)
		show_players_menu(id)
}
show_players_menu(id)
{
	new menu = menu_create("\r[\wHDservers\r] \ySelect Players \w| \yStep: \r[\w1/3\r] \w| \yPage: \r", "handler_players_menu")
	
	new szname[50], num[2], g_max = get_maxplayers()
	
	for(new i = 1; i <= g_max; i++)
	{
		if(!is_user_connected(i) || i == id)
			continue;
			
		get_user_name(i, szname, charsmax(szname))
		if(is_user_admin(i)) add(szname, charsmax(szname), " - \r[ADMIN]")
		
		num[0] = i
		num[1] = 0
		
		menu_additem(menu, szname, num)
	}
	menu_display(id, menu, 0)
}
public handler_players_menu(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED;
	}
	new deal, buffer[2]
	menu_item_getinfo(menu, item, deal, buffer, charsmax(buffer), _, _, deal)
	user_menu =  buffer[0]
	
	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}
	if(is_user_admin(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The ^4selected ^1user is ^3admin^1.")
		return PLUGIN_HANDLED;
	}
		
	show_selec_tipe(id)
	
	return PLUGIN_HANDLED;
}
show_selec_tipe(id)
{
	new menu, len[80], UserMenuName[33]; get_user_name(user_menu, UserMenuName, 32)
	
	formatex(len, charsmax(len), "\r[\wHDservers\r] \yGive Add \r%s \w| \yStep \r[\w2/3\r]", UserMenuName)
	menu = menu_create(len, "handler_selectipe")
	
	menu_additem(menu, "Name", "1")
	menu_additem(menu, "Steam", "2")
	menu_additem(menu, "IP", "3")
	
	menu_display(id, menu, 0)
}
public handler_selectipe(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		show_players_menu(id)
		return PLUGIN_HANDLED;
	}
	
	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}
	
	g_tipe = item
	show_selec_admin(id)
	return PLUGIN_HANDLED;
}	
show_selec_admin(id)
{
	new num[2], menu, len[75], UserMenuName[33]; get_user_name(user_menu, UserMenuName, 32)
	
	formatex(len, charsmax(len), "\r[\wHDservers\r] \yGive Flags \r%s \w| \yStep \r[\w3/3\r]", UserMenuName)
	menu = menu_create(len, "handler_selecadmin")
	
	new Data[100], AdminTipeName[15], AdminFlags[35]
	
	for(new i = 0; i < g_admin_tipes; i++)
	{
		ArrayGetString(Admins, i, Data, charsmax(Data))
		parse(Data, AdminTipeName, charsmax(AdminTipeName), AdminFlags, charsmax(AdminFlags))
		
		formatex(len, charsmax(len), "\w%s - \r[\w%s\r]", AdminTipeName, AdminFlags)
		num_to_str(i, num, 1)
		menu_additem(menu, len, num)
	}
	
	menu_display(id, menu, 0)
}
public handler_selecadmin(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		show_selec_tipe(id)
		return PLUGIN_HANDLED;
	}
	
	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}
	
	new Data[100], AdminTipeName[15], AdminFlags[35]
	
	new Admin[33], NewAdmin[33]
	get_user_name(id, Admin, 32)
	get_user_name(user_menu, NewAdmin, 32)
	
	ArrayGetString(Admins, item, Data, charsmax(Data))
	parse(Data, AdminTipeName, charsmax(AdminTipeName), AdminFlags, charsmax(AdminFlags))
	
	set_user_admin(user_menu, AdminFlags, g_tipe)
	ColorMessage(0, "^4[HDservers] ^1ADMIN [^3%s^1] ^1gave [^4%s^1] on [^3%s^1] Congratulations!", Admin, AdminTipeName, NewAdmin)
	
	return PLUGIN_HANDLED;
}
set_user_admin(target, Flags[], tipo)
{
	new ident[33], pw[5], linne[150]
	formatex(pw, 4, "%d%d%d%d", random_num(1, 9), random_num(1, 9), random_num(1, 9), random_num(1, 9))
	
	new File[120]; get_configsdir(File, charsmax(File))
	add(File, charsmax(File), "/users.ini")
	
	if(!file_exists(File))
		set_fail_state("File configs/users.ini Not Found")
	
	switch(tipo)
	{
		case 0: 
		{
			get_user_name(target, ident, charsmax(ident))
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"%s^" ^"%s^" ^"a^"", ident, pw, Flags)
			
			client_print(target, print_console, "------------------- | HDSERVERS SET ADMINS |-------------------")
			client_print(target, print_console, "[HDservers] You have been kiked because you have been given admin")
			client_print(target, print_console, "[HDservers] Your password|setinfo is: %s", pw)
			client_print(target, print_console, "[HDservers] You should put in your console: setinfo _pw %s", pw)
			client_print(target, print_console, "[HDservers] You have a problem, contact: csserversbg1")
			client_print(target, print_console, "------------------- | by: author |-------------------")
			server_cmd("kick #%d ^"You have been kiked because administrator is given, your password is %s, for more information see their console^"", get_user_userid(target), pw)
		}
		case 1:
		{
			get_user_authid(target, ident, charsmax(ident))
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"^" ^"%s^" ^"ce^"", ident, Flags)
		}
		case 2:
		{
			get_user_ip(target, ident, charsmax(ident), 1)
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"^" ^"%s^" ^"de^"", ident, Flags)
		}
	}
	/*new ident_user[35], Linea[150], open = fopen(File, "rt")
	
	while(!feof(open))
	{
		fgets(open, Linea, charsmax(Linea))
		trim(Linea)
		
		if(!Linea[0] || Linea[0] == ";")
			continue;
			
		parse(Linea, ident_user, charsmax(ident_user))	
		
		if(equal(ident, ident_user))
		{
			ColorMessage(id, "^4[HDservers] ^3%s ^1Already exists!", ident)
			//break;
			return PLUGIN_HANDLED;
		}
	}
	fclose(open)	*/ 
	//the menu is checked if admin
	
	write_file(File, linne)
	server_cmd("amx_reloadadmins")
}

stock ColorMessage(const id, const input[], any:...)
{
   new count = 1, players[32];
   static msg[ 191 ];
   vformat(msg, 190, input, 3);
   if (id) players[0] = id; else get_players(players , count , "ch"); {
   for (new i = 0; i < count; i++){
   if (is_user_connected(players[i])){
   message_begin(MSG_ONE_UNRELIABLE , get_user_msgid("SayText"), _, players[i]);
   write_byte(players[i]);
   write_string(msg);
   message_end();}}}
}

Код: Избери всички

93.123.18.77:27019

Потребителски аватар

OciXCrom TM
Администратор
Администратор
Мнения: 5805
Регистриран: 06 окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 107 пъти
Получена благодарност: 697 пъти
Години: 22
Контакти:

Заявка за преработка на set admin

Мнение от OciXCrom TM » 16 яну 2020, 22:09

Код: Избери всички

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "SET ADMIN"
#define VERSION "1.1"
#define AUTHOR "author"

#define ADMIN_DUENO ADMIN_RCON

new Array:Admins, g_admin_tipes, user_menu, g_tipe

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_cvar("SETADMIN", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
	register_concmd("amx_setadminmenu", "cmd_set_admin")

	load()
}
load()
{
	g_admin_tipes = 0
	Admins = ArrayCreate(64, 1)

	new File[120]; get_configsdir(File, charsmax(File))
	add(File, charsmax(File), "/AdminConfig.ini")

	if(!file_exists(File))
		set_fail_state("File configs/AdminConfig.ini Not Found")

	new Linea[100], open = fopen(File, "rt")

	while(!feof(open))
	{
		fgets(open, Linea, charsmax(Linea))
		trim(Linea)

		if(!Linea[0] || Linea[0] == ';')
			continue;

		ArrayPushString(Admins, Linea)
		g_admin_tipes++
	}
	fclose(open)
}

public cmd_set_admin(id)
{
	if(get_user_flags(id) & ADMIN_DUENO)
		show_players_menu(id)
}
show_players_menu(id)
{
	new menu = menu_create("\r[\wHDservers\r] \ySelect Players \w| \yStep: \r[\w1/3\r] \w| \yPage: \r", "handler_players_menu")

	new szname[50], num[2], g_max = get_maxplayers()

	for(new i = 1; i <= g_max; i++)
	{
		if(!is_user_connected(i) || i == id)
			continue;

		get_user_name(i, szname, charsmax(szname))
		if(is_user_admin(i)) add(szname, charsmax(szname), " - \r[ADMIN]")

		num[0] = i
		num[1] = 0

		menu_additem(menu, szname, num)
	}
	menu_display(id, menu, 0)
}
public handler_players_menu(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED;
	}
	new deal, buffer[2]
	menu_item_getinfo(menu, item, deal, buffer, charsmax(buffer), _, _, deal)
	user_menu =  buffer[0]

	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}
	if(is_user_admin(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The ^4selected ^1user is ^3admin^1.")
		return PLUGIN_HANDLED;
	}

	show_selec_tipe(id)

	return PLUGIN_HANDLED;
}
show_selec_tipe(id)
{
	new menu, len[80], UserMenuName[33]; get_user_name(user_menu, UserMenuName, 32)

	formatex(len, charsmax(len), "\r[\wHDservers\r] \yGive Add \r%s \w| \yStep \r[\w2/3\r]", UserMenuName)
	menu = menu_create(len, "handler_selectipe")

	menu_additem(menu, "Name", "1")
	menu_additem(menu, "Steam", "2")
	menu_additem(menu, "IP", "3")

	menu_display(id, menu, 0)
}
public handler_selectipe(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		show_players_menu(id)
		return PLUGIN_HANDLED;
	}

	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}

	g_tipe = item
	show_selec_admin(id)
	return PLUGIN_HANDLED;
}
show_selec_admin(id)
{
	new num[2], menu, len[75], UserMenuName[33]; get_user_name(user_menu, UserMenuName, 32)

	formatex(len, charsmax(len), "\r[\wHDservers\r] \yGive Flags \r%s \w| \yStep \r[\w3/3\r]", UserMenuName)
	menu = menu_create(len, "handler_selecadmin")

	new Data[100], AdminTipeName[15], AdminFlags[35]

	for(new i = 0; i < g_admin_tipes; i++)
	{
		ArrayGetString(Admins, i, Data, charsmax(Data))
		parse(Data, AdminTipeName, charsmax(AdminTipeName), AdminFlags, charsmax(AdminFlags))

		formatex(len, charsmax(len), "\w%s - \r[\w%s\r]", AdminTipeName, AdminFlags)
		num_to_str(i, num, 1)
		menu_additem(menu, len, num)
	}

	menu_display(id, menu, 0)
}
public handler_selecadmin(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		show_selec_tipe(id)
		return PLUGIN_HANDLED;
	}

	if(!is_user_connected(user_menu))
	{
		ColorMessage(id, "^4[HDservers] ^1The selected user is ^3disconnected ^1from the menu.")
		return PLUGIN_HANDLED;
	}

	new Data[100], AdminTipeName[15], AdminFlags[35]

	new Admin[33], NewAdmin[33]
	get_user_name(id, Admin, 32)
	get_user_name(user_menu, NewAdmin, 32)

	ArrayGetString(Admins, item, Data, charsmax(Data))
	parse(Data, AdminTipeName, charsmax(AdminTipeName), AdminFlags, charsmax(AdminFlags))

	set_user_admin(user_menu, AdminFlags, g_tipe)
	ColorMessage(0, "^4[HDservers] ^1ADMIN [^3%s^1] ^1gave [^4%s^1] on [^3%s^1] Congratulations!", Admin, AdminTipeName, NewAdmin)

	return PLUGIN_HANDLED;
}
set_user_admin(target, Flags[], tipo)
{
	new ident[33], pw[5], linne[150]
	formatex(pw, 4, "%d%d%d%d", random_num(1, 9), random_num(1, 9), random_num(1, 9), random_num(1, 9))

	new File[120]; get_configsdir(File, charsmax(File))
	add(File, charsmax(File), "/users.ini")

	if(!file_exists(File))
		set_fail_state("File configs/users.ini Not Found")

	new szTime[32]
	get_time("%d.%m.%Y - %H:%M", szTime, charsmax(szTime))

	switch(tipo)
	{
		case 0:
		{
			get_user_name(target, ident, charsmax(ident))
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"%s^" ^"%s^" ^"a^" ^"%s^"", ident, pw, Flags, szTime)

			client_print(target, print_console, "------------------- | HDSERVERS SET ADMINS |-------------------")
			client_print(target, print_console, "[HDservers] You have been kiked because you have been given admin")
			client_print(target, print_console, "[HDservers] Your password|setinfo is: %s", pw)
			client_print(target, print_console, "[HDservers] You should put in your console: setinfo _pw %s", pw)
			client_print(target, print_console, "[HDservers] You have a problem, contact: csserversbg1")
			client_print(target, print_console, "------------------- | by: author |-------------------")
			server_cmd("kick #%d ^"You have been kiked because administrator is given, your password is %s, for more information see their console^"", get_user_userid(target), pw)
		}
		case 1:
		{
			get_user_authid(target, ident, charsmax(ident))
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"^" ^"%s^" ^"ce^" ^"%s^"", ident, Flags, szTime)
		}
		case 2:
		{
			get_user_ip(target, ident, charsmax(ident), 1)
			formatex(linne, charsmax(linne), "^r^n^"%s^" ^"^" ^"%s^" ^"de^" ^"%s^"", ident, Flags, szTime)
		}
	}
	/*new ident_user[35], Linea[150], open = fopen(File, "rt")

	while(!feof(open))
	{
		fgets(open, Linea, charsmax(Linea))
		trim(Linea)

		if(!Linea[0] || Linea[0] == ";")
			continue;

		parse(Linea, ident_user, charsmax(ident_user))

		if(equal(ident, ident_user))
		{
			ColorMessage(id, "^4[HDservers] ^3%s ^1Already exists!", ident)
			//break;
			return PLUGIN_HANDLED;
		}
	}
	fclose(open)	*/
	//the menu is checked if admin

	write_file(File, linne)
	server_cmd("amx_reloadadmins")
}

stock ColorMessage(const id, const input[], any:...)
{
   new count = 1, players[32];
   static msg[ 191 ];
   vformat(msg, 190, input, 3);
   if (id) players[0] = id; else get_players(players , count , "ch"); {
   for (new i = 0; i < count; i++){
   if (is_user_connected(players[i])){
   message_begin(MSG_ONE_UNRELIABLE , get_user_msgid("SayText"), _, players[i]);
   write_byte(players[i]);
   write_string(msg);
   message_end();}}}
}
PS: client_print(target, print_console, "[HDservers] You have a problem, contact: csserversbg1")

Преведено на български: "Имаш проблем, свържи се: ..."
И в английския език има дума "ако".

Потребителски аватар

Автор на темата
Fatall ЦРУ
Потребител
Потребител
Мнения: 216
Регистриран: 30 авг 2018, 09:35
Местоположение: София
Се отблагодари: 22 пъти
Получена благодарност: 8 пъти
Години: 24
Контакти:

Заявка за преработка на set admin

Мнение от Fatall ЦРУ » 16 яну 2020, 22:31

:lock:

Код: Избери всички

93.123.18.77:27019

Заключена

Върни се в “Заявки за плъгини”

Кой е на линия

Потребители, разглеждащи този форум: Няма регистрирани потребители и 0 госта