Author Topic: LF: help. Problem with Database calling and setting  (Read 357 times)

Legacy_Devling

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« on: September 19, 2015, 02:13:05 pm »


               

Hello, i have recently starting to use the Database (which i think is the standard one).


 


When i 1st tried using the database with SetCampaignInt() and GetCampaignInt() functions, every thing went fine.


 


But after a few times, the system stopped working as intended.


but before everything screwed up, it managed to create some variables for my pc in the database.


 


 


At the moment whenever i call an integer from my db, like:


GetCampaignInt("MYDB", "whatever", oPC);


 


no matter the value i set manualy in the database, it will always return 0.


 


and if i try to use the SetCampaignInt() function, my nwserver gets a crash or a "stops working" message appears and awaits my action to close it.


 


 


I have added admin rights by default too all my nwn programs. But i still don't have any idea what can cause this,


especialy because it worked the first 1-3 times i tried using these CampaignInts.


 


Did anyone experience anything like this or is aware of a solution for my particular problem?


Thanks in advance



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« Reply #1 on: September 19, 2015, 03:30:20 pm »


               

Maybe the database file is corrupted or something. Try moving the database files out of the "database/" directory and launching your module. If this solves your problem there was something wrong with your DB files.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« Reply #2 on: September 19, 2015, 04:59:38 pm »


               

You cant use oPC parameter, it doesnt work. You need to save datas under PC name or better establish an ID for players and save datas on this ID.


 


See here.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« Reply #3 on: September 19, 2015, 05:19:38 pm »


               

But why is it crashing when he uses SetCampaignInt?



               
               

               
            

Legacy_The Mad Poet

  • Hero Member
  • *****
  • Posts: 715
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« Reply #4 on: September 19, 2015, 07:28:32 pm »


               

I find just setting simple variables and such for persistence, when PC specific, is easier to do by adding the variables to an item that stays in the players inventory. The variables actually stay on over server resets (for multiplayer), and I believe transfer with a character if the character is exported in a single player module. Not trying to tell you to avoid the database or anything. Sometimes it just isn't necessary. 



               
               

               
            

Legacy_Devling

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
LF: help. Problem with Database calling and setting
« Reply #5 on: September 19, 2015, 07:30:45 pm »


               

Thank you for your answers.


 


I tried moving all my database files within my \database directory.


 


And i removed the oPC object from the CampaignInts, and used GetPCPlayerName to make unique int names.


 


Result: Everything works as intended now. and i succeded in getting values from the database after server restart


 


So thanks alot, everything works fine now.