Wielebny Posted October 5, 2011 Share Posted October 5, 2011 Is it possible to enable streaming of custom elements (created with createElement) the way vehicles are streamed (only nearby elements are sent to player)? Also, it is possible to enable streaming of objects in the same way? Currently every client receives and operates on whole set of objects and custom elements. Link to comment
diegofkda Posted October 5, 2011 Share Posted October 5, 2011 They're streamed out when they're about 300 GTA SA units of distance from you. Link to comment
DiSaMe Posted October 5, 2011 Share Posted October 5, 2011 They're streamed out when they're about 300 GTA SA units of distance from you. Isn't that 500 units? Anyway, all physical elements are streamed in the same way. Streaming is done client-side. Every server-side element is available client-side unless you disable the visibility with setElementVisibleTo or visibility argument in element creation function (if it has such argument). However, visibility can't be toggled on players, vehicles and objects, so to make a server-side streamer, you need to trigger client events and use them to create client-side objects. But I can hardly see any point in streaming elements in such way. Link to comment
diegofkda Posted October 6, 2011 Share Posted October 6, 2011 Hehe, you're right, I got confused with the GTA streamer . Link to comment
Wielebny Posted October 7, 2011 Author Share Posted October 7, 2011 But I can hardly see any point in streaming elements in such way. To achieve a higher bandwidth usage-lower cpu usage tradeoff. If I want to create, for example, several thousands of custom elements, that would be rendered (onClientRender) on all connected clients, with an assumption that client won't see more than, let's say, 20 elements at once - it may be quicker to just stream nearby 20 elements to client, than to implement custom client-side sieve/streamer. Although I get it - I need to sift the elements clientside to save on processing power, and that's the way it should be done in MTA. All in all it doesn't seem a bad idea . Link to comment
DiSaMe Posted October 7, 2011 Share Posted October 7, 2011 If you want to lower CPU usage on clients, you will need to do those calculations server-side. It's better to make an efficient algorithm which finds the nearest elements and use it client-side. Link to comment
eAi Posted October 7, 2011 Share Posted October 7, 2011 It seems this could be useful - what are your custom elements? Link to comment
Wielebny Posted October 7, 2011 Author Share Posted October 7, 2011 "text" elements, containing position, interior, dimension, text value and few minor values like color, etc. They are rendered client-side on each onClientRender event, using dxDrawText. getElementsByType supports narrowing results to streamed in elements, the only function I lack is something like setElementStreamable(element, distance). Link to comment
diegofkda Posted October 8, 2011 Share Posted October 8, 2011 (edited) engineSetModelLODDistance should help you, it's like a setStreamLevel but it doesn't destroy the element at all when you're far (the collisions don't get destroyed). EDIT: There's actually a setElementStreamable function you might know, and well, that doesn't seem to work . Edited October 8, 2011 by Guest Link to comment
DiSaMe Posted October 8, 2011 Share Posted October 8, 2011 Element streaming in MTA is putting/taking the element into/out of GTA SA. Streaming means that GTA becomes aware of element, so only physical GTA elements can be used by MTA streamer. GTA itself is never aware of custom elements. Also, streamer needs to know element positions. Custom elements don't have positions. Even if you use element data to store coordinates, objectively it's still just element data and not position. So it's easy to understand why custom elements can't be streamed. As I said, just write an algorithm to find the nearest text labels. Lua has everything you may need, like tables or coroutines. Link to comment
Wielebny Posted October 8, 2011 Author Share Posted October 8, 2011 ... Custom elements don't have positions. Even if you use element data to store coordinates, objectively it's still just element data and not position. Actually, they do - position can be assigned with setElementPosition and is accesible with getElementPosition. Also it is processed like any other element - for example it can be selected using getElementsWithinColShape. As I said, just write an algorithm to find the nearest text labels. Lua has everything you may need, like tables or coroutines. Agree. Link to comment
Recommended Posts