Skip to content

Synchronize water wave phase between clients - #5380

Open
Xenius97 wants to merge 3 commits into
multitheftauto:masterfrom
Xenius97:new/water_wave_sync
Open

Synchronize water wave phase between clients#5380
Xenius97 wants to merge 3 commits into
multitheftauto:masterfrom
Xenius97:new/water_wave_sync

Conversation

@Xenius97

Copy link
Copy Markdown
Contributor

Summary

Synchronize water wave phase using server timestamps appended to existing map-info and return-sync packets.
Clients advance the phase using elapsed real time and smooth timing corrections.
Closes #2536

Motivation

setWaveHeight synchronizes wave amplitude, but GTA calculates wave phase using each client’s local game timer. Players can therefore see different waves.

Test plan

  • Connect two clients and set server-side setWaveHeight(2).
  • Compare waves at identical coordinates with one client at 30 FPS and another at 90 FPS.
  • Repeat after reconnecting, minimizing a client and introducing network latency.
  • Check swimming, boat buoyancy and custom water polygons.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@starfleet001

starfleet001 commented Sep 12, 2026

Copy link
Copy Markdown

This is a good idea. Great job!

I think it makes sense to expose "serverTime" to Lua. This way developers can use the same time variable to sync other things created in scripts. This will eliminate the need to sync server time using events.

Similar approach could be used to sync randomly generated grass between clients. Like syncing server start tick and using it to generate grass (obviously it will not be random anymore but that is the point).

@FileEX

FileEX commented Sep 12, 2026

Copy link
Copy Markdown
Member

PR #4821 introduces synchronized time, but it isn't available in Lua.

@starfleet001

Copy link
Copy Markdown

PR #4821 introduces synchronized time, but it isn't available in Lua.

Maybe it's a good idea to make synchronized time a separated system with Lua interface. And then other features will use this time variable (like your animations sync PR and this PR).

@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Id love to have server time in client side Lua. In milliseconds if possible, for precise synced operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synchronize water waves

4 participants