I need help with server/multicast functions. I am not sure if I am doing this correctly.

Hm, no this doesn’t seem as good way.

First of all:

You are passing the Locations from the Client to the Server. The Client could already pass wrong data here, as you never test it.
You should try to use Data that is available on the Server.

Then:

You are directly Multicasting to everyone. So this code is executed on Server/LocalClient/OtherClients and everyone does all the calculations.

So how should this be done?

As far as I can see, you have a ListenServer (who could cheat, so no idea why you want to prevent cheating here, but I’ll still further explain), so you want to check right after the Button press if you are on the Server or not.
SwitchHasAuthority is used for that.

Then you have a couple of ways you can go. I made a really crappy picture some time ago that shows the general process.
Few words to explain the picture below: “LocalClient” is the one who shoots. That could also be the ListenServer of course, but if you are on the ListenServer (SwitchHasAuthority), you don’t need the ServerRPC etc.
Picture shows the process from top to bottom.

So what this basically shows is this:

  • LocalClient wants to shoot
  • LocalClient tells Server with an RPC that he wants to shoot
  • LocalClient checks himself if he can shoot
  • If yes, he plays the FX (Sound, Particles, …)
    – He could also perform a LineTrace here to spawn other effects at the hit location
    – The LocalClient does this himself, because otherwise he would feel a bit of lag. So we let him do all of that instantly.
    – It’s important to note that this only results in effects and maybe reducing Ammo which should still be replicated so the Server still has Authority!
  • Now the Server (after ServerRPC), also checks if the Player can shoot
    – This includes ammo check and so on!
  • If yes
    – The Server calls a Multicast to tell everyone that the Player is shooting (later more about that)
    – He reduces ammo
    – He erforms a linetrace from NON passed data
    — Means he should find a way (replicated weapon location for example) to get location and direction without using Client Data!
    – If the linetrace hit an Enemy, the Server calls “Apply Damage” or what ever the build-in blueprint function is called
    – And then you also want to check if you are on a ListenServer or Dedicated Server
    — If it’s a ListenServer, you also want to play FX (Sounds, HitEffects, Fire events, etc. )
    — If it’s a DedicatedServer, then we are done here, because he only needs to notify everyone and deal damage if someone is hit
  • Now to the Multicast:
    – First major thing is: The Multicast gets called on the original Client and the Server too
    — This means you need to exclude them. Why? Because we already handled FX on the LocalClient and the Server. No need to do that again.
    — How can you do this? Well, SwitchHasAuthority filters the client already. And then you could do a few checks
    ---- If you are on the Character, you could try “IsLocalControlled”
    ---- You could also try to get the Owner, which is usually the PlayerController
    ----- The PlayerController is null on all OtherClients. Clients only know there own PlayerController. Only the Server knows all
    – This Multicast could/should have a few variables with it
    — HitLocation (if there is any)
    — Maybe even if it was an enemy (pass the HitActor or so)
    — You could also let them perform the Trace again and pass the Start and Direction Vector, but I think it’s enough to just pass the data needed to spawn FX
    – And then the Multicast just plays the FX (Sound, Animation, Effects, HitDecals, etc.)

I think that’s enough info to get started (: