Jump to content

Sending a large array to client


vovo4ka

Recommended Posts

I need to send client a large dynamic array. But I doubt how best to - send a big chunk at once,

triggerClientEvent(player, "AcceptData", player, serialize(array))

or send by parts like:

for ElementKey, ElementValue in ipairs (array) do
triggerClientEvent(player, "AcceptChunkData", player, ElementKey, ElementValue)
end

Are there any limits on the maximum size of data on triggerClientEvent params?

Link to comment
Keep in mind the bandwidth issues when using events - don't pass a large list of arguments unless you really need to. It is marginally more efficient to pass one large event than two smaller ones.

There are limits on everything. I doubt you'd hit this limit very quickly though. Why not just try and see? It won't destroy your PC or anything.

Link to comment
Keep in mind the bandwidth issues when using events - don't pass a large list of arguments unless you really need to. It is marginally more efficient to pass one large event than two smaller ones.

If your array is small (say, 1 - 4), you can loop through it but it's not good idea to do so. Just send the array with 1 call.

Link to comment

It is possible to send too much at once, but such data would be so considerably large that it would be a simple matter to split it up then.

I'll give an example from a script I was working on recently - I formed an array containing every gamemode (and it's "friendly name"), with a sub-array of every map compatible with that gamemode (and it's "friendly name" too) for sending to the client for a GUI. (getResourceInfo etc. functions are server-side only) With 10+ gamemodes and over 400+ maps, some of which are used in multiple gamemodes, that made for an incredibly large array, and was too much to send.

Such a large array was easily split by only requesting the gamemode list, then when a gamemode was selected, request the map list for just that gamemode. Even with 600+ individual race maps, this has been handled fine.

Basically, you can send very large arrays without issue, but not insanely large - which you'll be more than aware that it's too big if you attempted to!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...