Reducing console spam(ChangeTeam)

Тема в разделе "Кодинг", создана пользователем boom159, 18 май 2019.

  1. boom159

    boom159 Новенький

    Good afternoon,
    So here i have another problem , which is also kinda annoying.

    Warning: SRGameType KF-Defence-Classic.SRGameType (Function uliunailtperks.SRGameType.ChangeName:0165) Accessed None 'PlayerReplicationInfo'
    Warning: SRGameType KF-Defence-Classic.SRGameType (Function uliunailtperks.SRGameType.ChangeName:0165) Accessed None 'PlayerReplicationInfo'
    Warning: SRGameType KF-Defence-Classic.SRGameType (Function uliunailtperks.SRGameType.ChangeName:0165) Accessed None 'PlayerReplicationInfo'

    When person is connecting to the server, this one also spams the console.

    function ChangeName(Controller Other, string S, bool bNameChange)
    {
    local Controller APlayer,C, P;

    if ( S == "" )
    return;

    S = StripColor(s); // Stip out color codes

    //Tried to implement this , but it didn't work.
    if (Other.PlayerReplicationInfo == none)
    return;

    if (Other.PlayerReplicationInfo.playername~=S)
    return;

    S = Left(S,20);
    ReplaceText(S, " ", "_");
    ReplaceText(S, "|", "I");

    if ( bEpicNames && (Bot(Other) != None) )
    {
    if ( TotalEpic < 21 )
    {
    S = EpicNames[EpicOffset % 21];
    EpicOffset++;
    TotalEpic++;
    }
    else
    {
    S = NamePrefixes[NameNumber%10]$"CliffyB"$NameSuffixes[NameNumber%10];
    NameNumber++;
    }
    }

    for( APlayer=Level.ControllerList; APlayer!=None; APlayer=APlayer.nextController )
    if ( APlayer.bIsPlayer && (APlayer.PlayerReplicationInfo.playername~=S) )
    {
    if ( Other.IsA('PlayerController') )
    {
    PlayerController(Other).ReceiveLocalizedMessage( GameMessageClass, 8 );
    return;
    }
    else
    {
    if ( Other.PlayerReplicationInfo.bIsFemale )
    {
    S = FemaleBackupNames[FemaleBackupNameOffset%32];
    FemaleBackupNameOffset++;
    }
    else
    {
    S = MaleBackupNames[MaleBackupNameOffset%32];
    MaleBackupNameOffset++;
    }
    for( P=Level.ControllerList; P!=None; P=P.nextController )
    if ( P.bIsPlayer && (P.PlayerReplicationInfo.playername~=S) )
    {
    S = NamePrefixes[NameNumber%10]$S$NameSuffixes[NameNumber%10];
    NameNumber++;
    break;
    }
    break;
    }
    S = NamePrefixes[NameNumber%10]$S$NameSuffixes[NameNumber%10];
    NameNumber++;
    break;
    }

    if( bNameChange )
    GameEvent("NameChange",s,Other.PlayerReplicationInfo);

    if ( S ~= "CliffyB" )
    bEpicNames = true;
    Other.PlayerReplicationInfo.SetPlayerName(S);
    // notify local players
    if ( bNameChange )
    for ( C=Level.ControllerList; C!=None; C=C.NextController )
    if ( (PlayerController(C) != None) && (Viewport(PlayerController(C).Player) != None) )
    PlayerController(C).ReceiveLocalizedMessage( class'GameMessage', 2, Other.PlayerReplicationInfo );
    }

    I pretty much just copied ChangeName function from the DeathMatch.uc file, but maybe there's another way how this can be solved?
     
  2. Essence

    Essence Moderator Команда форума

    Need to add two more checks on None.

    Код:
    function ChangeName(Controller Other, string S, bool bNameChange)
    {
        local Controller APlayer,C, P;
    
        if ( S == "" )
            return;
    
        S = StripColor(s);    // Stip out color codes
    
        if (Other.PlayerReplicationInfo==None)
            return;
    
        if (Other.PlayerReplicationInfo.playername~=S)
            return;
    
        S = Left(S,20);
        ReplaceText(S, " ", "_");
        ReplaceText(S, "|", "I");
    
        if ( bEpicNames && (Bot(Other) != None) )
        {
            if ( TotalEpic < 21 )
            {
                S = EpicNames[EpicOffset % 21];
                EpicOffset++;
                TotalEpic++;
            }
            else
            {
                S = NamePrefixes[NameNumber%10]$"CliffyB"$NameSuffixes[NameNumber%10];
                NameNumber++;
            }
        }
    
        for( APlayer=Level.ControllerList; APlayer!=None; APlayer=APlayer.nextController )
        {
            if ( APlayer.bIsPlayer && (APlayer.PlayerReplicationInfo!=None && APlayer.PlayerReplicationInfo.playername~=S) ) // Essence
            {
                if ( Other.IsA('PlayerController') )
                {
                    PlayerController(Other).ReceiveLocalizedMessage( GameMessageClass, 8 );
                    return;
                }
                else
                {
                    if ( Other.PlayerReplicationInfo.bIsFemale )
                    {
                        S = FemaleBackupNames[FemaleBackupNameOffset%32];
                        FemaleBackupNameOffset++;
                    }
                    else
                    {
                        S = MaleBackupNames[MaleBackupNameOffset%32];
                        MaleBackupNameOffset++;
                    }
                    for( P=Level.ControllerList; P!=None; P=P.nextController )
                        if ( P.bIsPlayer && (P.PlayerReplicationInfo!=None && P.PlayerReplicationInfo.playername~=S) ) // Essence
                        {
                            S = NamePrefixes[NameNumber%10]$S$NameSuffixes[NameNumber%10];
                            NameNumber++;
                            break;
                        }
                    break;
                }
                S = NamePrefixes[NameNumber%10]$S$NameSuffixes[NameNumber%10];
                NameNumber++;
                break;
            }
        }
        if( bNameChange )
            GameEvent("NameChange",s,Other.PlayerReplicationInfo);
    
        if ( S ~= "CliffyB" )
            bEpicNames = true;
        Other.PlayerReplicationInfo.SetPlayerName(S);
        // notify local players
        if  ( bNameChange )
            for ( C=Level.ControllerList; C!=None; C=C.NextController )
                if ( (PlayerController(C) != None) && (Viewport(PlayerController(C).Player) != None) )
                    PlayerController(C).ReceiveLocalizedMessage( class'GameMessage', 2, Other.PlayerReplicationInfo );
    }
     
    3xzet нравится это.