Saving Player locations

I’m a a bit rusty on my scripting, I’m working on a PW again and was wondering, Is there anyway to store a player location without using a database? Everything I looked at so far uses a database and I’m trying to avoid using one.

I’m not much of a scripter but can you use GetLocation on the PC and then spawn a waypoint for this coordinates?

Although I have to admit that in all the NWN PWs I have played I never re-entered at the place I logged out after relogging, I always spawned at some fixed spawn point that was also used for death respawning.

To my (also rusty) knowledge, there is no way to do so if you want it to persist through a server reset/reboot. Need the DB for that.

If you just need it temporarily, though, you can store it on the PC.

does this work in NwN1?

// 'saveloc_inc'

void SetSavedLocation(string sVar, object oObject)
    object oModule = GetModule();

    string sArea = GetTag(GetArea(oObject));
    SetLocalString(oModule, sVar + "_area", sArea);

    float fFace = GetFacing(oObject);
    SetLocalFloat(oModule, sVar + "_face", fFace);

    vector vObject = GetPosition(oObject);
    SetLocalFloat(oModule, sVar + "_x", vObject.x);
    SetLocalFloat(oModule, sVar + "_y", vObject.y);
    SetLocalFloat(oModule, sVar + "_z", vObject.z);

location GetSavedLocation(string sVar)
    object oModule = GetModule();

    object oArea = GetObjectByTag(GetLocalString(oModule, sVar + "_area"));

    float fFace = GetLocalFloat(oModule, sVar + "_face");

    float fx = GetLocalFloat(oModule, sVar + "_x");
    float fy = GetLocalFloat(oModule, sVar + "_y");
    float fz = GetLocalFloat(oModule, sVar + "_z");
    vector vObject = Vector(fx, fy, fz);

    return Location(oArea, vObject, fFace);

//void main(){}

@kevL_s NWN1 has Set/GetLocalLocation which is a one-liner.

The problem raised by the OP is how to make it persistent without using a data base.

ah …

are vars on the module object not persistent? Or, is the problem defining sVar …

edit: ok i get it – reload wipes vars on the module.

Just a thought. Don’y know if this is 100% doable but here goes. You script it so that the player is given a code which they then enter on returning which takes them back to the location. It’s probably better to use a database though as it will probably hold more information than just the location.


use undroppable unstackable item, storing local variables on item will persist through server restart

see this module for example

1 Like

Thank you all for your help. After doing more searching on the vault I decided to go with this system I know its not really persistant but it will serve my purpose. Thanks again

You can store the location by unpacking the area name and co-ordinates and then storing them in PC’s skin using Taro94’s persvars_inc or my mod of it and have it persist across sessions and reboots without the need for a database.