Open haron4igg opened 5 years ago
this colshapes are used only serverside, but are unnecessary synced with client. You could use https://wiki.multitheftauto.com/wiki/GetElementsWithinRange if this possible don't update if player stay in one place ( compare last and current position, if distance > 0.1 then update )
@CrosRoad95 Yeah, good idea to not move it if player haven't moved, but my players never stand on one place :D
This col-shapes are used on client as well, so i can't get rid of them. I was already thinking to replace it with this function, need to run some performance tests first... Also if i will use this function client-side, will it search only streamed elements? or all?
this function is for all, but getElementsByType has stream argument and could be used as replacment
@CrosRoad95 so, basically you suggesting to maintain 2 different implementations of same functionality which more convenient with colshapes on both client and server sides. you just proved that col-shapes should be improved :)
Is your feature request related to a problem? Please describe. Colshapes may cause a huge CPU load on server or client side if server has a lot of 'mapping' objects or other physical elements.
Describe the solution you'd like Make possible to select group of elements visible by col-shape Or define parent element as target for col-shape, so only child's will be processed Or hide irrelevant elements from col-shape processing tree. Or at least set element type as a target for colshape. Also, make possible to limit client-side coshapes to see only streamed elements.
Describe alternatives you've considered
Additional context The script bellow is being executed on server side. The idea is to have ~120 meters col-sphere which would activate some server-side or client-side features which suppose to work only when player is near (keep them activated all the time may affect server performance or client fps). If attach this col-shapes directly to player, it will cause even more problems, so i moving them with 500 ms timer. Server has ~50 000 physical elements. ~8 000 of them has 'activating features'. I tried to do the same on client-only colshapes + server events, or on StreamedIn event + server event, but it is causes more FPS issues on client-side.
5 sec lua-timings metrics.
Related code: