Author Topic: logout location stored only if in inn help/suggestion  (Read 350 times)

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« on: March 11, 2013, 01:41:12 pm »


               Ok here is what I would like to do and was wandering the best way to do it.

If a player logs out while in a bedroom at the  inn, they will start there after reset.

the bedrooms are on the same map so on area wouldn't work.


Maybe be a triggerand set a variable?



EDIT: Ok lvl ones will start normal start location and level 2 and up will start in main inn unless they log out from a different inn.':wizard:'


Ok her is what I will put in trigger in start area to do the first part.

/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625    */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

if (GetHitDice(oPC) < 2)
   return;

object oTarget;
location lTarget;
oTarget = GetWaypointByTag("winterkeepinn");

lTarget = GetLocation(oTarget);

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(lTarget));

}



I just now need to check if the player has a variable on them from another trigger of a different inn then send them there?
               
               

               


                     Modifié par Knight_Shield, 11 mars 2013 - 03:14 .
                     
                  


            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #1 on: March 11, 2013, 06:37:07 pm »


               Ok this is what I have done so far and only if lvl 2 and over works ,cant get the stored Localint to work.


void main()
{

object oPC = GetEnteringObject();
object oTarget;
    location lTarget;
if (!GetIsPC(oPC)) return;

 if (GetLocalInt(oPC, "snowblizzard_port")== 1)
     {


       oTarget = GetWaypointByTag("winterkeepinn1");

       lTarget = GetLocation(oTarget);


       if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

       AssignCommand(oPC, ClearAllActions());

       AssignCommand(oPC, ActionJumpToLocation(lTarget));

      }

  if (GetLocalInt(oPC, "snowblizzard_port")== 2)

     {


      oTarget = GetWaypointByTag("winterkeepinn2");

      lTarget = GetLocation(oTarget);


      if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

      AssignCommand(oPC, ClearAllActions());

      AssignCommand(oPC, ActionJumpToLocation(lTarget));

     }


  if (GetLocalInt(oPC, "snowblizzard_port")== 3)
     {

      object oTarget;
      location lTarget;
      oTarget = GetWaypointByTag("winterkeepinn3");

      lTarget = GetLocation(oTarget);


      if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

      AssignCommand(oPC, ClearAllActions());

      AssignCommand(oPC, ActionJumpToLocation(lTarget));

   }

  else if (GetHitDice(oPC) < 2)
  return;


  oTarget = GetWaypointByTag("winterkeepinn");

  lTarget = GetLocation(oTarget);


  if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

  AssignCommand(oPC, ClearAllActions());

  AssignCommand(oPC, ActionJumpToLocation(lTarget));

  }
               
               

               


                     Modifié par Knight_Shield, 11 mars 2013 - 06:40 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #2 on: March 11, 2013, 08:15:25 pm »


               What happens to PC location normally? Is it not persistent?
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #3 on: March 11, 2013, 08:18:52 pm »


               No normally you start in start area every reset. This script goes in trigger so if level 2 and over you will go to the first towns inn.

It is also suppose to send you too a different room in this inn or another if you walk into the bedroom and trigger setlocalint , but the local intl isnt working.




Basically I want level 2 and over to go to the first towns INN , if they enter a differnet bedroom in this INN or another I want  that to be their start location after reset.
               
               

               


                     Modifié par Knight_Shield, 11 mars 2013 - 08:26 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #4 on: March 12, 2013, 03:27:12 am »


                 This: 

if (GetLocalInt(oPC, "snowblizzard_port")== 1)


Will not work over server resets.    Local Vars stored on the PC are not saved to the characters .bic file.  
You will need to save the data to a data base or onto an item in the in the players inventory.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #5 on: March 12, 2013, 07:28:19 pm »


               Yes, and a simpler way to designate to return to the Inn upon character re-entry, would be to put a local on the area.  So the local Inn set to 1.  Then if the local exsits save the location of the PC, and set the local Inn to 1 on the persistent object, for this discussion call the object database.  Now do nothing whatsoever on Inn exit.  In this way the pc will be sent back to the last Inn they entered or perhaps better the last one they rested in.  If you want to do it on rest.  In this way PC locations are only saved in Inns, but with the added flexiblity that you could add to the designated save location areas, by putting the local Inn set to 1 on them.
Personally I would scrap your first script, and look at some persistent location scripts available on the vault, and alter them to you own specifications.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #6 on: March 12, 2013, 07:32:37 pm »


               Zunath's persistent locations:
http://nwvault.ign.c....Detail&id=3348
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #7 on: March 13, 2013, 06:42:38 pm »


               Ok here is what I did .Please look it over for me.Scrapped the original lol.

The inlcude script supposed to do timed save location,I tried removing that so lever onused saves.

///////////////////////////This is onuse lever in bedroom///////////////////////////////////////////////////////

// -----------------------------------------------------------------------------
//  MAIN - Example OnUsed of placeable script
// -----------------------------------------------------------------------------
#include "se_inc_pc_loc"
void main()
{
    object oPC = GetLastUsedBy();
    SE_SaveLocation(oPC);
    ExecuteScript("x2_plc_used_act", OBJECT_SELF);
}




/////////////////////////////////////////////////////This is an include script/////////////////////////////////////////////////////////////////////
          // Timed Persistant Player Location Save(through a server reset)
// Written by Sir Elric
// 21st July, 2006
// script name - se_inc_pc_loc
// -----------------------------------------------------------------------------
//  CONSTANTS
// -----------------------------------------------------------------------------
const int SEND_MESSAGE = FALSE; // << Send a save location message to player?
const string PC_MESSAGE = "Your location has been saved.";// << Player location message(if active)
const float SAVE_LOCATION_DELAY = 600.0;// << Save location delay
const float JUMP_DELAY = 0.0;
const string CAMPAIGN_NAME = "PERSISTANT_LOCATION";
const string CAMPAIGN_VAR = "PCLocation";

// -----------------------------------------------------------------------------
//  FUNCTIONS
// -----------------------------------------------------------------------------
void SE_SaveLocation(object oPC)
{
    SetCampaignLocation(CAMPAIGN_NAME, CAMPAIGN_VAR, GetLocation(oPC), oPC);
    if(SEND_MESSAGE)
       SendMessageToPC(oPC, PC_MESSAGE);
}
void SE_JumpToPersistantLocation(object oPC)
{
    SetLocalInt(oPC, "ENTERED", TRUE);
    location lLoc = GetCampaignLocation(CAMPAIGN_NAME, CAMPAIGN_VAR, oPC);
    DelayCommand(JUMP_DELAY, AssignCommand(oPC, JumpToLocation(lLoc)));
}
void SE_SavePCLocation(object oPC)
{
   if(GetLocalInt(oPC, "ENTERED") == FALSE)
   {
      SE_JumpToPersistantLocation(oPC);
   }
   else
   {
      SetCampaignLocation(CAMPAIGN_NAME, CAMPAIGN_VAR, GetLocation(oPC), oPC);
      if(SEND_MESSAGE)
         SendMessageToPC(oPC, PC_MESSAGE);
   }
     // DelayCommand(SAVE_LOCATION_DELAY, SE_SavePCLocation(oPC));
      //ExportSingleCharacter(oPC);
}


////////////////////////////////////////////////////this is on a trigger in start area/////////////////////////////////////////////////////////

// -----------------------------------------------------------------------------
//  MAIN - Example OnClientEnter script
// -----------------------------------------------------------------------------
#include "se_inc_pc_loc"
void main()
{
    object oPC = GetEnteringObject();
    if(GetLocalInt(oPC, "ENTERED") == FALSE)
   {
      SE_JumpToPersistantLocation(oPC);
   }
   else
   {
     if (GetHitDice(oPC) < 2)
   return;
      object oTarget;
      location lTarget;

   oTarget = GetWaypointByTag("winterkeepinn");

   lTarget = GetLocation(oTarget);


   if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

   AssignCommand(oPC, ClearAllActions());

   AssignCommand(oPC, ActionJumpToLocation(lTarget));

 }}
               
               

               


                     Modifié par Knight_Shield, 13 mars 2013 - 06:47 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #8 on: March 13, 2013, 08:44:37 pm »


               Too bad Sir Elric could not spell persistent correctly, but his stuff is really good so it should work fine.
So you are going to do it with a placeable, a lever. I never cared for that but whatever works.
So if someone is first level they start at the winterkeep inn.
It should work, but instead of commenting out the save location delay why not just change it to 1 second? By the way you don't need to get the location of the waypoint you can just jump directly to it.

oTarget = GetWaypointByTag("winterkeepinn");

AssignCommand(oPC, ActionJumpToObject(oTarget));
               
               

               


                     Modifié par ffbj, 13 mars 2013 - 08:46 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #9 on: March 13, 2013, 09:23:27 pm »


               btw here's mine:

//goes in the onenter of your start area.
//base on Zunath's persistent locations.
void main()
{
object oPC = GetEnteringObject();
object oItem = GetItemPossessedBy(oPC, "database");
location lLocation = GetLocalLocation(oItem, "PC_LOCATION");
if (GetLocalInt(oItem, "Location") > 0)
{
AssignCommand(oPC, ActionJumpToLocation(lLocation));
}

}

//goes on a lever or whatever device to save current location
void main()
{
   object oPC = GetLastUsedBy();
   if (!GetIsPC(oPC))
  return;
   object  oDatabase = GetItemPossessedBy(oPC, "database");

 location lLocation = GetLocation(oPC);
  // Store the location on the PC's database object
 SetLocalLocation(oDatabase, "PC_LOCATION", lLocation);

   SetLocalInt(oDatabase,"Location", 1);
 //set location to 1 so the on enter will know you have a saved location.(could use True instead)
 SendMessageToPC(oPC, "Location Updated!");
// Inform the player their location was saved. You may comment this out
 // if you want.


}
//add into you onclient enter the script below to create the object database
//I use the blue egg name it Name: Player Database Tag: database Resref: database
void main()
{
object oPC = GetEnteringObject();
object oDatabase = GetItemPossessedBy(oPC, "database");

if (!GetIsObjectValid(oDatabase))
    {
      // Now create the database on the PC if they don't have one make it plot and undroppable
      CreateItemOnObject("database", oPC, 1);

    }
}
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #10 on: March 13, 2013, 09:31:24 pm »


               Thanks ffbj for your replies.

Looks like your way is easier but just spent 3 hours putting this together lol.

Basically have save location on lever so player joins after reset it will take them to their room.

The onenter is in a trigger instead of client enter so they dont go to their room every time.

I cant get them if no location saved but level 2 or greater teleport to the main INN?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #11 on: March 13, 2013, 09:36:18 pm »


               Well I did make one with a lever activated saving script just for you.
You could make a test module and try it out there.
It is always good to have test module. Also the persistent database object is a real bonus as you can use it for so many things. Not trying to tell you how to run your world, just trying to present the alternatives available to you.

To stop less than 2nd levels from going to a save location in mine you could just add in  
  if (GetHitDice(oPC) < 2)
   return;
To the top of the script which creates the database on client enter so they would just go to the start area.
Well good luck with everything.  I am sure it will be fine.   
               
               

               


                     Modifié par ffbj, 13 mars 2013 - 09:41 .
                     
                  


            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #12 on: March 13, 2013, 09:44:53 pm »


               Ok I will give yours a try .

I put "dmfi_pc_dicebag" to replace "database".
               
               

               


                     Modifié par Knight_Shield, 13 mars 2013 - 10:11 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #13 on: March 14, 2013, 12:52:35 pm »


               Sure that way you don't need the script that creates and adds the database to the PC, since they all have the undroppable item, the dicebag.
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
logout location stored only if in inn help/suggestion
« Reply #14 on: March 16, 2013, 04:03:54 pm »


               Script is working great.

I have a problem though.The Lever isn't movingany more?