chris421
Joined: 07 Apr 2005 Posts: 53
|
Posted: Sun Apr 10, 2005 18:45 Post subject: Problem recreating Henchmen objects with GetPersistentObject |
|
|
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");
}
}
}
|
|
|