Author Topic: RE: Sending a PC to a Stored Location After Server Reset - FAIL  (Read 552 times)

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #15 on: January 28, 2013, 04:40:51 am »


               Part of your problem may be that the PC object often becomes "invalid" when a player logs out, before any scripting can typically capture the PC object for any sort of use.

Using the heartbeat script to store the location to the BioWare database is a pretty decent idea.  Then, when your player(s) log back in, the location is reconstructed during the player client enter script run.

I just whipped up a quick and dirty set of script blocks that should help you out.  Just copy/paste into your own scripts. '<img'>

persistentlocation.txt
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #16 on: January 28, 2013, 04:53:11 am »


               If it's a server vault environment, storing the location to the PC skin works as well, as long as you're using the location plus area tag method already mentioned.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #17 on: January 29, 2013, 12:17:29 am »


               Got it working! Many thanks for the help. I ended up using AD's scripts - one in the module OnHeartbeat and one in the Character Setup area's OnEnter event. It was more slim than the others. However, I do like the way Henesua's puts the location handler into its own function - something I'll do with this no doubt.

I did also relearn something - why I dumped NBDE originally. When I converted the write functions over to NBDE everything broke. For some reason the database was no longer being written too. I tried deleting the database and starting over, but to no avail. I'm thinking it has something to do with the subsystems I've included:

The Krit's Alternate Horse Scripts
Axe Murderer's Killer Death System
Scarface's Persistent Banking System
Screw Tape's Simple XP

I have no idea what's causing the conflict because everything compiles fine once NBDE is added. NBDE just won't write to the database or create it if/when needed.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #18 on: January 29, 2013, 12:31:51 am »


               Pstemarie,

Glad the scripting will work with your module's systems.

I too got rid of NBDE.  It worked well for quite a while, but then started losing data on a too-often basis (like journal entries and quest states I was storing). Probably because I was using it to store a lot of variables. I ended up switching to a small PC inventory item for persistent data storage for almost everything (PC skins are frequently replaced in my PW, so that isn't a viable storage item).
               
               

               


                     Modifié par The Amethyst Dragon, 29 janvier 2013 - 12:32 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #19 on: January 29, 2013, 12:48:20 am »


               Yeah, I've only got five players so its not like a lot is getting stored in the database. I have a journal item that I can store data on as well as the PC skin.

I still have reservations about using a Heartbeat like this, but I'm sure the quantity of data won't be too taxing. If I notice too much lag I'll just store the values on the PC Data Item instead.

EDIT - Just thought of a way I can reduce any drag that might be caused by this...I can skip the location storage if the PC is in combat.
               
               

               


                     Modifié par Pstemarie, 29 janvier 2013 - 01:00 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #20 on: January 29, 2013, 02:19:17 am »


               That's a good idea.  I include a bit to the storage chunk to see if a PC has moved since the last check.  If not, no database storage. '<img'>
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #21 on: January 29, 2013, 03:02:13 am »


               Just to add 2 cents to the topic, I also do it as L8 suggests whether you do it with a DB or a DBItem. Something like so:

object oPlayer   = OBJECT_SELF;
object oDBItem   = GetItemPossessedBy(oPlayer, "item tag");
location lPlayer = GetLocation(oPlayer);
string sAreaTag  = GetTag(GetArea(oPlayer));

Store Location:

SetLocalLocation(oDBItem ,"MY_LOC" ,lPlayer);
SetLocalString(oDBItem ,"MY_AREA" ,sAreaTag);


Rebuild Location:

location lLoc   = GetLocalLocation(oDBItem ,"MY_LOC");
string sAreaTag = GetLocalString(oDBItem ,"MY_AREA");
lLoc = Location(GetObjectByTag(sAreaTag),
                GetPositionFromLocation(lLoc),
                GetFacingFromLocation(lLoc));


There's no need to store all the separate x,y,z and what not. I also dont use HB to store. Just multiple other events. OnPlayerRest, area OnEnter/OnExit, etc..

Glad to hear you got it worked out.
               
               

               


                     Modifié par GhostOfGod, 29 janvier 2013 - 03:05 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #22 on: January 29, 2013, 03:07:20 am »


               *smacks head*

Of course. Because the only bad part of the data is the area so you can still use everything else.

I've got to edit some scripts.

Thanks.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #23 on: January 29, 2013, 10:00:25 am »


               Thanks for the input GoG, I've also got some adjustments to make. Seems that storing the location like I am has broken KDS1's ability to drop a "cheater" that logs out to avoid the Purgatory penalty back into Purgatory.

EDIT - Everythings working smoothly now....

I had to add some checks to the function KDS1OnClientEnter() to check if an entering PC had the PC Data Item and if so port them to their stored persistent location. If they don't have the PC Data Item then they are assumed to be a First Time Login and sent to the Character Setup area.

Next, I had to relocate the module's start location to the module's first area  - where they go when they exit the Character Setup area. KDS1OnClientEnter() was then moved from the module's OnClientEnter script to the OnEnter script for this area.

So now the module basically functions as so:

PC logs into server and is sent to the module's first area. The area's OnEnter event then runs them through the KDS1OnClientEnter() function and checks for:
  • If the character went to the Purgatory area then logged out to avoid the penalty, they are penalized and sent to the Church area - where all characters go when leaving Purgatory.
  • Else, If the character was a "dead" body when they logged out they are sent to Purgatory.
  • Else, if none of the above applies and the character is not a first time login, then they are sent to their stored location.
  • Else, if a first time login they are sent to the Character Setup area.

               
               

               


                     Modifié par Pstemarie, 29 janvier 2013 - 11:44 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: Sending a PC to a Stored Location After Server Reset - FAIL
« Reply #24 on: January 29, 2013, 10:06:11 pm »


               This is coming together quite nicely - thanks in no small part to Henesua and his allowing me to look over Arnheim. I've got tons of ideas just spinning in circles about my head. Anyway, I've added some more persistent functionality...

I've got persistence working now for remaining feat (thanks to HCR 2.0) and spell uses. I've also modified the rest event so that feats and spells can only be regained once every 24 hours. Furthermore, for every 8 hour cycle you rest, you regain 1 HP per Level.