Author Topic: How to reset all stored variables in a mod? (when does it reset?)  (Read 710 times)

Legacy_kenween

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« on: September 11, 2010, 06:01:53 pm »


               hi

i have a mod with variables which are stored about each character - a particular score attached to each character name as a variable. there is a global score attached to the mod itself for the player with the highest score. there is even a variable attached to the name and build of each character. i didn't write this mod.

what strikes me as unusual is that in between reboots of the server (about once a day), the mod still retains the amounts in variables. i would have thought those values would have been erased after each server reboot? i do not want to retain those values in between server reboots as it is not really a persistent world per se.

do you know if there are mod temporary files i can delete or how does nwn store and retain those values in between server reboots?

thx !
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #1 on: September 11, 2010, 06:24:16 pm »


               How does your sever reboot?
               
               

               
            

Legacy_Invisig0th

  • Sr. Member
  • ****
  • Posts: 279
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #2 on: September 11, 2010, 06:32:28 pm »


               It's not possible to say exactly what is going on without seeing the scripts which are being used. However, it is likely that the original author is using the built in NWN persistent database, using the various GetCampaign* and SetCampaign* scripting functions.
               
               

               
            

Legacy_kenween

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #3 on: September 11, 2010, 07:28:25 pm »


               ahh.. the server crashes and i have to reboot it every about 3 hours.



i haven't seen any getcampaign/setcampaign functions being called in my browsing of the scripts. what seems to be being done is... attaching a variable to the module itself. however, i will keep an eye out for those 2 functions --- will i have to reinstall the whole of NWN to flush out the variables? (where is nwn's in built database kept anyway..)



(and yea i have a sucky crashy server. i am trying nwnx but this doesn't catch the crash in time. nwnx locks up whenever nwn locks up..)
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #4 on: September 11, 2010, 08:02:55 pm »


               If it uses bio db, then look int database folder, there should be some files with that mod database, however hard to say what will be their name. But think you can delete whole that module.
               
               

               
            

Legacy_Invisig0th

  • Sr. Member
  • ****
  • Posts: 279
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #5 on: September 11, 2010, 10:40:48 pm »


               It's hard to say what's going on until you actually post an example of a script so that we can see what it is doing. "Attaching a variable to the module itself" could mean several things.

If you want a direct answer, please post an actual example where this is being done in a script.

Variables set on the module object during a game definitely do not persist if the module is literally stopped and restarted, at least not with the default NWN game out of the box. That's exactly the reason why the campaign database features were added. 

There are also third party database tools that can be used, including NWNX. But if you were using one those, I'm pretty sure you'd already be aware of it, because it requires separate installation and configuration
               
               

               


                     Modifié par Invisig0th, 11 septembre 2010 - 09:52 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #6 on: September 12, 2010, 04:28:56 am »


               Check in your Neverwinter Nights/NWN/database folder and see if there are any entries in there. If so, the names of those entries could help point you in the right direction. It's also possible that these variables are being stored on an item all the players have. If this is the case, then you won't see any Set/GetCampaign fuctions and the scripts will just save variables to the item using Set/GetLocal.
               
               

               


                     Modifié par GhostOfGod, 12 septembre 2010 - 03:35 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #7 on: September 12, 2010, 05:50:59 am »


               If you downloaded the mod from the vault.  It would not hurt to give the name of the mod and a link.
               
               

               
            

Legacy_kenween

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #8 on: September 12, 2010, 07:27:12 am »


               you guys are quite tight - i checked the database subfolder and there are CDX (and some other extension) styled files there. i suppose those arise out of the inbuilt NWN database capabilities. i am not sure i can delete them safely to initialise the values.

if i can identify the portion of the scripts handling them i will see about posting them
regrettably, the mod is not publicly available (I don't own it) but if I can I will post some examples.
               
               

               


                     Modifié par kenween, 12 septembre 2010 - 05:31 .
                     
                  


            

Legacy_Invisig0th

  • Sr. Member
  • ****
  • Posts: 279
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #9 on: September 12, 2010, 01:58:05 pm »


               Just because you have files in that directory still doesn't necessarily mean that this specific module is using the NWN database. In my /database/ directory, for example, are files that were clearly added by the Pirates of the Sword Coast add-on module. Those just happen to have POTSC in the file name, but that's just good luck. A scripter can use any database name he likes with the GetCampaign and SetCampaign functions. If no such database exists, the game will create one. So you may not be able to tell anything about your module by looking at the files in the database directory.

IF you can be certain of the identify the *specific* database (or databases) that this specific module is actually using, then you have several options. Probably the most straightforward is using the DestroyCampaignDatabase() function. It removes the database entirely. You could put a call to this function in your module's OnLoad event. The database(s) will then be recreated whenever the first SetCampaign call occurs.

I'll repeat it for a third and final time -- you do need to post an example of a script setting a persistent value if you want someone to tell you what is going on and what your options are. At this point all of the advice above could be completely incorrect because you have not provided any clear indication of the exact nature of the persistent data you are asking about. Which is to say, you may be wasting our time as well as yours by not doing due diligence on your side to identify the nature of the problem before asking for help.
               
               

               


                     Modifié par Invisig0th, 12 septembre 2010 - 01:05 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #10 on: September 13, 2010, 02:26:51 am »


               I think the problem is that kenween can't find the scripts to post. Which is the reason for the other advice to try and track it down.
And something similar to what Invisigoth suggested, instead of trying to use a function to destroy your database, if you aren't concerned with anything from any of the nwn games or mods that might be using it, just delete everything in your database folder. Then start up your mod, do whatever it is that gives the player their score. Then re-check the database folder. You might want to check this folder several times before you get your score too, just to see if anything else is being stored before then. But anyway that should hopefully get you the database name as Invisigoth suggested. Then it would still be a matter of tracking down any scripts that are using the Get/SetCampaign functions. But at least you can pin point which script it is, because the database name will be in it as well.
               
               

               


                     Modifié par GhostOfGod, 13 septembre 2010 - 01:28 .
                     
                  


            

Legacy_kenween

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #11 on: September 13, 2010, 03:08:03 am »


               thanks GhostofGod, Invisigoth and every1 ! yea, the mod is that complex i don't know which scripts do what - pieces of scripts dealing with the variables in question seem scattered in lots of places.



i think i might just try deleting the files in the database folder. but i won't do so until i learn more about what the scripts do. my question was not directed towards solving the problem immediately, but rather trying to learn about how nwn dealt with these things so as to know which way is best to proceed towards.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #12 on: September 13, 2010, 05:16:33 am »


               As a test just to see if they are stored in a DB and not in local vars on a item the pc is carries. You could rename your 'database' folder to something like 'database_bak'. this would effectivly give you an empty database folder at the same time as keeping your data in it safe. Then just start the module up and see if a new folder with files shows up.

Finding out if the information is even stored in the DB would be the first step. After that is solved we can look at either items the players carry or possiable wrappers around the DB functions that could be hidding them from you.

note: the NWN DB files consist of three files per DB. Name.CDX, Name.FTP and Name.CDX. all three files make up the one DB .

Note 2: If you are running a lunix box. There is a known issue where the DB files can not be deleted from within the game.
               
               

               


                     Modifié par Lightfoot8, 13 septembre 2010 - 04:17 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #13 on: September 13, 2010, 12:34:49 pm »


               Additionally, you can do as Lightfoot8 suggested and start the module up with an empty /database directory to see what files to appear.

With that information, you can search all scripts in the module for the name of those files. When using SetCampaignInt functions to store variables outside of the module, the name of the database file must also be available.

So, if the files that appear are AdventureDB.CDX, AdventureDB.FTP and AdventureDB.CDX, there's a good bet you can search all scripts for the string AdventureDB and it will find something.

FP!
               
               

               


                     Modifié par Fester Pot, 13 septembre 2010 - 11:35 .
                     
                  


            

Legacy_Invisig0th

  • Sr. Member
  • ****
  • Posts: 279
  • Karma: +0/-0
How to reset all stored variables in a mod? (when does it reset?)
« Reply #14 on: September 13, 2010, 01:45:46 pm »


               Read the thread, people.

kenween has mentioned since the first post that he is fully aware that variables are stored for the mod and PCs using scripts. He even said in his most recent post that "pieces of scripts dealing with the variables in question seem scattered in lots of places". So he clearly knows at least one of the scripts we are talking about, and even exactly where some of those "pieces of scripts dealing with variables" are. Yet he has refused to post even a single line of those scripts for some unknown reason. It not unreasonable to ask him to provide that information in order for us to correctly answer his question.

It's like going to the doctor and saying "I have a severe pain, but I won't tell you where it is". Don't blame the doctor if you don't get the advice you need. At this point in the game, there is no reason he can't post *something* from a script related to the problem.

He has also insinuated that he may feel that he should be cautious about sharing work that was not authored by him. That's admirable, but that does not really apply here. No NWN script author would be offended by someone posting small sections of their scripts in order to remove undesired behavior.

As a side note, am I the only one here that remembers that the script editor has a "find in files" feature? Searching for "getcampaign" in files  literally could not be easier. Doing that would verify whether or not the default DB is being used, and well as showing what the name of the DB (or DBs) is. That's certainly less destructive than deleting everything.
               
               

               


                     Modifié par Invisig0th, 13 septembre 2010 - 01:08 .