Author Topic: Database?  (Read 469 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Database?
« on: September 17, 2010, 11:17:25 am »


               Okay, my problem here with the module is that everything is being erased when the server resets, Like the scores for our chess games/gladiator games and our CNR score.

This is what I would want to know:

Is a database really needed to store it all? Or is there an other way to store it? Maybe an object the PC's gain on enter?

I would appreciate any information I can get '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Database?
« Reply #1 on: September 17, 2010, 11:24:17 am »


               Database can be used for lal of it, however if you need some informations only available to given player, you can store it on some system item in player inventory as local variable which remains even after server. For persistent time or persistent chests however this is not possible as those are not player dependant.

Look HERE to get idea.
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Database?
« Reply #2 on: September 17, 2010, 11:26:46 am »


               Well...it would depend on a lot of things really. Like how it is scripted for example. I tried to find out if our module used the database or an internal system like you mentioned to save stuff and failed. Just to be sure we are running with database connectivity and also some minor stuff that we know is directly dependant on the external (MySQL) database.



Anyway...to come to the point...I am guessing you are running NWNX (as it is the only way I know of to connect to an external database). In that case...how are you doing the server restarts?



I noticed one thing...that closing down the server window while NWNX was running was not a good idea. NWNX would treat that situation like a "crash" and some data would be lost.



Then I recomend to close down NWNX first...then the server...then start NWNX again and let it start up the server as usual. We had no losses using this way...



If you are using Biowares built in database system I don't know...
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Database?
« Reply #3 on: September 17, 2010, 11:32:44 am »


               

SuperFly_2000 wrote...
I noticed one thing...that closing down the server window while NWNX was running was not a good idea. NWNX would treat that situation like a "crash" and some data would be lost.

Then I recomend to close down NWNX first...then the server...then start NWNX again and let it start up the server as usual. We had no losses using this way...

Eh?

The point of NWNX is exactly to not need to close it manually. There is plugin that crashes server and then NWNX will run it again, also if you manually close nwserver.exe it will run it again. I had never any issue with this... What behaviour are you experiencing? What data loss you mean?
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Database?
« Reply #4 on: September 17, 2010, 11:41:01 am »


               It might be just our module that has this problem.



At least that is what my error seeking led do. Restarting the server as I described led to us not having any problems.



We are using ATS crafting. I think it uses an internal inventory object system for saving the crafting point but some part of the system is connected to the database...at least that is what I suspect. The problem was that when a PC just started crafting...and the server was closed down in an "unproper way" or crashed...then his crafting points would be lost.



If however there was some time along the way that a "proper" server restart was done that PC would always have his points saves further on.



So the problem was with PC's beginning with crafting.



Anyway...this is a long story really. I am just explaining how we solved our problem...for what its worth.



Shadoow, you have to agree with me however that NWNX does record closing down the window as a server crash.
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Database?
« Reply #5 on: September 17, 2010, 11:42:12 am »


               *removed double post*
               
               

               


                     Modifié par SuperFly_2000, 17 septembre 2010 - 10:42 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Database?
« Reply #6 on: September 17, 2010, 11:50:56 am »


               

SuperFly_2000 wrote...

Shadoow, you have to agree with me however that NWNX does record closing down the window as a server crash.

I don't really know, its possible, or maybe it does not matter really. Im not such expert on NWNX to tell you.

The issue you had looks like ATS craft one, but since I can't see inside it, I can't offer you better solution.

Personaly using nwnx plugin to restart server from nwscript, every 10 hour now (as it runs only for betatesting), never had any issues...
               
               

               
            

Legacy_TheSpiritedLass

  • Hero Member
  • *****
  • Posts: 1118
  • Karma: +0/-0
Database?
« Reply #7 on: September 17, 2010, 04:40:00 pm »


               Perhaps a silly question here, but to write to the database are you using things like SetLocalInt or SetCampaignInt?  If you are using SetLocalInt, that could be the problem. Those database writes do not last across a server reset, only a player relog. Writes using SetCampaignInt remain across server resets.

-- Mistress
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Database?
« Reply #8 on: September 17, 2010, 08:19:32 pm »


               Soooooo....whats the handiest to do then in my case? seeing that I want to store the crafting skills the players have earned, and like time, basically checks if a player has entered the module for the first time or not.
               
               

               
            

Legacy_TheSpiritedLass

  • Hero Member
  • *****
  • Posts: 1118
  • Karma: +0/-0
Database?
« Reply #9 on: September 17, 2010, 08:40:38 pm »


               Never having used NWNx (but drooling and wishing!), I rely heavily on SetCampaignInt to keep track of things across resets.  I don't know what your current set up is using (NWNx, SetLocal, SetCampaign, something else I've never heard of, etc) so... yeah... not sure how to answer that.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Database?
« Reply #10 on: September 17, 2010, 09:14:43 pm »


               For checking whether the character entered into module for first time after restart use this in your OnClientEnter



if(!GetLocalInt(oPC,"FirstTime"))

{

SetLocalInt(oPC,"FirstTime",TRUE);

//add lines below this comment for anything that is required to make a first time after restart

}




If you want to check whether is the character brand new one, use this:



if(GetXP(oPC) == 0)

{

//add here

}


If you haven't looked into my link, consider it, there is example how to store time/character location/hp for both NWNX db and bioware one.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Database?
« Reply #11 on: September 17, 2010, 09:37:13 pm »


               This is a simple way to create an item on an entering player only once:

//OnEnter script
void main()
{
//Player is the entering object.
object oPC = GetEnteringObject();
//The DB item we will check for. This uses the tag of item.
object oDBItem = GetItemPossessedBy(oPC, "Tag Of DB Item Here");

//If not a player or is a DM then end.
if (!GetIsPC(oPC) || GetIsDM(oPC)) return;

//If the player does NOT have the DB item...
if (oDBItem == OBJECT_INVALID)
//create a DB item on the player. This uses the res ref of the item. Not tag.
CreateItemOnObject("res ref of DB item", oPC);
}


And then you could do something like this to set your mining skill when the player does whatever they need to do to increase this skill:

//example set mining skill script
void main()
{
//The player. Will need to be defined for your purpose. In this case it is the
//last user of a placeable.
object oPC = GetLastUsedBy();
//The DB item the player has. Checks the tag.
object oDBItem = GetItemPossessedBy(oPC, "TAG Of Item Here");
//Get current integer for "MINING_SKILL"
int iSkill = GetLocalInt(oDBItem, "MINING_SKILL");
//Set the new integer for "MINING_SKILL". In this case is the current amount +5
//You can change the 5 to however much you want to increase the skill.
SetLocalInt(oDBItem, "MINING_SKILL", iSkill + 5);
}


               
               

               


                     Modifié par GhostOfGod, 17 septembre 2010 - 08:41 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Database?
« Reply #12 on: September 17, 2010, 09:43:06 pm »


               

TheSpiritedLass wrote...

Perhaps a silly question here, but to write to the database are you using things like SetLocalInt or SetCampaignInt?  If you are using SetLocalInt, that could be the problem. Those database writes do not last across a server reset, only a player relog. Writes using SetCampaignInt remain across server resets.

-- Mistress



Just to clarify here.  Local Vars set on an object will only last across server resets if it in an item in the players inventory and the player was successfully exported(saved).  Any Vars on the PC's, module, placeables or any other object in the game will not last over resets.
 
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Database?
« Reply #13 on: September 18, 2010, 02:41:34 am »


               If you are playing server vault the local variable on the database item in the PC's possession persists over server resets.
               
               

               
            

Legacy_TheSpiritedLass

  • Hero Member
  • *****
  • Posts: 1118
  • Karma: +0/-0
Database?
« Reply #14 on: September 19, 2010, 01:47:59 am »


               Good point Lightfoot8 and ffbj.  I was looking at the databases strictly from the perspective of the player’s database.  Not data saved on an item.