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"

How disconnect a specific PlayerController from server ?

When my Match end, inside my GameMode, I need to check for some condition on each PlayerController and if the condition is true, disconnect from server that PlayerController. Later, call ServerTravel in order to move to another map only the PlayerControllers that are connected. But i don't know how disconnect a specific PlayerController from server.

Someone can help me with this, please ?

Thanks

Product Version: UE 4.10
Tags:
more ▼

asked Dec 09 '15 at 08:43 PM in C++ Programming

avatar image

nan2cc
502 23 13 38

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

2 answers: sort voted first

Regardinging nan2cc's answer:

Actually you're right!

If you look in GameSession.cpp, Epic does the same thing, except they make sure to clean up the Pawn first:

UnregisterPlayer

hough if you want a more gentile approach you can use

 GameSession::UnregisterPlayer

Rama

 bool AGameSession::KickPlayer(APlayerController* KickedPlayer, const FText& KickReason)
 {
     // Do not kick logged admins
     if (KickedPlayer != NULL && Cast<UNetConnection>(KickedPlayer->Player) != NULL)
     {
         if (KickedPlayer->GetPawn() != NULL)
         {
             KickedPlayer->GetPawn()->Destroy();
         }
 
         KickedPlayer->ClientWasKicked(KickReason);
 
         if (KickedPlayer != NULL)
         {
             KickedPlayer->Destroy();
         }
 
         return true;
     }
     return false;
 }
more ▼

answered Apr 02 '16 at 04:25 AM

avatar image

Rama
10.6k 445 343 1083

avatar image nan2cc Apr 08 '16 at 07:02 PM

Hi Rama, thank you for your answer, this is a old question, but is good to know that I was in a correct direction, thank you.

... and Rama, I will use this opportunity, because you are a UE4 Guru :), maybe you can help me with another two question that I did here more recently, but none one answer me. If is not to mush ask, can you take a look please ?

https://answers.unrealengine.com/questions/385618/dedicated-server-management-tool.html

https://answers.unrealengine.com/questions/392141/procedurally-alter-path-cost.html

I will appreciate if you can point me in the right direction at least on one of the two questions.

PD: Are two completely different questions

Again, thanks so much.

Best regards,

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

Well, I found some solution, but don't know if this is the best way to do this.

In my GameMode, when I found some PlayerController that I need to disconnect, I destroy it (calling Destroy()). So, in my game mode, on server, run a method like this:

 for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; ++It)
 {
     if ((*It)->MyCondition)
     {
         (*It)->Destroy();
     }
 } 

... apparently it work correctly, and exactly has I want. This client is disconnected, on gameMode is called the Logout function etc. But, the point is that I don't know if this is the best way to do it.

Best regards

more ▼

answered Dec 09 '15 at 08:56 PM

avatar image

nan2cc
502 23 13 38

(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