I've only started learning about database scripting and have been wondering how to set and retrieve global variables stored this way.
As far as I've read about it, SetCampaignInt and GetCampaignInt (or string or whatever) can only be used to persistently store and retrieve variables stored on PCs.
So how can global variables be stored persistently?
The Function SetCapaignInt/Float/String etc & GetCampaign.... both store everything persistently into a database, NOT on the PC...
If you store anything on the PC, if it's in single player game, then it will NOT stick to them if they start a new game, but I'm pretty sure that variables stick when loading a saved game. Online (Server or LAN Game), the variables always stick to (Stay with) the PC unless you are hosting a local vault, then the variables will NOT stick on the PC, because each time they load a character it will not have any variables on it...
I use to place variables on an item in the PC's inventory, the only problem with this is, you have to loop through the inventory of the PC to get the item, and that can run into server issues if the PC's inventory becomes bloated. (Which is often the case)
The NWN Database is slow & clonky, it doesn't store pesistent locations efficiently (as sometimes it will indeed be wrong), and that's an issue....
I haven't tried what the above poster recommended, but nwnx2 + aps seems to work just fine for most servers...
Personally, I'm ready to begin my own database, but alas I don't know how to code outside of the game, unfortunately, otherwise I'd put everything in an XML document, which can Store/Retrieve 10,000 entries in a fraction of a second!