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 
 
Problem recreating Henchmen objects with GetPersistentObject

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
chris421



Joined: 07 Apr 2005
Posts: 53

PostPosted: Sun Apr 10, 2005 18:45    Post subject: Problem recreating Henchmen objects with GetPersistentObject Reply with quote

Does this function work with creatures and items--or just items? Attempting to convert the MBHK set/retrievecampaigndb calls to Set/GetPersistentObject.

I have no problems creating the blob in the database, or deleting the right record when I fire a Hench (or they die). But for the life of me I can't get my Henchmen to retrieve from the database after a server shutdown.

What am I doing wrong??? Thanks.


Code:

void RetrieveCampaignHenchman69(object oPC)
{
    location lLoc = GetLocation(oPC);
    object oHench;
    object oDupe;
    int iSlot;
    int nCountHenchmen = GetMaxHenchmen();
    //Check for Leadership, TRUE resets nCountHenchman
    if(GetLocalInt(GetModule(), "nLeadership") == 1)
    {
      nCountHenchmen = GetMaxHenchmen69(oPC);
    }
    string sHench;
    for (iSlot = 1; iSlot <= nCountHenchmen; iSlot++)
    {
        sHench = "Henchman" + IntToString(iSlot);
        //oHench = RetrieveCampaignDBObject(oPC, sHench, lLoc);
        oHench = GetPersistentObject(oPC, sHench, OBJECT_INVALID, "pwhenchdata");
        //CopyObject(oHench, GetLocation(oPC));
        //DelayCommand(0.5, DeleteCampaignDBVariable(oPC, sHench));
        if (GetIsObjectValid(oHench))
        {
            DelayCommand(0.5, DeletePersistentVariable(oPC, sHench, "pwhenchdata"));
            DelayCommand(0.5, HireHenchman(oPC, oHench));
            SetLocalString(oHench, "SHENCH", sHench);
            oDupe = GetNearestObjectByTag(GetTag(oHench), oHench);
            if ((oDupe != OBJECT_INVALID) && (oDupe != oHench))
            {
                AssignCommand(oDupe,SetIsDestroyable(TRUE));
                SetPlotFlag(oDupe,FALSE);
                SetImmortal(oDupe,FALSE);
                DestroyObject(oDupe);
                PrintString("Duplicate Henchman was created & destroyed");
            }
        }
        else
        {
            DBG_msg("No valid henchman retrieved");
            PrintString("No valid henchman retrieved");
        }
    }
}

void StoreCampaignHenchman69(object oPC)
{
    object oHench;
    int ret;
    int iSlot;
    string sHench;
    int nCountHenchmen = GetMaxHenchmen();
    if(GetLocalInt(GetModule(), "nLeadership") == 1)
    {
      nCountHenchmen = GetMaxHenchmen69(oPC);
    }
    for (iSlot = 1; iSlot <= nCountHenchmen; iSlot++)
    {
        oHench = GetHenchman(oPC, iSlot);
        if (!GetIsObjectValid(oHench))
        {
            DBG_msg("No valid henchman to store");
        }
        else
        {
            DBG_msg("Storing henchman: " + GetTag(oHench));
            sHench = "Henchman" + IntToString(iSlot);
            SetLocalString(oHench, "SHENCH", sHench);
            SetPersistentObject(oPC, sHench, oHench, 0, "pwhenchdata");
            DBG_msg("Henchman " + GetName(oHench) + " stored successfully");
        }
    }
}
Back to top
View user's profile Send private message
chris421



Joined: 07 Apr 2005
Posts: 53

PostPosted: Sun Apr 10, 2005 22:16    Post subject: Reply with quote

never mind. i see my answer in another thread. Rolling Eyes
Back to top
View user's profile Send private message
CutterShane



Joined: 25 May 2005
Posts: 5

PostPosted: Wed May 25, 2005 3:37    Post subject: Reply with quote

Which thread? This is killing me.
Back to top
View user's profile Send private message Visit poster's website
eclipse2007



Joined: 08 Jun 2007
Posts: 1

PostPosted: Fri Jun 08, 2007 23:06    Post subject: Thread with a somewhat answer.... Reply with quote

http://www.nwnx.org/phpBB2/viewtopic.php?t=263&highlight=
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules 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