1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Asset - Scripts ZNet - Easy to use, entity-based networking framework!

Discussion in 'Marketplace' started by Zek, Nov 1, 2017.

  1. Zek

    Zek Member

    Jun 20, 2016
    Game Maker: Marketplace
    Price: $1.99
    Cross-Platform (Except for HTML5)

    Networking can be hard and time-consuming, especially for beginners.

    ZNet is a lightweight, cross-platform, networking framework for making multiplayer games a lot easier to create!

    The main focus when developing ZNet was to make an easy to use entity system.
    With this system you can easily create NPCs, enemies, etc... without writing a lot of extra code.

    Here's an example of how you would go about creating a simple enemy:
    znet_entity_create("enemy_type", "enemy_id", "x", 0, "y", 0, "hp", 100).
    You simply specify the entity type and the entity id, followed by a set of defined keys.

    With ZNet you can easily get the state of a client/server, making error handling a lot simpler!

    ZNet works on every platform, except for HTML5.

    ZNet also handles a lot of things such as:
    • Checking if the client is still connected to the server.
    • Better way of checking if the server if full.
    • Version checking.
    • Using both a client and a server in the same room.
    • Getting the ping of a client.
    • And more!
    Click here to download a platformer and chat demo.
    Click here for documentation and a list of all the features that comes with ZNet.
    Last edited: Dec 26, 2019
    Shadowblitz16 and slojanko like this.
  2. Shadowblitz16

    Shadowblitz16 Member

    Jun 23, 2016
    can you explain how znet_create_entity() and znet_entity_attach_client() works?

    it looks like they automatically syncs the variables you pass it to the other client's instances but I don't actually see where your passing in the instance or object
    Last edited: Jun 19, 2018
  3. Zek

    Zek Member

    Jun 20, 2016
    Sorry for the late reply! For some reason I never got a notification.

    Entities are not actually objects. They work similarly to how ds_maps works, you give them keys and assign values to them.
    So for example:
    znet_entity_create("enemy", "enemy_0", "x", 320, "y", 240, "hp", 100);
    When creating a entity you first need to set the entity_type and the entity_name.
    Here we give the entity a type of "enemy". This can be useful if want to get all the entities that is an enemy.
    Next we set the name of the entity. This basically acts as a unique identifier for that entity.
    The following arguments are keys that we can give to the entity. Think of them as variables. Here we set the x, y position to 320, 240 and the hp to 100.
    The keys will also be automatically synced now. So whenever you modify a key ZNet will automatically handle everything.

    znet_entity_attach_client basically attaches an entity to a specific client, meaning that once the client disconnects, that entity will also get destroyed. I added this because destroying an entity in the Game End event won't work. This would only really be useful for player entities.

    Feel free to ask if there's anything else you need help with. :)
  4. Zek

    Zek Member

    Jun 20, 2016
  5. Marko03970

    Marko03970 Member

    Mar 25, 2017

    Hi there,
    I just want to ask, did you test it on android and ios?

  6. yokun51

    yokun51 Member

    Sep 22, 2019
    Hello, I know that this framework is not new, but I am starting to use it. I notice that each time I send a packet, the ram increases without ever going down, is this normal and how to solve this problem?

Share This Page