Jump to content

Element Data or Tables


Recommended Posts

Hi there. Currently I'm writing large gamemode with smart NPCs and other features that needs a lot of data to be synchronized to all clients. Data update will be very short, I mean a lot of data needs to by sync every ~100ms. Should I use Element Data or may be I need to use one table with data every time sending to all clients? Please give me an advice. Because my current code seems to be really not good for server bandwidth. Also can somebody tell me how to track current bandwidth when scripts running? Thanks.

Link to comment
  • Moderators
31 minutes ago, Thomas_Nightfire said:

I mean a lot of data needs to by sync every ~100ms.

Why not thinking about reduction and faking continuous effects?

Instead of trying to solve the issue at the moment you already created too much data?

 

 

If you are dealing with too much data, the latent trigger event can reduce impact on clients. It is send when the network is free. (+ you need to merge all data in to 1 triggerEvent)

https://wiki.multitheftauto.com/wiki/TriggerLatentClientEvent

Forcing 100ms is more or less killing your network. Better to check the status of the latent event, before sending the next payload of data.

https://wiki.multitheftauto.com/wiki/GetLatentEventStatus

 

 

If you want to have some advice for reduction and faking. I need to know a lot more about the context of the data and a lot of the details (conditions).

 

 

 

 

 

Edited by IIYAMA
  • Confused 1
Link to comment
  • Scripting Moderators
16 hours ago, Thomas_Nightfire said:

Hi there. Currently I'm writing large gamemode with smart NPCs and other features that needs a lot of data to be synchronized to all clients. Data update will be very short, I mean a lot of data needs to by sync every ~100ms. Should I use Element Data or may be I need to use one table with data every time sending to all clients? Please give me an advice. Because my current code seems to be really not good for server bandwidth. Also can somebody tell me how to track current bandwidth when scripts running? Thanks.

I would choose tables, after that what @IIYAMA taught me, i use tables almost everywhere. I feel like tables are very efficient comparing to element data, yet they require more code to sync which imho gives an better control how do you send data.

  • Thanks 1
Link to comment
  • 2 weeks later...
On 29/08/2019 at 19:56, IIYAMA said:

Why not thinking about reduction and faking continuous effects?

Instead of trying to solve the issue at the moment you already created too much data?

 

If you are dealing with too much data, the latent trigger event can reduce impact on clients. It is send when the network is free. (+ you need to merge all data in to 1 triggerEvent)

https://wiki.multitheftauto.com/wiki/TriggerLatentClientEvent

Forcing 100ms is more or less killing your network. Better to check the status of the latent event, before sending the next payload of data.

https://wiki.multitheftauto.com/wiki/GetLatentEventStatus

 

If you want to have some advice for reduction and faking. I need to know a lot more about the context of the data and a lot of the details (conditions).

I'm working with peds and trying to make them "smart". But how I can reduce or fake?

Link to comment
  • Moderators
5 hours ago, Thomas_Nightfire said:

But how I can reduce or fake?

There is 1 important reduction, which is in my opinion the most important one.

"Don't tell the otherside what it already knows."

 

So if you reply to my previous post with a confused reaction. Then I know you did that, but also you know that you did that yourself.

Now we both know that it was a confused reaction and you do not have to tell me that again, because I already know.

 

If we apply that same concept on a smart ped system.

Ped move forwards.

Ped move forwards -- do not repeat

Ped move forwards -- do not repeat

Ped move backwards

Ped stop

Ped stop -- do not repeat

Ped stop -- do not repeat

Ped stop -- do not repeat

 

---‐–––––—————

If we want to fake something, we have to approach that a bit differently.

For example we have a ped which we want to bounce his head up and down.

And yes like this:

41UtItLW32L._AC_SY400_.jpg

Up and down while the car his driving.

If you program this, the only data that should be used, is the on and off state.

When ever the head is up or down, that is irrelevant. The data for the head orientation (up/down) is faked.

 

 

 

 

 

 

 

Edited by IIYAMA
  • Like 1
Link to comment
  • Scripting Moderators
5 hours ago, Thomas_Nightfire said:

I'm working with peds and trying to make them "smart". But how I can reduce or fake?

Not sure if it's related to your case, but IIYAMA showed me how this could be done for onClientVehicleDamage.

For important details, you would need to wait for his answer.

In my case:

Instead of triggering each hit, damage would be saved in table and after certain time, timer would execute triggerServerEvent, after data is cleared. This is called buffer/data reduction (probably?), as far i know.

So, basically you reduce triggerServerEvent calls and you save bandwith.

This might be helpful, it's also IIYAMA code :P 

local sendingDelay = 100 -- ms
local fps = 60

local timeSlice = 1000/fps
local dataReduction = sendingDelay/timeSlice
print("~"..(dataReduction - 1 ).." x times LESS per "..sendingDelay.."ms")

https://www.Lua.org/cgi-bin/demo

edit: great timing :D

Edited by majqq
  • Like 1
  • Thanks 1
Link to comment
15 hours ago, IIYAMA said:

There is 1 important reduction, which is in my opinion the most important one.

"Don't tell the otherside what it already knows."

 

So if you reply to my previous post with a confused reaction. Then I know you did that, but also you know that you did that yourself.

Now we both know that it was a confused reaction and you do not have to tell me that again, because I already know.

 

If we apply that same concept on a smart ped system.

Ped move forwards.

Ped move forwards -- do not repeat

Ped move forwards -- do not repeat

Ped move backwards

Ped stop

Ped stop -- do not repeat

Ped stop -- do not repeat

Ped stop -- do not repeat

 

---‐–––––—————

If we want to fake something, we have to approach that a bit differently.

For example we have a ped which we want to bounce his head up and down.

And yes like this:

41UtItLW32L._AC_SY400_.jpg

Up and down while the car his driving.

If you program this, the only data that should be used, is the on and off state.

When ever the head is up or down, that is irrelevant. The data for the head orientation (up/down) is faked.

If I understood u right then I have anotehr question: if I will reduce calls to server side and will try to fake the effects like not sending things which already sent, I need to check if they already sent? And it's another waste of bandwidth, no?
And the second: If I'll try to fake the effect, there will be a different situtations like: player joined but can't see what can see a player that joined before him.
 

P.S.: sry for my 'wonderful' English.

Link to comment
  • Moderators
8 hours ago, Thomas_Nightfire said:

if I will reduce calls to server side and will try to fake the effects like not sending things which already sent, I need to check if they already sent? And it's another waste of bandwidth, no?

 

8 hours ago, Thomas_Nightfire said:

I need to check if they already sent? And it's another waste of bandwidth, no?

You know that you already send it right? (That is if you did save that information)

Then you do not have to ask it again, which means no extra bandwidth.

MTA messages are always in the correct order delivered because of the TCP data transfer protocol. And they will always be delivered, except when the player timed out and get kicked out of the server.

 

 

8 hours ago, Thomas_Nightfire said:

If I'll try to fake the effect, there will be a different situtations like: player joined but can't see what can see a player that joined before him.

If that has happened then you forgot to register which actions are currently going on in your server and also forgot to send that information to the new joined player.

Edited by IIYAMA
  • Thanks 1
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...