Announcement

Collapse
No announcement yet.

Distinguish Between Listen Server and Dedicated Server

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

    Distinguish Between Listen Server and Dedicated Server

    Hi,

    Is there a way that I can distinguish between a listen server and a dedicated server? (For example I want to spawn particle effects if we are a listen server but not if we are a dedicated server).

    #2
    Grab this...
    ----------------------------------------------------------------------------------------------------------
    What are the BEST Unreal Tutorials / Docs? There are none tbh... Here's why
    Instead its better to just take projects apart (see the free 'creators' listed here)

    Comment


      #3
      In Blueprint there is a macro called CanExecuteCosmeticEvent which simply uses the IsDedicatedServer function.

      In C++ you can use
      Code:
      GetNetMode() != NM_DedicatedServer
      or if you want to get rid of the code completely on the dedicated server using the preprocessor.
      Code:
      #if !UE_SERVER
      #endif // !UE_SERVER
      Last edited by GarnerP57; 12-21-2019, 06:17 AM.

      Comment


        #4
        Thank you very much, perfect answer!

        Comment


          #5
          I picked this up somewhere in my searching/learning...

          Code:
          #define NETMODE_WORLD (((GEngine == nullptr) || (GetWorld() == nullptr)) ? TEXT("") \
                  : (GEngine->GetNetMode(GetWorld()) == NM_Client) ? TEXT("[Client] ") \
                  : (GEngine->GetNetMode(GetWorld()) == NM_ListenServer) ? TEXT("[ListenServer] ") \
                  : (GEngine->GetNetMode(GetWorld()) == NM_DedicatedServer) ? TEXT("[DedicatedServer] ") \
                  : TEXT("[Standalone] "))
          
              UE_LOG(<name of your log>, Log, TEXT("%s() NetMode: %s ")
                  , TEXT(__FUNCTION__)
                  , NETMODE_WORLD);

          Comment

          Working...
          X