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

Zek

Member

Game Maker: Marketplace
Itch.io
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:
S

Shadowblitz16

Guest
@Zek
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 by a moderator:

Zek

Member
@Zek
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
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. :)
 

yokun51

Member
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?
 
J

JustBeuno

Guest
Hello. I've sent multiple PMs asking for assistance and haven't received anything back past the initial message. Can you please clarify how you're able to spawn an instance (or alternatively, how an entity has an instance ID) with this system of entity keys.
 
Hello, i am trying to develop my first online game so, i bought this library, i have a question , if i use znet_entity_set_keys("player_1", "x", 320, "y", 240, "hp", 100) , can i use custom keys? eg: znet_entity_set_keys("player_1","x",310,"y",240,"hp",100,"points_to_achieve",500,"another_var",1000);

Please, HELP!
 

Zek

Member
Hello, i am trying to develop my first online game so, i bought this library, i have a question , if i use znet_entity_set_keys("player_1", "x", 320, "y", 240, "hp", 100) , can i use custom keys? eg: znet_entity_set_keys("player_1","x",310,"y",240,"hp",100,"points_to_achieve",500,"another_var",1000);

Please, HELP!
Yes! Any key name would work fine. :D
 
Yes! Any key name would work fine. :D
So! if i create an entity like this: znet_entity_create("player", nickname, "x", -100, "y", -100,"strength",10000); these keys can be manipulated later using
znet_entity_set_keys("player", "x", 320, "y", 240, "strength", 15000); right?

This means that we create keys when entities are created, right??
 

Zek

Member
So! if i create an entity like this: znet_entity_create("player", nickname, "x", -100, "y", -100,"strength",10000); these keys can be manipulated later using
znet_entity_set_keys("player", "x", 320, "y", 240, "strength", 15000); right?

This means that we create keys when entities are created, right??
Yup you're completely right! They're kinda like the "variables" of the entitiy.
 
J

John

Guest
How do I make an enemy that both characters can interact with? For example right now I can only create a boss on each player's games so the two bosses are disconnected resulting in the players being able to see each other but interacting with two separate enemies.
 
Top