public override void ProcessServer()
        {
            if (ConquestScript.Instance.DataLock.TryAcquireExclusive())
            {
                string Title   = "Conquest Faction Leaderboard";
                string Prefix  = "Points last updated " + (MyAPIGateway.Session.GameDateTime - ConquestScript.Instance.Data.LastRun).Minutes.ToString() + " minutes ago.";
                string Content = " Tag   Faction Name  Points  Base type count";


                foreach (ConquestFaction Faction in ConquestScript.Instance.Data.ConquestFactions)
                {
                    Content += string.Format("\n {0}   {1}  {2}     ", Faction.FactionTag, Faction.FactionName, Faction.VictoryPoints.ToString());
                    if (ConquestScript.Instance.Config.PlanetPoints > 0)
                    {
                        Content += string.Format("P:{0} ", Faction.PlanetBases.ToString());
                    }
                    if (ConquestScript.Instance.Config.MoonPoints > 0)
                    {
                        Content += string.Format("M:{0} ", Faction.MoonBases.ToString());
                    }
                    if (ConquestScript.Instance.Config.AsteroidPoints > 0)
                    {
                        Content += string.Format("A:{0} ", Faction.AsteroidBases.ToString());
                    }
                }
                ConquestScript.Instance.DataLock.ReleaseExclusive();
                MessageClientDialogMessage.SendMessage(SenderSteamId, Title, Prefix, Content);
            }
            else
            {
                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base", "Server busy, try again later.");
            }
        }
        public override void ProcessServer()
        {
            if (ConquestScript.Instance.DataLock.TryAcquireExclusive())
            {
                ConqDataStruct TempData = ConquestScript.Instance.Data;
                ConquestScript.Instance.DataLock.ReleaseExclusive();
                MyAPIGateway.Parallel.Start(delegate()
                {
                    try
                    {
                        bool IsValid   = true;
                        string Reasons = "";
                        if (TempData.ConquestExclusions.Count > 0)
                        {
                            foreach (ConquestExclusionZone Zone in TempData.ConquestExclusions)
                            {
                                if ((Vector3D.Distance(TempPosition, Zone.Position) < Zone.Radius))
                                {
                                    Reasons += string.Format("\nwithin exclusion zone: {0}", Zone.DisplayName);
                                    IsValid  = false;
                                }
                            }
                        }
                        bool boAR = false;
                        if ((ConquestScript.Instance.Config.AreaReq) && (TempData.ConquestAreas.Count > 0))
                        {
                            foreach (ConquestAreaZone Zone in TempData.ConquestAreas)
                            {
                                if ((Vector3D.Distance(TempPosition, Zone.Position) < Zone.Radius))
                                {
                                    boAR = true;
                                    break;
                                }
                            }

                            if (!boAR)
                            {
                                Reasons += "\n is not within a Conquest Area";
                            }
                        }
                        if (TempData.ConquestBases.Count > 0)
                        {
                            foreach (ConquestBase ConqBase in TempData.ConquestBases)
                            {
                                if (Vector3D.Distance(TempPosition, ConqBase.Position) < ConqBase.Radius)
                                {
                                    Reasons += string.Format("\nwithin broadcast range of Conquest Base: {0}", ConqBase.DisplayName);
                                    IsValid  = false;
                                }
                            }
                        }
                        if (IsValid)
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base", "This is a valid position for a conquest base");
                        }
                        else
                        {
                            MessageClientDialogMessage.SendMessage(SenderSteamId, "Conquest Base", "This is NOT a valid position for a conquest base", Reasons);
                        }
                    }
                    catch (Exception ex)
                    {
                        ConquestScript.Instance.ServerLogger.WriteException(ex);
                        MyAPIGateway.Utilities.ShowMessage("Error", "An exception has been logged in the file:" + ConquestScript.Instance.ServerLogger.LogFileName);
                    }
                });
            }
            else
            {
                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base", "Server busy, try again later.");
            }
        }
        public override void ProcessServer()
        {
            var player = MyAPIGateway.Players.FindPlayerBySteamId(SenderSteamId);

            // Only Admin can change config.
            if (!player.IsAdmin())
            {
                ShowConfig();
                return;
            }


            // These will match with names defined in the RegEx pattern <ConquestScript.Conquest ConfigPattern>
            switch (ConfigName)
            {
                #region planetpoints

            case "planetpoints":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for planet bases: {0}", ConquestScript.Instance.Config.PlanetPoints.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.PlanetPoints = intTest;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for planet bases updated to: {0}", ConquestScript.Instance.Config.PlanetPoints.ToString());
                        return;
                    }
                }
                break;

                #endregion

                #region moonpoints

            case "moonpoints":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for moon bases: {0}", ConquestScript.Instance.Config.MoonPoints.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.MoonPoints = intTest;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for moon bases updated to: {0}", ConquestScript.Instance.Config.MoonPoints.ToString());
                        return;
                    }
                }
                break;

                #endregion

                #region asteroidpoints

            case "asteroidpoints":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for asteroid bases: {0}", ConquestScript.Instance.Config.AsteroidPoints.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.AsteroidPoints = intTest;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Points for asteroid bases updated to: {0}", ConquestScript.Instance.Config.AsteroidPoints.ToString());
                        return;
                    }
                }
                break;

                #endregion

                #region planetsize

            case "planetsize":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Planet size: {0} (if it is smaller then it is a moon)", ConquestScript.Instance.Config.PlanetSize.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        if ((intTest > 120000) || (intTest < 19000))
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Planet size must be between 19000 and 120000");
                            return;
                        }
                        else
                        {
                            ConquestScript.Instance.Config.PlanetSize = intTest;
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Planet size updated to: {0}", ConquestScript.Instance.Config.PlanetSize.ToString());
                            return;
                        }
                    }
                }
                break;

                #endregion

                #region beacondistance

            case "beacondistance":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Required beacon/antenna broadcast distance: {0}", ConquestScript.Instance.Config.BeaconDistance.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        if (intTest > 50000)
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum broadcast radius for beacons/antennas is 50000m");
                            return;
                        }
                        else
                        {
                            ConquestScript.Instance.Config.BeaconDistance = intTest;
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Required beacon/antenna broadcast distance updated to: {0}", ConquestScript.Instance.Config.BeaconDistance.ToString());
                            return;
                        }
                    }
                }
                break;

                #endregion

                #region updatefrequency

            case "updatefrequency":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Conquest bases are checked and points are talled every {0} minutes.", ConquestScript.Instance.Config.UpdateFrequency.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.UpdateFrequency = intTest;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Update frequency updated to: {0} minutes. Server restart required.", intTest.ToString());
                        return;
                    }
                }
                break;

                #endregion

                #region assemblerreq

            case "assemblerreq":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Assembler required: {0}", ConquestScript.Instance.Config.AssemblerReq ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        ConquestScript.Instance.Config.AssemblerReq = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Assembler required updated to: {0}", ConquestScript.Instance.Config.AssemblerReq ? "On" : "Off");
                        return;
                    }

                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Assembler required: {0}", ConquestScript.Instance.Config.AssemblerReq ? "On" : "Off");
                }
                break;

                #endregion

                #region refineryreq

            case "refineryreq":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Refinery required: {0}", ConquestScript.Instance.Config.RefineryReq ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        ConquestScript.Instance.Config.RefineryReq = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Refinery required updated to: {0}", ConquestScript.Instance.Config.RefineryReq ? "On" : "Off");
                        return;
                    }

                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Refinery required: {0}", ConquestScript.Instance.Config.RefineryReq ? "On" : "Off");
                }
                break;

                #endregion

                #region cargoreq

            case "cargoreq":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Cargo required: {0}", ConquestScript.Instance.Config.CargoReq ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        ConquestScript.Instance.Config.CargoReq = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Cargo required updated to: {0}", ConquestScript.Instance.Config.CargoReq ? "On" : "Off");
                        return;
                    }

                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Cargo required: {0}", ConquestScript.Instance.Config.CargoReq ? "On" : "Off");
                }
                break;

                #endregion

                #region staticreq

            case "staticreq":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Conquests bases are required to be static grids: {0}", ConquestScript.Instance.Config.StaticReq ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        ConquestScript.Instance.Config.StaticReq = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Static required updated to: {0}", ConquestScript.Instance.Config.StaticReq ? "On" : "Off");
                        return;
                    }

                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Conquests bases are required to be static grids: {0}", ConquestScript.Instance.Config.StaticReq ? "On" : "Off");
                }
                break;

                #endregion

                #region areareq

            case "areareq":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Conquests bases are required to be inside a designated conquest area: {0}", ConquestScript.Instance.Config.AreaReq ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        ConquestScript.Instance.Config.AreaReq = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Designated Conquest area required updated to: {0}", ConquestScript.Instance.Config.AreaReq ? "On" : "Off");
                        return;
                    }

                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Designated Conquests area required: {0}", ConquestScript.Instance.Config.AreaReq ? "On" : "Off");
                }
                break;

                #endregion

                #region lcds

            case "lcds":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "LCD updating is: {0}", ConquestScript.Instance.Config.EnableLcds ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.EnableLcds && !boolTest.Value;
                        ConquestScript.Instance.Config.EnableLcds = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "LCD updates changed to: {0}", ConquestScript.Instance.Config.EnableLcds ? "On" : "Off");
                        if (clearRefresh)
                        {
                            LcdManager.BlankLcds();
                        }
                        return;
                    }



                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "LCD updating is: {0}", ConquestScript.Instance.Config.EnableLcds ? "On" : "Off");
                }
                break;

                #endregion

                #region antenna

            case "antenna":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Antenna usage is: {0}", ConquestScript.Instance.Config.Antenna ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.Antenna && !boolTest.Value;
                        ConquestScript.Instance.Config.Antenna = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Antenna usage changed to: {0}", ConquestScript.Instance.Config.Antenna ? "On" : "Off");

                        return;
                    }
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Antenna usage is: {0}", ConquestScript.Instance.Config.Antenna ? "On" : "Off");
                }
                break;

                #endregion

                #region persistent

            case "persistent":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "persistence is: {0}", ConquestScript.Instance.Config.Persistent ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.Persistent && !boolTest.Value;
                        ConquestScript.Instance.Config.Persistent = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "persistence changed to: {0}", ConquestScript.Instance.Config.Persistent ? "On" : "Off");

                        return;
                    }
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "persistence iss: {0}", ConquestScript.Instance.Config.Persistent ? "On" : "Off");
                }
                break;

                #endregion

                #region upgrades

            case "upgrades":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest upgrade modules are: {0}", ConquestScript.Instance.Config.Upgrades ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.Upgrades && !boolTest.Value;
                        ConquestScript.Instance.Config.Upgrades = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest upgrade modules are now: {0}", ConquestScript.Instance.Config.Upgrades ? "On" : "Off");

                        return;
                    }
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest upgrade modules are: {0}", ConquestScript.Instance.Config.Upgrades ? "On" : "Off");
                }
                break;

                #endregion

                #region Reward

            case "reward":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest rewards are: {0}", ConquestScript.Instance.Config.Reward ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.Reward && !boolTest.Value;
                        ConquestScript.Instance.Config.Reward = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest rewards are now: {0}", ConquestScript.Instance.Config.Reward ? "On" : "Off");

                        return;
                    }
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest rewards are: {0}", ConquestScript.Instance.Config.Reward ? "On" : "Off");
                }
                break;

                #endregion

                #region MaxBonusTime

            case "maxbonustime":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Time is {0} minutes", ConquestScript.Instance.Config.MaxBonusTime.ToString());
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.MaxBonusTime = intTest;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Time updated to: {0} minutes", ConquestScript.Instance.Config.MaxBonusTime.ToString());
                        return;
                    }
                }
                break;

                #endregion

                #region maxbonusmod

            case "maxbonusmod":
                if (string.IsNullOrEmpty(Value))
                {
                    if (ConquestScript.Instance.Config.MaxBonusMod > 1)
                    {
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Modifier is {0} (Time modifier is enabled)", ConquestScript.Instance.Config.MaxBonusMod.ToString());
                    }
                    else
                    {
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Modifier is {0} (Time modifier is disabled)", ConquestScript.Instance.Config.MaxBonusMod.ToString());
                    }
                }
                else
                {
                    int intTest;
                    if (int.TryParse(Value, out intTest))
                    {
                        ConquestScript.Instance.Config.MaxBonusMod = intTest;
                        if (intTest > 1)
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Modifier updated to: {0} (Time modifier is enabled)", ConquestScript.Instance.Config.MaxBonusMod.ToString());
                        }
                        else
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "Maximum Bonus Modifier updated to: {0} (Time modifier is disabled)", ConquestScript.Instance.Config.MaxBonusMod.ToString());
                        }
                        return;
                    }
                }
                break;

                #endregion

                #region Debug

            case "debug":
                if (string.IsNullOrEmpty(Value))
                {
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest debug is: {0}", ConquestScript.Instance.Config.Debug ? "On" : "Off");
                }
                else
                {
                    bool?boolTest = GetBool(Value);
                    if (boolTest.HasValue)
                    {
                        var clearRefresh = ConquestScript.Instance.Config.Debug && !boolTest.Value;
                        ConquestScript.Instance.Config.Debug = boolTest.Value;
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest debug is now: {0}", ConquestScript.Instance.Config.Debug ? "On" : "Off");

                        return;
                    }
                    MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Config", "conquest debug is: {0}", ConquestScript.Instance.Config.Debug ? "On" : "Off");
                }
                break;

                #endregion

            default:
                // No Cases matched!
                ShowConfig();
                break;
            }
        }
        public override void ProcessServer()
        {
            if (ConquestScript.Instance.DataLock.TryAcquireExclusive())
            {
                ConqDataStruct TempData = ConquestScript.Instance.Data;
                ConquestScript.Instance.DataLock.ReleaseExclusive();
                MyAPIGateway.Parallel.Start(delegate()
                {
                    try
                    {
                        bool IsValid             = true;
                        string Reasons           = "";
                        IMyCubeGrid SelectedGrid = MyAPIGateway.Entities.GetEntityById(SelectedGridId) as IMyCubeGrid;
                        if (SelectedGrid == null)
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base", "Error: Could not retrieve IMyCubeGrid, are you looking at a block with a terminal?");
                            return;
                        }
                        if (TempData.ConquestExclusions.Count > 0)
                        {
                            foreach (ConquestExclusionZone Zone in TempData.ConquestExclusions)
                            {
                                if ((Vector3D.Distance(SelectedGrid.GetPosition(), Zone.Position) < Zone.Radius))
                                {
                                    Reasons += string.Format("\n {0} is within exclusion zone: {1}", SelectedGrid.DisplayName, Zone.DisplayName);
                                    IsValid  = false;
                                }
                            }
                        }
                        bool boAR = false;
                        if ((ConquestScript.Instance.Config.AreaReq) && (TempData.ConquestAreas.Count > 0))
                        {
                            foreach (ConquestAreaZone Zone in TempData.ConquestAreas)
                            {
                                if ((Vector3D.Distance(TempPosition, Zone.Position) < Zone.Radius))
                                {
                                    boAR = true;
                                    break;
                                }
                            }

                            if (!boAR)
                            {
                                Reasons += string.Format("\n {0} is not within a Conquest Area", SelectedGrid.DisplayName);
                            }
                        }
                        ConquestGrid ConqGrid = new ConquestGrid(SelectedGrid);
                        if (TempData.ConquestBases.Count > 0)
                        {
                            foreach (ConquestBase ConqBase in TempData.ConquestBases)
                            {
                                // If this isn't the same grid...
                                if (SelectedGrid.EntityId != ConqBase.EntityId)
                                {
                                    if (Vector3D.Distance(SelectedGrid.GetPosition(), ConqBase.Position) < ConqBase.Radius)
                                    {
                                        Reasons += string.Format("\n {0} is within broadcast range of Conquest Base: {1}", SelectedGrid.DisplayName, ConqBase.DisplayName);
                                        IsValid  = false;
                                    }
                                    if (Vector3D.Distance(ConqGrid.Position, ConqBase.Position) < ConqGrid.Radius)
                                    {
                                        Reasons += string.Format("\n Conquest Base {0} is within broadcast range", ConqBase.DisplayName);
                                        IsValid  = false;
                                    }
                                }
                            }
                        }
                        if (ConqGrid.IsValid && IsValid)
                        {
                            //MyAPIGateway.Utilities.ShowMessage("ConquestBase", SelectedBlock.CubeGrid.DisplayName + " Is a valid Conquest Base!");
                            if (ConquestScript.Instance.Config.Reward)
                            {
                                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base",
                                                                     string.Format(" {0} Is a valid Conquest Base broadcasting at {1}m for {2}% of possible reward.", SelectedGrid.DisplayName, ConqGrid.Radius, Math.Round(ConqGrid.Radius / 500)));
                            }
                            else
                            {
                                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base",
                                                                     string.Format(" {0} Is a valid Conquest Base.", SelectedGrid.DisplayName));
                            }
                        }
                        else
                        {
                            foreach (string reason in ConqGrid.Reasons)
                            {
                                Reasons += reason;
                            }
                            MessageClientDialogMessage.SendMessage(SenderSteamId, "Conquest Base", string.Format(" {0} Is NOT a valid Conquest Base", SelectedGrid.DisplayName), Reasons);
                        }
                    }
                    catch (Exception ex)
                    {
                        ConquestScript.Instance.ServerLogger.WriteException(ex);
                        MyAPIGateway.Utilities.ShowMessage("Error", "An exception has been logged in the file: " + ConquestScript.Instance.ServerLogger.LogFileName);
                    }
                });
            }
            else
            {
                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Base", "Server busy, try again later.");
            }
        }
Esempio n. 5
0
        public override void ProcessServer()
        {
            if (ConquestScript.Instance.DataLock.TryAcquireExclusive())
            {
                try
                {
                    var player = MyAPIGateway.Players.FindPlayerBySteamId(SenderSteamId);
                    if (player == null || !player.IsAdmin()) // hold on there, are we an admin first?
                    {
                        return;
                    }
                    switch (CommandType)
                    {
                    case AreaManage.Add:
                    {
                        if (string.IsNullOrWhiteSpace(ZoneName) || ZoneName == "*")
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area Add", "Invalid name supplied for the zone name.");
                            ConquestScript.Instance.DataLock.ReleaseExclusive();
                            return;
                        }

                        var checkZone = ConquestScript.Instance.Data.ConquestAreas.FirstOrDefault(m => m.DisplayName.Equals(ZoneName, StringComparison.InvariantCultureIgnoreCase));
                        if (checkZone != null)
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area Add", "A conquest Area zone of name '{0}' already exists.", checkZone.DisplayName);
                            ConquestScript.Instance.DataLock.ReleaseExclusive();
                            return;
                        }

                        ConquestAreaZone NewZone = new ConquestAreaZone();
                        NewZone.DisplayName = ZoneName;
                        NewZone.Position    = new Vector3D(X, Y, Z);
                        NewZone.Radius      = Size;
                        ConquestScript.Instance.Data.ConquestAreas.Add(NewZone);
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area Add", "A new conquest Area zone called '{0}' has been created.", ZoneName);
                    }
                    break;

                    case AreaManage.Remove:
                    {
                        var zone = ConquestScript.Instance.Data.ConquestAreas.FirstOrDefault(m => m.DisplayName.Equals(ZoneName, StringComparison.InvariantCultureIgnoreCase));
                        if (zone == null)
                        {
                            var zones = ConquestScript.Instance.Data.ConquestAreas.Where(m => m.DisplayName.IndexOf(ZoneName, StringComparison.InvariantCultureIgnoreCase) >= 0).ToArray();
                            if (zones.Length == 0)
                            {
                                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area Remove", "The specified zone name could not be found.");
                                ConquestScript.Instance.DataLock.ReleaseExclusive();
                                return;
                            }
                            if (zones.Length > 1)
                            {
                                var str = new StringBuilder();
                                str.Append("The specified zone name could not be found.\r\n    Which did you mean?\r\n");
                                foreach (var m in zones)
                                {
                                    str.AppendLine(m.DisplayName);
                                }
                                MessageClientDialogMessage.SendMessage(SenderSteamId, "Conquest Area Remove", " ", str.ToString());
                                ConquestScript.Instance.DataLock.ReleaseExclusive();
                                return;
                            }
                            zone = zones[0];
                        }

                        ConquestScript.Instance.Data.ConquestAreas.Remove(zone);
                        MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area Remove", "The zone '{0}' has been removed.", zone.DisplayName);
                    }
                    break;

                    case AreaManage.List:
                    {
                        var str = new StringBuilder();

                        if (ConquestScript.Instance.Data.ConquestAreas.Count > 0)
                        {
                            foreach (var zone in ConquestScript.Instance.Data.ConquestAreas)
                            {
                                str.AppendFormat("Zone: {0}\r\n", zone.DisplayName);
                                str.AppendFormat("  Center Position=X:{0:N} | Y:{1:N} | Z:{2:N} Radius={3:N}m\r\n\r\n", zone.Position.X.ToString(), zone.Position.Y.ToString(), zone.Position.Z.ToString(), zone.Radius.ToString());
                            }
                            MessageClientDialogMessage.SendMessage(SenderSteamId, "Conquest Area Zone List", " ", str.ToString());
                        }
                        else
                        {
                            MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area List", "List is currently empty.");
                        }
                    }
                    break;
                    }
                    ConquestScript.Instance.DataLock.ReleaseExclusive();
                }
                catch (Exception ex)
                {
                    ConquestScript.Instance.ServerLogger.WriteException(ex);
                    MyAPIGateway.Utilities.ShowMessage("Error", "An exception has been logged in the file:" + ConquestScript.Instance.ServerLogger.LogFileName);
                    ConquestScript.Instance.DataLock.ReleaseExclusive();
                }
            }
            else
            {
                MessageClientTextMessage.SendMessage(SenderSteamId, "Conquest Area", "Server busy, try again later.");
            }
        }