.:[STICKY]:. How to sync clients (States & Vars)

Tutorials and guides for Plazma Burst and community features.

.:[STICKY]:. How to sync clients (States & Vars)

Postby Max teabag » 17 February 2018, 22:32

You joined a match.
You see that guest-23487 is walking straight through a door that is closed.


This is the most acient problems in PB2.

The reason is that timers, triggers and regions's states are client-sided.

Region activation, e.g when a player presses a button, it will send a message to every other client in that match saying "Hey guys, I just pressed a button!" Then your client will be like "Oh okay, let me run my client-sided trigger!"
That's all nice and stuff, until you join the game after someone else. The guest presses the button, tells everyone, and then you join afterwards, since you didn't get the message, we will have an unsynced state. That's why you see the guest walking through the door.

Asynced states is not the bad, they're actually quite nice.
Consider a timer, that activates a trigger that sends out a text "Welcome to my map!"

You don't want to see that message every time someone joins a map, only when you do. That's why It's nice the timers/triggers are client-sided.

However, some things should be synced up with everyone, like the door example, or an ammo system, or countless any examples. Until this day, we just had to suck it up. Now I found a solution.

We're about to break out of the matrix.
__________________________

We can exploit the fact that:
--- Players/character's health are synced up automatically. Otherwise, killing maps wouldn't be possible. ---

We can therefore, place a character in an isolated corner in the map, and then set the character's health to a specific value.
Every client will be constantly checking the character's health, and then check if it's a certain value, if it is, do an action. In other words, character-health is the channel that clients can communicate through.

A little demonstration:
http://plazmaburst2.com/level_editor/ma ... synced&a=#
_________
To sync states, use the "Shared stated" pattern: https://prnt.sc/ig6gdw
Last edited by Max teabag on 20 February 2018, 10:56, edited 3 times in total.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby lostmydollar » 17 February 2018, 23:46

god, i don't understand anything... but i'll try to figure it out. good job finding the solution!

-edit- your map doesn't synchronize the state of the door. tried it in DM mode, rejoined a couple of times after opening the door. doesn't work
User avatar
lostmydollar
Falkok [250]
 
Posts: 276
Joined: 11 April 2017, 17:36

Re: How to sync clients (States & Vars)

Postby Max teabag » 19 February 2018, 00:22

lostmydollar wrote:god, i don't understand anything... but i'll try to figure it out. good job finding the solution!

-edit- your map doesn't synchronize the state of the door. tried it in DM mode, rejoined a couple of times after opening the door. doesn't work


Thx for reporting. After a closer look I found that character-health is not as reliable as player health, so I updated the source map using player health instead. (Using character health IS possible, but I haven't been able to determine WHEN the character health is synced.)

The example map is a very crude example and it shouldn't actually be done in this way in a real game.
The match it-self does not store the data. However, the game syncs after the slot_0 players right now.
For example:
#1) Player_1 create the match
#2) Player_1 opens the door (his health updated to 129).
#3) Player_2 joins the match. (Since Player_1 health is 129 --- open the door) = Synced states.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby lostmydollar » 19 February 2018, 11:31

Max teabag wrote:Thx for reporting. After a closer look I found that character-health is not as reliable as player health, so I updated the source map using player health instead. (Using character health IS possible, but I haven't been able to determine WHEN the character health is synced.)

The example map is a very crude example and it shouldn't actually be done in this way in a real game.
The match it-self does not store the data. However, the game syncs after the slot_0 players right now.
For example:
#1) Player_1 create the match
#2) Player_1 opens the door (his health updated to 129).
#3) Player_2 joins the match. (Since Player_1 health is 129 --- open the door) = Synced states.

so basically syncing up requires presence of player_1 in the game? and it won't work if player_1 leave it? there is also a need to play with his health all the time which won't be quite comfortable for him. especially in combat maps with fall damage enabled

i'm too noob to improve the system. hope you'll be able to do it
User avatar
lostmydollar
Falkok [250]
 
Posts: 276
Joined: 11 April 2017, 17:36

Re: How to sync clients (States & Vars)

Postby Max teabag » 19 February 2018, 15:43

You are correct.
To address this problem, you could always sync up the states from the lowest slot player whoms health is not 0. (Health = 0 means he's not in the game).

I used player-health in my example, but character health IS possible.
Using a character-health (enemy/ally NPC), you will solve both problems you just addressed,
a demonstration using character health can be viewed here: (By Mac Tonight)
http://plazmaburst2.com/level_editor/ma ... t-ajkwrkar
(In case it gets unpublished --- It's exactly the same as MT-Synced, just that it uses enemy health above the map instead)
It seems to be working perfectly. But the making of MMO_arena, I resorted to player-health instead of character-health to save the "Golden helmet" state, because it was more reliable.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby lostmydollar » 19 February 2018, 16:48

Max teabag wrote:You are correct.
To address this problem, you could always sync up the states from the lowest slot player whoms health is not 0. (Health = 0 means he's not in the game).

I used player-health in my example, but character health IS possible.
Using a character-health (enemy/ally NPC), you will solve both problems you just addressed,
a demonstration using character health can be viewed here: (By Mac Tonight)
http://plazmaburst2.com/level_editor/ma ... t-ajkwrkar
(In case it gets unpublished --- It's exactly the same as MT-Synced, just that it uses enemy health above the map instead)
It seems to be working perfectly. But the making of MMO_arena, I resorted to player-health instead of character-health to save the "Golden helmet" state, because it was more reliable.

yeah Mac's map works. but it requires at least 1 player to stay in the game. i guess original version of MT-synced worked too. just had to test it out with someone who could stay in the game. couldn't do it earlier because first thing the newcomer does is pressing all the buttons he sees instead of answering my questions.

i want to sync a multilevel elevator, but this system doesn't seem suitable for it. so if you find a way to sync stuff without using continiously called triggers and moving doors, that'd be great. maybe URL trigger can help with this?
User avatar
lostmydollar
Falkok [250]
 
Posts: 276
Joined: 11 April 2017, 17:36

Re: How to sync clients (States & Vars)

Postby Max teabag » 19 February 2018, 17:31

Yep, this thing was just so everyone in your match sees the same things that they're supposed to see.

Saving permanent data is a whole different thing. I'm not too sure what you mean about a multilevel elevator, but max teabag-database_api (Opensource) may save permanent data in your map, from there you can combine it with the sync-system I described here, so make a synced-perma-data system. lol.

The way that would work is the player would constantly fetch the new map-state from the database.
Then all multiplayer-matches would share the same "state"
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby ChaoSquid » 20 February 2018, 02:21

Max teabag wrote:Protip: Use the trigger "Set character 'A' health to variable 'B'" for syncing up variables easily.


Did you mean "Set value of variable 'A' to hitpoints value of player 'B'"? Or is there a trigger to set a character's health to a variable that I just haven't seen yet?
Lazy innanet man who like, does stuff, sometimes.
My steam account's name is ChaoSquidingus.
User avatar
ChaoSquid
Cyber Grub [25]
 
Posts: 27
Joined: 23 November 2017, 15:34
Location: Last Place

Re: How to sync clients (States & Vars)

Postby Max teabag » 20 February 2018, 11:01

ChaoSquid wrote:
Max teabag wrote:Protip: Use the trigger "Set character 'A' health to variable 'B'" for syncing up variables easily.


Did you mean "Set value of variable 'A' to hitpoints value of player 'B'"? Or is there a trigger to set a character's health to a variable that I just haven't seen yet?


Sorry this is quite a messy tutorial, I misread the trigger-action type ... So scratch that.

Ditzy pointed out that you can sync up using player-teams to sync up states.
That would be perfect for DM game modes, but not TDM-Coop game modes.
You escape the team limit 0-20 by using the text editor.

---

There are three ways a game can get unsynced:
#1 Players join later than others
#2 Continue executing trigger if current player = X
#3 URL-trigger response that is based on the player-login

You can fix #1 entirely by using character-health. If you are not using any "current-slot-specific" triggers or URL-actions based on the player-login, then character health is definitely the way to go.

Otherwise, you will be in trouble.
http://prntscr.com/ihx5m5
(On the left: slot 0, on the right: slot 1)
Trigger set character health to 1 only if current slot = 0.
The result was the other client is now unsure about the health of the character, and therefore produces random health values

It's a different story about player-health and teams.
These are the most secure and stable but can disturb gameplay.
If a trigger changes the team/health value of all players if the current slot is 0, we will have a disagreement/async again. However, each client is the boss of their own health/team, and have the final say.
Therefore, I can't "secretly" change your health/team value without telling you. BUT, I can change mine.

If everyone is initially the same team, and if someone "secretly" changed their team value, other players can detect that their team is not equaled to his team.
Then, if they are unequal, then change to his team.
To check who should change to whom's team, each client should have a "wasLatestChange" variable = true, whenever you made the last change.

I will make a OS-map with this, demonstrating.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby Dandamage » 18 March 2018, 19:29

Topic stickied due to usefulness. Good job, Max teabag. I'm sure it will help out many map makers.
User avatar
Dandamage
Android T-01187 [200]
 
Posts: 234
Joined: 15 August 2015, 15:01
Location: dandamage

Re: How to sync clients (States & Vars)

Postby Max teabag » 9 April 2018, 20:20

^ Thanks. There seems to be a lot of discussion among some map makers about this. And I'm too often receiving complicated questions about this issue.

But, a thread like this shouldn't really be stickied. This is a guide how map-makers can use ridiculous methods to accomplish something widely desirable, but a part of the reason I made the topic was to shed light on the issue. The fact that this will help many map makers is a problem in itself.

My suggestion to the problem would be a trigger like: "Set multiplayer match variable 'A' to value 'B'"
The variable will be set for everyone in the room regardless if the message/rpc went through the trigger-logic(continue trigger exec.. if current player)... to perform that action.

The technology is already here with player teams and player health. It's just really annoying and hard to use.
Assuming the networking is peer-to-peer, the match-variable will stay alive as long as there are players in the match, and will be reset once the match is empty.
Last edited by Max teabag on 26 April 2018, 08:37, edited 1 time in total.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (Summen like that)

Postby SM_D » 15 April 2018, 19:26

So player/character health is the only up-to-date variable that remains fetched frequently across client-server?
User avatar
SM_D
 
Posts: 1
Joined: 4 March 2018, 12:56

Re: How to sync clients (Summen like that)

Postby Max teabag » 26 April 2018, 08:40

SM_D wrote:So player/character health is the only up-to-date variable that remains fetched frequently across client-server?


Other than those, I've only tested player-team. I would assume player-position is synced in some form, but not very accurately.
Max Teabag
User avatar
Max teabag
Usurpation Soldier [50]
 
Posts: 85
Joined: 15 July 2013, 13:41

Re: How to sync clients (States & Vars)

Postby GiraRay » 26 April 2018, 11:14

I made a nyove-rocket copy called nyeve-rocket where you start out with certain cheats that only affect you (i.e. 0 dmg rockets, no swords, increased game speed, etc.) The other players don't have access to these effects and neither are affected by them since they are client-sided only to the player/s that were there when the game started.

However, you can use a command that brings you to a certain area (you are brought into this area when the game starts, giving you the cheats) which gives every other player access to less powerful cheats, exploiting the fact that player location is server-sided.

I never thought about the HP. It's definitely a much easier and stable way of syncing the game with other clients. Once again; good job Max!
http://plazmaburst2.com/?s=9&a=&m=giraray-riddle1&id=826345
User avatar
GiraRay
Usurpation Soldier [50]
 
Posts: 72
Joined: 25 June 2015, 16:26


Return to Tutorials

Who is online

Users browsing this forum: No registered users



cron