# C++ Server functions can only be called by the owner

**URL:** <https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [February 2, 2015, 9:52pm UTC](https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793 "2015-02-02T21:52:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_adc3f730](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_adc3f730](https://forums.unrealengine.com/u/anonymous_user_adc3f730)\
**Post date:** [February 2, 2015, 9:52pm UTC](https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793/1 "2015-02-02T21:52:38Z")

</div>

I have created a simple “server, client” function and it works fine. For instance, if i have this “server, client” function in a pawn i was possessing and i called it, it would work fine. But if i have the same function in an actor and i called the “server, client” function from my pawn it doesn’t work? For some reason i can only call the function within that actor and not across actors, this i a problem for when my player is holding a weapon. I cant call the “server start fire” function from my pawn!

Is there any solution to this

```
AActor::ServerStartFire() // i CANT call this function from another actor,
{
       //Call client function from server
       ClientStartFire();
}

AActor::ClientStartFire()
{
       //Do stuff that replicates to all clients
}

```

---

<div class="post-metadata">

**Author:** ![Duncan\_Dam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Duncan\_Dam](https://forums.unrealengine.com/u/Duncan_Dam)\
**Post date:** [February 3, 2015, 1:19am UTC](https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793/2 "2015-02-03T01:19:15Z")

</div>

Hi, for Server-Client, if you already have UFUNCTION(client) then ClientStartFire\_Implementation() will be run on client when you call ClientStartFire on server, so you need to put that in your cpp.

Same for Client-Server, you need YourFunction-Implementation() in your .cpp

---

<div class="post-metadata">

**Author:** ![DarthB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarthB](https://forums.unrealengine.com/u/DarthB)\
**Post date:** [February 3, 2015, 9:19am UTC](https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793/3 "2015-02-03T09:19:40Z")

</div>

Did you read “Requirements and Caveats” in [https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html](https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html) ?

Also checkout this Question:  
[https://answers.unrealengine.com/questions/161378/rpc-never-being-called.html#answer-161393](https://answers.unrealengine.com/questions/161378/rpc-never-being-called.html#answer-161393)

As you said in the title “… can only be called by the Owner” but do you call AActor::SetOwner(AController) somewhere?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_adc3f730](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_adc3f730](https://forums.unrealengine.com/u/anonymous_user_adc3f730)\
**Post date:** [February 3, 2015, 11:19am UTC](https://forums.unrealengine.com/t/c-server-functions-can-only-be-called-by-the-owner/305793/4 "2015-02-03T11:19:50Z")

</div>

Oh, the problem was that my actor didn’t have a set owner. I’m trying to figure out how to set it because

```
CurrentActor->SetOwner(this);

```

Doesn’t work?
