Aller au contenu

Photo

PW Character Saving script


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
niapet

niapet
  • Members
  • 41 messages
Hey everyone,

I recently put up my ne PW <shameless plug> Dragonlance, Age of Despair </shameless plug> and I have a little issue i need to take care of asap.

I have noticed on PW i have played on that if the server crashes the server will save characters and send a message to the client letting players know their characters have been saved.

On my PW, if the server happens to crash the players can loose progress on their characters since the game does not automaticly save them. I am using NWNX4 and was wondering if there is a plugin, or a script function of some sort that I can put in the moduel's on exit event handler to save characters if the server crashes?

This would be very helpful to the players since no one wants to loose progress on their characters...

#2
niapet

niapet
  • Members
  • 41 messages
Anyone have any ideas?

#3
Sadistic Leprechaun

Sadistic Leprechaun
  • Members
  • 20 messages
I am surprised no one else chimed in, so here is what we use! We have a two-fold system for saving. One is a wand that allows players so save whenever they want. The second is the same function, but on triggers that are in all our areas:

This one is on a wand that players get:

#include "x2_inc_switches"

void main()
    if (nEvent ==  X2_ITEM_EVENT_ACTIVATE)
    {
{
     object oWand=GetItemActivated();
    object oUser=GetItemActivator();
    object oTarget=GetItemActivatedTarget();
    object oMod = GetModule();
    location lTargetLoc=GetItemActivatedTargetLocation();
    string sWandTag=GetTag(oWand);
   
        ExportSingleCharacter(oUser);
        SendMessageToPC (oUser, "Your character has been saved to the vault.");
        object oArea = GetArea(oUser);
        string sAreaTag = GetTag(oArea);
        location     lPC    =    GetLocation(oUser);
        string        sArea        = GetName(oArea);
        string        sSubString    = GetSubString(sArea,0,1);
        if  (sAreaTag != "01_startarea")
        {
            if (sSubString != "+")
            {
                  object oToken = GetItemPossessedBy(oUser, "tal3_infotoken");
                 SetLocalLocation(oToken, "persLoc", lPC);
                  SendMessageToPC (oUser, "Your persistent location has been set.");
            }
      }
    }

Here is the script on the oneneter part of a trigger:

void main()
{
    object oPC = GetEnteringObject();
    ExportSingleCharacter(oPC);
    location     lPC    =    GetLocation(oPC);
    object oToken = GetItemPossessedBy(oPC, "tal3_infotoken");
    SetLocalLocation(oToken, "persLoc", lPC);
}

Double check all the brackets, I am no scripter, the copy-paste might be flawed.

Anyhow, this is what we use. Players save when they want (after DM XP, getting a nice loot, etc) and they are autosaved when they go to a new area and step into the trigger placed at the transition.

Hope it helps!

(shameless plug: RP -orientated PW - http://worldoftalernon.com )