Thread: sm_rename
View Single Post
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-26-2012 , 15:41   Re: sm_rename
Reply With Quote #4

There is a stock provided by GoD-Tony you could implement into a new plugin that works - at least until the map is changed (unless you use another method to actively change the name back to what you want it after map change).

the sm_rename command shipped in SM doesn't work for CS:S - the game just changes the name right back to what the user had - but with the stock mentioned above, you could psuedo'ly change the players name.

Here you go - here's the include GoD-Tony provided:

PHP Code:
/**
 * Changes a clients name
 *
 * @param client        A client index.
 * @param name        Set to false to skip the IsClientConnected check
 * @param silent        Set to true to not broadcast the name change
 * @noreturn
 */
stock CS_SetClientName(client, const String:name[], bool:silent=false)
{
    
decl String:oldname[MAX_NAME_LENGTH];
    
GetClientName(clientoldnamesizeof(oldname));

    
SetClientInfo(client"name"name);
    
SetEntPropString(clientProp_Data"m_szNetname"name);

    new 
Handle:event CreateEvent("player_changename");

    if (
event != INVALID_HANDLE)
    {
        
SetEventInt(event"userid"GetClientUserId(client));
        
SetEventString(event"oldname"oldname);
        
SetEventString(event"newname"name);
        
FireEvent(event);
    }

    if (
silent)
        return;
    
    new 
Handle:msg StartMessageAll("SayText2");

    if (
msg != INVALID_HANDLE)
    {
        
BfWriteByte(msgclient);
        
BfWriteByte(msgtrue);
        
BfWriteString(msg"Cstrike_Name_Change");
        
BfWriteString(msgoldname);
        
BfWriteString(msgname);
        
EndMessage();
    }

__________________
View my Plugins | Donate

Last edited by TnTSCS; 04-26-2012 at 15:43.
TnTSCS is offline