ATTENTION! The process of updating WiKi to version Eco 10.x has begun. Those wishing to participate can find out more Information on our ECO Contribution Wiki Discord.
From April 26 to May 12, errors may occur in the Wiki, as we will be carrying out a major update to the information processing modules.

Debugging store interactions

From Eco - English Wiki
Warning: This content is outdated.

> Version: 7.3.1

> Difficulty: Medium

Introduction[edit | edit source]

Unfortunately, interaction objects that exhibit different behavior when owned or not owned by you are hard to debug. The reason is that there is currently no way that you can transfer ownership of an object to someone else programmatically. Even though there is a way to claim deeds, a dummy cannot do that for you. Besides dummies created by `/dummy` and `/metime` seem to have the same _slg _/ _steamId_ as you, which means that you jointly own property with them. To make debugging possible without having to invite a friend over to the server I decided to write a mod.

Principles[edit | edit source]

This mod introduces two new developer commands: `/transferproperty` and `/returnproperty`. The first creates or fetches a user named _PropertyHolderDummy_. This player will not be physically in the game. It is an offline player as it were. The mod then fetches all property held by you and transfers it to the dummy. The `/returnproperty` command will do the reverse and strip all property from the dummy and transfer it to you.

Mechanics[edit | edit source]

To get to the property of a player one uses `PropertyManager.PropertyForUser`. This returns so-called `PropertyPlot`s which refer to an `AuthrorizationController` that you can use to set ownership with the `SetOwner` method.

Code[edit | edit source]

transferproperty[edit | edit source]

 // Spawn a dummy player
var dummy = UserManager.GetOrCreateUser(null, "PropertyHolderDummy", "PropertyHolderDummy");
// Get all propery of this player
foreach (var a in PropertyManager.PropertyForUser(user).Select(p => p.GetAuth()))
{
    a.SetOwner(dummy.Name);
}

The second parameter of `UserManager.GetOrCreateUser` is the user's _slgId_. Assigning your _slgId_ to this would effectively clone yourself and you would jointly own property, defeating the purpose of this mod.

returnproperty[edit | edit source]

 // Get all propery back from the dummy
foreach (var a in PropertyManager.PropertyForUser(UserManager.FindUserByName(dummyName)).Select(p => p.GetAuth()))
{
    a.SetOwner(user.Name);
}

As you can see all the property owned by the dummy is returned to the user here.

That's all folks!