Author Topic: NBDE_SetCampaignLocation  (Read 309 times)

Legacy_Evelath

  • Full Member
  • ***
  • Posts: 108
  • Karma: +0/-0
NBDE_SetCampaignLocation
« on: June 21, 2013, 07:48:32 pm »


               I am attempting to work on a persistent location function that fires when a player uses their item, and can be pulled when a player uses a portal when the server resets. Here are my two scripts:

Item script:

#include "nbde_inc"

//------------------------------------------------
    const string CAMPAIGN_NAME = "PC_Location";
    const string CAMPAIGN_VAR = "PCLocation";
//------------------------------------------------

void main()
{


    object oPC;

    oPC = GetItemActivator();
    location locLocation;

    // Store the location in the PC's database
    NBDE_SetCampaignLocation(CAMPAIGN_NAME, CAMPAIGN_VAR, GetLocation(oPC), oPC);
    NBDE_FlushCampaignDatabase("PC_Location");

    // Inform the player their location was saved. You may comment this out
    // if you want.
    SendMessageToPC(oPC, "Location Saved!");

}

Portal Script:

#include "nbde_inc"

//------------------------------------------------
    const string CAMPAIGN_NAME = "PC_Location";
    const string CAMPAIGN_VAR = "PCLocation";
//------------------------------------------------

void main()
{

object   oPC = GetLastUsedBy();
location locLocation = NBDE_GetCampaignLocation(CAMPAIGN_NAME, CAMPAIGN_VAR, oPC);

if (!GetIsPC(oPC)) return;

if(GetIsObjectValid(GetAreaFromLocation(locLocation)))

{
DelayCommand(1.0,ActionJumpToLocation(locLocation));
}

}

I'm not the most skilled at scripting for NWN; but I am trying to figure this out. Any help would be appreciated. It appears the script is not writing to the DB, and I can't seem to get this to work itself out.
               
               

               


                     Modifié par Evelath, 21 juin 2013 - 06:50 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NBDE_SetCampaignLocation
« Reply #1 on: June 21, 2013, 07:57:23 pm »


               hmm,  It looks like the problem may be in your portal script.    

DelayCommand(1.0,ActionJumpToLocation(locLocation));

Since It looks like the script is running on the portal placeable you are in effect giving the portal the action to jump to the location.   Try assigning the action jump to the PC instead of delaying the action.
               
               

               
            

Legacy_Evelath

  • Full Member
  • ***
  • Posts: 108
  • Karma: +0/-0
NBDE_SetCampaignLocation
« Reply #2 on: June 21, 2013, 08:13:01 pm »


               That did it! Thanks for the extremely quick reply Lightfoot8, I appreciate it.

Funny how the problem with the script was the thing that I thought I had down easy. '<img'>