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 
 
Hello. Need Some Help...maybe....

 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Paco's Revenge



Joined: 24 Jan 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 19:17    Post subject: Hello. Need Some Help...maybe.... Reply with quote

Quote:
Starting out with NWNX ODBC2 can be a bit daunting at first, especially if you are on your own. We highly encourage you to visit us at www.nwnx.org to ask question and get help with setting this system up.


I saw this and figured what the hey before I started playing with it. We run a pretty large server and have gotten to the point where we should have included NWNX from the begining. The questions I have is what do we need to do to make this work.

We have gotten the NWNx to work and installing the ODBC. Now the APS is also essential I am guessing as well specially if we decide to use the Crafting Natural Resources from what I have seen on how large a resource hog it is.

Do we need to have SQL? Is that also a needed function as well? We have a multitude of systems that I have installed and most all of them are running as we want them but as more and more players discover us and we contuine to build I think we will despartly need a system like this.

Any help that anyone who has set up their system to use NWNx and the ODBC with the features we need would be greatly appreciated and will get from my wife a whole box of cookies in the mail. Razz
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Mon Jun 29, 2009 21:16    Post subject: Reply with quote

NWNX is nothing without its plugins, though the watchdog for the Windows version can be helpful. About ODBC, you can't just "install and go". It has to be very much an integral part of your systems, and if those systems do not currently use the Bioware database (Get/SetCampaign functions) then ODBC is irrelevant and isn't going to improve performance. That said, I'll try and explain what NWNX and the ODBC plugin can do.

Now, first of all, I think you're getting confused about each of the plugins. ODBC stands for Open DataBase Connectivity. SQL is Structured Query Language and APS is Avlis Persistence System. All three refer to the use of databases in a Neverwinter Nights server, and the functionality is all provided by the same plugin: nwnx_odbc.

In short, NWNX hooks the calls to SetLocalString when the string name starts with "NWNX!". It often sets the result to something completely different, so when you GetLocalString, you get new data. In this way, there is a two-way communication with an outside program.

The possibilities for this are endless, and indeed they have been developed a long way. But nwnx_odbc is quite straightforward: it is an interface with a database server.

So, to use nwnx_odbc, you need a database server. However, the default option is to use an SQLite database, which is not server-driven, and is simply a very scaled-down way of providing a database system like a full-scale server. This is ideal for starting out with, and comes with nwnx_odbc so there is no need for additional configuration. All you need to do is pick a database name, drop it in the config file and you're away.

Up until now, my post has been very technical and I apologise for that - I will try to keep it to the essentials from here.

There are two ways you can use an external database. There's the Easy Way, and the Expert Way. You could just as well combine the two, they aren't incompatible. Essentially, the Easy Way uses APS, and the Expert Way uses SQL. Technically the Easy Way also uses SQL, but you don't see any of that, it's hidden behind the APS front-end.

Let's go over using APS first. To install the necessary tables, after your database is configured simply edit your NWNX.ini file to load the module called aps_demo, which you should have put in your modules folder. You can have a look around the module if you like, but all you need to do is run NWNX, let the server run the module for a bit and then shut it down again once you've got to "Running, login at will". Now open up your own module and import the APS erf file. Now you can use the new SetPersistent functions in place of the SetCampaign functions, simply by adding the line #include "aps_include" to the top of any script that uses it. The new functions can transparently replace the old ones.

That's really all there is to it. Now for SQL. You can make use of result sets and multiple columns with this approach, and it's very much more efficient than using the SetPersistent functions. A database can have any number of tables in it, and each table has columns (fields) and rows (records). With this approach, you define all the fields, and how to search for a record. For example, you might persistently track PC locations and have a bank balance that they can access. One way of doing this would be to have 4 fields: pcname, cdkey, location and bank. You would define that yourself using the appropriate CREATE TABLE SQL syntax, and you would do something like the following:

- Is this PC new? Check for a matching pcname and cdkey.
- If a record is not found, the PC is new. Insert a new record with default values for location and bank.
- If a record is found, the PC is returning. So make use of the data (jump to the location stored, for example).
- When a PC logs out, and at frequent intervals (say - on area change), update that PC's record by storing their new location.
- When a PC accesses their bank, update that PC's record by storing their new bank balance.

What would normally be several campaign variables can be achieved in just one record set, so there is no data redundancy and the whole thing is nice and compact. And this is just a very small example of what SQL is capable of. To achieve all this, you would use a combination of the SQLExecDirect, SQLFetch and SQLGetData functions, contained within aps_include.

That, essentially, is it. There is more to it, but that's plenty to be getting started with.
Back to top
View user's profile Send private message
Paco's Revenge



Joined: 24 Jan 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 22:23    Post subject: Reply with quote

Wow...that is right on on what I was looking for. Thank you very much and I will start setting it up right now. If I have more questions I will come back and post them as you have gave me a very good and in depth answer that I appreciate very much.

*starts baking some cookies*
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Jun 30, 2009 11:33    Post subject: Reply with quote

Very nice reply, Fireboar. The one thing I would add is that using a MySQL server from the get-go is often much easier than the hassle of "upgrading" to it later. I have a tutorial on setting up MySQL at http://mercuric.net/nwn/mysql.html. The section "Creating the Database Tables" can be skipped, and you can run aps_demo.mod at the end instead (they have the same effect).
_________________
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
View user's profile Send private message Visit poster's website
Paco's Revenge



Joined: 24 Jan 2009
Posts: 7

PostPosted: Fri Jul 03, 2009 19:02    Post subject: Reply with quote

Okay...everythign is going good...nwnx is working and restarting and doing what it is suppose to do. The Profiler has helped me id some tweaks that have helped.

BUT

For some reason we cannot find where we create this table that is called for in the CNR documents. Matter of fact, where is the pwdata? It seems the database's are what we are having a problem finding, using and what not.

(I feel like an idiot. Embarassed )

This is from the CNR How To. It worked fine when I did it the "normal" way but for some reason it s not working right now.
I do have the aps include in the scripts that store data but I think I screwed up somewhere.

Quote:
When your module loads, CNR_MODULE_OML will attempt to create a table named "cnr_misc" using SQL.
If you have chosen to use the Bioware DB, then the table will not be created but the XP data will
be saved flat, using "cnr_misc" for sCampaigneName. The cnr_misc table has the exact structure as
the default APS table named "pwdata" - I duplicated it to keep the CNR data seperated.
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Fri Jul 03, 2009 19:19    Post subject: Reply with quote

That's the advantage of using the procedure I linked rather than aps_demo -- it lets you interact with the database more directly. Try connecting with SQLyog (or your SQL client of choice) and poking around the DB.
_________________
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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Page 1 of 1

 
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