Thread: SQL Item System
View Single Post
  #1  
Old 05-13-2009, 10:11 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Here's how I'm doing it on Maloria.


Table creation...
NPC Code:
CREATE TABLE items (entry_index INTEGER PRIMARY KEY AUTOINCREMENT, account VARCHAR NOT NULL DEFAULT 'ACCOUNT_ERROR', item_id VARCHAR NOT NULL DEFAULT 'ID_ERROR', item_data VARCHAR NOT NULL DEFAULT 'DATA_ERROR')



Loading of items...
NPC Code:
SELECT * FROM items WHERE account = '" @ player.account @ "'"



Then I just loop through the query and add each item to player.items which is a TStaticVar that gets cleared everytime the player logs out.

I also automatically save all the players current items to the SQLite database upon onPlayerLogout().
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote