Jump to content

Question regarding element datas


n0body

Recommended Posts

I know that element datas generate a lot of network traffic, but i need to sync (many) things with the clients.

Lets say that i have 20 element datas (that's not the actual number, just an example)

setElementData ( player, "data1", ... ); 
setElementData ( player, "data2", ... ); 
setElementData ( player, "data3", ... ); 
setElementData ( player, "data4", ... ); 
... 

This can cause issues, but what if i do something like this:

table = { 
    ["data1"] = "x", 
    ["data2"] = "y"; 
    -- etc 
} 
  
setElementData ( player, "data", toJSON ( table ) ); 

Is this possible ? Is it effective ? If yes there's a limit regarding the string lenght ?

Hope that someone can answer my questions :)

Link to comment
  • Moderators

It depends what kind of things you store in it. Elementdata is for sync data with all clients, which you only want to use for letting all player know that one specific player has 60 fps. When it comes to how much "items" a player caries, elementdata would totally ruining your server. You don't want/need to let other players know that information. Waste of your bandwidth if you ask me.

Your question: many elementdata vs one big

Every time you update the key "data", all players in your server have to re-download the elementdata.

Is a big elementdata efficient? No, it is exactly the opposite.

But there is one exception, if the elementdata has to be downloaded only ones, it might be more efficient.

Link to comment
It depends what kind of things you store in it. Elementdata is for sync data with all clients, which you only want to use for letting all player know that one specific player has 60 fps. When it comes to how much "items" a player caries, elementdata would totally ruining your server. You don't want/need to let other players know that information. Waste of your bandwidth if you ask me.

Your question: many elementdata vs one big

Every time you update the key "data", all players in your server have to re-download the elementdata.

Is a big elementdata efficient? No, it is exactly the opposite.

But there is one exception, if the elementdata has to be downloaded only ones, it might be more efficient.

My plan was update the element data sometimes, i'll try to use events to reduce the amount of element datas, thanks for the information :)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...