How do I sync player's 'equipped' items in multiplayer?

Get help using Construct 2

Post » Thu Mar 05, 2015 12:28 am

Say I'm building a persistent-world RPG with standard 'paper doll' equipment layered over the base player form. Some of this equipment is merely visual; some of it affects player stats. Generally, I would imagine the best way to store what equipment the player is using is via global variables, since my game will take place non-linearly across a large number of layouts.

However, that would be a problem when it comes time to connect to another peer and 'go multiplayer'; the host (another player, not a central host) has values of their own for these variables.

I can imagine two ways of handling this:

1. Have instance variables on the player object that mirror the relevant data from the global variables upon entering the layout, then copy this information over when the player enters the multiplayer space as a peer.

2. Transmit only the player's 'user ID'. The host then uses that user ID to contact the central character database and retrieve the relevant stats/information about each player.

Or perhaps there's a third and better way I haven't thought of yet?

Let me know what you think of this plan!

Best,
Joe
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Thu Mar 05, 2015 4:44 am

I'm also curious about this. I set my items up as sprites though, and they go in itemslots, which are also sprites. I'm a little wary of this setup, as I'm not sure what kind of problems I might run into down the road. I admit its a little odd to keep them as physical objects instead of abstractions.

Anyway I can see a multiplayer scenario where the host has dozens of ItemSlots, all associated with different players, invisible and not synced with each client. The "paperdoll" sprites, as well as any attacks etc., will of course be synced to each client.

It seems like only your Option 2 is really secure? It seems like using a player's own data in a multiplayer scenario is likely to be subject to manipulation of some kind.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Thu Mar 05, 2015 4:56 am

bladedpenguin wrote:I'm also curious about this. I set my items up as sprites though, and they go in itemslots, which are also sprites. I'm a little wary of this setup, as I'm not sure what kind of problems I might run into down the road. I admit its a little odd to keep them as physical objects instead of abstractions.

Anyway I can see a multiplayer scenario where the host has dozens of ItemSlots, all associated with different players, invisible and not synced with each client. The "paperdoll" sprites, as well as any attacks etc., will of course be synced to each client.

It seems like only your Option 2 is really secure? It seems like using a player's own data in a multiplayer scenario is likely to be subject to manipulation of some kind.


Option 1 can be secure as well as long as you occasionally sanity-check against the saved character data on the server... there are various ways you could 'append' security onto something functional after the fact. Option 1 might be the better bet, though.

Edit: I worry about setting up your items as sprites, because then that would create all sorts of limits on what you can do with that information; seems easier to set your items as data stored somehow (an array? a series of simple variables?) and then set the item slots to be sprites that display a different image (using animation frames perhaps?) to visually indicate what's in that slot according to the variable it's set to.
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Fri Mar 06, 2015 11:39 am

For example, you can add variables to player with names "pants_id", "weapon_id" and etc. Sync that variables. And when client connects it creates and pin clothing sprites on other players by checking they id's.
Creator of MiniDayZ
B
22
S
2
G
2
Posts: 69
Reputation: 1,846

Post » Tue Apr 14, 2015 3:53 pm

I have done this @Farsight, but once it syncs all the containers sprites go insane.
Even after applying the "every tick: move to layer(x)" patch.
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

Post » Thu Apr 16, 2015 7:00 am

Image


So this is how Im doing it. Peer variable changes graphic for a blank object pinned to the player. This method displays correctly what object the peer is holding to all other peers.

Since you are also working on an online game. do you know how to make an object be permanently destroyed. Like if host destroys object then it is not created on peer side when logging in.
B
10
S
1
Posts: 57
Reputation: 639


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u, jhjconstruct and 11 guests