SyncVariable

void SyncVariable(int tid, num value)

num - any numeric type (int or fixed)

Description

Synchronizes an arbitrary numeric variable from server to all clients. The synchronized value can be retrieved using GetSyncVar and GetSyncVarDefaut. If SyncVariable is called twice with the same value, no network traffic happens.

This function works by spawning an undetectable indestructible actor and using its Speed property to synchronize the value.

You can't synchronize strings this way. To synchronize strings, use a custom serverside string cvar in CVARINFO.

Examples

This function is intended to be used every tic in a single serverside OPEN script:

script "SyncVariables" OPEN
{
SyncVariable(TID_LIVESCOUNT, Lives);
SyncVariable(TID_LIVINGMONSTERCOUNT, LivingMonsterCount());
SyncVariable(TID_LIFEGAIN, GainedLives);
Delay(1);
restart;
}

This makes property synchronization immediate and efficient (no net traffic when no property changes happen).