How do I lower my recv? Td game enemy system

No, this can all be one single buffer. The diagram shows how you can use one buffer of size 6 to read and write 3 separate values.

Oh wait that makes sense, so per value I want to use I have to add +2 to the buffer (b / stream) right?
Also I still don’t understand how you tell it what value to read… lets say I call the read func and I want it to return the id but then it returns the amount. Do I just change the offset to 2 if it’s in this order and I want to return amount?

1. ID 
2. Amount
3. Succession

Yes, you have to add 2 to the buffer offset because 2 bytes is the size of each value you’re writing.

We know that the first 2 bytes (0 to 1) will store “ID,” so read 2 bytes from the buffer starting at offset 0, and the number we get will be “ID.”

Now, the next 2 bytes (2 to 3) will store “Amount,” so once again read 2 bytes but at offset 2 to get “Amount,” and similarly for “Succession.”

Ah ok, thanks now I understand data compression etc. Also happy new year from my side (it just hit 2024 for me lol)

1 Like

Hey hello it’s me again. I set up buffers and such but Im having a problem decoding them on the client side.

I send over lets say the id which looks like this (my id is 1 for example)

local enemyID = buffer.writeu16(stream, 0, tonumber(enemy))

(Stream is: buffer.create(6))

Then I’m passing enemyID over by using a remote

createEnemyEvent:FireAllClients(enemyID, amountOfSpawns, successionOfSpawns)

The problem is I’ not quite sure how to accept / read the data I just send to the client on the client. I tried using read16u() but I don’t have the stream for that now. Idk how can I do it?

Hmm, maybe I have found the way of doing it… I just send over “stream” as well. Is this a good method? Thank you

Yes. Compress the data on the server, then send the buffer directly through the remote event, and the clients decompress the data.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.