[ Plugins ] - Name Replacer - Plugins - GAMELIFE România Jump to content

Recommended Posts

  • Administrators
Posted

Name Replacer


Plugin details:
- this is a small but usefull plugin.
- you can restrict names from a file and give them a replacer.
- if a player enters on the server/change the name in a restricted name, the player's name will be changed.
- you need amxx 1.7 or higher.

Credit: Alka

Usage:
- add in amxmodx/configs/name_list.txt :

Code:

name;replacer name2;replacer2 name3;replacer3

- example:

 

Code:

mut2nt;reserved

if a player enters on the server/change the name in 'mut2nt', it will be changed it 'reserved'.

PHP Code:

#define NAMES        32 // max lines in the file
#define DELAY        10.0 // after how many seconds the name is checked after the player enters
#define ACCESS        ADMIN_IMMUNITY // acces needed to have immunity to name checking

new const g_File[] =     "name_list.txt"; // file name 


Cvars:
namereplacer_mode 0/1/2/3

0 - disabled

1 - name change

2 - kick

3 - ban

(default 1)

namereplacer_list 0/1

0 - the name will be changed to the last name the player has used

1 - the name will be changed from file

(default 1 )

For instance:
- if the cvar is set to 0: if a player has the name 'x' and change it to 'y' (y is restricted from file), his name will be set to 'x'
- if the cvar is set to 1: if a player has the name 'x' and change it to 'y' (y is restricted from file), his name will be set to x-1 (x-1 is replacer to x from file)

namereplacer_banlenght - ban lenght (default 1200)
namereplacer_evoyadmins - allow admins to have a restricted name from file (default 0)


 

Donator: SteamDB

Donator: SteamLadder

Steam Level Up: https://slvlup.com/r/krrna6

Steam™ Hour Boosting!: https://freehourboost.com/?r=cosminzm

3177671.png

  • 1 year later...
  • Administrators
Posted

Blog personal : https://www.facebook.com/jurnalulunuivisator/

Canal youtube : https://www.youtube.com/gabytzuspecial

Grup muzica : https://www.facebook.com/groups/muzica2025

 

FQ9snHC.gif

  • Administrators
Posted
On 4/11/2025 at 6:22 PM, Skillnet Gaming said:

hello, can you increase #define NAMES 32 // max lines in the file
at 2000

 

Take the source!

/*	
	/////////////////////////////////////
       ///////// NAME REPLACER ////////
      /////////////////////////////////////
	
	http://forums.alliedmods.net/showthread.php?t=77401
	
	
	(c) Copyright 2008, anakin_cstrike
	This file is provided as is (no warranties). 
	
	--| Version |-- 1.1.0
	
	Changelog:
		* [ 1.1.0 ]
			- added cvars
			- 3 options: name change, kick or ban
			- you can choose the way the name is changed: from list or the last name the player used
			- admins can have immunity
			
		* [ 1.0 ]
			- first released
*/

#include <amxmodx>
#include <amxmisc>

new PLUGIN[] =		"Name Replacer"
#define VERSION 	"1.1.0"

// * editable
#define NAMES		32
#define DELAY		10.0
#define ACCESS		ADMIN_IMMUNITY

new const g_File[] = 	"name_list.txt";
// *

new g_NameList[ 2 ][ NAMES ][ 32 ], g_Count;
new toggle_plugin, toggle_ban, toggle_list, toggle_evoy;

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, "anakin_cstrike" );
	
	toggle_plugin = register_cvar( "namereplacer_mode", "1" );
	toggle_list = register_cvar( "namereplacer_list", "1" );
	toggle_ban = register_cvar( "namereplacer_banlenght", "1200" );
	toggle_evoy = register_cvar( "namereplacer_evoyadmins", "0" );
}

public plugin_cfg()
{
	new iDir[ 64 ], iFile[ 64 ];
	get_configsdir( iDir, sizeof iDir - 1 );
	formatex( iFile, sizeof iFile - 1, "%s/%s", iDir, g_File );
	
	if( !file_exists( iFile ) )
		write_file( iFile, "[Name Replacer]", -1 );
		
	new szFile = fopen( iFile, "rt" ), Buffer[ 512 ];
	
	while( !feof( szFile ) )
	{
		fgets( szFile, Buffer,sizeof Buffer - 1 );
		if( !Buffer[ 0 ] || Buffer[ 0 ] == ';' || strlen( Buffer ) < 3 )
			continue;
		
		trim( Buffer );
		strtok( Buffer, g_NameList[ 0 ][ g_Count ], sizeof g_NameList[ ][ ] - 1, g_NameList[ 1 ][ g_Count ], sizeof g_NameList[ ][ ] - 1, ';', 0 );
		
		g_Count++;
	}
	
	fclose( szFile );
}

public client_putinserver( id )
{
	if( !get_pcvar_num( toggle_plugin ) )
		return PLUGIN_CONTINUE;
	
	set_task( DELAY, "verify", id );
	return PLUGIN_CONTINUE;
}

public verify( id )
{
	if( !is_user_connected( id ) )
		return PLUGIN_CONTINUE;
	if( get_pcvar_num( toggle_evoy ) && IsAdmin( id ) )
		return PLUGIN_CONTINUE;
		
	new name[ 32 ], i;
	get_user_name( id, name, sizeof name - 1 );
	
	new userid = get_user_userid( id );
	
	for( i = 0; i < g_Count; i++ )
	{
		if( equali( name, g_NameList[ 0 ][ i ] ) )
		{
			switch( get_pcvar_num( toggle_plugin ) )
			{
				case 1:
				{
					client_print( id, print_chat, "That name is not allowed here! Changing name to ^"%s^"",g_NameList[ 1 ][ i ] );
					client_cmd( id, "name ^"%s^"", g_NameList[ 1 ][ i ]);
				}
				
				case 2: server_cmd( "kick #%d ^"Name forbidden!^"", userid );
				
				case 3:
				{
					new authid[ 32 ];
					get_user_authid( id, authid, sizeof authid - 1 );
					server_cmd( "amx_ban ^"%s^" %d ^"Name forbidden!^"", authid, get_pcvar_num( toggle_ban ) );
				}
			}
		}
	}
	
	return PLUGIN_CONTINUE;
}

public client_infochanged( id )
{
	if( !get_pcvar_num( toggle_plugin ) )
		return PLUGIN_CONTINUE;
		
	if( get_pcvar_num( toggle_evoy ) && IsAdmin( id ) )
		return PLUGIN_CONTINUE;
		
	new newname[ 32 ], oldname[ 32 ], i;
	get_user_info( id, "name", newname, sizeof newname - 1 );
	get_user_name( id, oldname, sizeof oldname - 1 );
	
	if( equali( newname, oldname ) )
		return PLUGIN_CONTINUE;
		
	new userid = get_user_userid( id );
	
	for( i = 0; i < g_Count; i++ )
	{
		if( equali( newname, g_NameList[ 0 ][ i ] ) )
		{
			switch( get_pcvar_num( toggle_plugin ) )
			{
				case 1:
				{
					switch( get_pcvar_num( toggle_list ) )
					{
						case 0:
						{
							client_print( id, print_chat, "That name is not allowed here! Changing name to ^"%s^"", oldname );
							client_cmd( id, "name ^"%s^"", oldname );
						}
						
						case 1:
						{
							client_print( id, print_chat, "That name is not allowed here! Changing name to ^"%s^"", g_NameList[ 1 ][ i ] );
							client_cmd( id, "name ^"%s^"", g_NameList[ 1 ][ i ] );
						}
					}
				}
				
				case 2: server_cmd( "kick #%d ^"Name forbidden!^"", userid );
				
				case 3:
				{
					new authid[ 32 ];
					get_user_authid( id, authid, sizeof authid - 1 );
					server_cmd( "amx_ban ^"%s^" %d ^"Name forbidden!^"", authid, get_pcvar_num( toggle_ban ) );
				}
			}
				
			return PLUGIN_HANDLED;
		}
	}
	
	return PLUGIN_CONTINUE;
}

bool: IsAdmin( index )
{
	if( ! ( get_user_flags( index ) & ACCESS ) )
		return true;
		
	return false;
}

 

Donator: SteamDB

Donator: SteamLadder

Steam Level Up: https://slvlup.com/r/krrna6

Steam™ Hour Boosting!: https://freehourboost.com/?r=cosminzm

3177671.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...

Important Information