Announcement

Collapse
No announcement yet.

Problem getting playername client side

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem getting playername client side

    I am having a problem getting the player name client side. Some times this works and some times this does not. Can anyone see where I am screwing it up?

    class PTChecker extends UnrealSecurity;

    var ClientConnect MyClient;

    simulated function PostNetBeginPlay()
    {
    Super.PostNetBeginPlay();
    if ( ROLE < ROLE_Authority)
    {
    Log("============================================= ============================");
    Log("Mutator");
    Log("============================================= ============================");
    }
    GetClientInfo();
    }

    simulated function GetClientInfo()
    {
    local PlayerController PC;
    local string LocalPlayerName, LocalPlayerHash;
    if ( ROLE < ROLE_Authority )
    {
    PC = Level.GetLocalPlayerController();
    if ( PC != None )
    {
    LocalPlayerName = PC.PlayerReplicationInfo.PlayerName;
    LocalPlayerHash = PC.GetPlayerIDHash();
    }
    MyClient.ConnectClient(LocalPlayerHash, LocalPlayerName);
    }
    }

    defaultproperties
    {
    RemoteRole=ROLE_SimulatedProxy
    bAlwaysRelevant=True
    }
    This is the error I get in the log file.....
    Warning: PTChecker CTF-Grendelkeep.PTChecker (Function PlayerTracker.PTChecker.GetClientInfo:0127) Accessed None 'PlayerReplicationInfo'

    What is weird is that it will grab the player hash every single time. However the player name is grabs some times and other times it gives the error I have listed above. Any help would be appreciated.

    #2
    Looks like the PlayerReplicationInfo has not yet been spawned for the player. So i suggest you add:

    PC = Level.GetLocalPlayerController();
    if ( (PC != None) && PC.PlayerReplicationInfo !=None )
    {
    LocalPlayerName = PC.PlayerReplicationInfo.PlayerName;

    After all you are not checking to see if the PlayerReplicationInfo is available. That will fix your LOG error, but it may not fix getting the player name, you would need to recheck this at a later time, I guess.

    Comment


      #3
      Thanks for the reply. It gave me an idea. I set a loop to continue checking for when PlayerReplicationInfo becomes spawned and when it does it grabs the playername.

      Comment

      Working...
      X