SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 29/12/2018, 07:32 AM   #1
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 878
Reputation: 313
Default synchronizing information sent by clients

At IRL time T, player A shot player B. The player A sends information to the server about the shot (and other information) which is received by the server at time X. Player B keeps sending information every now and then.

In IRL time T, the player A had some state information (includes player B's state based on which B is rendered on A's screen). Player A's state at IRL time T is received at the server at IRL time X. I somehow need to find out the state of player B as seen by A.

What are the approaches to solving this problem of synchronization?

The player B continuously informs B's state to the server which is relayed to other nearby players based on which things are rendered on their screen. If I were to store the state information relayed by B in an array. How can I efficiently pick the correct state information of B that corresponds to the event that happened at T on A's screen?
Yashas is offline   Reply With Quote
Old 29/12/2018, 09:05 AM   #2
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,703
Reputation: 3226
Default Re: synchronizing information sent by clients

Short answer: You can't, not perfectly. Time T is time X - lag, but lag for that one packet, which varies minutely between packets (this variance is called jitter). The same happens to the data coming from B, AND the state of B being sent to A. The best you can do is interpolate based on average pings over a short sliding window. Fortunately this is very common - this is exactly what lag compensation is, so there's lots of information available.
Y_Less is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] synchronizing shoots fatlirmorina Scripting Help 3 17/04/2017 03:58 AM
Custom clients h4Xz0R Client Support 0 09/02/2014 05:36 PM
De-synchronizing. iGetty Scripting Help 3 15/11/2012 04:23 PM
[Tutorial] Synchronizing variables in includes KingHual Tutorials 2 29/09/2012 10:28 PM
synchronizing problem BeBest Help Archive 2 10/03/2009 11:30 PM


All times are GMT. The time now is 05:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.