How do I Access a Peer's global variables

0 favourites
  • 10 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • In my multiplayer game I want players to be able to pick their characters so in the beginning they pick one and it's stored as a number in a global variable, how can I have the host access it?

  • https://www.scirra.com/manual/174/multiplayer

    [quote:dnm45pzo]Send message

    Send a message to a specific peer with a given reliability mode. Peers can only message the host (and the Peer ID field must be left empty), but the host can send a message to any peer. Message tags can be used to identify messages for different purposes, such as "chat" or "gameplay-event". The message must be a text string, but could also be JSON data such as from an Array or Dictionary AsJSON expression; however be sure to avoid wasting bandwidth. The order messages arrive, or whether it is guaranteed to arrive at all, depends on the reliability mode.

  • I tried on signaling room joined, send a message to the host with a number for it's tag depending on the character picked and when the host receives a one of those numbers to spawn a corresponding character but that didn't work. How should I code it?

  • The tag isn't meant for sending the data, just for identifying the type of message. You should put data you plan to use in the message itself. If it is a number, use int() to convert it back to a number from the data string after you send it.

  • Ok, I have that when you're not the host send a message to the host with the value for the player you picked before.

    For the host it says that when it gets that message to set the global value character to int(multiplayer.message) and then it checks what the global variable is to spawn a character but that doesn't seem to work either

  • I won't be able to diagnose much further without seeing the debug.

    Can you check if the host is receiving the message and setting the variable on the host to the correct value? Also confirm that the host is able to spawn a character on its own properly based on a static variable.

  • Ok I'll check that stuff out and if it still doesn't work I'll post a capx

  • The issue seems to be that if I try to use on peer connected as a trigger the message doesn't send

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think on peer connected, as the peer, will not trigger. It seems like on peer connected is for the host to know when a peer connects. For the peer, I think you want to use On Joined Room.

  • Hmm that doesn't seem to work either but I figured a way around it

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)