Raised This Month: $51 Target: $400
 12% 

[ANY] Change your name ( sm_name )


Post New Thread Reply   
 
Thread Tools Display Modes
Author
eyal282
Veteran Member
Join Date: Aug 2011
Plugin ID:
6157
Plugin Version:
1.1
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    11 
    Plugin Description:
    Allows you to change your name with a chat command.
    Old 06-09-2018 , 11:05   [ANY] Change your name ( sm_name )
    Reply With Quote #1

    NOTE: The plugin will malfunction on ANY game that doesn't enforce the console command "name" to be equal to your steam name ( Works in CS:GO and L4D2 ). Doesn't break the plugin though.

    Commands:

    !name <new name> - Changes your name to the name you write after !name. For example: "!name Epic Guy" will change your name to Epic Guy. If you only write !name without anything after your name will change to your steam name.

    !oname <name/#userid> - Finds a target's steam name.

    setinfo secretname "New Name" - Next time you connect to the server, your name will be "New Name". This console command works on any server and even if you aren't inside a server.

    Bugs:

    Cheaters can give a wrong name on !oname. If a player sends a wrong name on !oname, he'll likely be VAC banned for doing so.
    Attached Files
    File Type: sp Get Plugin or Get Source (sm_name.sp - 1208 views - 3.8 KB)
    __________________
    I am available to make plugins for pay.

    Discord: Eyal282#1334

    Last edited by eyal282; 01-26-2019 at 16:13.
    eyal282 is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 06-09-2018 , 11:40   Re: [ANY] Change your name
    Reply With Quote #2

    Nice, but might wanna check out the new syntax since it's becoming more current.
    mug1wara is offline
    eyal282
    Veteran Member
    Join Date: Aug 2011
    Old 06-09-2018 , 12:28   Re: [ANY] Change your name
    Reply With Quote #3

    Quote:
    Originally Posted by mug1wara View Post
    Nice, but might wanna check out the new syntax since it's becoming more current.
    I'm from AmxModX so I'm keeping my syntax and I know both if I need to edit a code.
    __________________
    I am available to make plugins for pay.

    Discord: Eyal282#1334
    eyal282 is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 06-09-2018 , 12:47   Re: [ANY] Change your name
    Reply With Quote #4

    That's fine ^_^
    mug1wara is offline
    speedvoltage
    Junior Member
    Join Date: Jul 2017
    Old 06-09-2018 , 13:35   Re: [ANY] Change your name
    Reply With Quote #5

    I went ahead and edited the plugin to have the new style declarations (sorry for the leftover of the old code):
    Code:
    /**************************************************************************************************************************************************************
    **************************************************************************************************************************************************************
    ******************************************************************!AND HERE BEGINS A DREAM!*******************************************************************
    **************************************************************************************************************************************************************
    **************************************************************************************************************************************************************
    **************************************************************************************************************************************************************/
    
    /******************************
    INCLUDE ALL THE NECESSARY FILES
    ******************************/
    
    #include <sourcemod>
    #include <sdktools>
    
    /******************************
    COMPILE OPTIONS
    ******************************/
    
    #pragma semicolon 1
    #pragma newdecls required
    
    /******************************
    PLUGIN DEFINES
    ******************************/
    
    /*Plugin Info*/
    #define PLUGIN_NAME								"Set My Name"
    #define PLUGIN_AUTHOR							"Eyal282 ( FuckTheSchool ) [Modified by Peter Brev with new style declarations]"
    #define PLUGIN_VERSION							"1.1.0.0"
    #define PLUGIN_DESCRIPTION						"Allows players to use a new name"
    #define PLUGIN_URL								"https://forums.alliedmods.net/showthread.php?t=308179"
    
    /*Plugin defines for messages*/
    #define TAG									"[NAME]"
    #define TAG_COLOR 							"\x07cc3300"
    #define COLOR_AZURE 							"\x0700ace6"
    #define COLOR_LIME 							"\x073ff206"
    #define COLOR_PLAYER							"\x07daaf0c"
    #define COLOR_ERROR							"\x07ff0000"
    
    /******************************
    PLUGIN INFO BASED ON PREVIOUS DEFINES
    ******************************/
    
    public Plugin myinfo =
    {
    	name = PLUGIN_NAME,
    	author = PLUGIN_AUTHOR,
    	description = PLUGIN_DESCRIPTION,
    	version = PLUGIN_VERSION,
    	url = PLUGIN_URL,
    };
    
    /******************************
    INITIATE THE PLUGIN
    ******************************/
    public void OnPluginStart()
    {	
    	//We want to hook player_changename in order to block the default message from showing
    	
    	HookEvent("player_changename", namechange_callback, EventHookMode_Pre);
    
    	/***COMMANDS SETUP***/
    	
    	//Create a convar for plugin version
    	
    	CreateConVar("sm_name_version", PLUGIN_VERSION, "Plugin Version", FCVAR_NOTIFY|FCVAR_SPONLY);
    	
    	//Create the public command
    	
    	RegConsoleCmd("sm_name", Command_Name, "sm_name <new name>");
    	RegConsoleCmd("sm_oname", Command_Oname, "sm_oname <#userid|name> - Find the original Steam name of a player");
    	
    	//Are we done here? Can we move to coding the real thing?
    }
    
    /******************************
    PUBLIC CALLBACKS
    ******************************/
    
    public Action namechange_callback(Event event, const char[] name, bool dontBroadcast)
    {
    	SetEventBroadcast(event, true);
    	return Plugin_Continue;
    }
    
    public void OnClientAuthorized(int client)
    {
    	char pname[50];
    	
    	if (!GetClientInfo(client, "secretname", pname, sizeof(pname)))
    		return;
    	
    	if (pname[0] == EOS)
    	return;
    	
    	for (int i=0; i <= MaxClients; i++)
    	{
    		if (!IsClientInGame(i))
    			continue;
    		
    		else if (IsFakeClient(i))
    			continue;
    			
    		else if(!CheckCommandAccess(i, "sm_kick", ADMFLAG_KICK))
    			continue;
    			
    		PrintToServer("Client %N has joined with the name %s.", client, pname);
    	}
    	
    	SetClientInfo(client, "name", pname);
    }
    
    public Action Command_Name(int client, int args)
    {
    	if (args < 1)
    	{
    		ReplyToCommand(client, "%s%s %sUsage: %ssm_name <new name>", TAG_COLOR, TAG, COLOR_AZURE, COLOR_LIME);
    		return Plugin_Handled;
    	}
    	char NewName[MAX_NAME_LENGTH];
    	GetCmdArgString(NewName, sizeof(NewName));
    	
    	Handle DP = CreateDataPack();
    	
    	RequestFrame(TwoTotalFrames, DP);
    	
    	WritePackCell(DP, GetClientUserId(client));
    	WritePackString(DP, NewName);
    	
    	return Plugin_Handled;
    }
    
    public void TwoTotalFrames(Handle DP)
    {
    	RequestFrame(ChangeName, DP);
    }
    public void ChangeName(Handle DP)
    {
    	ResetPack(DP);
    	
    	int client = GetClientOfUserId(ReadPackCell(DP));
    	
    	if (client <= 0 || client > MaxClients)
    		return;
    		
    	else if(!IsClientInGame(client))
    		return;	
    	
    	char NewName[MAX_NAME_LENGTH];
    	ReadPackString(DP, NewName, sizeof(NewName));
    	
    	CloseHandle(DP);
    	
    	SetClientInfo(client, "name", NewName);
    	PrintToChatAll("%s%s %s%N %shas changed their name to %s%s.", TAG_COLOR, TAG, COLOR_PLAYER, client, COLOR_AZURE, COLOR_PLAYER, NewName);
    }
    
    public Action Command_Oname(int client, int args)
    {
    	char targetarg[MAX_NAME_LENGTH];
    	GetCmdArgString(targetarg, sizeof(targetarg));
    	
    	char target_name[MAX_TARGET_LENGTH];
    	int target_list[MAXPLAYERS], target_count;
    	bool tn_is_ml;
    	
    	int targetclient;
    	
    	if ((target_count = ProcessTargetString(
    			targetarg,
    			client,
    			target_list,
    			MAXPLAYERS,
    			COMMAND_FILTER_NO_MULTI,
    			target_name,
    			sizeof(target_name),
    			tn_is_ml)) > 0)
    	{		
    		for (int i = 0; i < target_count; i++)
    		{
    			targetclient = target_list[i];
    						
    			QueryClientConVar(targetclient, "name", OnSteamNameQueried, GetClientUserId(client));	
    		}
    	}
    	else
    	{
    		ReplyToTargetError(client, target_count);
    	}
    	return Plugin_Handled;
    }
    
    public void OnSteamNameQueried(QueryCookie cookie, int targetclient, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any UserId)
    {
    	int client = GetClientOfUserId(UserId);
    	if (result != ConVarQuery_Okay)
    	{
    		PrintToChat(client, "%s%s %sError: Couldn't retrieve %s%N%s's Steam name.", TAG_COLOR, TAG, COLOR_ERROR, COLOR_PLAYER, targetclient, COLOR_ERROR);
    		return;
    	}	
    	
    	if (client <= 0 || client > MaxClients)
    		return;
    		
    	else if (!IsClientInGame(client))
    		return;
    	
    	PrintToChat(client, "%s%s %s%N%s's Steam name is %s%s.", TAG_COLOR, TAG, COLOR_PLAYER, targetclient, COLOR_AZURE, COLOR_PLAYER, cvarValue);
    }
    
    /**************************************************************************************************************************************************************
    **************************************************************************************************************************************************************
    **************************************************************************************************************************************************************
    *****************************************************************!AND THE DREAM ENDS HERE!********************************************************************
    **************************************************************************************************************************************************************
    **************************************************************************************************************************************************************
    **************************************************************************************************************************************************************/

    Last edited by speedvoltage; 06-09-2018 at 14:10.
    speedvoltage is offline
    Zyten
    Senior Member
    Join Date: Jan 2018
    Old 06-09-2018 , 14:40   Re: [ANY] Change your name
    Reply With Quote #6

    https://forums.alliedmods.net/showthread.php?t=307637

    whats the diffrence?
    Zyten is offline
    eyal282
    Veteran Member
    Join Date: Aug 2011
    Old 06-09-2018 , 15:23   Re: [ANY] Change your name
    Reply With Quote #7

    Quote:
    Originally Posted by Zyten View Post
    1. Less colors therefore no need to waste time for includes.

    2. His !oname is capable of being false if you change your steam name while playing since it saves the steam name on login, and even then setinfo name "New Name" can fool his plugin. Mine uses a smarter method.

    3. setinfo secretname "New Name" which allows you to bypass any connect announce but ONLY if connect announce appears on "OnClientAuthorized" where it always should anyways.
    __________________
    I am available to make plugins for pay.

    Discord: Eyal282#1334
    eyal282 is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 06-09-2018 , 16:13   Re: [ANY] Change your name
    Reply With Quote #8

    Simple but useful. Thanks for this.
    __________________
    Psyk0tik is offline
    DarkDeviL
    SourceMod Moderator
    Join Date: Apr 2012
    Old 06-09-2018 , 16:24   Re: [ANY] Change your name
    Reply With Quote #9

    As posted in your thread Get steam name:

    Quote:
    Originally Posted by arne1288 View Post
    Quote:
    Originally Posted by eyal282 View Post
    Quote:
    Originally Posted by arne1288 View Post
    You can call the Steam API using some HTTP framework, e.g. SteamWorks.
    Too much work... Is there a way to hook setinfo command? The only way to change your name is setinfo and steam name change. Oh, the console variable name cannot be changed, and is always equal to your steam name.
    Not sure if that "name" always 100% identical to the Steam name though.

    But the "name" command comes from the client, and as such, I wouldn't trust it blindly.

    Just like there are some cheats that allows you to set r_drawothermodels (walhack) even if sv_cheats is 0, you can most likely use the same sort of cheats to fool your server into believing that the faked "name" is the real one.

    Too much work? It's maybe a little bit more with the HTTP calls, but isn't it worth it doing it that way, if you get a 100% accurate response, rather than having a 50-50 chance of some fake value?
    "Safety" before "cutting corners" would be my personal call.
    __________________
    Mostly known as "DarkDeviL".

    Dropbox FastDL: Public folder will no longer work after March 15, 2017!
    For more info, see the [SRCDS Thread], or the [HLDS Thread].
    DarkDeviL is offline
    eyal282
    Veteran Member
    Join Date: Aug 2011
    Old 06-09-2018 , 16:43   Re: [ANY] Change your name
    Reply With Quote #10

    Quote:
    Originally Posted by arne1288 View Post
    As posted in your thread Get steam name:



    "Safety" before "cutting corners" would be my personal call.
    Yeah, I'll just get me enough games to confirm it is impossible to change "name" and that it always automatically changes back to your steam name. Also sometimes the API might break ( it happens on Discord ) so it MAY be safer ( maybe steam API never breaks )

    If someone is willing to get himself VAC banned to bypass the !oname, I'll list it as a bug LMAO.
    __________________
    I am available to make plugins for pay.

    Discord: Eyal282#1334

    Last edited by eyal282; 01-26-2019 at 16:12.
    eyal282 is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 22:43.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode