Dear Community,
Replication Series
Part 1: Change Pawn Materials Based On a Unique PlayerID
Part 2: Efficiently Replicate Custom Special Effects & Projectile Bounces
Part 3: Grapple Hook and Custom Pawn Movements
Part 4: Listen Servers - Replicating Special Effects
1. Below is my code structure for replicating special effects on clients AND the listen server.
2. My code structure puts special emphasis on Network Efficiency.
3. Please note that this code I am presenting will also work perfectly for Dedicated Servers.
Special Thanks
Special Thanks goes to Solid Snake for encouraging me to not give up on figuring out the complexity of using Listen Servers. My entire game format will be relying on listen servers rather than dedicated!
Thanks Solid Snake!

~~~
Over View of Listen vs Dedicated Servers
Listen servers are different from dedicated servers because the server is also a player.
The complication here is that listen server players do not receive replication notification events (because its the server, there's no need to tell itself what it's doing).
In a dedicated server, every player is a client, so the code is always the same for all players.
But in a listen server, you literally have to write different code for the listen server player and the client player.
This usually just amounts to calling the function that you put in your replciation event directly from the server function.
See below for details!
~~~
Playing a Shield Effect
In this example there is a shield effect (I did not actually implement it, it could be any special effect).
I use a boolean to trigger the replication event, because I only need to tell the pawn to play the shield effect, and the actual effect itself is always centered on the pawn, so no need to pass any other data.
If you did need to pass data, dont use a boolean but a vector or whatever info you need to tell the pawn.
//pawn class
~~~
Network Efficiency
The advantage of only replicating a boolean is that it is extremely small amount of data to pass over a network
and using the structure bool = !bool guarantees that the event will always fire off due to the variable's value being guaranteed to change (becomes dirty)
//player controller class
~~~
Function Parameters ARE Replicated
The reason the player controller class needs to specify the pawn (even though since it is player controller you should be able to just use the pawn variable):
In order to trigger the repnotify event you have to change the repnotified var on the SERVER, using reliable server functions.
But since this is a server function, if a client player controller calls the code, the value of the pawn will be different when the server runs the function if you dont pass in which pawn you mean as a parameter.
So always pass in the pawn to the player controller function, it is not reduntant info, because you are using a reliable server function
so if a client calls the function, that code is NOT being run on the client, but on the other machine, the server machine, and any important data must be passed in as function parameters.
Enjoooy!

Rama
This is the code format I use for my own multiplayer game
Footage from several contiguous actual multiplayer game sessions,
most relevant footage starts around 4:20
Original Tutorial about this video:
http://forums.epicgames.com/threads/...2#post31594372
Replication Series
Part 1: Change Pawn Materials Based On a Unique PlayerID
Part 2: Efficiently Replicate Custom Special Effects & Projectile Bounces
Part 3: Grapple Hook and Custom Pawn Movements
Part 4: Listen Servers - Replicating Special Effects
1. Below is my code structure for replicating special effects on clients AND the listen server.
2. My code structure puts special emphasis on Network Efficiency.
3. Please note that this code I am presenting will also work perfectly for Dedicated Servers.
Special Thanks
Special Thanks goes to Solid Snake for encouraging me to not give up on figuring out the complexity of using Listen Servers. My entire game format will be relying on listen servers rather than dedicated!
Thanks Solid Snake!

~~~
Over View of Listen vs Dedicated Servers
Listen servers are different from dedicated servers because the server is also a player.
The complication here is that listen server players do not receive replication notification events (because its the server, there's no need to tell itself what it's doing).
In a dedicated server, every player is a client, so the code is always the same for all players.
But in a listen server, you literally have to write different code for the listen server player and the client player.
This usually just amounts to calling the function that you put in your replciation event directly from the server function.
See below for details!
~~~
Playing a Shield Effect
In this example there is a shield effect (I did not actually implement it, it could be any special effect).
I use a boolean to trigger the replication event, because I only need to tell the pawn to play the shield effect, and the actual effect itself is always centered on the pawn, so no need to pass any other data.
If you did need to pass data, dont use a boolean but a vector or whatever info you need to tell the pawn.
//pawn class
Code:
var repnotify bool r_playShield; replication{ if(bnetdirty) r_playShield; } //=============== REPLICATION EVENT ============ simulated event ReplicatedEvent( name VarName ) { //very important line super.ReplicatedEvent( VarName ); if (varname == 'r_playShield') { doShieldEffect(); } } simulated function doShieldEffect(){ //do the actual special effect code }
Network Efficiency
The advantage of only replicating a boolean is that it is extremely small amount of data to pass over a network
and using the structure bool = !bool guarantees that the event will always fire off due to the variable's value being guaranteed to change (becomes dirty)
//player controller class
Code:
reliable server function activateShield(yourpawnclass yourpawn){ //the listen server needs to run it directly yourpawn.doShieldEffect(); //ADVANCED: if your code is purely a special effect, //you do not need a dedicated server to do the line above //but if any pawn vars are changed to indicate for example //that no damage can be taken, you need to at least set those vars //on the dedicated server side. //repnotify for clients to call on their side yourpawn.r_playShield = !yourpawn.r_playShield; }
Function Parameters ARE Replicated
Code:
reliable server function activateShield(yourpawnclass yourpawn){}
In order to trigger the repnotify event you have to change the repnotified var on the SERVER, using reliable server functions.
But since this is a server function, if a client player controller calls the code, the value of the pawn will be different when the server runs the function if you dont pass in which pawn you mean as a parameter.
So always pass in the pawn to the player controller function, it is not reduntant info, because you are using a reliable server function
so if a client calls the function, that code is NOT being run on the client, but on the other machine, the server machine, and any important data must be passed in as function parameters.
Enjoooy!

Rama
This is the code format I use for my own multiplayer game

Footage from several contiguous actual multiplayer game sessions,
most relevant footage starts around 4:20
Original Tutorial about this video:
http://forums.epicgames.com/threads/...2#post31594372
Comment