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 .