View previous topic :: View next topic |
Author |
Message |
Jeddia
Joined: 18 Feb 2005 Posts: 4
|
Posted: Fri Feb 18, 2005 10:48 Post subject: Can't seem to write value to SQLite db - blank values |
|
|
Ok, I've set up the NWNX2 with SQLite. Scripts are imported into the module. My first test was to attach a script to the OnEquip event of the module to write the location of the PC to the db. By location, I mean I'm writing the vector of the PC and the tag of the area the PC is in.
Here is the code I'm using:
Code: | #include "aps_include"
void main()
{
object oPC = GetPCItemLastEquippedBy();
if(!GetIsPC(oPC))
return;
//database setup
string sName = GetName(oPC);
vector vVector = GetPosition(oPC);
string sTag = GetTag(GetArea(oPC));
//save persistent location
SetPersistentString(oPC, sName+"AreaTag", sTag);
SetPersistentVector(oPC, sName+"PCVector", vVector);
} |
I have the windows viewer for the SQlite db and it shows that the entries are in the database, but it also shows they are blank (the tag field is empty and the vector shows up as all zero's).
Any suggestions? Am I a complete retard and missing something simple? I've been wrestling with this all day and I'm Italian...which means something inanimate is about to pay the price. *looks around for something breakable*
Thanks.[/code] |
|
Back to top |
|
|
Primogenitor
Joined: 08 Jan 2005 Posts: 88
|
Posted: Fri Feb 18, 2005 13:51 Post subject: |
|
|
Can you post the nwnx_odbc.txt file from your logs.0 directory? That will give some pointers towards what the problem is.
Does the example module work?
Have you put the SQLInit() function in the OnModuleLoad event? |
|
Back to top |
|
|
Jeddia
Joined: 18 Feb 2005 Posts: 4
|
Posted: Fri Feb 18, 2005 14:05 Post subject: |
|
|
Yes, the example module worked fine. And yes, I've put the Init command into the OnModuleLoad event.
I'm about to paste in the text from the file you asked about in the logs.0, but first some new developments I've discovered that may help.
I made 3 wands to make sure I wasn't scripting something improperly. The 1st wand saves the area tag and vector to the database. The 2nd wand gets the information back from the database and shows it in the chat window. And the 3rd wand teleports the activator to the location built from the information that the 2nd wand gets (3rd wand also calls the info from the db).
If I start the server, join the game, and use the 3 wands in order - all is fine. It saves the location information to the database, calls it back properly with the 2nd wand, and the 3rd wand calls it and teleports to the precise location - just fine.
At this point, if I log out and shut down the server, I can still see the information in the database with SQliteCC. All is good. BUT, if I restart the server, the information disappears from the database. This is what is perplexing. It shows the entries, but the fields are blank and the vector info is all zero's. I also checked from within the game by using the 2nd wand. It shows all zero's in the chat window debug text.
Any reason the information in the database would disappear on server reset? That seems to be odd, given the nature of an external database to begin with.
Here is that text file:
NWNX ODBC2 plugin V.0.9.2.4
(c) 2005 by Ingmar Stieger (Papillon) and Jeroen Broekhuizen
visit us at http://www.nwnx.org
o Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using SQLite connection.
o Hooking SCO....hooked at 5c4320
o Hooking RCO....hooked at 5c4200
o Connect successful.
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Got request: SELECT player FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (10 bytes): Rage Saint
o Got request: UPDATE pwdata SET val='#POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#',expire=0 WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Got request: SELECT val FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (95 bytes): #POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#
o Got request: SELECT val FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (0 bytes):
o Got request: SELECT val FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoAreaTag'
o Sent response (0 bytes):
o Got request: SELECT val FROM pwdata WHERE player='Rage Saint' AND tag='Jeddia Seltarinéo' AND name='Jeddia SeltarinéoPCVector'
o Sent response (95 bytes): #POSITION_X# 0.000000000#POSITION_Y# 0.000000000#POSITION_Z# 0.000000000#END#
o Disconnecting from database. |
|
Back to top |
|
|
JeroenB
Joined: 31 Dec 2004 Posts: 228 Location: Netherlands
|
Posted: Fri Feb 18, 2005 15:00 Post subject: |
|
|
Do you have the latest odbc download. I believe there was a missing COMMIT call to end the transition when the plugin shutted down. In later versions this problem should have been solved.
Though, in game it should all work fine, as it will be kept correctly in memory to speed things up bigtime. |
|
Back to top |
|
|
Jeddia
Joined: 18 Feb 2005 Posts: 4
|
Posted: Fri Feb 18, 2005 15:40 Post subject: |
|
|
Yeah, I just downloaded and installed it a couple nights ago. So it's likely the most recent one.
Some more observations that make me even more confused:
1). I've noted that after the initial writing to the database (using wand #1), I can log out and shut down the server, and view the database with SQliteCC and the values are fine.
2). I start the server back up and log in. While I'm in on the server, I use SQliteCC on another (3rd) computer and on SQliteCC the values in the database are there - BUT if I use wand #2 in-game to call the values from the database they show as empty again (in chat window).... wtf. I look back at 3rd computer (using SQliteCC) and the values are there.
3). Now, I log out and shut the server down again. Now, the values are gone from the database according to SQliteCC.
I have no scripts that delete information from the database in the entire module. As I said, I only installed this like 36 hours ago and this is my first test of it's usage. This is boggling to me. I admit I'm new to NWNX/APS and SQlite but ... is it that hard? |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Sat Feb 19, 2005 9:51 Post subject: |
|
|
Can you send me that module ?
Btw, updates made to the SQLite Database show up in external programs only after the transaction has been commited, i.e. when the server shuts down or when you commit manually. _________________ Papillon |
|
Back to top |
|
|
Primogenitor
Joined: 08 Jan 2005 Posts: 88
|
Posted: Sat Feb 19, 2005 12:11 Post subject: |
|
|
Papillon wrote: | Btw, updates made to the SQLite Database show up in external programs only after the transaction has been commited, i.e. when the server shuts down or when you commit manually. | Is it worth doing periodic "commit" calls? for example, every 10 minues? 30 minutes? 60 minutes? What happens if the power cuts out, is the data lost? |
|
Back to top |
|
|
NoMercy
Joined: 03 Jan 2005 Posts: 123 Location: UK
|
Posted: Sat Feb 19, 2005 14:46 Post subject: |
|
|
I'm a bit dubious as to leaving transactions open for large ammounts of time, I'd recomend most people deal with this in nwscript, when your done doing something and you don't think anything more will happen for a while, issue a COMMIT and then another BEGIN.
For other databases where it doesn't write to file on COMMIT, it's probably fine doing the normal BEGIN at the start of a script, COMMIT at the end. |
|
Back to top |
|
|
JeroenB
Joined: 31 Dec 2004 Posts: 228 Location: Netherlands
|
Posted: Sat Feb 19, 2005 15:55 Post subject: |
|
|
Indeed, I recommend to that people dont wait to long with commits, as powerdown, or server failure will result in loss of data when not committed. |
|
Back to top |
|
|
Jeddia
Joined: 18 Feb 2005 Posts: 4
|
Posted: Sun Feb 20, 2005 6:21 Post subject: |
|
|
Welp, thanks for trying to help guys. I finally gave up and resorted to using the Bioware DB for the persistent location scripting. I'll have to figure it out later. |
|
Back to top |
|
|
dguntner
Joined: 31 Dec 2004 Posts: 116
|
Posted: Sun Feb 20, 2005 22:20 Post subject: |
|
|
You *could* try using MySQL, which is what nwnx was originally written to use....
I've got a persistent location system in place on my server, and it works fine using MySQL. FWIW.
--Dave |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|