Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

OnReplicated Functions Question for ListenServer?

Okay, I have some basic networking questions. I was under the impression that the ListenServer would run both the server and client functions, but it really doesn't. Here is an example.

In my game, the player has the choice to join a dedicated server or to host their own game as Listen Server.

//Level of unit Variable used for Replication UPROPERTY(replicatedUsing = OnRep_m_iUnitLevel)

uint8 m_iUnitLevel;

.....Gain enough experience on the server to level

Example::OnLevelUp() { .... m_iUnitLevel++; //Increase the level by one .... }

//On the replicated function I want to call the particle effect showing a level up on the client Example::OnRep_m_iUnitLevel() { Emit Levelup Particles }

This will work only for the pureclients and not the listenserver player. Is the fix just to check for Net_ListenServer and manually run "OnRep_m_iUnitLevel()" from the server?

I'm trying to save as much bandwith as possible so I combine where I can. I'm already sending down the unitlevel, but I don't want to also send down a RPC also for the particles. However, I want the ListenServer player to see the particles also, but not if its a dedicated server.

Hopefully I stated that clearly. Any suggestions on this? Thanks!

Product Version: Not Selected
more ▼

asked Jul 24 '14 at 01:34 PM in C++ Programming

avatar image

2.3k 114 62 234

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

A typical pattern for OnRep calls here is to make sure that the server calls it at the site of the variable change.

 void ChangeSomeStuff()
    myReplicatedVar = newValue;
    if (Role == ROLE_Authority)

That way you have one code path for the replication event and all clients/server get the change.

more ▼

answered Jul 24 '14 at 05:22 PM

avatar image

Crzyhomer STAFF
1.2k 34 26 103

avatar image Devero Jul 24 '14 at 05:56 PM

Thanks, that is what I was doing temporarily, now I know its a good solution. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question