Nilom's Recent Forum Activity

  • Hey there!

    Currently I have a problem with load image from url.

    I have many instances of the same sprite object and want to load different images from url for each of them.

    The very inpractical problem is, that load image from url ignores instance picking. I don't even know why it was designed that way.

    Anyway so when I load an image from url all of the instances will get the same image.

    I read from an old post, that I could use different frames, one for each image. But the problem is that there are a maximum of over 11.000 images and I would need to copy and paste that many frames manually in the editor.

    Isn't there just an easy way like the whole rest of construct is designed around picking instances and only have them manipulated?

  • Hello there!

    I use Ajax to access a servers API. The problem is that I do not receive the data as JSON but as an array.

    It looks like this:

    {"data":[{"id":543422,"name":"This is a name","type":"Normal"}]}

    Maybe I'm stupid but I have a hard time figuring out how I can access for example JSON.Get(".id"). How can I access the JSON data?

    (PS: I hate arrays and love JSON >:O)

    Edit:

    After a lot of testing I figured it out.

    "data.0.id" will access the id in this case.

  • Unfortunately the peer id is a string and not a number and will not be synced.

    I believe that this is the order of things to get it synced correctly:

    1. Host and peer both define the objects that need to be synced.

    2. Host creates the objects that need to be synced or their variables that need to be synced with its owners (players) multiplayer index in a local variable (not id). You get a joining players index with Multiplayer.PeerCount-1 or you loop through every peer and check if the id is matching and the index will be the loop index -1.

    3. Peer: On (synced) object created send a message to the host with this objects local multiplayer index, basically asking the host for information about the player with the given index.

    4. The host then uses this index to get and send all of the information back to the peer. The easiest way to do so would be to use JSON.set all of the information and then JSON.ToCompactString.

    .

    5. When the peer receives this message it will loop through all of the objects and check for the local index variable. If it matches the one from the message it can paste all of the data like id, name, level or whatever you just sent to the objects local variables. Do not forget to parse the JSON data from the message. Then use JSON.Get("").

    .

    This is a bit of a back and forth. If somebody knows a more efficient way please let me know. :D

  • Thank you both for your replies!

    Yesterday while laying in the bed I realized that I need to do this the other way around to have the right order of things happening.

    basically what you said. But not when a peer detects another peer but when it detects the creation of a player frame. This way it is ensured that it will not fire too early as it is the case right now.

    oosyrag Yes I know I should be very considerate with syncing. I sync the player stats so that I do not need to worry about sending all these messages. I think with only up to 5 players it shouldn't be an issue bandwidth wise.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi there.

    Currently I have a lot of hassle. I have to rewrite all of the unit frames creation because of the limitation of syncing variables to numbers only.

    My workaround was to store the players multiplayer index (multiplayer.peerCount-1) in a local variable on the object that I want to sync. They are basically the players character frames where you see their name, hp, mana and so on. After the local variable with the index is created the host will then broadcast a message to the players containing a JSON with alle the information, as well as which player has which index (as I discovered that the players multiplayer index will not be the same between peers).

    The problem now is that When the peers receive this message the sync objects are not created yet. So again it will not work.

    Now I'm having a headache on how to sync all of this. I just want to create a player frame when someone connects.

    I think I might drop all of this and just look into techniques of converting text to a number (double should be enough), just sync it and re-convert it to text on the peers side.

    Any ideas? Thank you in advance!

  • I was about to ask another question about the syncronisation of variables when I saw this topic.

    I had a similar issue just 2 days ago. Just scroll down to my last reply.

    I don't know if it will help you but what did the trick for me is to set the sync object and sync variable events on the host side as well as on peers side too. Before it didn't work for me, but after this it works now.

    Either the syncing must be initialized on both sides or I did something wrong. But either way the documentation is a bit confusing and needs some more clarification or an example on how to set this proper up.

    Also it is kinda sad that syncing variables doesn't work for strings.. .

  • oosyrag When I put the sync initialization events in the common group (active on host and peer) then on random either the host or the peer will have 2 SyncObjects and the other one will have one. Even when I only drag and drop one SyncObject on the layout inside the editor.

    I can further troubleshoot that later but maybe someone already sees the solution.

    eleanorjmorel About the date.now yeah I could possible do that but I need a working SyncObject anyway for other stats so I will just focus on finding a solution for syncing local variables. But thank you for the advice. Always good to know alternatives.

    .

    Edit:

    Okay I got it to work.

    For everyone having the same issue:

    You must set the multiplayer sync object events on both the host and the peer side, even if that seems counter-intuitive and the documentation doesn't mention this. I thought the multiplayer object would be smart enough to tell the peers which objects to sync if it sends them updates of their states. After I set that up I was able to create the SyncObject object with the eventing system and it was then created on the peers side and everything is working now.

  • Hello there!

    For my game, after the host pressing start in the lobby I want to have a 5 second countdown so the players can prepare for the game to start.

    To not get out of sync I do not just use a multiplayer message for the timer to start, but instead I use an invisible sprite object that I named SyncObject. It will have instance variables that I want to keep in sync with all of the, up to 4, other peers with the sync instance variable feature.

    The first problem I face is that this SyncObject object will not be created on the peers side If I create that object on the host side. It will only be created if I drag and drop the SyncObject inside the editor on the layout, but not if I create it inside the eventing system with create object.

    The second problem is that although I drag and drop the SyncObject and it will be created on the peers side the instance variable will just not sync.

    When the timer is started I set the timer variable of the SyncObject to 5 on the host side and after every 1 second I substract 1 from it. But it remains 0 on the peer for the whole duration.

    What am I doing wrong? As always, thanks in advance!

  • Thank you for your detailed reply.

    Maybe I overcomplicated my question with too much detail.

    My wish:

    Please mark strings in the Debugger with " " like in the editor or programming languages. That would make troubleshooting easier.

    But you are right it is not a bug and I will instead request it as an idea/feature in the thread you linked.

  • I tried it and it worked without using a function. When I put Wait 0 or Wait for previous actions to complete it will have the correct peer count.

    Thank you!

  • Hello there.

    For the ready check of my game I was trying to do the following logic:

    On peer disconnected {
    	If peer count = 1 {
    		Destroy Ready Button
    	}
    }
    

    Because if there are no other players there is no need for a ready button. The problem is, inside On peer disconnected it will still count the disconnected peer(s).

    For example:

    There are two players. Host and peer. The peer disonnects. Hosts On peer disconnected will trigger. Inside I have an Browser Alert Multiplayer.peerCount. It shows 2 although the second player just got disconnected.

    Is this a bug or intended? As that makes some if player leaves change stuff things difficult. Thanks in advance.

    Edit:

    This is my temporary fix. It works, although it looks funny. :D

    Multiplayer.PeerCount -1 = 1

  • Hey there!

    While testing the "ready-feature" before game start, where the host can only start the game after every player is ready, I had quite problems figuring out why it didn't work.

    Then after some time I realized that in the dictionary that I use to store values, every players ready-key had a value of "1" (string) and the hosts value was 1 (number).

    That happened because only strings can be sent through multiplayer and while doing the local stuff I accidantally put a number instead of a string for the ready value.

    But the unfortunate thing is, that I could not see that in Debug Mode. I almost thought I'm stupid or something because the dictionary values cleary showed a 1 on every of the keys.

    Is it possible to indicate strings with " " inside the debug mode, like usually? Thanks.

Nilom's avatar

Nilom

Member since 26 Dec, 2019

Twitter
Nilom has 1 followers

Trophy Case

  • 4-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

9/44
How to earn trophies