altv-issues
altv-issues copied to clipboard
Virtual entity recreation streaming issue
Description of the problem
Streaming of virtual entities breaks after recreation https://youtu.be/9wdjfPr6tXo
Note: it doesn't happen on low amount of entities
Reproduction steps
Enter "recreateEntities" to console as shown on video using provided reproduction code
Reproduction code
client
import alt from "alt-client"
alt.on('worldObjectStreamIn', (o) => {
if (!(o instanceof alt.VirtualEntity)) return
const id = o.getStreamSyncedMeta('customId')
if (id == null) return
o.tick = alt.Utils.drawText3d(`${id}`, o.pos, 4, 0.5)
})
alt.on('worldObjectStreamOut', (o) => {
if (!(o instanceof alt.VirtualEntity)) return
const id = o.getStreamSyncedMeta('customId')
if (id == null) return
o.tick?.destroy()
o.tick = null
})
new alt.Utils.ConsoleCommand('recreateEntities', () => {
alt.log('recreating...')
alt.emitServerRaw('recreateEntities')
})
server
import alt from "alt-server"
const group = new alt.VirtualEntityGroup(20)
let entities = []
alt.onClient('recreateEntities', () => {
entities.forEach(e => {
e.destroy()
})
entities = []
create()
})
function create() {
// first custom entity id is always 1
let customId = 0
// 100k entities
const LIMIT = Math.sqrt(100_000)
for(let x = 0; x < LIMIT; ++x) {
for(let y = 0; y < LIMIT; ++y) {
const e = new alt.VirtualEntity(group, new alt.Vector3(x, y, 72), 600, { customId: ++customId })
entities.push(e)
}
}
alt.log('created:', entities.length)
}
create()
Expected behaviour
/
Additional context
No response
Operating system
Windows 11
Version
16.0.0-dev.226
Crashdump ID
No response
Confirmation of issue's presence
- [X] By submitting this ticket, I affirm that I have verified the presence of this issue on the latest developer version available at the time of writing this ticket.