SpiderMonkey Client/Server sync

I am trying to make a multiplayer game, and from what I understand from https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
I need to send the tick that the program is in so when the other gets the packet it knows when it happened.

psudo code
server:

private long startEpochTime = System.currentTimeMillis();
private float time = 0;
public final float tps = 64f;
public final float secondsPerTick = 1 / tps;
public int currentTick;

public void simpleUpdate(float tpf){
    time += tpf;
    currentTick = (int) (time / secondsPerTick);
    //send message
}

public void connectionAdded(Server s, HostedConnection c){
    SendMessage(startEpochTime);
}

client:

public float time = 0;
public int tick = 0;
public float tps = 64f;
public float secondsPerTick = (1 / tps);

messageRecieved(Message m){
    time = System.currentTimeMillis() - m.getEpochTime();
}

public void simpleUpdate(float tpf){
    time += tpf;
    tick = (int) (time / secondsPerTick);
    //send message
}

is this convoluted? I would think that there would be a default way to sync but I couldnt find it. Thanks for the help

Okay … what is your goal, what do you need it for (later)?

Default way to sync what? If you mean object syncing… which of the dozens of trade offs should we have picked? ie: which games should have supported by default and which games should we have left out in the cold?

Anyway, there is an add-on library that does a lot of the work for you.

It’s pretty efficient.

You can find prebuilt examples here:

And an ES version of that example here:

My apologies, I was just being dumb. I have no idea what I was thinking Thanks for dealing with me :slight_smile: