How do I Multiplayer Global variable sync

Get help using Construct 2

Post » Wed Mar 26, 2014 8:15 am

Hi all,

I need some help about multiplayer object.

I would like to know the best way to make that each peer know his connected number: for exemple host is player: 1, the first peer logged is player: 2, the second peer is player: 3..., and put this value on a instance variable.

I don't find an inbuild variable which cover this.
So, I think create a global variable (integer) and send it from host to peer with "send message" function is a good way.
What do you think?

Is it possible to send an integer in "send message" fonction?
What I've test:
In the host block, On trigger "on peer connected", I use a multiplayer object with "send to peer" fonction (tag=toto), I send the int value of the global variable.
In the peer block, On the trigger "on peer message "toto", I affect the instance variable with multiplayer.message. witch must contain global variable value.
Then the instance variable receive a "nan" value... iven if I force the global variable with STR function before sending.

Thanks for your help.
Regards
B
5
S
1
Posts: 10
Reputation: 595

Post » Wed Mar 26, 2014 9:01 am

Use the system expression int(Multiplayer.message)
With int() you can convert a string to an int.
And with str() you can convert an int to a string.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Mar 26, 2014 11:47 am

Thx for your reply,
So no "multiplayer" variable that coud be use to simplify that?
B
5
S
1
Posts: 10
Reputation: 595


Return to How do I....?

Who is online

Users browsing this forum: divsyntax, pmerineau and 11 guests