Page 1 of 1

[Plugin] advanced_spam_nick

Posted: Thu Dec 26, 2024 10:22 am
by DarkAngel
  • Nume plugin: advanced_spam_nick
    Descriere plugin: Acest plugin schimba numele la jucatori din reclame in nume alese de voi in lista player_names.ini
    Descarcare: Log in or register to see all links !
    Instalare: ca orice alt plugin
    Cvars: Nu are
    Imagini: nu am pus

Re: [Plugin] advanced_spam_nick

Posted: Fri Dec 27, 2024 1:28 pm
by h4x0r_l33t_
DarkAngel wrote: Thu Dec 26, 2024 10:22 am
  • Nume plugin: advanced_spam_nick
    Descriere plugin: Acest plugin schimba numele la jucatori din reclame in nume alese de voi in lista player_names.ini
    Descarcare: Log in or register to see all links !
    Instalare: ca orice alt plugin
    Cvars: Nu are
    Imagini: nu am pus

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Advanced Spam Nick Changer"
#define VERSION "1.0"
#define AUTHOR "Fullserver"

new g_CvarImmun;

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	RegisterHam(Ham_Spawn, "player", "player_spawn", 1);
	g_CvarImmun = register_cvar("nick_admin", "1");
	register_clcmd("nicknames_menu", "nicknames_menu");
}

public player_spawn(id)
{
	if (!is_user_alive(id))
		return PLUGIN_CONTINUE;

	cmdNick2(id);
	return PLUGIN_CONTINUE;
}

public admin_change(id)
{
	if (get_pcvar_num(g_CvarImmun) && (get_user_flags(id) & ADMIN_IMMUNITY))
		return PLUGIN_CONTINUE;

	new nick[32];
	get_user_name(id, nick, sizeof(nick) - 1);

	new line2, text2[64], txtlen2, string_num;
	string_num = file_size("addons/amxmodx/configs/player_names.ini", 1);

	do
	{
		line2 = random_num(1, string_num);
		read_file("addons/amxmodx/configs/player_names.ini", line2, text2, sizeof(text2) - 1, txtlen2);
	} while (text2[0] == ';' || equali(text2, ""));

	set_user_info(id, "name", text2);

	new player_ip[23], player_authid[37];
	get_user_ip(id, player_ip, sizeof(player_ip) - 1, 1);
	get_user_authid(id, player_authid, sizeof(player_authid) - 1);
	log_to_file("advanced_spam_nick.log", "Changed nickname for player %s to %s [IP: %s | STEAM_ID: %s]", nick, text2, player_ip, player_authid);

	return PLUGIN_HANDLED;
}


public change_it(id)
{
	new line, text[64], txtlen, nick[32];
	get_user_name(id, nick, sizeof(nick) - 1);

	while ((line = read_file("addons/amxmodx/configs/bad_names.ini", line, text, sizeof(text) - 1, txtlen)) != 0)
	{
		if (containi(nick, text) != -1)
		{
			new line2, text2[64], txtlen2, string_num;
			string_num = file_size("addons/amxmodx/configs/player_names.ini", 1);

			do
			{
				line2 = random_num(1, string_num);
				read_file("addons/amxmodx/configs/player_names.ini", line2, text2, sizeof(text2) - 1, txtlen2);
			} while (text2[0] == ';' || equali(text2, ""));

			set_user_info(id, "name", text2);

			new player_ip[23], player_authid[37];
			get_user_ip(id, player_ip, sizeof(player_ip) - 1, 1);
			get_user_authid(id, player_authid, sizeof(player_authid) - 1);
			log_to_file("advanced_spam_nick.log", "Changed nickname for player %s to %s [IP: %s | STEAM_ID: %s]", nick, text2, player_ip, player_authid);

			return PLUGIN_HANDLED;
		}
	}

	return PLUGIN_HANDLED;
}

public cmdNick2(id)
{
	if (get_pcvar_num(g_CvarImmun) && (get_user_flags(id) & ADMIN_IMMUNITY))
		return PLUGIN_CONTINUE;

	set_task(1.0, "change_it", id);
	return PLUGIN_CONTINUE;
}

public client_infochanged(id)
{
	if (!is_user_alive(id))
		return PLUGIN_CONTINUE;

	cmdNick2(id);
	return PLUGIN_CONTINUE;
}

public nicknames_menu( id )
{
	//Create a variable to hold the menu
	new menu = menu_create( "\rSet random nickname:", "menu_handler" );

	//We will need to create some variables so we can loop through all the players
	new players[32], pnum, tempid;

	//Some variables to hold information about the players
	new szName[32], szUserId[32];

	//Fill players with available players
	get_players( players, pnum ); // flag "a" because we are going to add health to players, but this is just for this specific case

	//Start looping through all players
	for ( new i; i<pnum; i++ )
	{
		//Save a tempid so we do not re-index
		tempid = players[i];

		//Get the players name and userid as strings
		get_user_name( tempid, szName, charsmax( szName ) );
		//We will use the data parameter to send the userid, so we can identify which player was selected in the handler
		formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );

		//Add the item for this player
		menu_additem( menu, szName, szUserId, 0 );
	}

	//We now have all players in the menu, lets display the menu
	menu_display( id, menu, 0 );
}

public menu_handler( id, menu, item )
{
	//Do a check to see if they exited because menu_item_getinfo ( see below ) will give an error if the item is MENU_EXIT
	if ( item == MENU_EXIT )
	{
		menu_destroy( menu );
		return PLUGIN_HANDLED;
	}

	//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
	new szData[6], szName[64];
	new _access, item_callback;
	//heres the function that will give us that information ( since it doesnt magicaly appear )
	menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );

	//Get the userid of the player that was selected
	new userid = str_to_num( szData );

	//Try to retrieve player index from its userid
	new player = find_player( "k", userid ); // flag "k" : find player from userid
	
	admin_change(player);

	menu_destroy( menu );
	return PLUGIN_HANDLED;
}
Si are cvar-uri : nick_admin 0/1

P.S. Daca postezi plugin-uri, incearca sa postezi plugin-uri, relevante si care folosesc.