logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
NWNX on a single player module
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Thu Jan 13, 2005 19:10    Post subject: NWNX on a single player module Reply with quote

I am mid-way through developing a single player & LAN module based on the gameplay of the old roguelike games such as Angband. An early version is up on the vault at http://nwvault.ign.com/Files/modules/data/1074366809343.shtml

However, I am going to have to force the module to be run using NWNX for a couple of reasons (DB access with SQL and Letoscript). This will mainly be achieved by booting players from the module if its not setup correctly (GetPlayerCDKey() == "", Letoscript cant get the players name, DB doesnt work). What would be the best way to distribute such a setup? Would it be possible (given licensing and general good practice) to combine it all into a single download (i.e. mod+haks+NWNX+MySQL+Letoscript.dll)? What about possibly using some sort of auto-install package to put (at least some) files in the right place? Or would it be better to just provide links and have players download and install everything themselves (which would put a lot of people off if I have links leading to dozens of different sites)?

Also, I am thinking of turning the module into almost a SP PW given that the module is likely to end up being split over several different .mod files. This is due to the size of the module because of the number of areas, see http://nwn.bioware.com/forums/viewtopic.html?topic=405068&forum=47 for details) Obviously, NWNX will help to no end in this situation, which is yet another reason for using it Smile
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu Jan 13, 2005 22:06    Post subject: Reply with quote

I have mixed feelings on using NWNX with single player modules, or to be more specific, with modules that the end users needs to install instead of just connect to. Not because I do not like the idea - mind you. Just because that involves a lot of details that need to be taken care of.

With that said, here is what I would do:

1) Create a fool proof installer with e.g. the Nullsoft installer. It should install everything and ask almost no details

2) Try to find a database that is less complicated than MySQL. There are quite a few embedded database that need to external process, maybe there are some with an ODBC driver as well. Maybe even consider MSDE, since that is what Microsoft impositions on their users as well.

3) As long as the stuff your packaging is licensed under the GPL, you should have no problems, but be prepared to hand out the source code to everything on request.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Manuel



Joined: 30 Dec 2004
Posts: 51

PostPosted: Thu Jan 13, 2005 22:18    Post subject: Reply with quote

Go with SQLite. It is 100% freely distributable (even with commercial apps), is great with embedded type programs, has a very small footprint and requires no setup.

http://www.sqlite.org/
_________________
I only know enough to be dangerous.
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Thu Jan 13, 2005 23:57    Post subject: Reply with quote

Thank you papillon, that installer should be exactly what I need.

Manuel, thank you for the link, it does look very good. However, I am a scripter, not a developer, so I have no idea how to use it. Have you got any advice?
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Fri Jan 14, 2005 14:12    Post subject: Reply with quote

SQLite Shocked ?

an idea comes to mind.... Cool
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Fri Jan 14, 2005 14:35    Post subject: Reply with quote

Your not thinking what I think your thinking, are you?
Back to top
View user's profile Send private message
Manuel



Joined: 30 Dec 2004
Posts: 51

PostPosted: Fri Jan 14, 2005 17:45    Post subject: Reply with quote

Of course he is... Smile

That would make NWNX setup virtually fool proof.

@Primo
Install SQLite the normal way then use the ODBC connection from NWNX to the database. You will need the SQLite ODBC driver which is here: http://www.ch-werner.de/sqliteodbc/

That is, until Jeroen or Pap release a direct driver. With it's C/C++ APIs, this should be pretty damned easy.

Some things to note about SQLite, blob support is ONLY in version 3 or above (RCO/SCO). In general, all data types are treated the same. The database does NOT enforce strict types on columns!
_________________
I only know enough to be dangerous.
Back to top
View user's profile Send private message
JeroenB



Joined: 31 Dec 2004
Posts: 228
Location: Netherlands

PostPosted: Fri Jan 14, 2005 18:40    Post subject: Reply with quote

Ow .. no Shocked

Pap.. your not going to do it! You are NOT going to do it! Twisted Evil

Yesterday you complained we release to much Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
Manuel



Joined: 30 Dec 2004
Posts: 51

PostPosted: Fri Jan 14, 2005 18:59    Post subject: Reply with quote

JeroenB wrote:
Yesterday you complained we release to much Rolling Eyes


Bwahahahahaaaa!

Yeah, SQLite has become extrememly popular if for no other reason than it's Public Domain. Tons of folks bundle it with their apps for DB backends without having to pay royalties are sign expensive license agreements.
_________________
I only know enough to be dangerous.
Back to top
View user's profile Send private message
Liberty Valance



Joined: 06 Jan 2005
Posts: 21
Location: A Persistent World West2

PostPosted: Fri Jan 14, 2005 19:40    Post subject: Reply with quote

as long as you don't force it upon us, i think offering an SQLite package option would be a good idea for more novice users out there Smile

if y'all don't have the time, if you just show me how to set up SQLite (or maybe i could get motivated enough to look it up myself), i can write a NSIS installer - i've done the installer for the Generations Arena mod for Q3 since version 0.99b (we're now at 0.99e), and the team's been happy with it Smile
_________________
A Persistent World West2 | APWW2 Forums
Wirehead Studios
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Fri Jan 14, 2005 20:28    Post subject: Reply with quote

Wow, that was so simple its shocking. Thank you! I have SQLite setup and running, though I am using the NWNX2 and plugins from the vault because nwnx_leto.dll doesnt work with the latest version yet.

As for setup (on a windows XP machine) it couldn't be easier. Heres how I did it:

1. Get the SQLite file, http://www.sqlite.org/sqlite-3_0_8.zip

2. Get the ODBC SQLitedriver, http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe

3. Extract the sqlite3.exe file from the sqlite-3_0_8.zip and put in in your nwn root.

4. Run sqlite3.exe with the command sqlite3.exe database\nwn.db (either from a shortcut to it, from a batch file, or from the command prompt)

5. Enter the SQL command:

CREATE TABLE pwdata (player varchar(64) default NULL, tag varchar(64) default NULL, name varchar(64) default NULL, val text, expire int(11) default NULL, last timestamp(14) NOT NULL, KEY idx (player,tag,name));

and press enter (you cant use keyboard shortcuts to paste, but you can right click and paste) You may get an error (I did), ignore it. Im sure it means something, but it didnt stop it working for me.

6. Check you now have a file named nwn.db in your NWN database directory. Thats the database file to use.

7. Go to Control Panel -> Administrative Tools -> Data Sources (ODBC) -> System DSN tab (second from left) -> Add... (button right hand side at the top) -> Scroll down to the bottom and select "SQLite ODBC Driver" (see note at top of post about SQLite 3 driver) -> Finish -> enter NWN as the data source name -> press the browse button and select the nwn.db file you created earlier -> OK -> OK

8. Run NWNX2.exe and load the aps_demo module. Then follow the instructions on the signs to make sure its all connected up properly.
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Fri Jan 14, 2005 20:32    Post subject: Reply with quote

I tried the SQLite 3 ODBC Driver, but that didnt seem to work with either version. The log for the old NWNX said:

Code:
o Connect successfull.
o Got request: DROP TABLE pwdata
! SQL Error: file is encrypted or is not a database (26)
o Got request: CREATE TABLE pwdata (player text(64),tag text(64),name text(64),val memo,expire text(4),last date)
! SQL Error: file is encrypted or is not a database (26)
o Got request: SELECT player FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: file is encrypted or is not a database (26)
o Sent response (-1 bytes):
o Got request: INSERT INTO pwdata (player,tag,name,val,expire) VALUES('Primogenitor','Anyndur Imytholin','demoName','testValue',0)
! SQL Error: file is encrypted or is not a database (26)
o Got request: SELECT val FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: file is encrypted or is not a database (26)
o Sent response (-1 bytes):
o Disconnecting from database.


So Im not sure what thats about.

Interestingly, when using the SQL Lite ODBC driver and the latest NWNX version it didnt work either, this is what the log said then:

Code:

o Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using ODBC connection.
o Hooking SCO....hooked at 5c4320
o Hooking RCO....hooked at 5c4200
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 on update CURRENT_TIMESTAMP,PRIMARY KEY  (player,tag,name)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: near "on": syntax error (1)
o Got request: SELECT player FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: no such table: pwdata (1)
o Empty set
o Got request: INSERT INTO pwdata (player,tag,name,val,expire) VALUES('Primogenitor','Anyndur Imytholin','demoName','testValue',0)
! SQL Error: no such table: pwdata (1)
o Got request: SELECT val FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: no such table: pwdata (1)
o Empty set


And the other combination (SQLite 3 ODBC + latest NWNX) didnt work either
Code:

o Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using ODBC connection.
o Hooking SCO....hooked at 5c4320
o Hooking RCO....hooked at 5c4200
o Connect successful.
o Got request: DROP TABLE pwdata
! SQL Error: file is encrypted or is not a database (26)
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 on update CURRENT_TIMESTAMP,PRIMARY KEY  (player,tag,name)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: file is encrypted or is not a database (26)
o Got request: SELECT player FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: file is encrypted or is not a database (26)
o Empty set
o Got request: INSERT INTO pwdata (player,tag,name,val,expire) VALUES('Primogenitor','Anyndur Imytholin','demoName','testValue',0)
! SQL Error: file is encrypted or is not a database (26)
o Got request: SELECT val FROM pwdata WHERE player='Primogenitor' AND tag='Anyndur Imytholin' AND name='demoName'
! SQL Error: file is encrypted or is not a database (26)
o Empty set
o Got request: DROP TABLE pwobjdata
! SQL Error: file is encrypted or is not a database (26)
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 on update CURRENT_TIMESTAMP,PRIMARY KEY  (player,tag,name)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
! SQL Error: file is encrypted or is not a database (26)
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: file is encrypted or is not a database (26)
o Empty set
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_0',~s,0)
! SQL Error:
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_1'
! SQL Error: file is encrypted or is not a database (26)
o Empty set
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_1',~s,0)
! SQL Error:
o Got request: SELECT player FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_2'
! SQL Error: file is encrypted or is not a database (26)
o Empty set
o Got request (scorco): INSERT INTO pwobjdata (player,tag,name,val,expire) VALUES('~','Chest1','Item_2',~s,0)
! SQL Error:
o Got request (scorco): SELECT val FROM pwobjdata WHERE player='~' AND tag='Chest1' AND name='Item_0'
! SQL Error: file is encrypted or is not a database (26)
o Disconnecting from database.



So it looks like I was lucky and got the right combination first time, which is nice Wink

Hope that those logs actually help someone, rather than just being a load of spam. Oh well.
Back to top
View user's profile Send private message
JeroenB



Joined: 31 Dec 2004
Posts: 228
Location: Netherlands

PostPosted: Fri Jan 14, 2005 21:56    Post subject: Reply with quote

I suppose SQL Lite doesn't support the 'on update' part in the create table. This isn't really required functionality so you could remove that part and try the combo "SQL Lite ODBC driver and the latest NWNX version" again.
Back to top
View user's profile Send private message Visit poster's website
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Jan 15, 2005 1:06    Post subject: Reply with quote

Or you could wait till tomorrow and forget about the ODBC driver entirely Cool
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Acrodania



Joined: 02 Jan 2005
Posts: 208

PostPosted: Sat Jan 15, 2005 3:24    Post subject: Reply with quote

I think one part of you problems is:

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 on update CURRENT_TIMESTAMP,PRIMARY KEY (player,tag,name)) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Look at the ENGINE statement... MyISAM==SPecific MySQL format. The table create fails because you are passing a parameter SQL lite doesn't understand...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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