Broken after latest update
Broken after latest update
Error while compiling Trade: Property or indexer 'StorageContainer.inventory' cannot be assigned to -- it is read only | Line: 1004, Pos: 17
Not my plugin and I am not an expert, but I fixed this on my servers and tested it etc. Find these two methods in your plugin CS file and replace them with the ones I am pasting here ...
void OpenBoxView(BasePlayer player, BaseEntity targArg)
{
var pos = new Vector3(player.transform.position.x, player.transform.position.y - 1, player.transform.position.z);
var boxContainer = GameManager.server.CreateEntity(box, pos) as StorageContainer;
boxContainer.GetComponent<DestroyOnGroundMissing>().enabled = false;
boxContainer.GetComponent<GroundWatch>().enabled = false;
boxContainer.transform.position = pos;
if (!boxContainer) return;
StorageContainer view = boxContainer as StorageContainer;
view.limitNetworking = true;
player.EndLooting();
if (targArg is BasePlayer)
{
BasePlayer target = targArg as BasePlayer;
ItemContainer container = new ItemContainer();
container.playerOwner = player;
container.ServerInitialize(null, slots);
if (container.uid.Value == 0)
container.GiveUID();
view.enableSaving = false;
view.Spawn();
view.inventory.Clear();
foreach (Item item in container.itemList)
{
item.MoveToContainer(view.inventory);
}
onlinePlayers[player].View = view;
timer.In(0.1f, () => view.PlayerOpenLoot(player));
}
}
void CloseBoxView(BasePlayer player, StorageContainer view)
{
OnlinePlayer onlinePlayer;
if (!onlinePlayers.TryGetValue(player, out onlinePlayer)) return;
if (onlinePlayer.View == null) return;
HideTrade(player);
if (onlinePlayer.Trade != null)
{
OpenTrade t = onlinePlayer.Trade;
t.closing = true;
if (t.sourcePlayer == player && t.targetPlayer != player && t.target.View != null)
{
t.target.Trade = null;
CloseBoxView(t.targetPlayer, t.target.View);
}
else if (t.targetPlayer == player && t.sourcePlayer != player && t.source.View != null)
{
t.source.Trade = null;
CloseBoxView(t.sourcePlayer, t.source.View);
}
if (openTrades.Contains(t))
{
openTrades.Remove(t);
}
}
if (view.inventory.itemList.Count > 0)
{
foreach (Item item in view.inventory.itemList.ToArray())
{
if (item.position != -1)
{
item.MoveToContainer(player.inventory.containerMain);
}
}
}
if (view.inventory.itemList.Count > 0)
{
foreach (Item item in view.inventory.itemList.ToArray())
{
if (item.position != -1)
{
item.MoveToContainer(player.inventory.containerBelt);
}
}
}
if (player.inventory.loot.entitySource != null)
{
player.inventory.loot.Invoke("SendUpdate", 0.1f);
view.SendMessage("PlayerStoppedLooting", player, SendMessageOptions.DontRequireReceiver);
player.SendConsoleCommand("inventory.endloot", null);
}
player.inventory.loot.entitySource = null;
player.inventory.loot.itemSource = null;
player.inventory.loot.containers = new List<ItemContainer>();
view.inventory.Clear();
onlinePlayer.Clear();
view.Kill(BaseNetworkable.DestroyMode.None);
if (onlinePlayers.Values.Count(p => p.View != null) <= 0)
{
UnsubscribeAll();
}
}
tbird412
Not my plugin and I am not an expert, but I fixed this on my servers and tested it etc. Find these two methods in your plugin CS file and replace them with the ones I am pasting here ...
void OpenBoxView(BasePlayer player, BaseEntity targArg) { var pos = new Vector3(player.transform.position.x, player.transform.position.y - 1, player.transform.position.z); var boxContainer = GameManager.server.CreateEntity(box, pos) as StorageContainer; boxContainer.GetComponent<DestroyOnGroundMissing>().enabled = false; boxContainer.GetComponent<GroundWatch>().enabled = false; boxContainer.transform.position = pos; if (!boxContainer) return; StorageContainer view = boxContainer as StorageContainer; view.limitNetworking = true; player.EndLooting(); if (targArg is BasePlayer) { BasePlayer target = targArg as BasePlayer; ItemContainer container = new ItemContainer(); container.playerOwner = player; container.ServerInitialize(null, slots); if (container.uid.Value == 0) container.GiveUID(); view.enableSaving = false; view.Spawn(); view.inventory.Clear(); foreach (Item item in container.itemList) { item.MoveToContainer(view.inventory); } onlinePlayers[player].View = view; timer.In(0.1f, () => view.PlayerOpenLoot(player)); } } void CloseBoxView(BasePlayer player, StorageContainer view) { OnlinePlayer onlinePlayer; if (!onlinePlayers.TryGetValue(player, out onlinePlayer)) return; if (onlinePlayer.View == null) return; HideTrade(player); if (onlinePlayer.Trade != null) { OpenTrade t = onlinePlayer.Trade; t.closing = true; if (t.sourcePlayer == player && t.targetPlayer != player && t.target.View != null) { t.target.Trade = null; CloseBoxView(t.targetPlayer, t.target.View); } else if (t.targetPlayer == player && t.sourcePlayer != player && t.source.View != null) { t.source.Trade = null; CloseBoxView(t.sourcePlayer, t.source.View); } if (openTrades.Contains(t)) { openTrades.Remove(t); } } if (view.inventory.itemList.Count > 0) { foreach (Item item in view.inventory.itemList.ToArray()) { if (item.position != -1) { item.MoveToContainer(player.inventory.containerMain); } } } if (view.inventory.itemList.Count > 0) { foreach (Item item in view.inventory.itemList.ToArray()) { if (item.position != -1) { item.MoveToContainer(player.inventory.containerBelt); } } } if (player.inventory.loot.entitySource != null) { player.inventory.loot.Invoke("SendUpdate", 0.1f); view.SendMessage("PlayerStoppedLooting", player, SendMessageOptions.DontRequireReceiver); player.SendConsoleCommand("inventory.endloot", null); } player.inventory.loot.entitySource = null; player.inventory.loot.itemSource = null; player.inventory.loot.containers = new List<ItemContainer>(); view.inventory.Clear(); onlinePlayer.Clear(); view.Kill(BaseNetworkable.DestroyMode.None); if (onlinePlayers.Values.Count(p => p.View != null) <= 0) { UnsubscribeAll(); } }
dont worked for me :(
can u please share the .cs file`?
aselsa
dont worked for me :(
can u please share the .cs file`?
I think random plugin updates are against the rules, but snippets are okay.
PPlank
I think random plugin updates are against the rules, but snippets are okay.
did it work for u?
Yes it worked for me after a bit of trial and error. The formatting was a little different from the official plugin. e.g.
void OpenBoxView(BasePlayer player, BaseEntity targArg)was
void OpenBoxView (BasePlayer player, BaseEntity targArg)
So thank you @tbird412, all working. 🙂
PPlank
Yes it worked for me after a bit of trial and error. The formatting was a little different from the official plugin. e.g.
void OpenBoxView(BasePlayer player, BaseEntity targArg)was
in the official plugin and it wasn't so obvious to do a "find" but the space shouldn't have made a difference to the functionality. After a bit of careful copy-pasting it started compiling.
void OpenBoxView (BasePlayer player, BaseEntity targArg)
So thank you @tbird412, all working. 🙂
Oh my bad, I may have been on an old version of it or something. But yes, it should work. No problem!