Cyber14 Posted January 6, 2019 Share Posted January 6, 2019 Hi. I have a lot of objects on my server, all of them are created by server-side createObject() function on resource start but there is one problem with that. When someone connects to my server and the resource is started, the player have to wait a lot for objects loading. (It takes about 1 minute) So in order to reduce this time I moved some objects to other dimensions but It didnt give an effect. Now I have a question. Im going to change the way of creating objects. Im thinking about creating objects client-side and creating only this objects which actually are in the same dimension as the player is. When the player changes dimension, objects in previous dimension will be deleted and new objects from proper dimension will be created. Is that the good idea or there is any better solution? Link to comment
Saml1er Posted January 8, 2019 Share Posted January 8, 2019 Are those custom objects? Link to comment
iDannz [Breno] Posted January 8, 2019 Share Posted January 8, 2019 (edited) 1 hour ago, Saml1er said: Are those custom objects? I have the same problem with custom objects too Edited January 8, 2019 by iDannz Link to comment
Saml1er Posted January 8, 2019 Share Posted January 8, 2019 15 hours ago, iDannz said: I have the same problem with custom objects too createObject function executes pretty quickly. I think you're talking about engine functions, like engineLoadDFF, *TXD, and *COL. Link to comment
Scripting Moderators thisdp Posted January 9, 2019 Scripting Moderators Share Posted January 9, 2019 Use "onClientRender" to disperse the pressure Link to comment
Cyber14 Posted January 9, 2019 Author Share Posted January 9, 2019 17 minutes ago, thisdp said: Use "onClientRender" to disperse the pressure What exactly do you mean? Link to comment
Scripting Moderators thisdp Posted January 9, 2019 Scripting Moderators Share Posted January 9, 2019 Just now, Cyber14 said: What exactly do you mean? Create a queue, and deal with it inside "onClientRender". For example, 200 objects will be created in 1 frame. Link to comment
Cyber14 Posted January 9, 2019 Author Share Posted January 9, 2019 On 08/01/2019 at 05:50, iDannz said: I have the same problem with custom objects too 20 hours ago, Saml1er said: createObject function executes pretty quickly. I think you're talking about engine functions, like engineLoadDFF, *TXD, and *COL. I have no any problems with custom objects. I know It can be weird but I tested how long it takes to load objects with and without replacing models and it turned out that objects without replacing loaded faster.. Even when I create objects with no custom objects and then I run resource which replaces models it doesn't take more than 1-2 seconds to replace all models. I would like to add that I have about 3.000 objects to create on my server. In that case I will check solution with onClientRender event. Link to comment
Saml1er Posted January 9, 2019 Share Posted January 9, 2019 (edited) 4 hours ago, Cyber14 said: I have no any problems with custom objects. I know It can be weird but I tested how long it takes to load objects with and without replacing models and it turned out that objects without replacing loaded faster Can you post the script where you create the objects? I'd like to test it. Edited January 9, 2019 by Saml1er 1 Link to comment
Cyber14 Posted January 9, 2019 Author Share Posted January 9, 2019 13 minutes ago, Saml1er said: Can you post the script where you create the objects? I'd like to test it. Ok you were right. I analyzed the code and createObject() function works really quickly. My problem was connected with adding textures to all of this models on client-side (im using "UV scripted" resource from this site https://wiki.multitheftauto.com/wiki/Shader_examples) Maybe now @thisdp 's solution will have sense for loading shaders a bit slower? Link to comment
Moderators IIYAMA Posted January 9, 2019 Moderators Share Posted January 9, 2019 (edited) Quote My problem was connected with adding textures to all of this models You can also use the onClientRender event to load the textures one by one. To keep up the frame- rate, you can use getTickCount() function to delay the process even further. https://wiki.multitheftauto.com/wiki/OnClientRender https://wiki.multitheftauto.com/wiki/GetTickCount 24 minutes ago, Cyber14 said: Ok you were right. I analyzed the code and createObject() function works really quickly. Have you ever considered using a map file? Loading map files is damn xxxxxxx fast in compare to create every single element with createObject.Take it or leave it. (of course this means that you will lose the ability to send specific maps to each client) local file = xmlCreateFile("saved.map", "map") if file then local mapRoot = createElement("map") setElementParent(createObject([[...]]), mapRoot) -- all your objects saveMapData ( file, mapRoot) xmlSaveFile ( file ) xmlUnloadFile ( file ) end https://wiki.multitheftauto.com/wiki/SaveMapData Edited January 9, 2019 by IIYAMA 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