Database for persistence?

Okay not entirely sure if I should be here or in custom content but as I am working on my PW mod, I was wondering if anyone has any good suggestions for a DB system to make my PW more…well persistent…

I kinda want to know your thoughts on how to get this done best.

With persistence I kinda have this in mind:

  • Status saving: Saves if the pc is dead, dying, diseased, cursed ETC on leave
  • Saves character periodically

So would love to hear of what YOU think would be the best way to do this. I personally was thinking of getting al this stored on an item but not sure how workable that is.

There are actually two ways:

  • you could use the “unidentified desciption” on an identified Item to store a number of variables. I’ve seen examples of this here in the vault. Howevers this requires a bit of scripting.
  • you could use the database system of NWN, where you can store “CampaignVariables”. Every player could have its own DB, Identified by the players name (which must be unique in this case).

He mentioned PW ie. multiplayer which means he can simply use local variable on an undroppable item in inventory. The solution you mentioned is for a persistency between singleplayer modules.

Persistency between single player modules should actually work in multiplayer as well. Of course, just setting variables is much easier.

Ehm yes, but this method has very limited storage, you cannot really store number of kills of any npc in a PW this way for example (very typical usage).

You’re right, the space is rather limited, it might work if every PC is saved on a separate item. Dead, dying, diseased, cursed ETC are only 5 variables. :slight_smile:.

However, setting normal variables on an item is much easier, and if this is persistent in a PW, then he/she should give it a try.

So storing variables on an items is easiest, like for example player skin? Would that be possible?

I used to work with skin but it is not safe, even with community patch which prevents losing the skin, with the way how it works you cannot be 100% sure the skin is not lost due to some coding error in horse system or some other issue. Best to use 1x1 miscelanious item in inventory. Maybe not as clean but prone to errors.

If you want to avoid even that 1x1 item you need to use database. Either SetCampaign* functions (in EE they shouldn’t be that slow anymore) or SQL databases via NWNX.

Btw, regarding the disable effects, this is problematic to record because of various factors.

Vanilla nwn is missing the function to retrieve effect value, ie how much constitution did the poison drained or how much ability stats did curse drain. This can be workarounded to some degree but then again, you cannot really apply disease/poison to player again. This is because each application will run the initial saving throw again and apply the penalties only when it fails. Additionally it will start the secondary effects timer. I recommend to store ability values when logging out instead, if they differ in time of login apply ability decrease effects to force the previous values.

Another issue is that unless you use EE or nwnx you cannot get remaining duration of the effect which can be important for disables. Of course you can just apply it for specific value like 5 rounds instead but it is not clean. Btw, the effect timers are running while is player logged out. But I suppose you know that hence why are you asking for this.

(And there are dozens of issues with diseases, poisons, curses and ability decrease immunities, some are solved in community patch, some needs nwnx to fix them. Either way that is different issue.)

Thank you! Yes this is one of the reasons why i asked.

For the most part I have been contemplating on how people could “cheat the system” so to say, now I want to make sure that status, inventory, level, is being stored and such so that when the server resets they keep the status the moment they relog or rejoin the PW.

Hence why i wondered what would be the best way for this.

think this issue has been fixed by a system I just installed. Not sure if anyone is familiar with it?

Don’t local variables get deleted when you reset your server? Unless you save it that is, but then you could be saving bugs too. If anyone knows how to save local integers without having to load a save file I would like to know how too.

think if you store them on an item they don’t I think. Hence why I am asking the braintank :wink: