Tripwire Interactive Forums

Go Back   Tripwire Interactive Forums > Red Orchestra 2 / Rising Storm Forums > RO2/RS Modifications > Coding

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2012, 11:04 AM
-=THOR=-'s Avatar
-=THOR=- -=THOR=- is offline
Senior Member
 
Join Date: Sep 2011
Posts: 837
Default Calling client/server functions (mutator)

Hi,

When someone calls Mutate MyMutatorName in the console, it calls the function Mutate on the server. I want the server to trigger a mutator function call on each client. Inside that function, the client must trigger a function call on the server, with a struct as parameter. So basically, there are 3 functions, mutate(...), ClientFunction(), and ServerFunction(param).

So for example, the following execution scenario could happen:
1. Client 1 types Mutate MyMutatorName
2. Server calls Mutate(...)
3. In the Mutate function, the server triggers a mutator function call on each client.
4. ClientFunction called on client 1, and triggers a server function call.
5. ClientFunction called on client 2, and triggers a server function call.
6. ServerFunction("Ack from 1") called on the server
7. ClientFunction called on client 3, and triggers a server function call.
8. ServerFunction("Ack from 2") called on the server
9. ServerFunction("Ack from 3") called on the server

What is the simplest solution to "route" these function calls? What is the syntax required?

Thanks

Last edited by -=THOR=-; 05-02-2012 at 11:25 AM.
Reply With Quote
  #2  
Old 05-02-2012, 04:33 PM
Mekhazzio's Avatar
Mekhazzio Mekhazzio is offline
Senior Member
 
Join Date: Sep 2011
Posts: 1,104
Default

The documentation: http://udn.epicgames.com/Three/FunctionReplication.html

The short version: you need to make an object that exists on both client and server, owned by the client's playercontroller on both sides, before the function calls will replicate both ways. After that, it's fairly straight-forward, you just route the calls through that object. The clients call a method of that object that's flagged with the server keyword, and the server calls a method flagged with the client keyword, and they work just like any other function call.
Reply With Quote
  #3  
Old 05-02-2012, 09:16 PM
-=THOR=-'s Avatar
-=THOR=- -=THOR=- is offline
Senior Member
 
Join Date: Sep 2011
Posts: 837
Default

Thanks I'll try this out!
Reply With Quote
  #4  
Old 03-28-2013, 10:14 PM
chasse chasse is offline
Junior Member
 
Join Date: Mar 2013
Posts: 17
Default

Include a replication block for small variables. You can also have a repnotify event block to detect when those variables are changed. You generally want to only pass through ints/floats (same size in memory), and bytes/bools (same size in memory) and you want to limit the amount you pass through as best as you can.

A lot of objects, including the Pawn, exist twice: one for the player, one for the server. Variables, such as Location, have to be declared as needing to be replicated. If the client value is different than the server, then the server will change the client value using the replication block. When a variable is changed, you can use the repnotify block to detect that.

The server handles such things as the functionality behind weapons, projectiles, players (not input), collision, triggers, game (game is never run on the client).
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:56 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2005 - 2013, Tripwire Interactive, LLC