[C++]How to replicate BlueprintNativeEvent?

i have the next function in my code:

   UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
bool fire();

if i try to add replication to it this way:

   UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Server, Reliable, WithValidation)
bool fire();

it yells me this error upon compilation:

Error: BlueprintImplementableEvent or BlueprintNativeEvent functions cannot be declared as Client or Server


even if i create some wrapper around it this way:

   UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "local")
bool fire();                                  //actual logics here
    UFUNCTION(Server, Reliable, WithValidation)
		bool fire_onServer();     //just calls fire_Implementation()

it tells me

Error: Replicated functions can’t have return values

how can i work this out without using hacky bad code like external variables for return value etc?

thanks!

bump please

It already tells you what you can’t do.

Why do you even need BlueprintNativeEvent?
It only allows you to override a function in the BP.

Anyway, if you want a function that can be overriden in the BP, then you have to call the replicated function in the BP.

Obviously i need BlueprintNativeEvent to override it in the BP.

It doesn’t answer the question though, because i have mentioned i did it in the question.

> Error: Replicated functions can't have return values 


this issue still exist in both cases

Well, it says it cant have return values. It means all replicated functions must be void. Because there’s a delay when calling function to the server.
I’m not sure if there’s anyway to synchronize client and server function.

But you can just put all the logic on the server side so that you don’t have to ask for a return value.
Like this:

The object calling this must be spawned from the server.

bool fire() {}

void fire_onServer()
{
    if (fire())
    {
         // fired
    }
}

i see, didn’t think about the delay between the server and the client.
my case is a bit more complicated and includes inheritance, but ill look further into it. thank you!