Example #1
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         var _cInfo = _senderInfo.RemoteClientInfo;
         if (_cInfo != null)
         {
             if (_params[0].ToLower().Equals("off"))
             {
                 Zones.IsEnabled = false;
                 LoadConfig.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("Zones has been set to off"));
                 return;
             }
             else if (_params[0].ToLower().Equals("on"))
             {
                 Zones.IsEnabled = true;
                 LoadConfig.WriteXml();
                 SdtdConsole.Instance.Output(string.Format("Zones has been set to on"));
                 return;
             }
             else if (_params[0].ToLower().Equals("new"))
             {
                 if (newZone.ContainsKey(_cInfo.entityId))
                 {
                     newZone[_cInfo.entityId] = 1;
                 }
                 else
                 {
                     newZone.Add(_cInfo.entityId, 1);
                 }
                 if (Zones.zoneSetup1.ContainsKey(_cInfo.entityId))
                 {
                     Zones.zoneSetup1.Remove(_cInfo.entityId);
                 }
                 if (Zones.zoneSetup2.ContainsKey(_cInfo.entityId))
                 {
                     Zones.zoneSetup2.Remove(_cInfo.entityId);
                 }
                 string[] _strings = { "", "", "", "", "", "" };
                 bool[]   _bools   = { false, false, false };
                 Zones.zoneSetup1.Add(_cInfo.entityId, _strings);
                 Zones.zoneSetup2.Add(_cInfo.entityId, _bools);
                 SdtdConsole.Instance.Output(string.Format("Stand at the first corner of the zone and type zone save."));
                 SdtdConsole.Instance.Output(string.Format("If you would like a circle, stand in the middle of the circle and type zone circle."));
             }
             else if (_params[0].ToLower().Equals("list"))
             {
                 if (Zones.Box1.Count > 0)
                 {
                     for (int i = 0; i < Zones.Box1.Count; i++)
                     {
                         string[] _box  = Zones.Box1[i];
                         bool[]   _box2 = Zones.Box2[i];
                         if (_box != null)
                         {
                             SdtdConsole.Instance.Output(string.Format("Zone number {0}:", i));
                             SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _box[0]));
                             SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _box[1]));
                             SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _box[2]));
                             SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _box[3]));
                             SdtdConsole.Instance.Output(string.Format("Response = {0}", _box[4]));
                             SdtdConsole.Instance.Output(string.Format("Reminder Notice = {0}", _box[5]));
                             SdtdConsole.Instance.Output(string.Format("Circle = {0}", _box2[0]));
                             SdtdConsole.Instance.Output(string.Format("PvE = {0}", _box2[1]));
                             SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _box2[2]));
                             SdtdConsole.Instance.Output(string.Format(""));
                         }
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("There are no zones setup."));
                 }
             }
             else if (_params[0].ToLower().Equals("delete"))
             {
                 if (Zones.Box1.Count > 0)
                 {
                     int _number;
                     if (int.TryParse(_params[1], out _number))
                     {
                         Zones.Box1.RemoveAt(_number);
                         Zones.Box2.RemoveAt(_number);
                         Zones.UpdateXml();
                         SdtdConsole.Instance.Output(string.Format("Removed zone entry number {0} from the list.", _number));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Invalid format or non numeric entry. Type zone delete <number> from the list of zones."));
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("There are no zones setup."));
                 }
             }
             else if (_params[0].ToLower().Equals("circle"))
             {
                 if (newZone.ContainsKey(_cInfo.entityId))
                 {
                     int _stage;
                     newZone.TryGetValue(_cInfo.entityId, out _stage);
                     if (_stage == 1)
                     {
                         bool[] _bools;
                         Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                         _bools[0] = true;
                         Zones.zoneSetup2[_cInfo.entityId] = _bools;
                         EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         Vector3      _position  = _player.GetPosition();
                         int          x          = (int)_position.x;
                         int          y          = (int)_position.y;
                         int          z          = (int)_position.z;
                         string       _sposition = x + "," + y + "," + z;
                         string[]     _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[0] = _sposition;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 2;
                         SdtdConsole.Instance.Output(string.Format("Saved the zone as a circle. Circle center point = {0} {1} {2}", x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Type zone circle <number> to set the amount of blocks from center the zone will reach."));
                     }
                     else if (_stage == 2)
                     {
                         bool[] _bools;
                         Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                         if (_bools[0])
                         {
                             int _result;
                             if (int.TryParse(_params[1], out _result))
                             {
                                 string[] _strings;
                                 Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                                 _strings[1] = _result.ToString();
                                 Zones.zoneSetup1[_cInfo.entityId] = _strings;
                                 newZone[_cInfo.entityId]          = 3;
                                 SdtdConsole.Instance.Output(string.Format("Saved the circle radius to {0}.", _result));
                                 SdtdConsole.Instance.Output(string.Format("Type zone save \"entry message\". This is the message players receive upon entering the zone."));
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("This zone is not setup as a circle, go back by typing zone back."));
                             }
                         }
                         else
                         {
                             SdtdConsole.Instance.Output(string.Format("This zone is not setup as a circle, go back by typing zone back."));
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Start a new zone setup or go back to the circle setup if you need to change it by typing zone back."));
                     }
                 }
             }
             else if (_params[0].ToLower().Equals("save"))
             {
                 if (newZone.ContainsKey(_cInfo.entityId))
                 {
                     int _stage;
                     newZone.TryGetValue(_cInfo.entityId, out _stage);
                     if (_stage == 1)
                     {
                         bool[] _bools;
                         Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                         _bools[0] = false;
                         Zones.zoneSetup2[_cInfo.entityId] = _bools;
                         EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         Vector3      _position  = _player.GetPosition();
                         int          x          = (int)_position.x;
                         int          y          = (int)_position.y;
                         int          z          = (int)_position.z;
                         string       _sposition = x + "," + y + "," + z;
                         string[]     _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[0] = _sposition;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 2;
                         SdtdConsole.Instance.Output(string.Format("Corner 1 = {0} {1} {2}", x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Corner 1 saved. Stand in the opposite corner of the zone and type zone save."));
                     }
                     if (_stage == 2)
                     {
                         EntityPlayer _player    = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                         Vector3      _position  = _player.GetPosition();
                         int          x          = (int)_position.x;
                         int          y          = (int)_position.y;
                         int          z          = (int)_position.z;
                         string       _sposition = x + "," + y + "," + z;
                         string[]     _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[1] = _sposition;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 3;
                         SdtdConsole.Instance.Output(string.Format("Corner 2 = {0} {1} {2}", x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Corner 2 saved. Type zone save \"entry message\". This is the message players receive upon entering the zone."));
                     }
                     else if (_stage == 3)
                     {
                         string   _entry = _params[1];
                         string[] _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[2] = _entry;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 4;
                         SdtdConsole.Instance.Output(string.Format("Zone entry message = \"{0}\"", _entry));
                         SdtdConsole.Instance.Output(string.Format("Zone entry message saved. Type zone save \"exit message\". This is the message players receive upon exiting the zone."));
                     }
                     else if (_stage == 4)
                     {
                         string   _exit = _params[1];
                         string[] _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[3] = _exit;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 5;
                         SdtdConsole.Instance.Output(string.Format("Zone exit message = \"{0}\"", _exit));
                         SdtdConsole.Instance.Output(string.Format("Zone exit message saved. Type zone save \"response\". This is the console command that will occur when a player enters this zone."));
                     }
                     else if (_stage == 5)
                     {
                         string   _response = _params[1];
                         string[] _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[4] = _response;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 6;
                         SdtdConsole.Instance.Output(string.Format("Zone response = \"{0}\"", _response));
                         SdtdConsole.Instance.Output(string.Format("Zone response saved. Type zone save \"reminder message\". This will set the message players receive if they stay in this zone long enough."));
                     }
                     else if (_stage == 6)
                     {
                         string   _response = _params[1];
                         string[] _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         _strings[5] = _response;
                         Zones.zoneSetup1[_cInfo.entityId] = _strings;
                         newZone[_cInfo.entityId]          = 7;
                         SdtdConsole.Instance.Output(string.Format("Zone reminder message = \"{0}\"", _response));
                         SdtdConsole.Instance.Output(string.Format("Zone reminder message saved. Type zone save 'true or false'. This will set PvE to true or false."));
                     }
                     else if (_stage == 7)
                     {
                         bool _result;
                         if (bool.TryParse(_params[1], out _result))
                         {
                             if (_result)
                             {
                                 bool[] _bools;
                                 Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                                 _bools[1] = true;
                                 Zones.zoneSetup2[_cInfo.entityId] = _bools;
                                 newZone[_cInfo.entityId]          = 8;
                                 SdtdConsole.Instance.Output(string.Format("Zone PvE = {0}", _result));
                                 SdtdConsole.Instance.Output(string.Format("Zone PvE saved. Type zone save 'true or false'. This will set No_Zombie to true or false."));
                             }
                             else
                             {
                                 bool[] _bools;
                                 Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                                 _bools[1] = false;
                                 Zones.zoneSetup2[_cInfo.entityId] = _bools;
                                 newZone[_cInfo.entityId]          = 8;
                                 SdtdConsole.Instance.Output(string.Format("Zone PvE = {0}", _result));
                                 SdtdConsole.Instance.Output(string.Format("Zone PvE saved. Type zone save 'true or false'. This will set No_Zombie to true or false."));
                             }
                         }
                         else
                         {
                             SdtdConsole.Instance.Output(string.Format("Incorrect format. Type zone save 'true or false'."));
                         }
                     }
                     else if (_stage == 8)
                     {
                         bool _result;
                         if (bool.TryParse(_params[1], out _result))
                         {
                             if (_result)
                             {
                                 string[] _strings;
                                 Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                                 bool[] _bools;
                                 Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                                 _bools[2] = true;
                                 Zones.zoneSetup2[_cInfo.entityId] = _bools;
                                 newZone[_cInfo.entityId]          = 9;
                                 SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _result));
                                 SdtdConsole.Instance.Output(string.Format("No zombie saved"));
                                 SdtdConsole.Instance.Output("");
                                 SdtdConsole.Instance.Output(string.Format("Zone Review:"));
                                 SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0]));
                                 SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1]));
                                 SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[2]));
                                 SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[3]));
                                 SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[4]));
                                 SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[5]));
                                 SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0]));
                                 SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1]));
                                 SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _bools[2]));
                                 SdtdConsole.Instance.Output(string.Format("Type zone save. This will complete the setup."));
                             }
                             else
                             {
                                 string[] _strings;
                                 Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                                 bool[] _bools;
                                 Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                                 _bools[2] = false;
                                 Zones.zoneSetup2[_cInfo.entityId] = _bools;
                                 newZone[_cInfo.entityId]          = 9;
                                 SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _result));
                                 SdtdConsole.Instance.Output(string.Format("No zombie saved"));
                                 SdtdConsole.Instance.Output("");
                                 SdtdConsole.Instance.Output(string.Format("Zone Review:"));
                                 SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0]));
                                 SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1]));
                                 SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[2]));
                                 SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[3]));
                                 SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[4]));
                                 SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[5]));
                                 SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0]));
                                 SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1]));
                                 SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _bools[2]));
                                 SdtdConsole.Instance.Output(string.Format("Type zone save. This will complete the setup."));
                             }
                         }
                         else
                         {
                             SdtdConsole.Instance.Output(string.Format("Incorrect format. Type zone save true or zone save false."));
                         }
                     }
                     else if (_stage == 9)
                     {
                         string[] _strings;
                         Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                         bool[] _bools;
                         Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                         string[] _box1 = { _strings[0], _strings[1], _strings[2], _strings[3], _strings[4], _strings[5] };
                         bool[]   _box2 = { _bools[0], _bools[1], _bools[2] };
                         if (!Zones.Box1.Contains(_box1))
                         {
                             Zones.Box1.Add(_box1);
                             Zones.Box2.Add(_box2);
                             Zones.UpdateXml();
                             SdtdConsole.Instance.Output(string.Format("New zone setup has been completed."));
                         }
                         else
                         {
                             SdtdConsole.Instance.Output(string.Format("This zone is already setup. Setup a new zone by typing zone new."));
                         }
                         newZone.Remove(_cInfo.entityId);
                         Zones.zoneSetup1.Remove(_cInfo.entityId);
                         Zones.zoneSetup1.Remove(_cInfo.entityId);
                     }
                 }
                 else if (_params[0].ToLower().Equals("back"))
                 {
                     if (newZone.ContainsKey(_cInfo.entityId))
                     {
                         int _stage;
                         newZone.TryGetValue(_cInfo.entityId, out _stage);
                         if (_stage == 1)
                         {
                             SdtdConsole.Instance.Output(string.Format("You can not go any further back in the setup process."));
                             SdtdConsole.Instance.Output(string.Format("Stand at the first corner of the zone and type zone save."));
                             SdtdConsole.Instance.Output(string.Format("If you would like a circle, stand in the middle of the circle and type zone circle."));
                         }
                         else if (_stage == 2)
                         {
                             newZone[_cInfo.entityId] = 1;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             string[] _corner1 = _strings[0].Split(',');
                             int      x, y, z;
                             int.TryParse(_corner1[0], out x);
                             int.TryParse(_corner1[1], out y);
                             int.TryParse(_corner1[2], out z);
                             bool[] _bools;
                             Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                             if (_bools[0])
                             {
                                 SdtdConsole.Instance.Output(string.Format("Saved the zone as a circle. Circle center point = {0} {1} {2}", x, y, z));
                                 SdtdConsole.Instance.Output(string.Format("Stand at the furthest point from the center and type zone circle."));
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("Corner 1 = {0} {1} {2}", x, y, z));
                                 SdtdConsole.Instance.Output(string.Format("Corner 1 saved. Stand in the opposite corner of the zone and type zone save."));
                             }
                         }
                         else if (_stage == 3)
                         {
                             newZone[_cInfo.entityId] = 2;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             bool[] _bools;
                             Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                             if (_bools[0])
                             {
                                 string _distance = _strings[1];
                                 SdtdConsole.Instance.Output(string.Format("Saved the circle radius to {0}.", _distance));
                                 SdtdConsole.Instance.Output(string.Format("Type zone save 'entry message'. This is the message players receive upon entering the zone."));
                             }
                             else
                             {
                                 string[] _corner2 = _strings[1].Split(',');
                                 int      x, y, z;
                                 int.TryParse(_corner2[0], out x);
                                 int.TryParse(_corner2[1], out y);
                                 int.TryParse(_corner2[2], out z);
                                 SdtdConsole.Instance.Output(string.Format("Corner 2 = {0} {1} {2}", x, y, z));
                                 SdtdConsole.Instance.Output(string.Format("Corner 2 saved. Type zone save 'entry message'. This is the message players receive upon entering the zone."));
                             }
                         }
                         else if (_stage == 4)
                         {
                             newZone[_cInfo.entityId] = 3;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             SdtdConsole.Instance.Output(string.Format("Zone entry message = \"{0}\"", _strings[2]));
                             SdtdConsole.Instance.Output(string.Format("Zone entry message saved. Type zone save 'exit message'. This is the message players receive upon exiting the zone."));
                         }
                         else if (_stage == 5)
                         {
                             newZone[_cInfo.entityId] = 4;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             SdtdConsole.Instance.Output(string.Format("Zone exit message = \"{0}\"", _strings[3]));
                             SdtdConsole.Instance.Output(string.Format("Zone exit message saved. Type zone save 'response'. This is the console command that will occur when a player enters this zone."));
                         }
                         else if (_stage == 6)
                         {
                             newZone[_cInfo.entityId] = 5;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             SdtdConsole.Instance.Output(string.Format("Zone response = \"{0}\"", _strings[4]));
                             SdtdConsole.Instance.Output(string.Format("Zone response saved. Type zone save 'reminder message'. This will set the message players receive if they stay in this zone long enough."));
                         }
                         else if (_stage == 7)
                         {
                             newZone[_cInfo.entityId] = 6;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             SdtdConsole.Instance.Output(string.Format("Zone reminder message = \"{0}\"", _strings[5]));
                             SdtdConsole.Instance.Output(string.Format("Zone reminder message saved. Type zone save 'true or false'. This will set the zone as a PvE zone or not."));
                         }
                         else if (_stage == 8)
                         {
                             newZone[_cInfo.entityId] = 7;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             bool[] _bools;
                             Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                             SdtdConsole.Instance.Output(string.Format("Zone PvE = {0}", _bools[1]));
                             SdtdConsole.Instance.Output(string.Format("Zone PvE saved. Type zone save 'true or false'. This will set the zone as a PvE zone or not."));
                         }
                         else if (_stage == 9)
                         {
                             newZone[_cInfo.entityId] = 8;
                             SdtdConsole.Instance.Output(string.Format("Zone setup has gone back one step."));
                             string[] _strings;
                             Zones.zoneSetup1.TryGetValue(_cInfo.entityId, out _strings);
                             bool[] _bools;
                             Zones.zoneSetup2.TryGetValue(_cInfo.entityId, out _bools);
                             SdtdConsole.Instance.Output(string.Format("Zone Review:"));
                             SdtdConsole.Instance.Output(string.Format("Corner 1 = {0}", _strings[0]));
                             SdtdConsole.Instance.Output(string.Format("Corner 2 = {0}", _strings[1]));
                             SdtdConsole.Instance.Output(string.Format("Entry message = {0}", _strings[2]));
                             SdtdConsole.Instance.Output(string.Format("Exit message = {0}", _strings[3]));
                             SdtdConsole.Instance.Output(string.Format("Response = {0}", _strings[4]));
                             SdtdConsole.Instance.Output(string.Format("Reminder notice = {0}", _strings[5]));
                             SdtdConsole.Instance.Output(string.Format("Circle = {0}", _bools[0]));
                             SdtdConsole.Instance.Output(string.Format("PvE = {0}", _bools[1]));
                             SdtdConsole.Instance.Output(string.Format("No zombie = {0}", _bools[2]));
                             SdtdConsole.Instance.Output(string.Format("Type zone save. This will complete the setup."));
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("You have not started the setup for a new zone. Type zone new to begin setting up a new zone."));
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ZoneSetupConsole.Run: {0}.", e));
     }
 }
Example #2
0
        public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
        {
            try
            {
                var _cInfo = _senderInfo.RemoteClientInfo;
                if (_cInfo != null)
                {
                    if (_params[0].ToLower().Equals("off"))
                    {
                        if (Zones.IsEnabled)
                        {
                            Zones.IsEnabled = false;
                            Config.WriteXml();
                            Config.LoadXml();
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Zones has been set to off"));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Zones is already off"));

                            return;
                        }
                    }
                    else if (_params[0].ToLower().Equals("on"))
                    {
                        if (!Zones.IsEnabled)
                        {
                            Zones.IsEnabled = true;
                            Config.WriteXml();
                            Config.LoadXml();
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Zones has been set to on"));

                            return;
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Zones is already on"));

                            return;
                        }
                    }
                    else if (_params[0].ToLower().Equals("new"))
                    {
                        if (SetupStage.ContainsKey(_cInfo.entityId))
                        {
                            SetupStage[_cInfo.entityId] = 1;
                        }
                        else
                        {
                            SetupStage.Add(_cInfo.entityId, 1);
                        }
                        if (Zones.ZoneSetup.ContainsKey(_cInfo.entityId))
                        {
                            Zones.ZoneSetup.Remove(_cInfo.entityId);
                        }
                        string[] _newZone = new string[11];
                        _params.RemoveAt(0);
                        string _name = string.Join(" ", _params);
                        _newZone[0] = _name;
                        Zones.ZoneSetup.Add(_cInfo.entityId, _newZone);
                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Started a new zone setup. Zone name set to {0}", _newZone[0]));

                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Stand at the first corner of the zone and type zns save"));

                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] If you would like a circle, stand in the middle of the circle and type zns circle"));
                    }
                    else if (_params[0].ToLower().Equals("list"))
                    {
                        if (Zones.ZoneList.Count > 0)
                        {
                            for (int i = 0; i < Zones.ZoneList.Count; i++)
                            {
                                string[] _zone = Zones.ZoneList[i];
                                if (_zone != null)
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Zone number {0}:", i));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _zone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _zone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _zone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _zone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _zone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _zone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _zone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _zone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Reminder Notice = {0}", _zone[8]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("PvPvE = {0}", _zone[9]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("No zombie = {0}", _zone[10]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format(""));
                                }
                            }
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] There are no zones setup"));
                        }
                    }
                    else if (_params[0].ToLower().Equals("delete"))
                    {
                        if (Zones.ZoneList.Count > 0)
                        {
                            if (int.TryParse(_params[1], out int _number))
                            {
                                if (Zones.ZoneList.Count >= _number)
                                {
                                    Zones.ZoneList.RemoveAt(_number);
                                    Zones.UpdateXml();
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed zone entry number {0} from the list", _number));

                                    return;
                                }
                                else
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Could not delete number {0} from the list. Entry not found", _number));

                                    return;
                                }
                            }
                            else
                            {
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid format or non numeric entry. Type zns delete <number> from the list of zones"));

                                return;
                            }
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] There are no zones setup"));

                            return;
                        }
                    }
                    else if (_params[0].ToLower().Equals("circle"))
                    {
                        if (SetupStage.ContainsKey(_cInfo.entityId))
                        {
                            SetupStage.TryGetValue(_cInfo.entityId, out int _stage);
                            if (_stage == 1)
                            {
                                EntityPlayer _player   = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                Vector3      _position = _player.GetPosition();
                                Zones.ZoneSetup.TryGetValue(_cInfo.entityId, out string[] _newZone);
                                int _x = (int)_position.x;
                                int _y = (int)_position.y;
                                int _z = (int)_position.z;
                                _newZone[1] = _x + "," + _y + "," + _z;
                                _newZone[3] = "true";
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 2;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Circle center point = {0}", _newZone[1]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns circle 'number' to set the amount of blocks from center the zone will reach"));
                            }
                            else if (_stage == 2)
                            {
                                Zones.ZoneSetup.TryGetValue(_cInfo.entityId, out string[] _newZone);
                                if (_newZone[3].ToLower() == "true")
                                {
                                    if (int.TryParse(_params[1], out int _radius))
                                    {
                                        _newZone[2] = _radius.ToString();
                                        Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                        SetupStage[_cInfo.entityId]      = 3;
                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Saved the circular zone radius to {0} blocks", _newZone[2]));

                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This is the message players receive upon entering the zone"));
                                    }
                                    else
                                    {
                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid radius for circlular zone, try again"));
                                    }
                                }
                                else
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] This zone is not setup as a circle, go back by typing zns back"));
                                }
                            }
                            else
                            {
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Start a new zone setup or go back to the circle setup if you need to change it by typing zns back."));
                            }
                        }
                    }
                    else if (_params[0].ToLower().Equals("save"))
                    {
                        if (SetupStage.ContainsKey(_cInfo.entityId))
                        {
                            SetupStage.TryGetValue(_cInfo.entityId, out int _stage);
                            Zones.ZoneSetup.TryGetValue(_cInfo.entityId, out string[] _newZone);
                            switch (_stage)
                            {
                            case 1:
                                EntityPlayer _player   = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                Vector3      _position = _player.GetPosition();
                                int          _x        = (int)_position.x;
                                int          _y        = (int)_position.y;
                                int          _z        = (int)_position.z;
                                _newZone[1] = _x + "," + _y + "," + _z;
                                _newZone[3] = "false";
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 2;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Corner 1 = {0}", _newZone[1]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Stand in the opposite corner of the zone and type zns save"));

                                break;

                            case 2:
                                _player   = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                _position = _player.GetPosition();
                                _x        = (int)_position.x;
                                _y        = (int)_position.y;
                                _z        = (int)_position.z;
                                if (_newZone[1].Contains(_y.ToString()))
                                {
                                    _y++;
                                }
                                _newZone[2] = _x + "," + _y + "," + _z;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 3;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Corner 2 = {0}", _newZone[2]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This is the message players receive upon entering the zone"));

                                break;

                            case 3:
                                _params.RemoveAt(0);
                                string _entryMessage = string.Join(" ", _params);
                                _newZone[4] = _entryMessage;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 4;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Entry message = \"{0}\"", _newZone[4]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This is the message players receive upon exiting the zone"));

                                break;

                            case 4:
                                _params.RemoveAt(0);
                                string _exitMessage = string.Join(" ", _params);
                                _newZone[5] = _exitMessage;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 5;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Exit message = \"{0}\"", _newZone[5]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"command\". This is the console command that will occur when a player enters this zone"));

                                break;

                            case 5:
                                _params.RemoveAt(0);
                                string _entryCommand = string.Join(" ", _params);
                                if (_entryCommand == "")
                                {
                                    _entryCommand = "***";
                                }
                                _newZone[6] = _entryCommand;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 6;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Entry command = \"{0}\"", _newZone[6]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"command\". This is the console command that will occur when a player exits this zone"));

                                break;

                            case 6:
                                _params.RemoveAt(0);
                                string _exitCommand = string.Join(" ", _params);
                                if (_exitCommand == "")
                                {
                                    _exitCommand = "***";
                                }
                                _newZone[7] = _exitCommand;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 7;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Exit command = \"{0}\"", _newZone[7]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This will set the message players receive if they stay in this zone long enough"));

                                break;

                            case 7:
                                _params.RemoveAt(0);
                                string _reminder = string.Join(" ", _params);
                                _newZone[8] = _reminder;
                                Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                SetupStage[_cInfo.entityId]      = 8;
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Reminder message = \"{0}\"", _newZone[8]));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save '0 to 3'. This will set PvPvE to a specific player killing mode"));

                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] 0 = No Killing, 1 = Kill Allies Only, 2 = Kill Strangers Only, 3 = Kill Everyone"));

                                break;

                            case 8:
                                if (int.TryParse(_params[1], out int _playerKillingMode))
                                {
                                    _newZone[9] = _playerKillingMode.ToString();
                                    Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                    SetupStage[_cInfo.entityId]      = 9;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Zone PvPvE = {0}", _newZone[9]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save 'true or false'. This will set no zombie to true or false"));
                                }
                                else
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Incorrect format. Type zns save '0 to 3'"));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] 0 = No Killing, 1 = Kill Allies Only, 2 = Kill Strangers Only, 3 = Kill Everyone"));
                                }
                                break;

                            case 9:
                                if (bool.TryParse(_params[1], out bool _noZombie))
                                {
                                    if (_noZombie)
                                    {
                                        _newZone[10] = "true";
                                    }
                                    else
                                    {
                                        _newZone[10] = "false";
                                    }
                                    Zones.ZoneSetup[_cInfo.entityId] = _newZone;
                                    SetupStage[_cInfo.entityId]      = 10;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] No zombie = {0}", _newZone[10]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output("");

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Zone Review:"));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _newZone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Reminder notice = {0}", _newZone[8]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("PvPvE = {0}", _newZone[9]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("No zombie = {0}", _newZone[10]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Type zns save. This will complete the setup"));
                                }
                                else
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Incorrect format. Type zns save 'true or false'"));
                                }
                                break;

                            case 10:
                                if (!Zones.ZoneList.Contains(_newZone))
                                {
                                    Zones.ZoneList.Add(_newZone);
                                    Zones.UpdateXml();
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] New zone setup has been completed"));
                                }
                                else
                                {
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] This zone is already setup. Setup a new zone by typing zns new"));
                                }
                                Zones.ZoneSetup.Remove(_cInfo.entityId);
                                SetupStage.Remove(_cInfo.entityId);
                                break;
                            }
                        }
                        else if (_params[0].ToLower().Equals("back"))
                        {
                            if (SetupStage.ContainsKey(_cInfo.entityId))
                            {
                                SetupStage.TryGetValue(_cInfo.entityId, out int _stage);
                                Zones.ZoneSetup.TryGetValue(_cInfo.entityId, out string[] _newZone);
                                switch (_stage)
                                {
                                case 1:
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Stand at the first corner of the zone and type zns save"));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] If you would like a circle, stand in the middle of the circle and type zns circle"));

                                    break;

                                case 2:
                                    SetupStage[_cInfo.entityId] = 1;
                                    if (_newZone[3].ToLower() == "true")
                                    {
                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Stand at the furthest point from the center and type zns circle"));
                                    }
                                    else
                                    {
                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                        SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Corner 1 is saved. Stand in the opposite corner of the zone and type zns save"));
                                    }
                                    break;

                                case 3:
                                    SetupStage[_cInfo.entityId] = 2;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This is the message players receive upon entering the zone"));

                                    break;

                                case 4:
                                    SetupStage[_cInfo.entityId] = 3;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This is the message players receive upon exiting the zone"));

                                    break;

                                case 5:
                                    SetupStage[_cInfo.entityId] = 4;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"command\". This is the console command that will occur when a player enters this zone"));

                                    break;

                                case 6:
                                    SetupStage[_cInfo.entityId] = 5;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"command\". This is the console command that will occur when a player exits this zone"));

                                    break;

                                case 7:
                                    SetupStage[_cInfo.entityId] = 6;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _newZone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save \"message\". This will set the message players receive if they stay in this zone long enough"));

                                    break;

                                case 8:
                                    SetupStage[_cInfo.entityId] = 7;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _newZone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Reminder notice = {0}", _newZone[8]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save '0 to 3'. This will set PvPvE to a specific player killing mode"));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] 0 = No Killing, 1 = Kill Allies Only, 2 = Kill Strangers Only, 3 = Kill Everyone"));

                                    break;

                                case 9:
                                    SetupStage[_cInfo.entityId] = 8;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _newZone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Reminder notice = {0}", _newZone[8]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("PvPvE = {0}", _newZone[9]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Type zns save 'true or false'. This will set no zombie to true or false"));

                                    break;

                                case 10:
                                    SetupStage[_cInfo.entityId] = 9;
                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Name = {0}", _newZone[0]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 1 = {0}", _newZone[1]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Corner 2 = {0}", _newZone[2]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Circle = {0}", _newZone[3]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry message = {0}", _newZone[4]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit message = {0}", _newZone[5]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entry Command = {0}", _newZone[6]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Exit Command = {0}", _newZone[7]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Reminder notice = {0}", _newZone[8]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("PvPvE = {0}", _newZone[9]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("No zombie = {0}", _newZone[10]));

                                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Type zns save. This will complete the setup"));

                                    break;
                                }
                            }
                            else
                            {
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] You have not started the setup of a new zone. Type zns new 'name' to begin setting up a new zone"));
                            }
                        }
                        else if (_params[0].ToLower().Equals("forward"))
                        {
                            if (SetupStage.ContainsKey(_cInfo.entityId))
                            {
                            }
                            else
                            {
                                SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] You have not started the setup of a new zone. Type zns new 'name' to begin setting up a new zone"));
                            }
                        }
                        else
                        {
                            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid argument {0}", _params[0]));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in ZonesConsole.Execute: {0}", e.Message));
            }
        }
Example #3
0
 public static void AddProtection(string[] _vectors)
 {
     try
     {
         int _xMin = int.Parse(_vectors[0]), _zMin = int.Parse(_vectors[1]), _xMax = int.Parse(_vectors[2]), _zMax = int.Parse(_vectors[3]);
         int _xMinAlt = _xMin, _zMinAlt = _zMin, _xMaxAlt = _xMax, _zMaxAlt = _zMax;
         if (_xMin > _xMax)
         {
             _xMinAlt = _xMax;
             _xMaxAlt = _xMin;
         }
         if (_zMin > _zMax)
         {
             _zMinAlt = _zMax;
             _zMaxAlt = _zMin;
         }
         List <Chunk> _chunkList  = new List <Chunk>();
         string[]     _vectorsAlt = { _xMinAlt.ToString(), _zMinAlt.ToString(), _xMaxAlt.ToString(), _zMaxAlt.ToString() };
         if (!Zones.ProtectedList.Contains(_vectorsAlt))
         {
             Zones.ProtectedList.Add(_vectorsAlt);
             for (int i = _xMinAlt; i <= _xMaxAlt; i++)
             {
                 for (int j = _zMinAlt; j <= _zMaxAlt; j++)
                 {
                     if (GameManager.Instance.World.IsChunkAreaLoaded(i, 1, j))
                     {
                         Chunk _chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(i, 1, j);
                         if (!_chunkList.Contains(_chunk))
                         {
                             _chunkList.Add(_chunk);
                         }
                         Bounds bounds = _chunk.GetAABB();
                         int    _x = i - (int)bounds.min.x, _z = j - (int)bounds.min.z;
                         _chunk.SetTraderArea(_x, _z, true);
                     }
                     else
                     {
                         continue;
                     }
                 }
             }
             if (_chunkList.Count > 0)
             {
                 for (int k = 0; k < _chunkList.Count; k++)
                 {
                     Chunk             _chunk      = _chunkList[k];
                     List <ClientInfo> _clientList = PersistentOperations.ClientList();
                     if (_clientList != null && _clientList.Count > 0)
                     {
                         for (int l = 0; l < _clientList.Count; l++)
                         {
                             ClientInfo _cInfo2 = _clientList[l];
                             if (_cInfo2 != null)
                             {
                                 _cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageChunk>().Setup(_chunk, true));
                             }
                         }
                     }
                 }
             }
             Zones.UpdateXml();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Zones.AddProtection: {0}", e.Message));
     }
 }