Legacy:Replication Examples/Replication Test - Unreal Wiki

# Legacy:Replication Examples/Replication Test

### From Unreal Wiki, The Unreal Engine Documentation Site

< Legacy:Replication Examples

## Under Construction

errmm yeah righto... still working on this. I'll have quite a few examples up here shortly.

    // ========================================================================

    //
    // Coded by JonAzz

    // ========================================================================

    class ReplicationTestD extends Actor
            Placeable;

    var int intA;

    // replication Block
    replication
    {
            // Sends these values from the server to the clients
        reliable if(Role == ROLE_Authority)
            ClientFunction, intA;

    }

    simulated event PostNetReceive()
    {
        if ( IntA == 1 )
        {
            ClientFunctionB();
        }
    }

    function ServerParseFunction(int A)
    {
        if(A == 1)
        {
            ClientFunction(); // Other server required changes
    //        A = 0;

        if(Role == Role_Authority)
                    log("A The server has done something");
            else if(Role < Role_Authority)
                    log("A The client has done something");

        }
    }

    simulated function ClientFunction()   // THIS DOES NOT WORK!!
    {
    //    if(Level.NetMode == NM_DedicatedServer)
    //        return;

        if(Role == Role_Authority)
                    log("B The server has done something");
            else if(Role < Role_Authority)
                    log("B The client has done something");

    }

    simulated function ClientFunctionB()    // THIS WORKS!
    {
    //    if(Level.NetMode == NM_DedicatedServer)
    //        return;

        if(Role == Role_Authority)
                    log("C The server has done something");
            else if(Role < Role_Authority)
                    log("C The client has done something");

    }

    function Trigger(Actor Other, Pawn EventInstigator)
    {
        ServerParseFunction( 1 );
        intA = 1;
    }

    defaultproperties
    {
        bEdShouldSnap=true
            DrawType=DT_StaticMesh
            StaticMesh=StaticMesh'AS_Decos.ExplodingBarrel'
            DrawScale=1

            bStaticLighting=True
            bCollideActors=True
            bBlockActors=True
            bBlockKarma=True
            CollisionHeight=+000001.000000
            CollisionRadius=+000001.000000

            Physics=PHYS_None

            bAlwaysRelevant=true
    //    bNoDelete=false
            bStasis=True
            bStatic=False
            bSkipActorPropertyReplication=false
            RemoteRole=ROLE_SimulatedProxy
            bReplicateMovement=false
            NetPriority=3.0
            NetUpdateFrequency=10
            bNetNotify=true
    }

Server Log:

  ScriptLog: B The server has done something
  ScriptLog: A The server has done something

Client log:

  ScriptLog: C The client has done something

##### Views

- Legacy
- Discussion
- Current revision

##### Search