Иконка ресурса

FREE BuildingBlockZones : 1.0.0 1.0.0

Нет прав для скачивания
C#:
/*
 * Exotic Plugins © 2021
 * Stealing my plugins is prohibited (even if you edited them)
 * Sharing my plugins with others is prohibited
 * For support join our discord - https://discord.gg/YnbYaugRMh
 */

using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Plugins.BuildingBlockZonesEx;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Building Block Zones", "Tryhard", "1.0.0")]
    [Description("Damages building blocked players")]
    class BuildingBlockZones : RustPlugin
    {

        private Configuration config;

        public class Configuration
        {
            [JsonProperty("Drop Sound Effect")]
            public string DamageSoundEffect = "assets/bundled/prefabs/fx/impacts/bullet/generic/generic4.prefab";

            [JsonProperty("Damage player amount (1 - 500)")]
            public int DamageAmount { get; set; } = 20;

            [JsonProperty("Damage player every (seconds)")]
            public int DamageEvery { get; set; } = 1;

            [JsonProperty("Building block damage text")]
            public string damageText = "Leave the building blocked zone immediately!";
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config == null)
                {
                    LoadDefaultConfig();
                }
            }
            catch
            {
                LoadDefaultConfig();
            }
            SaveConfig();
        }

        protected override void LoadDefaultConfig()
        {
            config = new Configuration();
        }

        protected override void SaveConfig() => Config.WriteObject(config);

        private readonly Dictionary<ulong, Timer> timers = new Dictionary<ulong, Timer>();

        private void OnServerInitialized()
        {
            timer.Every(1f, CheckBlock);
        }
        private void Init()
        {
            permission.RegisterPermission("BuildingBlockZones.exclude", this);
        }

        void CheckBlock()
        {
            foreach (var player in BasePlayer.activePlayerList)
            {
                if (!permission.UserHasPermission(player.UserIDString, "BuildingBlockZones.exclude") && player.IsBuildingBlocked())
                {
                    if (!timers.ContainsKey(player.userID))
                    {
                        timers[player.userID] = timer.Every(config.DamageEvery, () =>
                        {
                            player.RunEffect(config.DamageSoundEffect);
                            player.Hurt(config.DamageAmount);
                            SendReply(player, $"{config.damageText}");
                        });
                    }
                }

                if (!permission.UserHasPermission(player.UserIDString, "BuildingBlockZones.exclude") && !player.IsBuildingBlocked())
                {
                    if (timers.ContainsKey(player.userID))
                    {
                        timers[player.userID].Destroy();
                        timers.Remove(player.userID);
                    }
                }
            }
        }

        void OnPlayerDeath(BasePlayer player)
        {

            if (timers.ContainsKey(player.userID))
            {
                timers[player.userID].Destroy();
                timers.Remove(player.userID);
            }
        }
    }

    namespace BuildingBlockZonesEx
    {
        public static class PlayerEx
        {
            public static void RunEffect(this BasePlayer player, string prefab)
            {
                Effect effect = new Effect();
                effect.Init(Effect.Type.Generic, player.ServerPosition, Vector3.zero);
                effect.pooledString = prefab;
                EffectNetwork.Send(effect, player.Connection);
            }
        }
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху