Hi there,
I've successfully spawned in a shopfront, and I'm trying to automatically open it for two players (vendor and customer).
I've attempted to achieve this by replicating the code for ShopFront's implementation of PlayerOpenLoot, since the virtual override will automatically pass true for positionChecks, and I want the two players to open the shop front from anywhere in the world.
What I get is both players opening the shop front, and both players can add/remove items from their respective containers, but the shop front controls and the vendor/customer names do not appear.
private static bool PlayerOpenShopFront(BasePlayer player, ShopFront shopFront)
{
StorageContainer container = shopFront;
bool flag = player.inventory.loot.StartLootingEntity(container, false);
if (flag)
{
BaseEntity ent = container;
if (ent == null) return false;
ent.SetFlag(BaseEntity.Flags.Open, true, false, true);
container.AddContainers(player.inventory.loot);
player.inventory.loot.SendImmediate();
player.ClientRPCPlayer(null, player, "RPC_OpenLootPanel", container.panelName);
ent.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
player.inventory.loot.AddContainer(shopFront.customerInventory);
player.inventory.loot.SendImmediate();
}
return flag;
}
// This is basically a torn apart implementation of the ShopFront class's PlayerOpenLoot function
private static bool OpenShopFront(BasePlayer vendorPlayer, BasePlayer customerPlayer, ShopFront shopFront)
{
if (vendorPlayer == null || !IsPlayerValid(vendorPlayer.IPlayer) || customerPlayer == null || !IsPlayerValid(customerPlayer.IPlayer)
|| shopFront == null || !shopFront.IsValid() || shopFront.IsDestroyed || shopFront.vendorPlayer != null || shopFront.customerPlayer != null) return false;
if (!PlayerOpenShopFront(vendorPlayer, shopFront))
{
return false;
}
if (!PlayerOpenShopFront(customerPlayer, shopFront))
{
return false;
}
shopFront.vendorPlayer = vendorPlayer;
shopFront.customerPlayer = customerPlayer;
shopFront.ResetTrade();
shopFront.UpdatePlayers();
return true;
}
private ShopFront NewTradeShopFront()
{
ShopFront shopFront = GameManager.server.CreateEntity(SHOPFRONT_PREFAB) as ShopFront;
if (shopFront == null) return null;
shopFront.Spawn();
return shopFront;
}