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 
 
Re-posted, pwdata table and variable help please?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
weaverdh



Joined: 08 Jan 2005
Posts: 4

PostPosted: Sat Jan 08, 2005 11:38    Post subject: Re-posted, pwdata table and variable help please? Reply with quote

New guild member, first post....so please excuse the preamble i'm about to start. If you don't like preamble then skip to the bit that starts with *RELEVANT.

I am creating a persistant world, not very large just now as i am wanting to create something with real atmosphere and feeling. I have managed to impliment hunger/thirst/fatigue, a four way craft system, armour and weapon wear, realistic camping and so on, all with the wonderful help of Dom Queron's systems. I have four nicely laid out cities, a wide variety of areas with about twenty strong story lines to develop....

So, i now need persistancy. Four weeks ago i sat down to find out what was needed, a day or two later i found that i needed SQL knowledge, some other software and code against everything that was needed to be stored. Two weeks of reading and searching the net after that i managed to find that the best way to do this would be with NWNX2/APS.

A week and much coffee later....i have the NWNS/APS system installed as per the instructions, it is storing the test module values to a MS access database and that's all nice.

*RELEVANT.

I'm confused as hell. Okay, so i can store these test values, a player name and a character name with a couple of extra misc values as well. What i need to do is that when a character logs out and back in again, they are still at the same hit points, still have any spell effects that were on them and still have inventory in the exact same manner. I also need for their hunger/thirst/fatigue, armour/weapon wear and so forth all to be as they were.

I have learned the basics of scripting, i can handle simple events with that. But what is required for my needs?

To give you an idea of where i am at, i don't fully understand how persistancy works, does a variable assigned to say, a 'fish' in inventory get written every heartbeat to the database saying 'i am still here ,i am still here, i have now moved to this slot, i am still here, etc?'. Or is it the case that a variable assigned to the 'fish' says to the database the same thing, but on significant events like resting or exiting the server? What would this variable be? What would the corresponding table value be and would this mean hundreds of values in the table? *baffle* Does some info get saved with the character bic file and if so, how can i make that persistant?

I have read and re-read so many guides, my brain is now falling out of my ears like wet cake. Any help would be seriously appreciated. If you can point me towards something that explains how to lay out a pwdata table that would be perfect, if you can point me towards a guide that discusses how to handle variables for persistancy that would also be wonderful. I promise i have tried to work on this myself, this is the first time i have posted for help on anything and it is simply because i have become completely stuck.

Best wishes, Scott.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Jan 08, 2005 17:30    Post subject: Reply with quote

I would suggest sticking to the default pwdata table and the functions supplied in aps_include for now. This is the safe path and probably enough for most of your persistency needs.

If you understand how to store local variables on an object, you automatically understand how to do it persistently.

Say, you have a player (oPC), that just finished a quest (quest1), and you want to store that info, so he can not do the quest again. The non persistent way of storing that info on the player is:

SetLocalInt(oPC, "quest1", 1);

As soon as you restart the server, the variable is lost and the player could do the quest again. If you want to store the variable persistently, you call the following function:

SetPersistentInt(oPC, "quest1", 1);

The variable is now stored in the database permanently. If you want to check if the player has done the quest before, you fetch the value from the database like this:

int iDone = GetPersistentInt(oPC, "quest1");

Nothing happens automatically or in the background. You call the functions, and the database is accessed, nothing more, nothing less. There is information that cannot be stored persistently (I think map pins are an example, the location of an item is another) using NWNX, but most of this information is stored by NWN on the character file and you do not have to take care of this.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Undertowe



Joined: 03 Jan 2005
Posts: 33

PostPosted: Sat Jan 08, 2005 20:34    Post subject: Re: Re-posted, pwdata table and variable help please? Reply with quote

weaverdh wrote:
I am creating a persistant world, not very large just now as i am wanting to create something with real atmosphere and feeling.


Good on ya! I'm working on a PW as well, and approaching it with much the same philosophy.

weaverdh wrote:
i have the NWNS/APS system installed as per the instructions, it is storing the test module values to a MS access database and that's all nice.


Consider using MySQL instead of MS Access. In my understanding, MySQL is more robust and, in my experience, you're more likely to find community support for MySQL.

weaverdh wrote:
I'm confused as hell.


Yup, been there. If you truly want to understand what you're doing, and thereby use NWNx/APS to best advantage, you should invest a little time reading some introductory materials on SQL and database design. It should help you immensely.

You might consider picking up a good book on the subject (check amazon). Also, you can start immediately at http://dev.mysql.com/doc/mysql/en/Tutorial.html

Once you understand a little theory behind how databases are designed and accessed, and have spent some time studying the functions in aps_include, you will be able to design your own solutions. I'm assuming you are handy with nwscript, of course. If not, you probably should invest some time in that, as well. There's nothing particularly mysterious about APS/NWNx once you understand the fundamentals of databases.

weaverdh wrote:
What i need to do is that when a character logs out and back in again, they are still at the same hit points, still have any spell effects that were on them and still have inventory in the exact same manner. I also need for their hunger/thirst/fatigue, armour/weapon wear and so forth all to be as they were.


As for hit points, take a look at this thread, which might give you a better idea of what is involved.

Some things, like inventory, are stored persistently in the .bic file. Therefore, the standard approach is to use something like the ExportSingleCharacter() function periodically to save the PC to the vault.

Instead of tracking the amount of wear and tear on every single weapon individually, consider writing a script that fires when a weapon is used, wherein a check is made (percentage, whatever) to see if the weapon breaks. Admittedly, this approach is not very sophisticated, but it might be enough to simulate what you want.

I'd also heartily recommend reading over the forums here and the NWNX APS Help guild at bioware. This is the best way to learn useful techniques.

I hope this helps. If you have any more questions, don't hesitate to ask.
Back to top
View user's profile Send private message
weaverdh



Joined: 08 Jan 2005
Posts: 4

PostPosted: Tue Jan 18, 2005 14:30    Post subject: And so on... Reply with quote

Okay, i think i maybe sounded more in the know that i actually am. Smile Sorry for the delay in replying, i hit a busy spell....building my own house at present also. I'm actually more confused now than before, i thought i was starting to understand.

You suggest to use mysql, in the nwnx2 guide it recommends access and actually sets itself up as an access db initially? To start, would it be easier for me to learn about handling access rather than sql? I have yet to manage to get mysql to actually work without me failing at the installation. All the install guides are for old versions of mysql, the downloads i have are all graphical interface versions and i constantly got 1045 errors.

I can see that the bioware database saves some information to the bic file in the vault automatically. I also understand that it is up to me to create a table and to make the calls myself to store anything further. What i do not understand is how to store persistant data regarding a characters current condition in game. From hit points to spell effects, from items in inventory to charges on items. The basic table that comes with the demo module does not appear to save hit points or player state when i log out and back in with the server staying running in-between.

I mean that i just do not know how to do it, i don't know if i should be clicking the variables tab in the toolset to assign these variables that people mention, i don't know if i am expected to hand code moduleonload/onleave scripts, i don't know the names of variables to call even if i do find out what is going on. Has no one got a system that is truly persistant up and running with the ability to say, here are my scripts, here is the pwdata table i use and it records everything to do with stats, hps, items, charges, locations, death state and so on?

I have found by trawling constantly, various little solutions to all of these individually but nothing that says, here is the way to do it and everything is stored. People must be using NWNX to store persistant player data so it's very odd to me that i cannot find any hard and solid information on it for people such as myself who are struggling to even find out what the accepted procedures are. I realise that it comes down to a volunteer willing to share their hard work but it would be so appreciated by the whole community i am sure.

You mention that nothing happens automatically and that i have to "call the functions", well again do i need some sort of script that constantly checks for a players stats over and over and if so, i guess i would need a table with over 20 columns for every player?

The most confusing thing is, how on earth does anyone know about this stuff? I tried hard to find anything that lists what stats are called when you want to save them to a table, for example if i wanted to create a column for storing current hit points, what would i call it and what would be the name of the variable to call? On top of that, would i call this as a heartbeat script, would it be on significant events?

The tone of utter whine in my post is due to several weeks of head banging, sorry. Smile I have grasped the NESS spawn system, i have grasped lilac souls excellent script generator and using that to add wonderful things to the module, but i'm having such a blind spot with database use and NWN.
Back to top
View user's profile Send private message
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Tue Jan 18, 2005 15:22    Post subject: Reply with quote

It's odd that your having problems geting MySQL to install, most geeks will probably recomend mysql to an access database, I personally would also recomend MySQL, just to check your using the Windows (x86) 35Mb download (.exe install) from http://dev.mysql.com/downloads/mysql/4.1.html?

No real need to create any special tables, the following woul store the players hitpoints in the default table created by the demo module without any hastle:
Code:
#include "aps_include"
void main() {
object oPC = Whatever;
SetPersistentInt( oPC, "hitPoints",  GetCurrentHitPoints( oPC ) );
}


EPOlson wrote some handy PW scripts which use the built in campaign database:
http://nwvault.ign.com/Files/scripts/data/1078122324000.shtml

Should give you a guide on how to do many of the things, or you can use them as-is, or if your feeling up to it change all the SetCampaign***() type calls to SetPersistent***() type calls :)


To extend the issue of creating your own tables, you can but at some point you'd probably find yourself creating a table to store your data in exactly the same type of way as the default aps_include does and end up with a lot more functions to store that data in your database include file.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
MacLir



Joined: 13 Jan 2005
Posts: 22

PostPosted: Tue Jan 18, 2005 19:58    Post subject: Reply with quote

I see what you're asking Weaver, or at least I think I do. Wink

You wish to know where to place these scripting calls as well as how to configure your database tables to work how you need them.

  1. Database tables don't have to be configured.

    1. Most usually people that hand access their tables or those wishing for 'complete, total, fast as lightning' accessing will worry about seperating their tables. As it stands for using a single table, most setups won't show noticable speed loss. Meaning, you as a player won't realise that that last read took 15 milliseconds instead of 2 milliseconds.

    2. Unless you have a specific reason for looking at the tables, all you need to do is merely save your variables. The demo module included in the latest ODBC package will take care of creating standard tables for you to use. That module, when used, will set up your tables with the proper necessary fields.


  2. Database perfomance as its commonly known, list from fastest to slowest when used for PW persistence.

    • Professional DB. ie. MySQL, MSSQL, SQLite
    • MS Access
    • Bioware DB


    • In the version of the guide you were reading, at the time it was wrote, Access was the easiest databasing method to use to setup NWNx. Now, with the latest version of the ODBC plugin, SQLite is the already preconfigured and built-in database for your usage.


  3. SQL language knowledge, or even the lack of, won't help you without a firm base knowledge of NWScript.

    1. The Lexicon is the Scripter's Bible. I suggest you begin with the scripting tutorials there.

    2. Bioware also has a few Scripting Tutorials.

    3. Another helpful tutorial, for me (when I was learning), is the Bioware Module Construction Tutorial.

    4. Beyond that, if you don't wish to delve that deeply into the 'fold', you can always advertise in the 'Help Wanted' Sticky of the Builders - NWN Scripting Forum.


  4. Last, but certainly not least, where to place these 'scripting calls'.

      If you follow through those tutorials you'll learn what all the script slots are for various things; ie. module, creature, placeable, trigger, etc. What you're looking to accomplish will determine where these go. If your looking into a persistent banking setup; it could be done in a conversation, on a placeble, or even both.

      That's the beauty of this beast; the possibilites are endless, and the learning, at first, is seemingly just as endless. But with a little perserverence and a bit of a brain (that's me letting you know that I'm not as smart as I may come across at first Wink ), it won't be all that long before you're able to sit down and bang out a 'new' system for your module.



I'd offer my scripting services, but at the moment I'm slowly working on my own setup. I wish you the best of luck. Smile
Back to top
View user's profile Send private message Send e-mail
weaverdh



Joined: 08 Jan 2005
Posts: 4

PostPosted: Tue Jan 25, 2005 15:51    Post subject: Update Reply with quote

Hiya there again, thanks everyone for all the advice.

I have the module up and running as BETA at present using Intrepid's staggered Exportallcharactersfix script setup for now. It is dumping all the characters in the server to the servervault every 40 seconds and on exit/rest/enter etc. It is basic but it will suffice while i learn the appropriate SQL and NWNX knowledge.

The reason i did this was simply because i am 5 weeks away from moving into the new house i am building and just cannot sit and learn SQL until the house is done. Smile I do however get time to sit with the laptop here and there to impliment ideas into the module. Once i get back to thinking about NWNX/SQL i'll see if i can cobble together a complete idiots method which will help people like myself who are unfamiliar with the whole concept.

See you soon!

Module is at 192.168.0.8 and will be on open BETA from 1st February. Forum is at http://xsorbit27.com/users5/totl/index.php[/url]
Back to top
View user's profile Send private message
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Tue Jan 25, 2005 22:01    Post subject: Re: Update Reply with quote

Glad to hear things are going well for you. Post here when you have more questions, right now it seems they've already been answered pretty well.

weaverdh wrote:
Module is at 192.168.0.8 and will be on open BETA from 1st February.


A quick note about the IP address you listed, no one will be able to access it. An IP address that begins with 192.x.x.x is non-routable, which means that it will only work for a local area network. This type of setup usually occurs when you have a cable/dsl router (or a few rare cable/dsl modems), but in order to get people to actually connect you'll have to find your real IP address, and possibly forward the appropriate ports to the internal PC.

If you have questions about that, post away, and let us know how you have your home network setup so we can give you the best way to find your real IP address.
_________________
Nepenthe - An NWN2 Persistant World, coming to a planet near you. http://www.nepentheonline.com
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
weaverdh



Joined: 08 Jan 2005
Posts: 4

PostPosted: Wed Jan 26, 2005 18:00    Post subject: ongoing. Reply with quote

Hiya there Asmodae,

I got the IP address from the upper right corner of the Nwserver window, the full number i realise now is 192.168.0.8:5121

I have had up to 15 people at a time in the server, running a cut down test section of the module, but perhaps they just clicked on the server name via the bioware search tool or gamespy? I'll look at finding the proper IP if it turns out to be different from the one i just mentioned, should be able to do that tonight. I am behind a 4 port router on the 1Mb broadband service and i followed a guide for port forwarding and opening so i think my setup is correct for that part at least.

Shall post later once i dig up the server IP via gamespy on a friends PC tonight.

Thanks again for all help, it is really appreciated everyone considering that it is not currently nwnx related and outwith the forums scope.
Back to top
View user's profile Send private message
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Wed Jan 26, 2005 18:36    Post subject: Reply with quote

http://www.whatismyip.com/

There's probably plenty of sites like the above, the'll find out what your public IP address is without any hastle digging around in your router/modem, if people area able to connect via gamespy then I would asume that your router is already forwarding packets to the server correctly, so all you'd need is the correct IP.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Wed Jan 26, 2005 20:34    Post subject: Reply with quote

yep, you should be all set. Smile

I mispoke earlier, its 192.168.x.x that's non-routable (meaning a subset of IP addresses that you can use for non-public networks).

Anyway, glad to hear things are going ok.
_________________
Nepenthe - An NWN2 Persistant World, coming to a planet near you. http://www.nepentheonline.com
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related 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