Mann56 Posted January 28, 2016 Share Posted January 28, 2016 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
NewbProgramming Posted January 28, 2016 Share Posted January 28, 2016 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
Mann56 Posted January 28, 2016 Author Share Posted January 28, 2016 Got it , thanks.... Link to comment
KariiiM Posted January 28, 2016 Share Posted January 28, 2016 I know that we can do it easily by looping dbExec We don't loop data from a table by using dbExec, Use dbQuery instead. Link to comment
Mann56 Posted January 29, 2016 Author Share Posted January 29, 2016 I know that we can do it easily by looping dbExec We don't loop data from a table by using dbExec, Use dbQuery instead. I'll keep that in mind, thanks Karim! Link to comment
KariiiM Posted January 29, 2016 Share Posted January 29, 2016 You're welcome also use dbPoll to return the result Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now