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"

Multiplayer: How to check that the player is ready

Hi, as the titles says. My client player start receiving message before it even has had the chance to create its AGameState.

I tried checking (below) before sending data to client

 if (APawn->GetNetConnection()->State == EConnectionState::USOCK_Open)
 {
     // Send data
 }

This doesn't work

Thank you :)

Product Version: Not Selected
Tags:
more ▼

asked Sep 11 '14 at 04:40 PM in C++ Programming

avatar image

MiniTurtle
259 17 10 18

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Anyone who wants to know how I did a workaround here it is:

File .h

  class AMyCharacter : public ACharacter
     {
     ...
 
     virtual void OnRep_Controller() override;
 
     private:
         /** Sends ready message from client to server */
         UFUNCTION(Reliable, Server, WithValidation)
         void SRecvReady();
 
         #ifdef WITH_SERVER_CODE
         /** Player status */
     bool bReady;
         #endif
     ...
     }

File .cpp

 void AMyCharacter::OnRep_Controller()
 {
     Super::OnRep_Controller();
 
     if (IsLocallyControlled())
     {
         SRecvReady();
     }
 }
 
 void AMyCharacter::SRecvReady_Implementation()
 {
 #ifdef WITH_SERVER_CODE
     bReady = true;
 #endif
 }
 
 bool AMyCharacter::SRecvReady_Validate()
 {
 #ifdef WITH_SERVER_CODE
     // Check if player already sent ready message
     return (!bReady);
 #endif
         return false;
 }

Hope this helps someone :)

more ▼

answered Sep 19 '14 at 12:12 PM

avatar image

MiniTurtle
259 17 10 18

(comments are locked)
10|2000 characters needed characters left
Your answer
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