Let's keep working with AwesomeWeaponUpgrade
, and add in some variable replication.
First let's add a new variable to the class:
var int TestInt;
Now let's write the replication block. We've already discussed
bNetDirty
, which we'll be using here. If any replicated property is changed,bNetDirty
will be set to true. We need to let the game know that our variable needs to be replicated in that case.replication { if(bNetDirty) TestInt; }
Now for
PostBeginPlay
. We'll leave it as simulated, but we'll call different functions for the client and the server.simulated function PostBeginPlay() { if(Role == ROLE_Authority) SetTimer(1.0, true, 'ServerTest'); else SetTimer(1.0, true, 'ClientTest'); }
function ServerTest() { TestInt++; `log("ServerTest:" @ TestInt); }
simulated function ClientTest() { `log("ClientTest:" @ TestInt); }
Now compile the code.
ServerTest
will only be called...