Table with 672 entries (12 x 56) - Can I use server-sided resource specific statebags?

Hey yall! Continuation from my last post (huge shout out to @ChristopherM as always for the help!) - I’ve been looking at statebags, and I’m liking what I’m seeing, however, one recommendation is to not use large scale data entries (source : @AvarianKnight ) - Anyways, my question is twofold:

  1. Even though we have global state bags (accessible by everyone but immutable), is it possible to have resource specific statebags? I’ve tried creating one with some arbitrary global variable / table, but of course that was a dud :frowning: If not, would convars, decorators, or latentclientevents work in place of this?
    Note: My goal is to use an “is-entity-in-angled-area” native against an arbitrary list of coordinates;

  2. How big is too big? I loaded a 672 value nested table within my global statebag, and it seems fine for now, but I assume the more latent a given client is, the more likely they are to disconnect, yes?

Sorry for the ignorance, I promise Im learning! :smiley:

Not too sure about the whole “large scale data entry” thing, I defer to Avaian on that matter, but could you consider restructuring your resource so not all your data sitting in statebags? Do you have any code to show so we can see?

Well I’ll try but a looot of it is arbitrary so I’ll cut back on the building of the table and actually just show you what the data looks like via abstraction:

totaltable = {}
beginningv3 = vector3(100.0, 100.0, 100.0)

function createdata(v3)
temptable = {}
  for i = 1, 56 do
    firstsavedvalue = vector3(v3.x + i, v3.y + i, v3.z + i)
    secondsavedvalue = vector3(v3.x + i + i, v3.y + i + i, v3.z + i + i
    table.insert(temptable, {firstsavedvalue, secondsavedvalue})
  end
  return temptable
end

totaltable = {}
totaltable["hello"] = createdata(beginningv3)
totaltable["there"] = createdata(totaltable["hello"][56][1])
totaltable["How"] = createdata(totaltable["there"][56][1])
totaltable["was"] = createdata(totaltable["How"][56][1])
totaltable["your"] = createdata(totaltable["was"][56][1])
totaltable["day"] = createdata(totaltable["your"][56][1])
totaltable["today"] = createdata(totaltable["day"][56][1])
totaltable["mine"] = createdata(totaltable["today"][56][1])
totaltable["was"] = createdata(totaltable["mine"][56][1])
totaltable["great"] = createdata(totaltable["was"][56][1])
totaltable["thanks"] = createdata(totaltable["great"][56][1])
totaltable["for"] = createdata(totaltable["thanks"][56][1])
totaltable["asking"] = createdata(totaltable["for"][56][1])

So now when you print totaltable at index[“thanks”], it’ll return:

{vec3(101.000000, 101.000000, 101.000000) vec3(102.000000, 102.000000, 102.000000)}, 
{vec3(102.000000, 102.000000, 102.000000) vec3(104.000000, 104.000000, 104.000000)}, 
{vec3(103.000000, 103.000000, 103.000000) vec3(106.000000, 106.000000, 106.000000)}

(like 56 times)

Now that 56 is now x 12 (since there are 12 tables).
Hope this helps…Note this isn’t a direct 1-1 of the code, but it’s similar in how the nested tables are built and stored…

Even though we have global state bags (accessible by everyone but immutable), is it possible to have resource specific statebags?

Not entirely sure how this would work

How big is too big? I loaded a 672 value nested table within my global statebag, and it seems fine for now, but I assume the more latent a given client is, the more likely they are to disconnect, yes?

This depends on how large the data actually is, iirc the rule of thumb is everything over 30,000 bytes should probably be latent (though I will ask @nta to correct me here).

Hey yall! I’ve run some tests, and the way I’m using it is really, really bad…lol - basically I’m doing nested for loops and checking each value in the table against the player’s coordinates…I’ve never seen my client lag so bad, LMFAOO…I just threw that table into a local variable for comparison…not only is it significantly faster, but it doesn’t freeze up my whole damn client. Instead of directly comparing 672 values against the current player’s position, I just threw the table into a clientsided table. Meaning it’s now modifiable, but I’ll just add extra validation;

I feel like convars will have the same problem;