UE2 - UT2kX Name change help

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

forrestmark9

New Member
Aug 6, 2009
56
0
0
I made some code that uses a system in a KF mod called ScrnBalance that allows people to add color codes to there names currently with my system I had to work it around to only allow certain people to do so. Sadly though currently people can do things such as change there names to someone elses and overall steal someone elses name and cause havoc without me knowing who is who in the logs

So far I only know that I'd need to loop through all the current PRIs and check if someones name is the same as someone else then forbid the name change.

Sadly I do not know how to do this, and there's still the problem if the person changes his name to someones after they leave or if the said person is not there. If possible could maybe set it so everytime a player leaves save a array of joined PRIs and then loop through those plus the players currently in the server

Here is the code I did for the function

Code:
var() globalconfig string AltPlayerName;
var int NameChangeCoolDown,NameChanged;
var bool bNameCoolDown;

replication
{
    //TODO: Is this even needed? Function is called from the server function InitVIPinfo but is called by the client from SetName
    reliable if( Role == ROLE_Authority )
        SetupPlayerName;
        
    unreliable if( Role<ROLE_Authority )
        BroadcastMessage;
}

exec function SetName(coerce string S) 
{
    local ForrestPRI FPlayerRepInfo;
    local string OldName, NewName, Gender;
    
    if( PlayerReplicationInfo == none )
        return;
        
    FPlayerRepInfo = ForrestPRI(PlayerReplicationInfo);
    
    if( !FPlayerRepInfo.bSuperVIP )
        return;
        
    if( NameChanged > 4 && !bNameCoolDown )
    {
        bNameCoolDown = true;
        NameChangeCoolDown = Level.TimeSeconds;
    }
    
    if( bNameCoolDown )
    {
        ClientMessage("Name changed too many times, please wait 10 seconds");
        return;
    }
        
    if( S == "" )
    {
        AltPlayerName = S;
        SetupPlayerName(FPlayerRepInfo);
        SaveConfig();
        return;
    }   
    
    if( FPlayerRepInfo.AltPlayerName == "" )
        OldName = PlayerReplicationInfo.PlayerName;
    else
        OldName = FPlayerRepInfo.AltPlayerName;
        
    NewName = S;
    
    ReplaceText(NewName, " ", "_");
    ReplaceText(NewName, "\"", "");
    
    Gender = eval(PlayerReplicationInfo.bIsFemale, "her", "his");

    if( FPlayerRepInfo.bSuperVIP && NewName != "")
    {
        AltPlayerName = NewName;
        SetupPlayerName(FPlayerRepInfo);
        SaveConfig();
        
        if( Mut.StripColorTags(NewName) == Mut.StripColorTags(OldName) )
            return;
        
        BroadcastMessage(Mut.ParseColorTags(OldName)@"has changed"@Gender@"name to"@Mut.ParseColorTags(NewName));
        NameChanged++;
    }
}

simulated function SetupPlayerName( ForrestPRI FPlayerRepInfo )
{   
    if( AltPlayerName != "" && Mut.StripColorTags(AltPlayerName) != PlayerReplicationInfo.PlayerName )
        log(Mut.StripColorTags(AltPlayerName)$"'s old name was"@PlayerReplicationInfo.PlayerName);
    
    if( Level.NetMode == NM_DedicatedServer )
        return;
    
    if( AltPlayerName != "" )
        FPlayerRepInfo.AltPlayerName = AltPlayerName;
}

function PlayerTick( float DeltaTime )
{
    if( bNameCoolDown )
    {
        if( Level.TimeSeconds >= NameChangeCoolDown+10 )
        {
            NameChanged = 0;
            bNameCoolDown = false;
        }
    }
    
    Super.PlayerTick(DeltaTime);
}

function BroadcastMessage(string Msg, optional bool bSaveToLog)
{
    Mut.BroadcastMessage(Msg, bSaveToLog);
}

Ignore the AltPlayerName value being set and the call to Mut, the Mut is the mutator for ScrnBalance which does most of thinsg such as finding the color tags and applying the color, AltPlayerName is used by the PRI to change someones name without affecting his overall default name
 
Last edited by a moderator:

forrestmark9

New Member
Aug 6, 2009
56
0
0
Also appears I'm having replication issues with AltPlayerName, it appears that only the owning client can see the name change, anyone else will see the default name. I have absolutely no idea how to fix this