Axel Posted October 16, 2017 Share Posted October 16, 2017 Our server went over a peak of 205 players, and has constant 150, and lag has become a serious problem. What are some tips you, reader, can give me to reduce lag, loading time, etc on a crowded sever with lots of objects, vehicles, etc? 1 Link to comment
WorthlessCynomys Posted October 16, 2017 Share Posted October 16, 2017 Local variables, computing on client side (balanced), reducing the amount or the size of changed models, improving the server pc, optimizing code, setting unused variables to nil etc Link to comment
Moderators Popular Post IIYAMA Posted October 16, 2017 Moderators Popular Post Share Posted October 16, 2017 (edited) Always a solution: Reduce elementdata updates. Every time you call setElementData(without disabling synchronization), it will send data. (even if the value is the same) I often see people do this: (clientside) addEventHandler("onClientRender", root, function () local data = "random data" setElementData(localPlayer, "key", data) end) He, Frame 1: please update (16 ms later) Frame 2: please update (16 ms later) Frame 3: please update (16 ms later) Etc. Not even a second has past and you almost requested 62 UPDATES! (not sure if there is elementdata reduction clientside, but I don't think so) Which is IDIOTIC! (for the ones who do this, please go in your microwave) Which should/could be done like this: addEventHandler("onClientRender", root, function () local data = "random data" if data ~= getElementData(localPlayer, "key") then setElementData(localPlayer, "key", data) end end) Or this: (serverside) -- element could be a team for key, data in ipairs(example) do setElementData(element, "score", getElementData(element, "score") + 1) end Updating the score to 20? = Tell all clients/players 20x > "I have grown 1 more!" Which is stupid. Should/could be done like this. local score = getElementData(element, "score") or 0 for key, data in ipairs(example) do score = score + 1 end setElementData(element, "score", score) Edited October 16, 2017 by IIYAMA 6 1 Link to comment
idarrr Posted October 18, 2017 Share Posted October 18, 2017 Like IIYAMA said, mostly, because of element data. Avoid using element data unless you really need to. Link to comment
MTA Anti-Cheat Team Dutchman101 Posted October 18, 2017 MTA Anti-Cheat Team Share Posted October 18, 2017 It's not only about elementdata, the case you describe can be a sign that your gamemode/scripts were just coded inefficiently, maybe not by very skilled scripters. You can achieve functionality of the desired script in several ways, using different kind of techniques, and one can be more well-thought out than the other approach. A good scripter won't start writing immediately, but will draw a plan or design an efficient core which he'll work from in that moment to add all functionality. Sometimes it's said; development is 60% planning/thinking it out and 40% actively writing. If you first brainstorm about effective approaches and then pick the most performance friendly one, you'll not easily end up with the problem you are encountering now. @Axel to resolve this I advise looking in performancebrowser (or ingame ''ipb'' default resource) to see which resource is peaking in usage with that amount of players, or just regularly, so you can make a list of culprits. Then take a look at each of those resources and identify the structural problems, so you can improve its code efficiency (you can call this ''duct taping'' already doomed resources, or just rewrite chunks using different and optimized techniques, then re-check on IPB/performance browser with the updated version if those rewritten parts were at the heart of the performance problem.. for some stuff you see in the code you can just know it plays a role in the slowdowns though) 2 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