View previous topic :: View next topic |
Author |
Message |
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Jun 20, 2005 9:47 Post subject: Problem with Bank Script |
|
|
I've just got the APS system worked out, I think - I at least managed to get the demo mod to function, using MySQL instead of SQLite. Now I'm trying to convert a banking system, using APS commands, and running into difficulty. When I deposited 3 or 4 items into the chest, only the first (a shortsword) was saved, and it was duped many times over. I opened and closed the chest, and each time more appearead, until I started getting consistent TMI errors and the total number of short swords capped out at 351. I went back and tinkered with the scripts, and after a few failed attempts, cleared out the database, both the nwn db and the sql db. The sql db named nwn had a table named pwobjdata, with 3 lines, each near 2000 characters long! Only after deleting both db's did the 351 shortswords dissappear.
I then went back with another character and tried again. This time I deposited one one square item, a gem, and on closing the chest it replicated until there were 568. I am at a loss. Here is the relevant chunk of nwnx.ini:
Code: |
[ODBC2]
; Log file
MaxLogSize = 512 ; in KByte
LogLevel = 2 ; 0=nothing, 1=only errors, 2=everything
; Use these two settings for the SQLite internal database
;source = sqlite
;file = sqlite.db
; Use these two settings for ODBC connections
;source = odbc
;dsn = nwn
; Use these five settings for MySQL connections
source = mysql
server = localhost
user = root
pwd = censored
db = nwn
; Set hookscorco to false if you want to disable hooking of
; StoreCampaignObject and RetrieveCampaignObject entirely
hookscorco = true
|
Here's the log file:
Code: |
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 5c65d0
o Hooking RCO....hooked at 5c64b0
o Connect successful.
o Got request: DROP TABLE pwdata
o Got request: 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)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: near "ENGINE": syntax error
o Got request: SELECT player FROM pwdata WHERE player='FunkySwerve' AND tag='Agrin Al~Aban' AND name='demoName'
! SQL Error: no such table: pwdata
o Sent response (0 bytes):
o Got request: INSERT INTO pwdata (player,tag,name,val,expire) VALUES('FunkySwerve','Agrin Al~Aban','demoName','testValue',0)
! SQL Error: no such table: pwdata
o Got request: SELECT val FROM pwdata WHERE player='FunkySwerve' AND tag='Agrin Al~Aban' AND name='demoName'
! SQL Error: no such table: pwdata
o Sent response (0 bytes):
o Got request: DROP TABLE pwdata
! SQL Error: no such table: pwdata
o Got request: 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)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: near "ENGINE": syntax error
o Got request: DROP TABLE pwobjdata
o Got request: 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)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: near "ENGINE": syntax error
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_0',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_1'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_1',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_2'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_2',~s,0)
! SQL Error: no such table: pwobjdata
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_0',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_1'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_1',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_2'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_2',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_3'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_3',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_4'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_4',~s,0)
! SQL Error: no such table: pwobjdata
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_0',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_1'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_1',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_2'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_2',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_3'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_3',~s,0)
! SQL Error: no such table: pwobjdata
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_4'
! SQL Error: no such table: pwobjdata
o Sent response (0 bytes):
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_4',~s,0)
! SQL Error: no such table: pwobjdata
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: no such table: pwobjdata
o Disconnecting from database.
|
When I check for the 'nonexistant' table in both the command line client and the aministrator, it shows the correct setup, with 6 columns, player, tag, name, etc. It is named the correct thing and is in the nwn database. Here are the 2 scripts for the chest:
onopen:
Code: |
//ScarFace's Persistent Banking system
//Modified for NWNX/APS by FunkySwerve
//Commented out functions are Bioware standard db calls; the APS calls replacing them are underneath them
#include "aps_include"
void main()
{
object oPC = GetLastOpenedBy();
string sKey = GetPCPublicCDKey(oPC);
int iCount = 1;
string sCount;
string sResRef;
object oCreate;
int nContinue = TRUE;
location lLoc = GetLocation(OBJECT_SELF);
while (nContinue)
{
sCount = IntToString(iCount);
//RetrieveCampaignObject("STORAGE", sKey+sCount, lLoc, OBJECT_SELF, oPC);
oCreate = GetPersistentObject(oPC, "STORAGE"+sKey+sCount, OBJECT_SELF);
if (!GetIsObjectValid(oCreate))
{
nContinue = FALSE;
}
else
{
//DeleteCampaignVariable("STORAGE", sKey+sCount, oPC);
DeletePersistentVariable(oPC, "STORAGE"+sKey+sCount, "pwobjdata");
iCount++;
}
}
}
|
onclosed:
Code: |
//ScarFace's Persistent Banking system
//Modified for NWNX/APS by FunkySwerve
//Commented out functions are Bioware standard db calls; the APS calls replacing them are underneath them
//Changed limit to 50, changed to disallow stacked items and containers
#include "aps_include"
void main()
{
object oPC = GetLastUsedBy();
ActionLockObject(OBJECT_SELF);
string sKey = GetPCPublicCDKey(oPC);
object oItem = GetFirstItemInInventory(OBJECT_SELF);
int iCount = 1;
int nStack;
int nContainer;
if (GetItemStackSize(oItem) > 1)
{
nStack = 1;
}
if (GetHasInventory(oItem))
{
nContainer = 1;
}
while (GetIsObjectValid(oItem))
{
oItem = GetNextItemInInventory(OBJECT_SELF);
if (GetItemStackSize(oItem) > 1)
{
nStack = 1;
}
if (GetHasInventory(oItem))
{
nContainer = 1;
}
iCount++;
}
if (nStack == 1)
{
FloatingTextStringOnCreature("**WARNING** You can't store stacked items in this chest. No items were saved. Please remove the stacked items.", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
if (nContainer == 1)
{
FloatingTextStringOnCreature("**WARNING** You can't store containers in this chest. No items were saved. Please remove the container or containers.", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
//Changed limit to 50
if (iCount >=51)
{
FloatingTextStringOnCreature("**WARNING** You can't store more than 50 items. You have "+IntToString(iCount)+" items in the chest. No items were saved. Please remove some items.", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
iCount = 1;
oItem = GetFirstItemInInventory(OBJECT_SELF);
if (!GetIsObjectValid(oItem))
{
iCount = 0;
}
string sCount;
while (GetIsObjectValid(oItem))
{
sCount = IntToString(iCount);
//StoreCampaignObject("STORAGE", sKey+sCount, oItem, oPC);
SetPersistentObject(oPC, "STORAGE"+sKey+sCount, oItem);
DestroyObject(oItem);
iCount++;
oItem = GetNextItemInInventory(OBJECT_SELF);
}
if (iCount == 0)
{
FloatingTextStringOnCreature("Chest empty, No items saved", oPC);
ActionUnlockObject(OBJECT_SELF);
return;
}
FloatingTextStringOnCreature("Items successfully saved", oPC);
ActionUnlockObject(OBJECT_SELF);
}
|
Sorry, I know thats a fair chunk, but I'm not sure where the problem lies. Any assistance would be most welcome, I'm near my wit's end.
Thanks,
Funky |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Mon Jun 20, 2005 13:28 Post subject: |
|
|
First of all, you are not using the MySQL connection:
Code: | o Using SQLite connection. |
Your INI file looks good, there seems to be something else going wrong.
Second, due to the MySQL syntax your tables where not created. Have a look at the log file, it always comes back with a !SQL Error: table xxx does not exist. _________________ Papillon |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Jun 20, 2005 22:10 Post subject: |
|
|
There was an old sqlite dll still in the NWN folder. Much thanks for pointing that out. It runs flawlessly now.
Funky |
|
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
|