To answer questions 1 and 2: you can use AActor::GetNetMode() which returns whether you are a listen server, dedicated server or network client.
if (GetNetMode() == ENetMode::NM_ListenServer)
{
}
The ENetMode values are:
NM_Standalone = 0
NM_DedicatedServer = 1
NM_ListenServer = 2
NM_Client = 3 // is only when you are actually connected to a server
The ordering of the ENetMode values allows you to check multiple things at once: GetNetMode() <= 2 means you are the server or standalone, so you have ‘global authority’.
To answer question 3, if you’re the server you can always execute server RPCs. If you’re a network client, you can only use server RPCs on actors owned by the local player’s player controller. So you can grab a reference to that player controller and check whether that’s the actor’s owner.
if (GetOwner() == GetWorld()->GetFirstPlayerController())
{
}
The default game mode code automatically makes the player’s default Pawn owned by the player’s player controller, allowing you to call RPCs on the pawn. To make more actors on which a network client can call RPC’s, the server has to set those actors’ owners to a player controller.
Here is one more possibility way to check by calling UGameInstace::IsDedicatedServerInstance(). This is not detailed like the answer above, but I think you should also know about it. That is works if the game world is not ready yet.