Ejemplo n.º 1
0
        private void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (info == null)
            {
                return;
            }

            if (!IsRaidEntity(entity))
            {
                return;
            }
            if (info.InitiatorPlayer == null)
            {
                return;
            }

            var buildingPrivilege = entity.GetBuildingPrivilege();

            if (buildingPrivilege == null || buildingPrivilege.authorizedPlayers.IsEmpty())
            {
                return;
            }

            var victims = new List <ulong>(buildingPrivilege.authorizedPlayers.Count);

            foreach (PlayerNameID victim in buildingPrivilege.authorizedPlayers)
            {
                if (victim == null)
                {
                    continue;
                }
                if (config.usePermissions && !permission.UserHasPermission(victim.userid.ToString(), PERMISSION))
                {
                    return;
                }
                if (victim.userid == info.InitiatorPlayer.userID)
                {
                    return;
                }
                if (disabled.Contains(victim.userid))
                {
                    continue;
                }
                victims.Add(victim.userid);
            }

            NotificationList.SendNotificationTo(
                victims, NotificationChannel.SmartAlarm, lang.GetMessage(AlarmLoc.TITLE, this),
                string.Format(lang.GetMessage(AlarmLoc.BODY, this),
                              entity.ShortPrefabName, GetGrid(entity.transform.position)), Util.GetServerPairingData());
        }
Ejemplo n.º 2
0
        private void ChatRaidAlarm(BasePlayer player, string command, string[] args)
        {
            if (config.usePermissions && !permission.UserHasPermission(player.UserIDString, PERMISSION))
            {
                SendReply(player, lang.GetMessage(AlarmLoc.NO_PERMISSION, this, player.UserIDString));
                return;
            }
            if (args.Length == 0)
            {
                SendReply(player, lang.GetMessage(AlarmLoc.HELP, this, player.UserIDString));
                return;
            }

            switch (args[0].ToLower())
            {
            case "status":
                SendReply(player, GetStatusText(player));
                break;

            case "enable":
                disabled.Remove(player.userID);
                SendReply(player, lang.GetMessage(AlarmLoc.STATUS_ENABLED, this, player.UserIDString));
                break;

            case "disable":
                disabled.Add(player.userID);
                SendReply(player, lang.GetMessage(AlarmLoc.STATUS_DISABLED, this, player.UserIDString));
                break;

            case "test":
                if (disabled.Contains(player.userID))
                {
                    SendReply(player, lang.GetMessage(AlarmLoc.STATUS_DISABLED, this, player.UserIDString));
                    return;
                }

                NotificationList.SendNotificationTo(player.userID, NotificationChannel.SmartAlarm,
                                                    lang.GetMessage(AlarmLoc.TITLE, this, player.UserIDString),
                                                    string.Format(lang.GetMessage(AlarmLoc.BODY, this, player.UserIDString),
                                                                  string.Format(lang.GetMessage(AlarmLoc.TEST_DESTROYED, this, player.UserIDString)),
                                                                  GetGrid(player.transform.position)), Util.GetServerPairingData());
                SendReply(player, lang.GetMessage(AlarmLoc.TEST_SENT, this, player.UserIDString));
                break;

            default:
                SendReply(player, lang.GetMessage(AlarmLoc.HELP_COMMANDS, this, player.UserIDString));
                break;
            }
        }