Can't list received photon data

0 favourites
  • 7 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Friends, through the for loop, I send all usernames with "list" through photon and separate each username with the "_" character. After the user receives a list of all users, these names are added to his "list" again using the "for" loop with tokenat(event.data,loopindex,"_")

    But some names are added 2 or 3 times, that is, they will be added several times. I tried to stop the loop 0.5 seconds after the user names fit in there, but it didn’t work.

    By the way, empty elements were also added to the list, but I deleted them using the "for" loop.

  • Your two loops are nested one inside another, this is wrong. They need to be in separate sub-events.

    Also, never use "Trigger once" in loops.

    It's possible that duplicate player names are received from Photon, to check this you can add Browser Log action to the event.

    I suggest joining Russian C3 group on VK, there are lots of people who have experience with Photon.

  • Thanks to. I have been a member of this group for a long time. But why can’t you use a cycle in a cycle. As I understand it, the for cycle in a cycle where the cycle of the first action can already be completed and stop the "stop loop", then the second one will work without problems. problems arise, again based on my experience, as I understand it, if the first cycle does not end and the second one starts to work, then they intersect.

    And also I want to add that the photon did not send repeated data several times. I understood this by the fact that I output data from the variable into the text into which this data received from the photon "list of all people" was actually recorded

  • If you want to prevent adding empty strings to the list, the second cycle is not really needed. You can just add another condition to the first loop - that the tokenat(....) is not equal "".

    I don't know why there are duplicate people in the list. Either this data comes from Photon, or maybe added to the list somewhere else in your code.

  • There are no other places for sure. I already opened a new test project and there it was this part of my project, and there I also recorded several times

    You can try too

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Noticed another mistake in the "For X" loop - it should be from 0 to tokencount(..)-1

    Other than that I don't know what else can cause duplicate entries in the list. Add console logging to double check that Photon sends the correct data, and that this event only runs once.

  • Noticed another mistake in the "For X" loop - it should be from 0 to tokencount(..)-1

    Other than that I don't know what else can cause duplicate entries in the list. Add console logging to double check that Photon sends the correct data, and that this event only runs once.

    ок

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