Im currently making a Persistent Store Framework for my Server, which will be re-usable for all the stores in the module.
However, I've run into a snag.
1. I have the onOpen event set to Load All ITEMS from the nwnx database, into the inventory of the Store - This works
2. The on Close Event Wipes all items stored in the db, for that store, and then Stores the inventory items from the store, into the database again - To Account for any items that may have been purchased. This also works.
However, I realised that I would need to add a function in here, to delete items once they have been stored in the db, from the inventory, via DestroyObject. This is to prevent object duplication. eg - Original Stays in store, and then re-open store, gets duplicate.
I however had another problem - If the store has any base items - eg Items normally sold defined by toolset, these too would appear in the inventory, and be subject to the same storage/recovery.
The only way to solve this I thought, might be to Delete Inventory Contents onStore open event before doing any recovery, thus preventing Toolset items from being stored over and over again, after mod loads etc on StoreOpens - this also causes the problem that means that stocking the Shop's becomes an issue.
Does anyone have any thoughts on this?
When I ran Worlds of Rhun, I did get very much into Database Integration with website content management systems. eg - Control Game Settings via Website Control Panel, or Creation of Items via database. eg - Define the Items in a database, and then the gameserver creates them via the spec's I specified.
Because the framework im working on, uses database already, it occurs to me, I could make a similar system, where I could define my items in a WebSite, and have a CronJob or something or other kick off once a week to re-stock my shops. (Cronjob's are scripts that run on a website).
The idea I am leaning towards, is not to actually define the items via website, but to actually Store a single item of each type into the nwnx database, which could then become a new Palette of sorts.
eg - Instead of copying items from DM Creator Pallette, copy the items from the Database Table instead.
Restocking of the Shops could be as simple as
Copying Item1 from ITEM_TEMPLATES to PER_STORE1 (times x amount of times)
Also - I'd be interested in hearing peoples opinions on Database driven Stores vs Standard ones. I know that Standard Stores suffer from the issue of Lag if they are over stocked, this often why we need to restart our servers once in a while, but the system im building the Inventories of the Stores themselves, will actually be empty, until the players come along to buy something.
Plus - If utilizing mySQL database as the storage system, and using the Expiration value, it allows for Items to be given a LifeTime - eg Items will remain in the store until either Purchased, or until X amount of days have passed.
Once again - to use the Expire ,I will likely have to use a CronJob.
Does anyone else use CronJobs?
I realise it might sound like a silly idea, but if you think of it, CronJobs are external to the nwn server, so would allow you to create large loops, and powerful database queries, that would not affect the server in the slightest.
CronJob's I used to use included
Transfer Players Post Count from forum to InGame Rewards
Transfer Players Forum Rank to InGame Rank (eg - Admin = Admin, Moderator = DM etc)
Im actually getting kinda excited at the prospects of this system - the geek in me. Lol