Beispiel #1
0
        private static void ValidateAndUpdateConfig(EconConfigStruct config)
        {
            EconomyScript.Instance.ServerLogger.WriteInfo("Validating and Updating Config.");

            // Sync in whatever is defined in the game (may contain new cubes, and modded cubes).
            MarketManager.SyncMarketItems(ref config.DefaultPrices);

            if (config.TradeTimeout.TotalSeconds < 1f)
            {
                config.TradeTimeout = new TimeSpan(0, 0, 1); // limit minimum trade timeout to 1 second.
                EconomyScript.Instance.ServerLogger.WriteWarning("TradeTimeout has been reset, as it was below 1 second.");
            }
        }
Beispiel #2
0
        /// <summary>
        /// This is for more complex and CPU intensive check that should be run less often.
        /// </summary>
        private static void DisplayHud100()
        {
            ClientConfig clientConfig = EconomyScript.Instance.ClientConfig;

            // client config has not been received from server yet.
            if (clientConfig == null)
                return;

            if (clientConfig.ClientHudSettings.ShowHud && clientConfig.HudReadout != null)
            {
                // if the player does not have a controlable body yet, no point displaying a hud.
                if (MyAPIGateway.Session.Player.Controller?.ControlledEntity?.Entity != null)
                {
                    Vector3D position = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetPosition();

                    if (clientConfig.ClientHudSettings.ShowRegion)
                    {
                        string tradeZoneName = "None";
                        List<ulong> tradeZones = new List<ulong>();
                        // Get tradezone from player current position.
                        List<MarketStruct> markets = MarketManager.ClientFindMarketsFromLocation(
                            clientConfig.Markets,
                            position,
                            clientConfig.ServerConfig.EnablePlayerTradezones,
                            clientConfig.ServerConfig.EnableNpcTradezones);

                        if (markets.Count > 0)
                        {
                            tradeZoneName = markets.Select(m => m.DisplayName).Aggregate((current, next) => current + ", " + next);
                        }
                        bool newZoneDetected = false;
                        foreach (MarketStruct market in markets)
                        {
                            newZoneDetected |= !clientConfig.TradeZones.Contains(market.MarketId);
                            tradeZones.Add(market.MarketId);
                        }

                        clientConfig.TradeZoneName = tradeZoneName;
                        clientConfig.TradeZones = tradeZones;

                        // don't play sound if this is the first update of hud.
                        if (newZoneDetected && !_initialUpdate)
                        {
                            // play sound on NEW zone.
                            MessageClientSound.PlaySound("tradezonedetA", 0.2f);
                        }
                    }
                    _initialUpdate = false;
                }
            }
        }