Ejemplo n.º 1
0
 private void OnLongPulse()
 {
     foreach (var zone in _zones.ToArray())
     {
         if (_autoFillStakes)
         {
             zone.FillStakes();
         }
         var identity = _helpers.GetIdentityBySteamId(zone.SteamId);
         if (identity == null ||
             !Zone.IsCellOwnedByPlayer(_helpers.GetIdentityBySteamId(zone.SteamId), zone.MainCell))
         {
             var session = _helpers.GetSessionBySteamId(zone.SteamId);
             if (session != null)
             {
                 hurt.SendChatMessage(session, null,
                                      lang.GetMessage("Zone - Auto Removed", this, session.SteamId.ToString())
                                      .Replace("{name}", zone.Name));
             }
             _zones.Remove(zone);
             Log(ELogType.Info, $"The zone {zone.Name} got automatically removed.");
         }
     }
     _c4Logs.RemoveAll(c => (DateTime.Now - c.Date).TotalSeconds > 60);
     SaveData();
 }
Ejemplo n.º 2
0
        private void CommandAdd(PlayerSession session, string[] args)
        {
            var name      = args.First();
            var existZone =
                _zones.FirstOrDefault(
                    z =>
                    z.SteamId.Equals(session.SteamId.ToString()) &&
                    z.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (existZone != null)
            {
                hurt.SendChatMessage(session, null,
                                     lang.GetMessage("Zone - Exists", this, session.SteamId.ToString())
                                     .Replace("{name}", existZone.Name));
                return;
            }
            var cell = Zone.GetCell(session.WorldPlayerEntity.transform.position);

            if (cell <= 0)
            {
                hurt.SendChatMessage(session, null, lang.GetMessage("Zone - Not Found", this, session.SteamId.ToString()));
                return;
            }
            if (!Zone.IsCellOwnedByPlayer(session.Identity, cell))
            {
                hurt.SendChatMessage(session, null, lang.GetMessage("Zone - Not Owned", this, session.SteamId.ToString()));
                return;
            }
            if (_zones.Any(z => z.AllCells.Contains(cell)))
            {
                hurt.SendChatMessage(session, null, lang.GetMessage("Zone - Already", this, session.SteamId.ToString()));
                return;
            }
            var zone = new Zone(session.SteamId.ToString(), name, cell);

            zone.Update(_helpers.GetConfig(false, "Settings", "Add Extra Cell Layer"));
            if (_autoFillStakes)
            {
                zone.FillStakes();
            }
            _zones.Add(zone);
            hurt.SendChatMessage(session, null,
                                 lang.GetMessage("Zone - Added", this, session.SteamId.ToString())
                                 .Replace("{name}", zone.Name)
                                 .Replace("{count}", zone.Bounds.Count.ToString()));
            SaveData();
        }
Ejemplo n.º 3
0
 // ReSharper disable UnusedMember.Local
 private void OnServerInitialized()
 {
     foreach (var zone in _zones.ToArray())
     {
         var identity = _helpers.GetIdentityBySteamId(zone.SteamId);
         if (identity == null || zone.MainCell <= 0 || !Zone.IsCellOwnedByPlayer(identity, zone.MainCell))
         {
             _zones.Remove(zone);
             Log(ELogType.Info, $"The zone {zone.Name} got automatically removed.");
             continue;
         }
         zone.Update(_helpers.GetConfig(false, "Settings", "Add Extra Cell Layer"));
         if (_autoFillStakes)
         {
             zone.FillStakes();
         }
     }
     SaveData();
 }
Ejemplo n.º 4
0
        private void CommandUpdate(PlayerSession session, string[] args)
        {
            var name = args.First();
            var zone =
                _zones.FirstOrDefault(
                    z =>
                    z.SteamId.Equals(session.SteamId.ToString()) &&
                    z.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (zone == null)
            {
                hurt.SendChatMessage(session, null,
                                     lang.GetMessage("Zone - Unknown", this, session.SteamId.ToString()).Replace("{name}", name));
                return;
            }
            if (zone.MainCell <= 0)
            {
                hurt.SendChatMessage(session, null, lang.GetMessage("Zone - Not Found", this, session.SteamId.ToString()));
                return;
            }
            if (!Zone.IsCellOwnedByPlayer(session.Identity, zone.MainCell))
            {
                hurt.SendChatMessage(session, null,
                                     lang.GetMessage("Zone - Auto Removed", this, session.SteamId.ToString())
                                     .Replace("{name}", zone.Name));
                _zones.Remove(zone);
                Log(ELogType.Info, $"The zone {zone.Name} got automatically removed.");
                SaveData();
                return;
            }
            zone.Update(_helpers.GetConfig(false, "Settings", "Add Extra Cell Layer"));
            if (_autoFillStakes)
            {
                zone.FillStakes();
            }
            hurt.SendChatMessage(session, null,
                                 lang.GetMessage("Zone - Updated", this, session.SteamId.ToString())
                                 .Replace("{name}", zone.Name)
                                 .Replace("{count}", zone.Bounds.Count.ToString()));
        }