Time for action – Using ReplicatedEvent
We need to make some changes to AwesomeWeaponUpgrade
for this to work.
Delete
ClientTest
, but we're still going to useServerTest
so leave that for now.Let's rewrite the
PostBeginPlay
function:simulated function PostBeginPlay() { if(Role == ROLE_Authority) SetTimer(3.0, false, 'ServerTest'); }
This time we're using a non-repeating timer with a longer delay.
ServerTest
doesn't need to be changed for this, so let's leave it as it is.Now we need to let the game know that we want
ReplicatedEvent
called whenTestInt
is replicated, so let's put the variable modifier in:var repnotify int TestInt;
Now let's write the
ReplicatedEvent
function:simulated event ReplicatedEvent(name VarName) { if(VarName == 'TestInt') `log("TestInt was replicated!"); }
Compile the code.
Run the server and the client, and hit the trigger.
Now let's take a look at what happened on the server:
[0016.42] ScriptLog: ServerTest: 1
We'll notice that
ReplicatedEvent
wasn...