x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Not Able to Get Player ID

Hi all, I'm trying to write achievement progress in C++ now and my player ID always turns to be null so I'm not able to call write achievement successfully. Any suggestion on this?

 void APlayerController_WeepingDoll::UpdateTrophyProgress(const FString& AchName, float Percent)
 {
     ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
     if (LocalPlayer)
     {
         IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
         if (OnlineSub)
         {
             IOnlineIdentityPtr Identity = OnlineSub->GetIdentityInterface();
             if (Identity.IsValid())
             {
                 TSharedPtr<const FUniqueNetId> UserId = LocalPlayer->GetCachedUniqueNetId();
 
                 if (UserId.IsValid())
                 {
                     GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, AchName);
                     IOnlineAchievementsPtr Achievements = OnlineSub->GetAchievementsInterface();
                     if (Achievements.IsValid() && (!WriteObject.IsValid() || WriteObject->WriteState != EOnlineAsyncTaskState::InProgress))
                     {
                         WriteObject = MakeShareable(new FOnlineAchievementsWrite());
                         WriteObject->SetFloatStat(*AchName, Percent);
 
                         FOnlineAchievementsWriteRef WriteObjectRef = WriteObject.ToSharedRef();
                         Achievements->WriteAchievements(*UserId, WriteObjectRef);
                     }
                 }
             }
         }
     }
 }

Product Version: UE 4.12
Tags:
more ▼

asked Jul 30 '16 at 09:44 AM in C++ Programming

avatar image

PhoenixThrough
101 18 23 30

avatar image theonecalledtom Jun 10 '17 at 02:12 PM

Did you find a solution?

avatar image Midsoft Games Jul 05 '18 at 03:50 PM

GetPreferredUniqueNetId()

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question