View previous topic :: View next topic |
Author |
Message |
_Mordred_
Joined: 08 Sep 2009 Posts: 4
|
Posted: Tue Sep 08, 2009 6:45 Post subject: Persistent Chest |
|
|
Greetings!
I was trying to create my own persistent banking system. At the begining i used the Bioware Database and everything worked just as i wanted.
Then i tried to obtain the same result with a faster solution using NWNX
I put this script on the OnDisturbed event of the chest
Code: |
#include "nwnx_sql"
int GetNumItems()
{
int nItems = 1;
object oItem = GetFirstItemInInventory();
while(GetIsObjectValid(oItem))
{
nItems = nItems+1;
oItem = GetNextItemInInventory();
}
return nItems;
}
void SaveData(object oPC)
{
int nNum = 1;
object oItem = GetFirstItemInInventory();
while(GetIsObjectValid(oItem))
{
SetPersistentObject(oPC,"Slot"+IntToString(nNum),oItem);
nNum = nNum+1;
oItem = GetNextItemInInventory();
}
}
void DeleteData(object oPC)
{
int nCounter;
for(nCounter = GetNumItems(); nCounter > 0; nCounter --)
{
DeletePersistentVariable(oPC,"Slot"+IntToString(nCounter),"pwobjdata");
}
}
void main()
{
object oPC = GetLocalObject(OBJECT_SELF,"VaultUser");
DeleteData(oPC);
SaveData(oPC);
}
|
and this one on the OnOpened event
Code: |
#include "nwnx_sql"
void LoadData(object oPC)
{
int nNum = 1;
object oItem = GetPersistentObject(oPC,"Slot"+IntToString(nNum),OBJECT_SELF);
while(GetIsObjectValid(oItem))
{
nNum = nNum+1;
oItem = GetPersistentObject(oPC,"Slot"+IntToString(nNum),OBJECT_SELF);
}
}
void main()
{
object oPC = GetLocalObject(OBJECT_SELF,"VaultUser");
LoadData(oPC);
}
|
This is the log file
Code: |
NWNX SQLite Plugin V.0.0.8
(c) 2007 by Ingmar Stieger (Papillon)
visit us at http://www.nwnx.org
(built using SQLite 3.3.17)
* Log level set to 2 (everything)
* SQLite database file is C:\nwnx4\sqlite.db
* Plugin initialized.
* Registering under function class SQL
* Executing: SELECT count(*) FROM pwdata
! SQL Error: no such table: pwdata
* Executing: CREATE TABLE pwdata (player varchar(64) NOT NULL default '~',tag varchar(64) NOT NULL default '~',name varchar(64) NOT NULL default '~',val text,expire int(11) default NULL,last timestamp NOT NULL default current_timestamp,PRIMARY KEY (player,tag,name))
* Executing: SELECT count(*) FROM pwdata
* Returning: 0
* Executing: SELECT count(*) FROM pwobjdata
! SQL Error: no such table: pwobjdata
* Executing: CREATE TABLE pwobjdata (player varchar(64) NOT NULL default '~',tag varchar(64) NOT NULL default '~',name varchar(64) NOT NULL default '~',val blob,expire int(11) default NULL,last timestamp NOT NULL default current_timestamp,PRIMARY KEY (player,tag,name))
* Executing: SELECT count(*) FROM pwobjdata
* Returning: 0
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot3'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Plugin unloaded.
|
It seems that the first script works fine and stores the items on the database, but the second one, just fails to retrieve the items when i open the chest. Any suggestions? |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Tue Sep 08, 2009 8:01 Post subject: |
|
|
You'll notice that there are no lines beginning with "INSERT" in the log file. This indicates that the SetPersistentObject() call in SaveData() isn't working properly -- it's doesn't look like it's even getting called. I'd add some debugging messages, particularly in SaveData(), to see if the code there is running at all.
Disclaimer: I have no experience with xp_sqlite, and I haven't read through your scripts in detail, so I might be missing something glaringly obvious. _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Zaith
Joined: 05 Jun 2007 Posts: 21
|
Posted: Tue Sep 08, 2009 20:23 Post subject: |
|
|
Code: | ! SQL Error: no such table: pwdata |
Code: | ! SQL Error: no such table: pwobjdata |
Those two errors, in your log file, tell you why you are having a problem. |
|
Back to top |
|
|
_Mordred_
Joined: 08 Sep 2009 Posts: 4
|
Posted: Tue Sep 08, 2009 20:31 Post subject: |
|
|
Code: |
NWNX SQLite Plugin V.0.0.8
(c) 2007 by Ingmar Stieger (Papillon)
visit us at http://www.nwnx.org
(built using SQLite 3.3.17)
* Log level set to 2 (everything)
* SQLite database file is C:\nwnx4\sqlite.db
* Plugin initialized.
* Registering under function class SQL
* Executing: SELECT count(*) FROM pwdata
! SQL Error: no such table: pwdata
* Executing: CREATE TABLE pwdata (player varchar(64) NOT NULL default '~',tag varchar(64) NOT NULL default '~',name varchar(64) NOT NULL default '~',val text,expire int(11) default NULL,last timestamp NOT NULL default current_timestamp,PRIMARY KEY (player,tag,name))
* Executing: SELECT count(*) FROM pwdata
* Returning: 0
* Executing: SELECT count(*) FROM pwobjdata
! SQL Error: no such table: pwobjdata
* Executing: CREATE TABLE pwobjdata (player varchar(64) NOT NULL default '~',tag varchar(64) NOT NULL default '~',name varchar(64) NOT NULL default '~',val blob,expire int(11) default NULL,last timestamp NOT NULL default current_timestamp,PRIMARY KEY (player,tag,name))
* Executing: SELECT count(*) FROM pwobjdata
* Returning: 0
|
I don't think the problem is related to that error, because the script automatically creates the missing table after the error message |
|
Back to top |
|
|
_Mordred_
Joined: 08 Sep 2009 Posts: 4
|
Posted: Wed Sep 09, 2009 5:16 Post subject: |
|
|
Problem solved. I set up a Mysql database istead of Sqlite and now everything works fine
Code: |
NWNX MySQL Plugin V.0.0.9
(c) 2007 by Ingmar Stieger (Papillon)
(c) 2008 by virusman
visit us at http://www.nwnx.org
(built using mysql-5.0.27 source)
* Log level set to 2 (everything)
o SCO located at 78f440.
o RCO located at 78f090.
* Hooking successful
* Connecting to server Localhost
* Plugin initialized.
* Registering under function class SQL
* RCO query: SELECT val FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Empty RCO resultset
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* SCO query: INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('HortensiaNeraspina','Emma Goodneighbor','Slot1',%s,0)
* RCO query: SELECT val FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* RCO query: SELECT val FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Empty RCO resultset
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* SCO query: UPDATE pwobjdata SET val=%s,expire=0 WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot3'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* SCO query: UPDATE pwobjdata SET val=%s,expire=0 WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* SCO query: INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('HortensiaNeraspina','Emma Goodneighbor','Slot2',%s,0)
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot4'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot3'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: DELETE FROM pwdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* SCO query: UPDATE pwobjdata SET val=%s,expire=0 WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot1'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* SCO query: UPDATE pwobjdata SET val=%s,expire=0 WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot2'
* Executing: SELECT player FROM pwobjdata WHERE player='HortensiaNeraspina' AND tag='Emma Goodneighbor' AND name='Slot3'
* SCO query: INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('HortensiaNeraspina','Emma Goodneighbor','Slot3',%s,0)
* Plugin unloaded.
|
|
|
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
|