How to best get data from server (without storing it all client side)

So I have my server storing a bunch of data from an SQL database. I am trying to access the data on the client.

I know I can pass an event to the server, then have the server send an event back to the client, but is there a way to do it asynchronously? The data I am trying to get is something I am trying to evaluate on, so having it available when I am trying to evaluate it is needed. I also don’t want to add in a new event handler for every piece of data I want to get from the server, and don’t want to store the entire chunk of data on the client either.

Basically, I am trying to write some wrapper that I can use to pass data back and forth between client and server effectively so I can receive data I need from the server when I request it, again without having to setup a generic event handler and parsing out the data I need, and without setting up an individual event handler for each piece of data I want.

I understand there’s not a true callback system in place, but is there something else I can do?

(At one point, the data will be a 100+ item table, and don’t want to have to store the entire chunk of data client side + sync it whenever it changes to each and every client)

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the Cfx.re community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

As an example of what I’m trying to do, I have a players table on the server like this:

players = {
  playerid = {
    "character" = {
      name = "Testie McTesterson"
    } 
  } 
} 

And if I want to get this players name to display on the client, or to reference at the client, I’d like to be able to do something like

playerName = ServerCallback('getplayername', playerid)

print playerName

You can write your own pretty trivially. Save callbacks, have a single event for dispatching responses, and a single event for handling requests.

I’m not sure I follow the workflow for this.

I tried looking at some code from esx to see how they handle it, but they don’t seem to accept parameters to be passed into their callbacks so it made it not useful.

Nevermind, I’m an idiot. I was able to do what I needed to.

Thanks for the guidance.

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