Thomas_Nightfire Posted August 29, 2019 Share Posted August 29, 2019 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 IIYAMA Posted August 29, 2019 Moderators Share Posted August 29, 2019 (edited) 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 August 29, 2019 by IIYAMA 1 Link to comment
Scripting Moderators ds1-e Posted August 30, 2019 Scripting Moderators Share Posted August 30, 2019 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. 1 Link to comment
Thomas_Nightfire Posted September 12, 2019 Author Share Posted September 12, 2019 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 IIYAMA Posted September 12, 2019 Moderators Share Posted September 12, 2019 (edited) 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: 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 September 12, 2019 by IIYAMA 1 Link to comment
Scripting Moderators ds1-e Posted September 12, 2019 Scripting Moderators Share Posted September 12, 2019 (edited) 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 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 Edited September 12, 2019 by majqq 1 1 Link to comment
Thomas_Nightfire Posted September 12, 2019 Author Share Posted September 12, 2019 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: 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 IIYAMA Posted September 13, 2019 Moderators Share Posted September 13, 2019 (edited) 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 September 13, 2019 by IIYAMA 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now