I just learned a bit of buffers so I used them to compress my data that im going to send through a remote every frame through an unreliable remote event but it still says that im 5000 bytes over. There are about 100 objects that are being updated to the client and im using one script to control it all.
Code:
local dataToSend = {}
for containerName, container in pairs(AIModule.Positions) do
for id, origin in pairs(container) do
local result = Run(origin, container, containerName, id, delta)
if result then
local bufferTable = buffer.create(24)
local posX = result.Position.X
local posY = result.Position.Y
local posZ = result.Position.Z
local dirX = math.floor(result.Direction.X * 100)
local dirY = math.floor(result.Direction.Y * 100)
local dirZ = math.floor(result.Direction.Z * 100)
buffer.writef32(bufferTable, 0, posX)
buffer.writef32(bufferTable, 4, posY)
buffer.writef32(bufferTable, 8, posZ)
buffer.writef32(bufferTable, 12, dirX)
buffer.writef32(bufferTable, 16, dirY)
buffer.writef32(bufferTable, 20, dirZ)
local storedData = {
["ID"] = id,
["Result"] = result.Result,
["Buffer"] = bufferTable
}
table.insert(dataToSend, storedData)
end
end
end
if #dataToSend > 0 then
Remote:FireAllClients(dataToSend)
end
what’s the data being used for? considering just the buffers alone 100 buffers with a capacity of 24 will add up to roughly 2400 bytes which exceeds the 900 byte limit for unreliable events
it also looks like you’re sending the table that you encoded into the buffer to the clients as well which defeats the purpose of encoding it
The data is to move all the parts to the CFrame. Using Remote events work in studio but in real game, ping spikes due to many events being sent with lots of data. Using Unreliable remote events has a limit and I want to reduce the amount of bytes being sent since it goes 5000 bytes past its limit.
Its because its also handling collision. I made a custom collision system so I do need to update often. I can’t put it on the client because the server is the one that checks if it has reached a destination and exploiters can abuse that.
collisions are usually handled on client? idk why you fear no existant thread? can’t you just security check few values instead of sending 5 kilobytes through network? for now unreliable remotes are less secure, they can be abused by stopping packages from comming
im only sending letters and numbers but having hundreds of objects being updated, the table gets too large and each data being sent is probably over 100 bytes. i wanted to try string.pack but its a bit complicated for me right now.
table.insert(dataToSend, {ID = id, Position = result.Position, Direction = result.Direction, Result = result.Result})
for me still it’s too much, no matter what kind of data you send but how many bytes, you should calculate collisions on client to prevent this, otherwise rip performance, exploiters are no thread in comparison to broken network, you still can check if collisions are secure via server checks
also another thing would be probably to send data not all at once, loop through table and send invidual enemies to client, this way you can send 50 bytes 100 times instead of 5k one time
I recently helped someone solve something similar to this. And yes its basically converting the vector3 to a string by using tostring then return it back to its og form using a function.
I did a test using string.pack and it was successful but is there anyway I can shorten it more?
local packedData = {}
for i = 1, 1000, 1 do
local data = string.pack("i4 i4 i4", i, i+1, i+5)
table.insert(packedData, data)
end
packedData = table.concat(packedData)
print(packedData)