Copy Area Transition

Trying to instance player housing. I have been messing with this for far too long and cannot get it to work. Any insights would be great. playerhouse is the name and tag of the house area.
void main() { object oPC = GetPCSpeaker(); string spc = GetName(oPC); object oArea = GetObjectByTag("playerhouse"); int iexist = GetIsObjectValid(oArea); if (iexist !=1) CreateArea("playerhouse"); //rename waypoint for player object oWP = GetWaypointByTag("playerhousestart"); string destination = spc + "dest"; SetTag(oWP,destination); object oTarget = GetWaypointByTag(destination); // create area CopyArea(oArea); // Teleport the PC. AssignCommand(oPC, ClearAllActions()); AssignCommand(oPC, JumpToObject(oTarget));
0
Comments
Your first if statement should look more like:
Now the CopyArea call. I don't think it's doing anything helpful. Let's say you have a template area for a player house. When a player builds a house, that template could be copied, then populated with placeables.
(Or the server has reset and the built house needs to be recreated and populated.) If that is the way it's being done, then that template area should never be modified by scripts.
One idea I suggest is to add a function to your OnClientEnter script that assigns players a unique tag.
That way, any time you need to tie something to a character, you can just use GetTag on them. (I am more than happy to share my function with you if you want.)
Here's my function: And then the if statements in OnClientEnter: Obviously you can change the ZZ part to whatever you want. I just have it in there in the off chance that someone is somehow able to sneak a character in that already has a tag. If they already have that, what else have they given themself?
CopyArea follows the naming convention. It Copies an area that currently exists and makes a replica of the area in it's current state.
Let's imagine a tiny area with a single chest in the middle. The Chest is empty in the toolset and when the module loads.
A player walks into the area, and puts a longsword into the chest, then leaves.
Now:
CreateArea: Creates a new area with an empty chest, as it was in the toolset.
CopyArea: Creates a new area with a chest that has a longsword in it, as the area currently does.
There are now three areas. The Original, the Created one (no sword) and the Copied one (Sword)
The biggest change I would make is this:
However, you have provided a cleaner method of doing this so thank you very much.