Jump to content

A question [SQLite]


Mann56

Recommended Posts

Hey guys,

I recently learned SQL and am making my first resource running on SQLite.

It is a vehicle-system and my question is...

I have a table which contains some information about some cars and their cost,max speed,fuel etc. I want to get it in my database 'vehicles'. I know that we can do it easily by looping dbExec , but it will repeat the same process every time i restart the resource. How can i prevent this?

Link to comment

When you restart a resource all of the variables associated with that resource gets niled for garbage collection due to the Lua state being deleted from memory. So there is no way of store information unless you do so externally.

You can have a separate resource that loads the information and have the resource you want restarted to make export calls to the resource storing the information.

You can also make a custom element for the type of information you're storing (in this case custom vehicles) and you can have your script to see if that element already exists and if it doesn't, load from SQLite the information for that specific vehicle id and store into the custom element data. (having a custom vehicle manager and using custom elements are important for this type of system, but it is the best way to do it)

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...